[TASK] Remove unneeded parenthesis on array-access
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Extension / DefaultClean.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\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi;
19
20 /**
21 * Default Clean extension for htmlArea RTE
22 */
23 class DefaultClean extends RteHtmlAreaApi
24 {
25 /**
26 * The name of the plugin registered by the extension
27 *
28 * @var string
29 */
30 protected $pluginName = 'DefaultClean';
31
32 /**
33 * The comma-separated list of button names that the registered plugin is adding to the htmlArea RTE toolbar
34 *
35 * @var string
36 */
37 protected $pluginButtons = 'cleanword';
38
39 /**
40 * The name-converting array, converting the button names used in the RTE PageTSConfing to the button id's used by the JS scripts
41 *
42 * @var array
43 */
44 protected $convertToolbarForHtmlAreaArray = array(
45 'cleanword' => 'CleanWord'
46 );
47
48 /**
49 * Returns TRUE if the plugin is available and correctly initialized
50 *
51 * @param array $configuration Configuration array given from calling object down to the single plugins
52 * @return bool TRUE if this plugin object should be made available in the current environment and is correctly initialized
53 */
54 public function main(array $configuration)
55 {
56 return parent::main($configuration)
57 && $this->configuration['thisConfig']['enableWordClean']
58 && !is_array($this->configuration['thisConfig']['enableWordClean.']['HTMLparser.']);
59 }
60
61 /**
62 * Return JS configuration of the htmlArea plugins registered by the extension
63 *
64 * @return string JS configuration for registered plugins, in this case, JS configuration of block elements
65 */
66 public function buildJavascriptConfiguration()
67 {
68 $jsArray = array();
69 $button = 'cleanword';
70 if (in_array($button, $this->toolbar)) {
71 if (!is_array($this->configuration['thisConfig']['buttons.']) || !is_array($this->configuration['thisConfig']['buttons.'][$button . '.'])) {
72 $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . ' = new Object();';
73 }
74 $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . ' = {"hotKey" : "' . ($this->configuration['thisConfig']['enableWordClean.']['hotKey'] ? $this->configuration['thisConfig']['enableWordClean.']['hotKey'] : '0') . '"};';
75 }
76 return implode(LF, $jsArray);
77 }
78
79 /**
80 * Return an updated array of toolbar enabled buttons
81 * Force inclusion of hidden button cleanword
82 *
83 * @param array $show: array of toolbar elements that will be enabled, unless modified here
84 * @return array toolbar button array, possibly updated
85 */
86 public function applyToolbarConstraints($show)
87 {
88 return array_unique(array_merge($show, GeneralUtility::trimExplode(',', $this->pluginButtons)));
89 }
90 }