[TASK] Re-work/simplify copyright header in PHP files - Part 5
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Extension / Plaintext.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 * Copy as Plain Text extension for htmlArea RTE
18 *
19 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
20 */
21 class Plaintext extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
22
23 protected $extensionKey = 'rtehtmlarea';
24
25 // The key of the extension that is extending htmlArea RTE
26 protected $pluginName = 'PlainText';
27
28 // The name of the plugin registered by the extension
29 protected $relativePathToLocallangFile = '';
30
31 // Path to this main locallang file of the extension relative to the extension dir.
32 protected $relativePathToSkin = 'extensions/PlainText/skin/htmlarea.css';
33
34 // Path to the skin (css) file relative to the extension dir
35 protected $htmlAreaRTE;
36
37 // Reference to the invoking object
38 protected $thisConfig;
39
40 // Reference to RTE PageTSConfig
41 protected $toolbar;
42
43 // Reference to RTE toolbar array
44 protected $LOCAL_LANG;
45
46 // Frontend language array
47 protected $pluginButtons = 'pastetoggle,pastebehaviour';
48
49 protected $convertToolbarForHtmlAreaArray = array(
50 'pastetoggle' => 'PasteToggle',
51 'pastebehaviour' => 'PasteBehaviour'
52 );
53
54 public function main($parentObject) {
55 // Opera has no onPaste event to handle
56 return parent::main($parentObject) && $this->htmlAreaRTE->client['browser'] != 'opera';
57 }
58
59 /**
60 * Return JS configuration of the htmlArea plugins registered by the extension
61 *
62 * @param integer Relative id of the RTE editing area in the form
63 * @return string JS configuration for registered plugins
64 */
65 public function buildJavascriptConfiguration($RTEcounter) {
66 $registerRTEinJavascriptString = '';
67 $button = 'pastebehaviour';
68 // Get current TYPO3 User Setting, if available
69 if (TYPO3_MODE === 'BE' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('setup') && is_array($GLOBALS['TYPO3_USER_SETTINGS']) && is_object($GLOBALS['BE_USER'])) {
70 if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][($button . '.')])) {
71 $registerRTEinJavascriptString .= '
72 RTEarea[' . $RTEcounter . '].buttons.' . $button . ' = new Object();';
73 }
74 $registerRTEinJavascriptString .= '
75 RTEarea[' . $RTEcounter . '].buttons.' . $button . '.current = "' . (isset($GLOBALS['BE_USER']->uc['rteCleanPasteBehaviour']) ? $GLOBALS['BE_USER']->uc['rteCleanPasteBehaviour'] : 'plainText') . '";';
76 }
77 return $registerRTEinJavascriptString;
78 }
79
80 /**
81 * Return an updated array of toolbar enabled buttons
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 $removeButtons = array();
88 // Remove pastebehaviour button if pastetoggle is not configured
89 if (!in_array('pastetoggle', $show)) {
90 $removeButtons[] = 'pastebehaviour';
91 }
92 // Remove pastebehaviour button if TYPO3 User Settings are available
93 if (TYPO3_MODE === 'BE' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('setup') && is_array($GLOBALS['TYPO3_USER_SETTINGS']) && is_object($GLOBALS['BE_USER'])) {
94 $removeButtons[] = 'pastebehaviour';
95 }
96 return array_diff($show, $removeButtons);
97 }
98
99 }