[CLEANUP] Use comments not PHPDoc style comments in copyright block
[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 /**
24 * The key of the extension that is extending htmlArea RTE
25 *
26 * @var string
27 */
28 protected $extensionKey = 'rtehtmlarea';
29
30 /**
31 * The name of the plugin registered by the extension
32 *
33 * @var string
34 */
35 protected $pluginName = 'PlainText';
36
37 /**
38 * Path to this main locallang file of the extension relative to the extension directory
39 *
40 * @var string
41 */
42 protected $relativePathToLocallangFile = '';
43
44 /**
45 * Path to the skin file relative to the extension directory
46 *
47 * @var string
48 */
49 protected $relativePathToSkin = 'Resources/Public/Css/Skin/Plugins/plain-text.css';
50
51 /**
52 * Reference to the invoking object
53 *
54 * @var \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaBase
55 */
56 protected $htmlAreaRTE;
57
58 protected $thisConfig;
59
60 // Reference to RTE PageTSConfig
61 protected $toolbar;
62
63 // Reference to RTE toolbar array
64 protected $LOCAL_LANG;
65
66 // Frontend language array
67 protected $pluginButtons = 'pastetoggle,pastebehaviour';
68
69 protected $convertToolbarForHtmlAreaArray = array(
70 'pastetoggle' => 'PasteToggle',
71 'pastebehaviour' => 'PasteBehaviour'
72 );
73
74 public function main($parentObject) {
75 // Opera has no onPaste event to handle
76 return parent::main($parentObject) && $this->htmlAreaRTE->client['browser'] != 'opera';
77 }
78
79 /**
80 * Return JS configuration of the htmlArea plugins registered by the extension
81 *
82 * @param int Relative id of the RTE editing area in the form
83 * @return string JS configuration for registered plugins
84 */
85 public function buildJavascriptConfiguration($RTEcounter) {
86 $registerRTEinJavascriptString = '';
87 $button = 'pastebehaviour';
88 // Get current TYPO3 User Setting, if available
89 if (TYPO3_MODE === 'BE' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('setup') && is_array($GLOBALS['TYPO3_USER_SETTINGS']) && is_object($GLOBALS['BE_USER'])) {
90 if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][($button . '.')])) {
91 $registerRTEinJavascriptString .= '
92 RTEarea[' . $RTEcounter . '].buttons.' . $button . ' = new Object();';
93 }
94 $registerRTEinJavascriptString .= '
95 RTEarea[' . $RTEcounter . '].buttons.' . $button . '.current = "' . (isset($GLOBALS['BE_USER']->uc['rteCleanPasteBehaviour']) ? $GLOBALS['BE_USER']->uc['rteCleanPasteBehaviour'] : 'plainText') . '";';
96 }
97 return $registerRTEinJavascriptString;
98 }
99
100 /**
101 * Return an updated array of toolbar enabled buttons
102 *
103 * @param array $show: array of toolbar elements that will be enabled, unless modified here
104 * @return array toolbar button array, possibly updated
105 */
106 public function applyToolbarConstraints($show) {
107 $removeButtons = array();
108 // Remove pastebehaviour button if pastetoggle is not configured
109 if (!in_array('pastetoggle', $show)) {
110 $removeButtons[] = 'pastebehaviour';
111 }
112 // Remove pastebehaviour button if TYPO3 User Settings are available
113 if (TYPO3_MODE === 'BE' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('setup') && is_array($GLOBALS['TYPO3_USER_SETTINGS']) && is_object($GLOBALS['BE_USER'])) {
114 $removeButtons[] = 'pastebehaviour';
115 }
116 return array_diff($show, $removeButtons);
117 }
118
119 }