[TASK] RTE: Remove unused css files
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Extension / Typo3Image.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea\Extension;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi;
20 use TYPO3\CMS\Rtehtmlarea\RteHtmlAreaBase;
21
22 /**
23 * TYPO3 Image plugin for htmlArea RTE
24 *
25 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
26 */
27 class Typo3Image extends RteHtmlAreaApi {
28
29 /**
30 * The name of the plugin registered by the extension
31 *
32 * @var string
33 */
34 protected $pluginName = 'TYPO3Image';
35
36 /**
37 * The comma-separated list of button names that the registered plugin is adding to the htmlArea RTE toolbar
38 *
39 * @var string
40 */
41 protected $pluginButtons = 'image';
42
43 /**
44 * The name-converting array, converting the button names used in the RTE PageTSConfing to the button id's used by the JS scripts
45 *
46 * @var array
47 */
48 protected $convertToolbarForHtmlAreaArray = array(
49 'image' => 'InsertImage'
50 );
51
52 /**
53 * Returns TRUE if the plugin is available and correctly initialized
54 *
55 * @param RteHtmlAreaBase $parentObject parent object
56 * @return bool TRUE if this plugin object should be made available in the current environment and is correctly initialized
57 */
58 public function main($parentObject) {
59 $enabled = parent::main($parentObject);
60 // Check if this should be enabled based on extension configuration and Page TSConfig
61 // The 'Minimal' and 'Typical' default configurations include Page TSConfig that removes images on the way to the database
62 $enabled = $enabled && !($this->thisConfig['proc.']['entryHTMLparser_db.']['tags.']['img.']['allowedAttribs'] == '0' && $this->thisConfig['proc.']['entryHTMLparser_db.']['tags.']['img.']['rmTagIfNoAttrib'] == '1') && !$this->thisConfig['buttons.']['image.']['TYPO3Browser.']['disabled'];
63 return $enabled;
64 }
65
66 /**
67 * Return JS configuration of the htmlArea plugins registered by the extension
68 *
69 * @param string $rteNumberPlaceholder A dummy string for JS arrays
70 * @return string JS configuration for registered plugins, in this case, JS configuration of block elements
71 */
72 public function buildJavascriptConfiguration($rteNumberPlaceholder) {
73 $registerRTEinJavascriptString = '';
74 $button = 'image';
75 if (in_array($button, $this->toolbar)) {
76 if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][($button . '.')])) {
77 $registerRTEinJavascriptString .= '
78 RTEarea[' . $rteNumberPlaceholder . ']["buttons"]["' . $button . '"] = new Object();';
79 }
80 $registerRTEinJavascriptString .= '
81 RTEarea[' . $rteNumberPlaceholder . '].buttons.' . $button . '.pathImageModule = ' .
82 GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('rtehtmlarea_wizard_select_image')) . ';';
83 }
84 return $registerRTEinJavascriptString;
85 }
86
87 }