[FEATURE] htmlArea RTE: Remove RTE cache
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / class.tx_rtehtmlarea_base.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004-2011 Kasper Skårhøj (kasper@typo3.com)
6 * (c) 2004-2011 Philipp Borgmann <philipp.borgmann@gmx.de>
7 * (c) 2004-2012 Stanislas Rolland <typo3(arobas)sjbr.ca>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * A RTE using the htmlArea editor
31 *
32 * @author Philipp Borgmann <philipp.borgmann@gmx.de>
33 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
34 */
35
36 class tx_rtehtmlarea_base extends t3lib_rteapi {
37 // Configuration of supported browsers
38 var $conf_supported_browser = array (
39 'msie' => array (
40 array (
41 'version' => 6.0,
42 'system' => array(
43 'allowed' => array(
44 'winNT',
45 'win98',
46 'win95',
47 ),
48 ),
49 ),
50 ),
51 'gecko' => array (
52 array (
53 'version' => 1.8,
54 ),
55 ),
56 'webkit' => array (
57 array (
58 'version' => 523,
59 'system' => array(
60 'disallowed' => array(
61 'iOS',
62 'android',
63 ),
64 ),
65 ),
66 ),
67 'opera' => array (
68 array (
69 'version' => 9.62,
70 'system' => array(
71 'disallowed' => array(
72 'iOS',
73 'android',
74 ),
75 ),
76 ),
77 )
78 );
79
80 // Always hide these toolbar buttons (TYPO3 button name)
81 var $conf_toolbar_hide = array (
82 'showhelp', // Has no content yet
83 );
84
85 // The order of the toolbar: the name is the TYPO3-button name
86 var $defaultToolbarOrder;
87
88 // Conversion array: TYPO3 button names to htmlArea button names
89 var $convertToolbarForHtmlAreaArray = array (
90 'showhelp' => 'ShowHelp',
91 'space' => 'space',
92 'bar' => 'separator',
93 'linebreak' => 'linebreak',
94 );
95
96 var $pluginButton = array();
97 var $pluginLabel = array();
98 // Alternative style for RTE <div> tag.
99 public $RTEdivStyle;
100 // Relative path to this extension. It ends with "/"
101 public $extHttpPath;
102 public $backPath = '';
103 // TYPO3 site url
104 public $siteURL;
105 // TYPO3 host url
106 public $hostURL;
107 // Typo3 version
108 public $typoVersion;
109 // Identifies the RTE as being the one from the "rtehtmlarea" extension if any external code needs to know
110 var $ID = 'rtehtmlarea';
111 // If set, the content goes into a regular TEXT area field - for developing testing of transformations.
112 var $debugMode = FALSE;
113 // For the editor
114 var $client;
115
116 /**
117 * Reference to parent object, which is an instance of the TCEforms
118 *
119 * @var t3lib_TCEforms
120 */
121 var $TCEform;
122 var $elementId;
123 var $elementParts;
124 var $tscPID;
125 var $typeVal;
126 var $thePid;
127 var $RTEsetup;
128 var $thisConfig;
129 var $confValues;
130 public $language;
131 public $contentTypo3Language;
132 public $contentISOLanguage;
133 public $contentCharset;
134 public $OutputCharset;
135 var $editorCSS;
136 var $specConf;
137 var $toolbar = array(); // Save the buttons for the toolbar
138 var $toolbarOrderArray = array();
139 protected $pluginEnabledArray = array(); // Array of plugin id's enabled in the current RTE editing area
140 protected $pluginEnabledCumulativeArray = array(); // Cumulative array of plugin id's enabled so far in any of the RTE editing areas of the form
141 public $registeredPlugins = array(); // Array of registered plugins indexed by their plugin Id's
142 protected $fullScreen = FALSE;
143 protected $pageRenderer;
144
145 /**
146 * Returns TRUE if the RTE is available. Here you check if the browser requirements are met.
147 * If there are reasons why the RTE cannot be displayed you simply enter them as text in ->errorLog
148 *
149 * @return boolean TRUE if this RTE object offers an RTE in the current browser environment
150 */
151 function isAvailable() {
152
153 $this->client = $this->clientInfo();
154 $this->errorLog = array();
155 if (!$this->debugMode) { // If debug-mode, let any browser through
156 $rteIsAvailable = FALSE;
157 $rteConfBrowser = $this->conf_supported_browser;
158 if (is_array($rteConfBrowser)) {
159 foreach ($rteConfBrowser as $browser => $browserConf) {
160 if ($browser == $this->client['browser']) {
161 // Config for Browser found, check it:
162 if (is_array($browserConf)) {
163 foreach ($browserConf as $browserConfSub) {
164 if ($browserConfSub['version'] <= $this->client['version'] || empty($browserConfSub['version'])) {
165 // Version is supported
166 if (is_array($browserConfSub['system'])) {
167 // Check against allowed systems
168 if (is_array($browserConfSub['system']['allowed'])) {
169 foreach ($browserConfSub['system']['allowed'] as $system) {
170 if (in_array($system, $this->client['all_systems'])) {
171 $rteIsAvailable = TRUE;
172 break;
173 }
174 }
175 } else {
176 // All allowed
177 $rteIsAvailable = TRUE;
178 }
179 // Check against disallowed systems
180 if (is_array($browserConfSub['system']['disallowed'])) {
181 foreach ($browserConfSub['system']['disallowed'] as $system) {
182 if (in_array($system, $this->client['all_systems'])) {
183 $rteIsAvailable = FALSE;
184 break;
185 }
186 }
187 }
188 } else {
189 // No system config: system is supported
190 $rteIsAvailable = TRUE;
191 break;
192 }// End of System
193 }// End of Version
194 }// End of foreach-BrowserSubpart
195 } else {
196 // no config for this browser found, so all versions or system with this browsers are allow
197 $rteIsAvailable = TRUE;
198 break;
199 }
200 } // End of Browser Check
201 } // foreach: Browser Check
202 } else {
203 // no Browser config for this RTE-Editor, so all Clients are allow
204 }
205 if (!$rteIsAvailable) {
206 $this->errorLog[] = 'RTE: Browser not supported.';
207 }
208 if (t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) < 4000000) {
209 $rteIsAvailable = FALSE;
210 $this->errorLog[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.';
211 }
212 }
213 return $rteIsAvailable;
214 }
215
216 /**
217 * Draws the RTE as an iframe
218 *
219 * @param object Reference to parent object, which is an instance of the TCEforms.
220 * @param string The table name
221 * @param string The field name
222 * @param array The current row from which field is being rendered
223 * @param array Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
224 * @param array "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
225 * @param array Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
226 * @param string Record "type" field value.
227 * @param string Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
228 * @param integer PID value of record (true parent page id)
229 * @return string HTML code for RTE!
230 */
231
232 function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue) {
233 global $LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
234
235 $this->TCEform = $parentObject;
236 $inline = $this->TCEform->inline;
237 $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
238 $this->client = $this->clientInfo();
239 $this->typoVersion = t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version);
240 $this->userUid = 'BE_' . $GLOBALS['BE_USER']->user['uid'];
241
242 // Draw form element:
243 if ($this->debugMode) { // Draws regular text area (debug mode)
244 $item = parent::drawRTE($this->TCEform, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
245 } else { // Draw real RTE
246
247 /* =======================================
248 * INIT THE EDITOR-SETTINGS
249 * =======================================
250 */
251 // Set backPath
252 $this->backPath = $this->TCEform->backPath;
253 // Get the path to this extension:
254 $this->extHttpPath = $this->backPath . t3lib_extMgm::extRelPath($this->ID);
255 // Get the site URL
256 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
257 // Get the host URL
258 $this->hostURL = $this->siteURL . TYPO3_mainDir;
259 // Element ID + pid
260 $this->elementId = $PA['itemFormElName']; // Form element name
261 $this->elementParts = explode('][',preg_replace('/\]$/','',preg_replace('/^(TSFE_EDIT\[data\]\[|data\[)/','',$this->elementId)));
262 // Find the page PIDs:
263 list($this->tscPID,$this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]),trim($this->elementParts[1]),$thePidValue);
264
265 // Record "types" field value:
266 $this->typeVal = $RTEtypeVal; // TCA "types" value for record
267
268 // Find "thisConfig" for record/editor:
269 unset($this->RTEsetup);
270 $this->RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($this->tscPID));
271 $this->thisConfig = $thisConfig;
272
273 // Special configuration and default extras:
274 $this->specConf = $specConf;
275
276 if ($this->thisConfig['forceHTTPS']) {
277 $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
278 $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
279 $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
280 }
281 // Register RTE windows
282 $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
283 $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
284 $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId));
285
286 /* =======================================
287 * LANGUAGES & CHARACTER SETS
288 * =======================================
289 */
290
291 // Languages: interface and content
292 $this->language = $LANG->lang;
293 if ($this->language == 'default' || !$this->language) {
294 $this->language = 'en';
295 }
296 $this->contentTypo3Language = ($this->language == 'en') ? 'default' : $this->language;
297 $this->contentISOLanguage = 'en';
298 $this->contentLanguageUid = ($row['sys_language_uid'] > 0) ? $row['sys_language_uid'] : 0;
299 if (t3lib_extMgm::isLoaded('static_info_tables')) {
300 if ($this->contentLanguageUid) {
301 $tableA = 'sys_language';
302 $tableB = 'static_languages';
303 $languagesUidsList = $this->contentLanguageUid;
304 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
305 $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
306 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
307 $whereClause .= t3lib_BEfunc::BEenableFields($tableA);
308 $whereClause .= t3lib_BEfunc::deleteClause($tableA);
309 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
310 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
311 $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):''));
312 $this->contentTypo3Language = trim($languageRow['lg_typo3']) ? strtolower(trim($languageRow['lg_typo3'])) : 'default';
313 }
314 } else {
315 $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ? trim($this->thisConfig['defaultContentLanguage']) : 'en';
316 $selectFields = 'lg_iso_2, lg_typo3';
317 $tableAB = 'static_languages';
318 $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
319 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
320 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
321 $this->contentTypo3Language = trim($languageRow['lg_typo3']) ? strtolower(trim($languageRow['lg_typo3'])) : 'default';
322 }
323 }
324 }
325
326 // Character sets: interface and content
327 $this->charset = $LANG->charSet;
328 $this->OutputCharset = $this->charset;
329
330 $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
331 $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
332 $this->origContentCharSet = $this->contentCharset;
333 $this->contentCharset = (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset);
334
335 /* =======================================
336 * TOOLBAR CONFIGURATION
337 * =======================================
338 */
339 $this->initializeToolbarConfiguration();
340
341 /* =======================================
342 * SET STYLES
343 * =======================================
344 */
345 // Check if wizard_rte called this for fullscreen edtition
346 if (basename(PATH_thisScript) == 'wizard_rte.php') {
347 $this->fullScreen = TRUE;
348 $RTEWidth = '100%';
349 $RTEHeight = '100%';
350 $RTEPaddingRight = '0';
351 $editorWrapWidth = '100%';
352 } else {
353 $RTEWidth = isset($GLOBALS['BE_USER']->userTS['options.']['RTESmallWidth']) ? $GLOBALS['BE_USER']->userTS['options.']['RTESmallWidth'] : '530';
354 $RTEHeight = isset($GLOBALS['BE_USER']->userTS['options.']['RTESmallHeight']) ? $GLOBALS['BE_USER']->userTS['options.']['RTESmallHeight'] : '380';
355 $RTEWidth = $RTEWidth + ($this->TCEform->docLarge ? (isset($GLOBALS['BE_USER']->userTS['options.']['RTELargeWidthIncrement']) ? $GLOBALS['BE_USER']->userTS['options.']['RTELargeWidthIncrement'] : '150') : 0);
356 $RTEWidth -= ($inline->getStructureDepth() > 0 ? ($inline->getStructureDepth()+1)*$inline->getLevelMargin() : 0);
357 $RTEWidthOverride = (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth'])) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride']);
358 if ($RTEWidthOverride) {
359 if (strstr($RTEWidthOverride, '%')) {
360 if ($this->client['browser'] != 'msie') {
361 $RTEWidth = (intval($RTEWidthOverride) > 0) ? $RTEWidthOverride : '100%';
362 }
363 } else {
364 $RTEWidth = (intval($RTEWidthOverride) > 0) ? intval($RTEWidthOverride) : $RTEWidth;
365 }
366 }
367 $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px';
368 $RTEHeight = $RTEHeight + ($this->TCEform->docLarge ? (isset($GLOBALS['BE_USER']->userTS['options.']['RTELargeHeightIncrement']) ? $GLOBALS['BE_USER']->userTS['options.']['RTELargeHeightIncrement'] : 0) : 0);
369 $RTEHeightOverride = (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && intval($GLOBALS['BE_USER']->uc['rteHeight'])) ? intval($GLOBALS['BE_USER']->uc['rteHeight']) : intval($this->thisConfig['RTEHeightOverride']);
370 $RTEHeight = ($RTEHeightOverride > 0) ? $RTEHeightOverride : $RTEHeight;
371 $RTEPaddingRight = '2px';
372 $editorWrapWidth = '99%';
373 }
374 $editorWrapHeight = '100%';
375 $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px ' . $RTEPaddingRight . ' 2px 2px;';
376 /* =======================================
377 * LOAD CSS AND JAVASCRIPT
378 * =======================================
379 */
380 $this->pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
381 // Preloading the pageStyle and including RTE skin stylesheets
382 $this->addPageStyle();
383 $this->addSkin();
384 // Register RTE in JS
385 $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
386 // Set the save option for the RTE
387 $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId, $PA['itemFormElName']);
388 $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
389 // Loading ExtJs inline code
390 $this->pageRenderer->enableExtJSQuickTips();
391 // Add TYPO3 notifications JavaScript
392 $this->pageRenderer->addJsFile('../t3lib/js/extjs/notifications.js');
393 // Add RTE JavaScript
394 $this->addRteJsFiles($this->TCEform->RTEcounter);
395 $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
396 $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
397 /* =======================================
398 * DRAW THE EDITOR
399 * =======================================
400 */
401
402 // Transform value:
403 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
404
405 // Further content transformation by registered plugins
406 foreach ($this->registeredPlugins as $pluginId => $plugin) {
407 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "transformContent")) {
408 $value = $plugin->transformContent($value);
409 }
410 }
411 // Draw the textarea
412 $visibility = 'hidden';
413 $item = $this->triggerField($PA['itemFormElName']).'
414 <div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
415 <div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
416 <textarea id="RTEarea' . $textAreaId . '" name="'.htmlspecialchars($PA['itemFormElName']).'" rows="0" cols="0" style="'.t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)).'">'.t3lib_div::formatForTextarea($value).'</textarea>
417 </div>' . LF;
418 }
419
420 // Return form item:
421 return $item;
422 }
423
424 /**
425 * Add link to content style sheet to document header
426 *
427 * @return void
428 */
429 protected function addPageStyle() {
430 $this->addStyleSheet(
431 'rtehtmlarea-page-style',
432 $this->getContentCssFileName(),
433 'htmlArea RTE Content CSS',
434 'alternate stylesheet'
435 );
436 }
437
438 /**
439 * Get the name of the contentCSS file to use
440 *
441 * @return the full file name of the content css file to use
442 */
443 protected function getContentCssFileName() {
444 // Get stylesheet file name from Page TSConfig if any
445 $fileName = trim($this->thisConfig['contentCSS']);
446 if ($fileName) {
447 $fileName = $this->getFullFileName($fileName);
448 }
449 $absolutePath = $fileName
450 ? t3lib_div::resolveBackPath(PATH_site . (($this->is_FE() || $this->isFrontendEditActive()) ? '' : TYPO3_mainDir) . $fileName)
451 : '';
452
453 // Fallback to default content css file if configured file does not exists or is of zero size
454 if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
455 $fileName = $this->getFullFileName('EXT:' . $this->ID . '/res/contentcss/default.css');
456 }
457 return $fileName;
458 }
459
460 /**
461 * Add links to skin style sheet(s) to document header
462 *
463 * @return void
464 */
465 protected function addSkin() {
466 // Get skin file name from Page TSConfig if any
467 $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
468 $this->editorCSS = $this->getFullFileName($skinFilename);
469 $skinDir = dirname($this->editorCSS);
470 // Editing area style sheet
471 $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
472 $this->addStyleSheet(
473 'rtehtmlarea-editing-area-skin',
474 $this->editedContentCSS
475 );
476 // Main skin
477 $this->addStyleSheet(
478 'rtehtmlarea-skin',
479 $this->editorCSS
480 );
481 // Additional icons from registered plugins
482 foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
483 if (is_object($this->registeredPlugins[$pluginId])) {
484 $pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
485 if ($pathToSkin) {
486 $key = $this->registeredPlugins[$pluginId]->getExtensionKey();
487 $this->addStyleSheet(
488 'rtehtmlarea-plugin-' . $pluginId . '-skin',
489 ($this->is_FE() ? t3lib_extMgm::siteRelPath($key) : $this->backPath . t3lib_extMgm::extRelPath($key)) . $pathToSkin
490 );
491 }
492 }
493 }
494 }
495
496 /**
497 * Add style sheet file to document header
498 *
499 * @param string $key: some key identifying the style sheet
500 * @param string $href: uri to the style sheet file
501 * @param string $title: value for the title attribute of the link element
502 * @return string $relation: value for the rel attribute of the link element
503 * @return void
504 */
505 protected function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
506 // If it was not known that an RTE-enabled would be created when the page was first created, the css would not be added to head
507 if (is_object($this->TCEform->inline) && $this->TCEform->inline->isAjaxCall) {
508 $this->TCEform->additionalCode_pre[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '" title="' . $title. '" />';
509 } else {
510 $this->pageRenderer->addCssFile($href, $relation, 'screen', $title);
511 }
512 }
513
514 /**
515 * Initialize toolbar configuration and enable registered plugins
516 *
517 * @return void
518 */
519 protected function initializeToolbarConfiguration() {
520
521 // Enable registred plugins
522 $this->enableRegisteredPlugins();
523
524 // Configure toolbar
525 $this->setToolbar();
526
527 // Check if some plugins need to be disabled
528 $this->setPlugins();
529
530 // Merge the list of enabled plugins with the lists from the previous RTE editing areas on the same form
531 $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = $this->pluginEnabledArray;
532 if ($this->TCEform->RTEcounter > 1 && isset($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1]) && is_array($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1])) {
533 $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = array_unique(array_values(array_merge($this->pluginEnabledArray,$this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1])));
534 }
535 }
536
537 /**
538 * Add registered plugins to the array of enabled plugins
539 *
540 */
541 function enableRegisteredPlugins() {
542 global $TYPO3_CONF_VARS;
543 // Traverse registered plugins
544 if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'])) {
545 foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'] as $pluginId => $pluginObjectConfiguration) {
546 $plugin = FALSE;
547 if (is_array($pluginObjectConfiguration) && count($pluginObjectConfiguration)) {
548 $plugin = t3lib_div::getUserObj($pluginObjectConfiguration['objectReference']);
549 }
550 if (is_object($plugin)) {
551 if ($plugin->main($this)) {
552 $this->registeredPlugins[$pluginId] = $plugin;
553 // Override buttons from previously registered plugins
554 $pluginButtons = t3lib_div::trimExplode(',', $plugin->getPluginButtons(), 1);
555 foreach ($this->pluginButton as $previousPluginId => $buttonList) {
556 $this->pluginButton[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginButton[$previousPluginId], 1), $pluginButtons));
557 }
558 $this->pluginButton[$pluginId] = $plugin->getPluginButtons();
559 $pluginLabels = t3lib_div::trimExplode(',', $plugin->getPluginLabels(), 1);
560 foreach ($this->pluginLabel as $previousPluginId => $labelList) {
561 $this->pluginLabel[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginLabel[$previousPluginId], 1), $pluginLabels));
562 }
563 $this->pluginLabel[$pluginId] = $plugin->getPluginLabels();
564 $this->pluginEnabledArray[] = $pluginId;
565 }
566 }
567 }
568 }
569 // Process overrides
570 $hidePlugins = array();
571 foreach ($this->registeredPlugins as $pluginId => $plugin) {
572 if ($plugin->addsButtons() && !$this->pluginButton[$pluginId]) {
573 $hidePlugins[] = $pluginId;
574 }
575 }
576 $this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins));
577 }
578
579 /**
580 * Set the toolbar config (only in this PHP-Object, not in JS):
581 *
582 */
583
584 function setToolbar() {
585 if ($this->client['browser'] == 'msie' || $this->client['browser'] == 'opera') {
586 $this->thisConfig['keepButtonGroupTogether'] = 0;
587 }
588
589 $this->defaultToolbarOrder = 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
590 bar, formattext, bold, strong, italic, emphasis, big, small, insertedtext, deletedtext, citation, code, definition, keyboard, monospaced, quotation, sample, variable, bidioverride, strikethrough, subscript, superscript, underline, span,
591 bar, fontstyle, space, fontsize, bar, formatblock, insertparagraphbefore, insertparagraphafter, blockquote, line,
592 bar, left, center, right, justifyfull,
593 bar, orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, lefttoright, righttoleft, language, showlanguagemarks,
594 bar, textcolor, bgcolor, textindicator,
595 bar, editelement, emoticon, insertcharacter, insertsofthyphen, link, unlink, image, table,' . (($this->thisConfig['hideTableOperationsInToolbar'] && is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['toggleborders.']) && $this->thisConfig['buttons.']['toggleborders.']['keepInToolbar']) ? ' toggleborders,': '') . ' user, acronym, bar, findreplace, spellcheck,
596 bar, chMode, inserttag, removeformat, bar, copy, cut, paste, pastetoggle, pastebehaviour, bar, undo, redo, bar, showhelp, about, linebreak,
597 ' . ($this->thisConfig['hideTableOperationsInToolbar'] ? '': 'bar, toggleborders,') . ' bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
598 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
599 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
600
601 // Additional buttons from registered plugins
602 foreach($this->registeredPlugins as $pluginId => $plugin) {
603 if ($this->isPluginEnabled($pluginId)) {
604 $this->defaultToolbarOrder = $plugin->addButtonsToToolbar();
605 }
606 }
607 $toolbarOrder = $this->thisConfig['toolbarOrder'] ? $this->thisConfig['toolbarOrder'] : $this->defaultToolbarOrder;
608
609 // Getting rid of undefined buttons
610 $this->toolbarOrderArray = array_intersect(t3lib_div::trimExplode(',', $toolbarOrder, 1), t3lib_div::trimExplode(',', $this->defaultToolbarOrder, 1));
611 $toolbarOrder = array_unique(array_values($this->toolbarOrderArray));
612
613 // Fetching specConf for field from backend
614 $pList = is_array($this->specConf['richtext']['parameters']) ? implode(',',$this->specConf['richtext']['parameters']) : '';
615 if ($pList != '*') { // If not all
616 $show = is_array($this->specConf['richtext']['parameters']) ? $this->specConf['richtext']['parameters'] : array();
617 if ($this->thisConfig['showButtons']) {
618 if (!t3lib_div::inList($this->thisConfig['showButtons'],'*')) {
619 $show = array_unique(array_merge($show,t3lib_div::trimExplode(',',$this->thisConfig['showButtons'],1)));
620 } else {
621 $show = array_unique(array_merge($show, $toolbarOrder));
622 }
623 }
624 if (is_array($this->thisConfig['showButtons.'])) {
625 foreach ($this->thisConfig['showButtons.'] as $buttonId => $value) {
626 if ($value) $show[] = $buttonId;
627 }
628 $show = array_unique($show);
629 }
630 } else {
631 $show = $toolbarOrder;
632 }
633
634 // Resticting to RTEkeyList for backend user
635 if(is_object($GLOBALS['BE_USER'])) {
636 $RTEkeyList = isset($GLOBALS['BE_USER']->userTS['options.']['RTEkeyList']) ? $GLOBALS['BE_USER']->userTS['options.']['RTEkeyList'] : '*';
637 if ($RTEkeyList != '*') { // If not all
638 $show = array_intersect($show, t3lib_div::trimExplode(',',$RTEkeyList,1));
639 }
640 }
641
642 // Hiding buttons of disabled plugins
643 $hideButtons = array('space', 'bar', 'linebreak');
644 foreach ($this->pluginButton as $pluginId => $buttonList) {
645 if (!$this->isPluginEnabled($pluginId)) {
646 $buttonArray = t3lib_div::trimExplode(',',$buttonList,1);
647 foreach ($buttonArray as $button) {
648 $hideButtons[] = $button;
649 }
650 }
651 }
652
653 // Hiding labels of disabled plugins
654 foreach ($this->pluginLabel as $pluginId => $label) {
655 if (!$this->isPluginEnabled($pluginId)) {
656 $hideButtons[] = $label;
657 }
658 }
659
660 // Hiding buttons
661 $show = array_diff($show, $this->conf_toolbar_hide, t3lib_div::trimExplode(',',$this->thisConfig['hideButtons'],1));
662
663 // Apply toolbar constraints from registered plugins
664 foreach ($this->registeredPlugins as $pluginId => $plugin) {
665 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "applyToolbarConstraints")) {
666 $show = $plugin->applyToolbarConstraints($show);
667 }
668 }
669 // Getting rid of the buttons for which we have no position
670 $show = array_intersect($show, $toolbarOrder);
671 $this->toolbar = $show;
672 }
673
674 /**
675 * Disable some plugins
676 *
677 */
678 function setPlugins() {
679
680 // Disabling a plugin that adds buttons if none of its buttons is in the toolbar
681 $hidePlugins = array();
682 foreach ($this->pluginButton as $pluginId => $buttonList) {
683 if ($this->registeredPlugins[$pluginId]->addsButtons()) {
684 $showPlugin = FALSE;
685 $buttonArray = t3lib_div::trimExplode(',', $buttonList, 1);
686 foreach ($buttonArray as $button) {
687 if (in_array($button, $this->toolbar)) {
688 $showPlugin = TRUE;
689 }
690 }
691 if (!$showPlugin) {
692 $hidePlugins[] = $pluginId;
693 }
694 }
695 }
696 $this->pluginEnabledArray = array_diff($this->pluginEnabledArray, $hidePlugins);
697
698 // Hiding labels of disabled plugins
699 $hideLabels = array();
700 foreach ($this->pluginLabel as $pluginId => $label) {
701 if (!$this->isPluginEnabled($pluginId)) {
702 $hideLabels[] = $label;
703 }
704 }
705 $this->toolbar = array_diff($this->toolbar, $hideLabels);
706
707 // Adding plugins declared as prerequisites by enabled plugins
708 $requiredPlugins = array();
709 foreach ($this->registeredPlugins as $pluginId => $plugin) {
710 if ($this->isPluginEnabled($pluginId)) {
711 $requiredPlugins = array_merge($requiredPlugins, t3lib_div::trimExplode(',', $plugin->getRequiredPlugins(), 1));
712 }
713 }
714 $requiredPlugins = array_unique($requiredPlugins);
715 foreach ($requiredPlugins as $pluginId) {
716 if (is_object($this->registeredPlugins[$pluginId]) && !$this->isPluginEnabled($pluginId)) {
717 $this->pluginEnabledArray[] = $pluginId;
718 }
719 }
720 $this->pluginEnabledArray = array_unique($this->pluginEnabledArray);
721
722 // Completing the toolbar conversion array for htmlArea
723 foreach ($this->registeredPlugins as $pluginId => $plugin) {
724 if ($this->isPluginEnabled($pluginId)) {
725 $this->convertToolbarForHtmlAreaArray = array_unique(array_merge($this->convertToolbarForHtmlAreaArray, $plugin->getConvertToolbarForHtmlAreaArray()));
726 }
727 }
728 }
729 /**
730 * Convert the TYPO3 names of buttons into the names for htmlArea RTE
731 *
732 * @param string buttonname (typo3-name)
733 *
734 * @return string buttonname (htmlarea-name)
735 */
736 function convertToolbarForHTMLArea($button) {
737 return $this->convertToolbarForHtmlAreaArray[$button];
738 }
739 /**
740 * Add RTE main scripts and plugin scripts
741 *
742 * @param string $RTEcounter: The index number of the current RTE editing area within the form.
743 *
744 * @return void
745 */
746 protected function addRteJsFiles($RTEcounter) {
747 $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $this->ID . '/htmlarea/htmlarea.js'));
748 if ($this->client['browser'] == 'msie') {
749 $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $this->ID . '/htmlarea/htmlarea-ie.js'));
750 } else {
751 $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $this->ID . '/htmlarea/htmlarea-gecko.js'));
752 }
753 foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) {
754 $extensionKey = is_object($this->registeredPlugins[$pluginId]) ? $this->registeredPlugins[$pluginId]->getExtensionKey() : $this->ID;
755 $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js'));
756 }
757 }
758 /**
759 * Return RTE initialization inline JavaScript code
760 *
761 * @return string RTE initialization inline JavaScript code
762 */
763 protected function getRteInitJsCode() {
764 return '
765 if (typeof(RTEarea) == "undefined") {
766 RTEarea = new Object();
767 RTEarea[0] = new Object();
768 RTEarea[0].version = "' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['version'] . '";
769 RTEarea[0].editorUrl = "' . $this->extHttpPath . 'htmlarea/";
770 RTEarea[0].editorCSS = "' . t3lib_div::createVersionNumberedFilename($this->editorCSS) . '";
771 RTEarea[0].editorSkin = "' . dirname($this->editorCSS) . '/";
772 RTEarea[0].editedContentCSS = "' . t3lib_div::createVersionNumberedFilename($this->editedContentCSS) . '";
773 RTEarea[0].hostUrl = "' . $this->hostURL . '";
774 RTEarea.init = function() {
775 if (typeof(HTMLArea) == "undefined" || !Ext.isReady) {
776 window.setTimeout("RTEarea.init();", 10);
777 } else {
778 Ext.QuickTips.init();
779 HTMLArea.init();
780 }
781 };
782 RTEarea.initEditor = function(editorNumber) {
783 if (typeof(HTMLArea) == "undefined" || !HTMLArea.isReady) {
784 RTEarea.initEditor.defer(40, null, [editorNumber]);
785 } else {
786 HTMLArea.initEditor(editorNumber);
787 }
788 };
789 }
790 RTEarea.init();';
791 }
792 /**
793 * Return the Javascript code for configuring the RTE
794 *
795 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
796 * @param string $table: The table that includes this RTE (optional, necessary for IRRE).
797 * @param string $uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
798 * @param string $field: The field of that record that includes this RTE (optional).
799 *
800 * @return string the Javascript code for configuring the RTE
801 */
802 function registerRTEinJS($RTEcounter, $table='', $uid='', $field='', $textAreaId = '') {
803 $configureRTEInJavascriptString = '
804 if (typeof(configureEditorInstance) == "undefined") {
805 configureEditorInstance = new Object();
806 }
807 configureEditorInstance["' . $textAreaId . '"] = function() {
808 if (typeof(RTEarea) == "undefined" || typeof(HTMLArea) == "undefined") {
809 window.setTimeout("configureEditorInstance[\'' . $textAreaId . '\']();", 40);
810 } else {
811 editornumber = "' . $textAreaId . '";
812 RTEarea[editornumber] = new Object();
813 RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
814 RTEarea[editornumber].number = editornumber;
815 RTEarea[editornumber].deleted = false;
816 RTEarea[editornumber].textAreaId = "' . $textAreaId . '";
817 RTEarea[editornumber].id = "RTEarea" + editornumber;
818 RTEarea[editornumber].RTEWidthOverride = "' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth'])) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride'])) . '";
819 RTEarea[editornumber].RTEHeightOverride = "' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && intval($GLOBALS['BE_USER']->uc['rteHeight'])) ? intval($GLOBALS['BE_USER']->uc['rteHeight']) : intval($this->thisConfig['RTEHeightOverride'])) . '";
820 RTEarea[editornumber].resizable = ' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteResize']) && $GLOBALS['BE_USER']->uc['rteResize']) ? 'true' : (trim($this->thisConfig['rteResize']) ? 'true' : 'false')) . ';
821 RTEarea[editornumber].maxHeight = "' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteMaxHeight']) && intval($GLOBALS['BE_USER']->uc['rteMaxHeight'])) ? trim($GLOBALS['BE_USER']->uc['rteMaxHeight']) : (intval($this->thisConfig['rteMaxHeight']) ? intval($this->thisConfig['rteMaxHeight']) : '2000')) . '";
822 RTEarea[editornumber].fullScreen = ' . ($this->fullScreen ? 'true' : 'false') . ';
823 RTEarea[editornumber].showStatusBar = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
824 RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig['enableWordClean'])?'true':'false') . ';
825 RTEarea[editornumber].htmlRemoveComments = ' . (trim($this->thisConfig['removeComments'])?'true':'false') . ';
826 RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig['disableEnterParagraphs'])?'true':'false') . ';
827 RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig['disableObjectResizing'])?'true':'false') . ';
828 RTEarea[editornumber].removeTrailingBR = ' . (trim($this->thisConfig['removeTrailingBR'])?'true':'false') . ';
829 RTEarea[editornumber].useCSS = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . ';
830 RTEarea[editornumber].keepButtonGroupTogether = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . ';
831 RTEarea[editornumber].disablePCexamples = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . ';
832 RTEarea[editornumber].showTagFreeClasses = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
833 RTEarea[editornumber].useHTTPS = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
834 RTEarea[editornumber].tceformsNested = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(TRUE) : '[]') . ';
835 RTEarea[editornumber].dialogueWindows = new Object();';
836 // The following property is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8
837 if (isset($this->thisConfig['showTagFreeClasses'])) {
838 $this->logDeprecatedProperty('showTagFreeClasses', 'buttons.blockstyle.showTagFreeClasses', '4.8');
839 $this->logDeprecatedProperty('showTagFreeClasses', 'buttons.textstyle.showTagFreeClasses', '4.8');
840 }
841 // The following property is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8
842 if (isset($this->thisConfig['disablePCexamples'])) {
843 $this->logDeprecatedProperty('disablePCexamples', 'buttons.blockstyle.disableStyleOnOptionLabel', '4.8');
844 $this->logDeprecatedProperty('disablePCexamples', 'buttons.textstyle.disableStyleOnOptionLabel', '4.8');
845 }
846 if (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromTop'])) {
847 $configureRTEInJavascriptString .= '
848 RTEarea[editornumber].dialogueWindows.positionFromTop = ' . intval($this->thisConfig['dialogueWindows.']['defaultPositionFromTop']) . ';';
849 }
850 if (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft'])) {
851 $configureRTEInJavascriptString .= '
852 RTEarea[editornumber].dialogueWindows.positionFromLeft = ' . intval($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft']) . ';';
853 }
854 // The following properties apply only to the backend
855 if (!$this->is_FE()) {
856 $configureRTEInJavascriptString .= '
857 RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid . '";
858 RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language . '";
859 RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset . '";
860 RTEarea[editornumber].userUid = "' . $this->userUid . '";';
861 }
862
863 // Setting the plugin flags
864 $configureRTEInJavascriptString .= '
865 RTEarea[editornumber].plugin = new Object();
866 RTEarea[editornumber].pathToPluginDirectory = new Object();';
867 foreach ($this->pluginEnabledArray as $pluginId) {
868 $configureRTEInJavascriptString .= '
869 RTEarea[editornumber].plugin.'.$pluginId.' = true;';
870 if (is_object($this->registeredPlugins[$pluginId])) {
871 $pathToPluginDirectory = $this->registeredPlugins[$pluginId]->getPathToPluginDirectory();
872 if ($pathToPluginDirectory) {
873 $configureRTEInJavascriptString .= '
874 RTEarea[editornumber].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";';
875 }
876 }
877 }
878
879 // Setting the buttons configuration
880 $configureRTEInJavascriptString .= '
881 RTEarea[editornumber].buttons = new Object();';
882 if (is_array($this->thisConfig['buttons.'])) {
883 foreach ($this->thisConfig['buttons.'] as $buttonIndex => $conf) {
884 $button = substr($buttonIndex, 0, -1);
885 if (is_array($conf)) {
886 $configureRTEInJavascriptString .= '
887 RTEarea[editornumber].buttons.'.$button.' = ' . $this->buildNestedJSArray($conf) . ';';
888 }
889 }
890 }
891
892 // Setting the list of tags to be removed if specified in the RTE config
893 if (trim($this->thisConfig['removeTags'])) {
894 $configureRTEInJavascriptString .= '
895 RTEarea[editornumber].htmlRemoveTags = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;';
896 }
897
898 // Setting the list of tags to be removed with their contents if specified in the RTE config
899 if (trim($this->thisConfig['removeTagsAndContents'])) {
900 $configureRTEInJavascriptString .= '
901 RTEarea[editornumber].htmlRemoveTagsAndContents = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;';
902 }
903 // Process default style configuration
904 // This default configuration is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8.
905 // Use contentCSS instead.
906 $configureRTEInJavascriptString .= '
907 RTEarea[editornumber].defaultPageStyle = "' . $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
908 // Setting the pageStyle
909 $configureRTEInJavascriptString .= '
910 RTEarea[editornumber].pageStyle = "' . t3lib_div::createVersionNumberedFilename($this->getContentCssFileName()) .'";';
911 // Process classes configuration
912 $classesConfigurationRequired = FALSE;
913 foreach ($this->registeredPlugins as $pluginId => $plugin) {
914 if ($this->isPluginEnabled($pluginId)) {
915 $classesConfigurationRequired = $classesConfigurationRequired || $plugin->requiresClassesConfiguration();
916 }
917 }
918 if ($classesConfigurationRequired) {
919 $configureRTEInJavascriptString .= $this->buildJSClassesConfig($RTEcounter);
920 }
921 // Add Javascript configuration for registered plugins
922 foreach ($this->registeredPlugins as $pluginId => $plugin) {
923 if ($this->isPluginEnabled($pluginId)) {
924 $configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
925 }
926 }
927 // Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call
928 $configureRTEInJavascriptString .= '
929 RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . ';
930 RTEarea[editornumber].convertButtonId = ' . json_encode(array_flip($this->convertToolbarForHtmlAreaArray)) . ';
931 RTEarea.initEditor(editornumber);
932 }
933 };
934 configureEditorInstance["' . $textAreaId . '"]();';
935 return $configureRTEInJavascriptString;
936 }
937
938 /**
939 * Return TRUE, if the plugin can be loaded
940 *
941 * @param string $pluginId: The identification string of the plugin
942 *
943 * @return boolean TRUE if the plugin can be loaded
944 */
945
946 function isPluginEnabled($pluginId) {
947 return in_array($pluginId, $this->pluginEnabledArray);
948 }
949
950 /**
951 * Build the default content style sheet
952 *
953 * @return string Style sheet
954 * @deprecated since TYPO3 4.8, will be removed in TYPO3 4.10
955 */
956 function buildStyleSheet() {
957 // This function will be DEPRECATED as of TYPO3 4.8 and will be removed in TYPO3 4.10
958 //t3lib_div::logDeprecatedFunction();
959 // These PageTSConfig properties are DEPRECATED as of TYPO3 4.6 and will be removed in TYPO3 4.8
960 $properties = array('mainStyle_font', 'mainStyle_size', 'mainStyle_color', 'mainStyle_bgcolor', 'mainStyleOverride');
961 foreach ($properties as $property) {
962 if (isset($this->thisConfig[$property])) {
963 $this->logDeprecatedProperty($property, 'contentCSS', '4.8');
964 }
965 }
966 if (is_array($this->thisConfig['mainStyleOverride_add.'])) {
967 $this->logDeprecatedProperty('mainStyleOverride_add', 'contentCSS', '4.8');
968 }
969 if (is_array($this->thisConfig['inlineStyle.'])) {
970 $this->logDeprecatedProperty('inlineStyle', 'contentCSS', '4.8');
971 }
972 if (!trim($this->thisConfig['ignoreMainStyleOverride'])) {
973 $mainStyle_font = $this->thisConfig['mainStyle_font'] ? $this->thisConfig['mainStyle_font']: 'Verdana,sans-serif';
974 $mainElements = array();
975 $mainElements['P'] = $this->thisConfig['mainStyleOverride_add.']['P'];
976 $elList = explode(',','H1,H2,H3,H4,H5,H6,PRE');
977 foreach ($elList as $elListName) {
978 if ($this->thisConfig['mainStyleOverride_add.'][$elListName]) {
979 $mainElements[$elListName] = $this->thisConfig['mainStyleOverride_add.'][$elListName];
980 }
981 }
982
983 $addElementCode = '';
984 foreach ($mainElements as $elListName => $elValue) {
985 $addElementCode .= strToLower($elListName) . ' {' . $elValue . '}' . LF;
986 }
987
988 $stylesheet = $this->thisConfig['mainStyleOverride'] ? $this->thisConfig['mainStyleOverride'] : LF .
989 'body.htmlarea-content-body { font-family: ' . $mainStyle_font .
990 '; font-size: '.($this->thisConfig['mainStyle_size'] ? $this->thisConfig['mainStyle_size'] : '12px') .
991 '; color: '.($this->thisConfig['mainStyle_color']?$this->thisConfig['mainStyle_color'] : 'black') .
992 '; background-color: '.($this->thisConfig['mainStyle_bgcolor'] ? $this->thisConfig['mainStyle_bgcolor'] : 'white') .
993 ';'.$this->thisConfig['mainStyleOverride_add.']['BODY'].'}' . LF .
994 'td { ' . $this->thisConfig['mainStyleOverride_add.']['TD'].'}' . LF .
995 'div { ' . $this->thisConfig['mainStyleOverride_add.']['DIV'].'}' . LF .
996 'pre { ' . $this->thisConfig['mainStyleOverride_add.']['PRE'].'}' . LF .
997 'ol { ' . $this->thisConfig['mainStyleOverride_add.']['OL'].'}' . LF .
998 'ul { ' . $this->thisConfig['mainStyleOverride_add.']['UL'].'}' . LF .
999 'blockquote { ' . $this->thisConfig['mainStyleOverride_add.']['BLOCKQUOTE'].'}' . LF .
1000 $addElementCode;
1001
1002 if (is_array($this->thisConfig['inlineStyle.'])) {
1003 $stylesheet .= LF . implode(LF, $this->thisConfig['inlineStyle.']) . LF;
1004 }
1005 } else {
1006 $stylesheet = '/* mainStyleOverride and inlineStyle properties ignored. */';
1007 }
1008 return $stylesheet;
1009 }
1010
1011 /**
1012 * Return Javascript configuration of classes
1013 *
1014 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1015 *
1016 * @return string Javascript configuration of classes
1017 */
1018 function buildJSClassesConfig($RTEcounter) {
1019 // Build JS array of lists of classes
1020 // These PageTSConfig properties are DEPRECATED as of TYPO3 4.6 and will be removed in TYPO3 4.8
1021 $classesTagList = 'classesCharacter, classesParagraph, classesImage, classesTable, classesLinks, classesTD';
1022 $classesTagConvert = array('classesCharacter' => 'span', 'classesParagraph' => 'div', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td');
1023 $classesUseInstead = array('classesCharacter' => 'buttons.textstyle.tags.span.allowedClasses', 'classesParagraph' => 'buttons.blockstyle.tags.div.allowedClasses', 'classesImage' => 'buttons.image.properties.class.allowedClasses', 'classesTable' => 'buttons.blockstyle.tags.table.allowedClasses', 'classesLinks' => 'buttons.link.properties.class.allowedClasses', 'classesTD' => 'buttons.blockstyle.tags.td.allowedClasses');
1024 $classesTagArray = t3lib_div::trimExplode(',' , $classesTagList);
1025 $configureRTEInJavascriptString = '
1026 RTEarea[editornumber].classesTag = new Object();';
1027 foreach ($classesTagArray as $classesTagName) {
1028 $HTMLAreaJSClasses = $this->thisConfig[$classesTagName] ? ('"' . $this->cleanList($this->thisConfig[$classesTagName]) . '";') : 'null;';
1029 $configureRTEInJavascriptString .= '
1030 RTEarea[editornumber].classesTag.'. $classesTagConvert[$classesTagName] .' = '. $HTMLAreaJSClasses;
1031 if (isset($this->thisConfig[$classesTagName])) {
1032 $this->logDeprecatedProperty($classesTagName, $classesUseInstead[$classesTagName], '4.8');
1033 }
1034 }
1035 // Include JS arrays of configured classes
1036 $configureRTEInJavascriptString .= '
1037 RTEarea[editornumber].classesUrl = "' . $this->writeTemporaryFile('', 'classes_' . $this->language, 'js', $this->buildJSClassesArray(), TRUE) . '";';
1038 return $configureRTEInJavascriptString;
1039 }
1040
1041 /**
1042 * Return JS arrays of classes configuration
1043 *
1044 * @return string JS classes arrays
1045 */
1046 function buildJSClassesArray() {
1047 if ($this->is_FE()) {
1048 $RTEProperties = $this->RTEsetup;
1049 } else {
1050 $RTEProperties = $this->RTEsetup['properties'];
1051 }
1052 $classesArray = array('labels' => array(), 'values' => array(), 'noShow' => array(), 'alternating' => array(), 'counting' => array(), 'XOR' => array());
1053 $JSClassesArray = '';
1054 // Scanning the list of classes if specified in the RTE config
1055 if (is_array($RTEProperties['classes.'])) {
1056 foreach ($RTEProperties['classes.'] as $className => $conf) {
1057 $className = rtrim($className, '.');
1058 $classesArray['labels'][$className] = $this->getPageConfigLabel($conf['name'], FALSE);
1059 $classesArray['values'][$className] = str_replace('\\\'', '\'', $conf['value']);
1060 if (isset($conf['noShow'])) {
1061 $classesArray['noShow'][$className] = $conf['noShow'];
1062 }
1063 if (is_array($conf['alternating.'])) {
1064 $classesArray['alternating'][$className] = $conf['alternating.'];
1065 }
1066 if (is_array($conf['counting.'])) {
1067 $classesArray['counting'][$className] = $conf['counting.'];
1068 }
1069 }
1070 }
1071 // Scanning the list of sets of mutually exclusives classes if specified in the RTE config
1072 if (is_array($RTEProperties['mutuallyExclusiveClasses.'])) {
1073 foreach ($RTEProperties['mutuallyExclusiveClasses.'] as $listName => $conf) {
1074 $classSet = t3lib_div::trimExplode(',', $conf, 1);
1075 $classList = implode(',', $classSet);
1076 foreach ($classSet as $className) {
1077 $classesArray['XOR'][$className] = '/^(' . implode('|', t3lib_div::trimExplode(',', t3lib_div::rmFromList($className, $classList), 1)) . ')$/';
1078 }
1079 }
1080 }
1081 foreach ($classesArray as $key => $subArray) {
1082 $JSClassesArray .= 'HTMLArea.classes' . ucfirst($key) . ' = ' . $this->buildNestedJSArray($subArray) . ';' . LF;
1083 }
1084 return $JSClassesArray;
1085 }
1086
1087 /**
1088 * Translate Page TS Config array in JS nested array definition
1089 * Replace 0 values with false
1090 * Unquote regular expression values
1091 * Replace empty arrays with empty objects
1092 *
1093 * @param array $conf: Page TSConfig configuration array
1094 *
1095 * @return string nested JS array definition
1096 */
1097 function buildNestedJSArray($conf) {
1098 $convertedConf = t3lib_div::removeDotsFromTS($conf);
1099 if ($this->is_FE()) {
1100 $GLOBALS['TSFE']->csConvObj->convArray($convertedConf, ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : 'iso-8859-1'), 'utf-8');
1101 } else {
1102 $GLOBALS['LANG']->csConvObj->convArray($convertedConf, $GLOBALS['LANG']->charSet, 'utf-8');
1103 }
1104 return str_replace(array(':"0"', ':"\/^(', ')$\/i"', ':"\/^(', ')$\/"', '[]'), array(':false', ':/^(', ')$/i', ':/^(', ')$/', '{}'), json_encode($convertedConf));
1105 }
1106
1107 /**
1108 * Return a Javascript localization array for htmlArea RTE
1109 *
1110 * @return string Javascript localization array
1111 */
1112 function buildJSMainLangArray() {
1113 $JSLanguageArray = 'HTMLArea.I18N = new Object();' . LF;
1114 $labelsArray = array('tooltips' => array(), 'msg' => array(), 'dialogs' => array());
1115 foreach ($labelsArray as $labels => $subArray) {
1116 $LOCAL_LANG = t3lib_div::readLLfile('EXT:' . $this->ID . '/htmlarea/locallang_' . $labels . '.xml', $this->language, 'utf-8');
1117 if (!empty($LOCAL_LANG[$this->language])) {
1118 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language]);
1119 } else {
1120 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
1121 }
1122 $labelsArray[$labels] = $LOCAL_LANG[$this->language];
1123 }
1124 $JSLanguageArray .= 'HTMLArea.I18N = ' . json_encode($labelsArray) . ';' . LF;
1125 return $JSLanguageArray;
1126 }
1127
1128 /**
1129 * Writes contents in a file in typo3temp/rtehtmlarea directory and returns the file name
1130 *
1131 * @param string $sourceFileName: The name of the file from which the contents should be extracted
1132 * @param string $label: A label to insert at the beginning of the name of the file
1133 * @param string $fileExtension: The file extension of the file, defaulting to 'js'
1134 * @param string $contents: The contents to write into the file if no $sourceFileName is provided
1135 *
1136 * @return string The name of the file writtten to typo3temp/rtehtmlarea
1137 */
1138 public function writeTemporaryFile($sourceFileName='', $label, $fileExtension='js', $contents='', $concatenate = FALSE) {
1139 if ($sourceFileName) {
1140 $output = '';
1141 $source = t3lib_div::getFileAbsFileName($sourceFileName);
1142 $output = file_get_contents($source);
1143 } else {
1144 $output = $contents;
1145 }
1146 $relativeFilename = 'typo3temp/' . $this->ID . '_' . str_replace('-','_',$label) . '_' . t3lib_div::shortMD5((TYPO3_version . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . ($sourceFileName ? $sourceFileName : $output)), 20) . '.' . $fileExtension;
1147 $destination = PATH_site . $relativeFilename;
1148 if (!file_exists($destination)) {
1149 $minifiedJavaScript = '';
1150 if ($fileExtension == 'js' && $output != '') {
1151 $minifiedJavaScript = t3lib_div::minifyJavaScript($output);
1152 }
1153 $failure = t3lib_div::writeFileToTypo3tempDir($destination, $minifiedJavaScript ? $minifiedJavaScript : $output);
1154 if ($failure) {
1155 throw new RuntimeException($failure, 1294585668);
1156 }
1157 }
1158 if ($this->is_FE()) {
1159 $filename = ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . $relativeFilename;
1160 } else {
1161 $filename = ($this->isFrontendEditActive() ? '' : ($this->backPath . '../')) . $relativeFilename;
1162 }
1163 return t3lib_div::resolveBackPath($filename);
1164 }
1165 /**
1166 * Return a file name containing the main JS language array for HTMLArea
1167 *
1168 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1169 *
1170 * @return string filename
1171 */
1172 function buildJSMainLangFile($RTEcounter) {
1173 $contents = $this->buildJSMainLangArray() . LF;
1174 foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) {
1175 $contents .= $this->buildJSLangArray($pluginId) . LF;
1176 }
1177 return $this->writeTemporaryFile('', $this->language.'_'.$this->OutputCharset, 'js', $contents, TRUE);
1178 }
1179
1180 /**
1181 * Return a Javascript localization array for the plugin
1182 *
1183 * @param string $plugin: identification string of the plugin
1184 *
1185 * @return string Javascript localization array
1186 */
1187 function buildJSLangArray($plugin) {
1188 $LOCAL_LANG = FALSE;
1189 $extensionKey = is_object($this->registeredPlugins[$plugin]) ? $this->registeredPlugins[$plugin]->getExtensionKey() : $this->ID;
1190 $LOCAL_LANG = t3lib_div::readLLfile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $plugin . '/locallang.xml', $this->language, 'utf-8', 1);
1191 $JSLanguageArray = 'HTMLArea.I18N["' . $plugin . '"] = new Object();' . LF;
1192 if (is_array($LOCAL_LANG)) {
1193 if (!empty($LOCAL_LANG[$this->language])) {
1194 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'],$LOCAL_LANG[$this->language]);
1195 } else {
1196 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
1197 }
1198 $JSLanguageArray .= 'HTMLArea.I18N["' . $plugin . '"] = ' . json_encode($LOCAL_LANG[$this->language]) . ';'. LF;
1199 }
1200 return $JSLanguageArray;
1201 }
1202
1203 /**
1204 * Return the JS code of the toolbar configuration for the HTMLArea editor
1205 *
1206 * @return string the JS code as nested JS arrays
1207 */
1208 protected function getJSToolbarArray() {
1209 // The toolbar array
1210 $toolbar = array();
1211 // The current row; a "linebreak" ends the current row
1212 $row = array();
1213 // The current group; each group is between "bar"s; a "linebreak" ends the current group
1214 $group = array();
1215 // Process each toolbar item in the toolbar order list
1216 foreach ($this->toolbarOrderArray as $item) {
1217 switch ($item) {
1218 case 'linebreak':
1219 // Add row to toolbar if not empty
1220 if (!empty($group)) {
1221 $row[] = $group;
1222 $group = array();
1223 }
1224 if (!empty($row)) {
1225 $toolbar[] = $row;
1226 $row = array();
1227 }
1228 break;
1229 case 'bar':
1230 // Add group to row if not empty
1231 if (!empty($group)) {
1232 $row[] = $group;
1233 $group = array();
1234 }
1235 break;
1236 case 'space':
1237 if (end($group) != $this->convertToolbarForHTMLArea($item)) {
1238 $group[] = $this->convertToolbarForHTMLArea($item);
1239 }
1240 break;
1241 default:
1242 if (in_array($item, $this->toolbar)) {
1243 // Add the item to the group
1244 $convertedItem = $this->convertToolbarForHTMLArea($item);
1245 if ($convertedItem) {
1246 $group[] = $convertedItem;
1247 }
1248 }
1249 break;
1250 }
1251 }
1252 // Add the last group and last line, if not empty
1253 if (!empty($group)) {
1254 $row[] = $group;
1255 }
1256 if (!empty($row)) {
1257 $toolbar[] = $row;
1258 }
1259 return json_encode($toolbar);
1260 }
1261
1262 public function getLLContent($string) {
1263 global $LANG;
1264
1265 $BE_lang = $LANG->lang;
1266 $BE_charSet = $LANG->charSet;
1267 $LANG->lang = $this->contentTypo3Language;
1268 $LANG->charSet = $this->contentCharset;
1269 $LLString = $LANG->JScharCode($LANG->sL($string));
1270 $LANG->lang = $BE_lang;
1271 $LANG->charSet = $BE_charSet;
1272 return $LLString;
1273 }
1274
1275 public function getPageConfigLabel($string,$JScharCode=1) {
1276 global $LANG, $TSFE, $TYPO3_CONF_VARS;
1277
1278 if ($this->is_FE()) {
1279 if (strcmp(substr($string,0,4),'LLL:') && $TYPO3_CONF_VARS['BE']['forceCharset']) {
1280 // A pure string coming from Page TSConfig must be in forceCharset, otherwise we just don't know..
1281 $label = $TSFE->csConvObj->conv($TSFE->sL(trim($string)), $TYPO3_CONF_VARS['BE']['forceCharset'], $this->OutputCharset);
1282 } else {
1283 $label = $TSFE->csConvObj->conv($TSFE->sL(trim($string)), $this->charset, $this->OutputCharset);
1284 }
1285 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1286 $label = $JScharCode ? $this->feJScharCode($label) : $label;
1287 } else {
1288 if (strcmp(substr($string,0,4),'LLL:')) {
1289 $label = $string;
1290 } else {
1291 $label = $LANG->sL(trim($string));
1292 }
1293 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1294 $label = $JScharCode ? $LANG->JScharCode($label): $label;
1295 }
1296 return $label;
1297 }
1298
1299 function feJScharCode($str) {
1300 global $TSFE;
1301 // Convert string to UTF-8:
1302 if ($this->OutputCharset != 'utf-8') $str = $TSFE->csConvObj->utf8_encode($str,$this->OutputCharset);
1303 // Convert the UTF-8 string into a array of char numbers:
1304 $nArr = $TSFE->csConvObj->utf8_to_numberarray($str);
1305 return 'String.fromCharCode('.implode(',',$nArr).')';
1306 }
1307
1308 public function getFullFileName($filename) {
1309 if (substr($filename,0,4)=='EXT:') { // extension
1310 list($extKey,$local) = explode('/',substr($filename,4),2);
1311 $newFilename = '';
1312 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
1313 $newFilename = (($this->is_FE() || $this->isFrontendEditActive()) ? t3lib_extMgm::siteRelPath($extKey) : $this->backPath . t3lib_extMgm::extRelPath($extKey)) . $local;
1314 }
1315 } elseif (substr($filename,0,1) != '/') {
1316 $newFilename = (($this->is_FE() || $this->isFrontendEditActive()) ? '' : ($this->backPath . '../')) . $filename;
1317 } else {
1318 $newFilename = (($this->is_FE() || $this->isFrontendEditActive()) ? '' : ($this->backPath . '../')) . substr($filename, 1);
1319 }
1320 return t3lib_div::resolveBackPath($newFilename);
1321 }
1322
1323 /**
1324 * Return the Javascript code for copying the HTML code from the editor into the hidden input field.
1325 * This is for submit function of the form.
1326 *
1327 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1328 * @param string $formName: the name of the form
1329 * @param string $textareaId: the id of the textarea
1330 * @param string $textareaName: the name of the textarea
1331 *
1332 * @return string Javascript code
1333 */
1334 function setSaveRTE($RTEcounter, $formName, $textareaId, $textareaName) {
1335 return 'if (RTEarea["' . $textareaId . '"]) { document.' . $formName . '["' . $textareaName . '"].value = RTEarea["' . $textareaId . '"].editor.getHTML(); } else { OK = 0; };';
1336 }
1337
1338 /**
1339 * Return the Javascript code for copying the HTML code from the editor into the hidden input field.
1340 * This is for submit function of the form.
1341 *
1342 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1343 * @param string $formName: the name of the form
1344 * @param string $textareaId: the id of the textarea
1345 *
1346 * @return string Javascript code
1347 */
1348 function setDeleteRTE($RTEcounter, $formName, $textareaId) {
1349 return 'if (RTEarea["' . $textareaId . '"]) { RTEarea["' . $textareaId . '"].deleted = true;}';
1350 }
1351
1352 /**
1353 * Return TRUE if we are in the FE, but not in the FE editing feature of BE.
1354 *
1355 * @return boolean
1356 */
1357
1358 function is_FE() {
1359 return is_object($GLOBALS['TSFE']) && !$this->isFrontendEditActive() && TYPO3_MODE=='FE';
1360 }
1361
1362 /**
1363 * Checks whether frontend editing is active.
1364 *
1365 * @return boolean
1366 */
1367 public function isFrontendEditActive() {
1368 return is_object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->beUserLogin && ($GLOBALS['BE_USER']->frontendEdit instanceof t3lib_frontendedit);
1369 }
1370 /**
1371 * Client Browser Information
1372 *
1373 * @param string $userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT')
1374 * @return array Contains keys "useragent", "browser", "version", "system"
1375 * where "browser" is limited to the engines
1376 * and where "version" is a floating number
1377 */
1378 function clientInfo ($userAgent='') {
1379 if (!$userAgent) {
1380 $userAgent = t3lib_div::getIndpEnv('HTTP_USER_AGENT');
1381 }
1382 $browserInfo = t3lib_utility_Client::getBrowserInfo($userAgent);
1383 // Known engines: order is not irrelevant!
1384 $knownEngines = array('opera', 'msie', 'gecko', 'webkit');
1385 if (is_array($browserInfo['all'])) {
1386 foreach ($knownEngines as $engine) {
1387 if ($browserInfo['all'][$engine]) {
1388 $browserInfo['browser'] = $engine;
1389 $browserInfo['version'] = t3lib_utility_Client::getVersion($browserInfo['all'][$engine]);
1390 break;
1391 }
1392 }
1393 }
1394 return $browserInfo;
1395 }
1396 /**
1397 * Log usage of deprecated Page TS Config Property
1398 *
1399 * @param string $deprecatedProperty: Name of deprecated property
1400 * @param string $useProperty: Name of property to use instead
1401 * @param string $version: Version of TYPO3 in which the property will be removed
1402 *
1403 * @return void
1404 */
1405 public function logDeprecatedProperty ($deprecatedProperty, $useProperty, $version) {
1406 if (!$this->thisConfig['logDeprecatedProperties.']['disabled']) {
1407 $message = sprintf('RTE Page TSConfig property "%1$s" used on page id #%4$s is DEPRECATED and will be removed in TYPO3 %3$s. Use "%2$s" instead.', $deprecatedProperty, $useProperty, $version, $this->thePid);
1408 t3lib_div::deprecationLog($message);
1409 if (is_object($GLOBALS['BE_USER']) && $this->thisConfig['logDeprecatedProperties.']['logAlsoToBELog']) {
1410 $message = sprintf($GLOBALS['LANG']->getLL('deprecatedPropertyMessage'), $deprecatedProperty, $useProperty, $version, $this->thePid);
1411 $GLOBALS['BE_USER']->simplelog($message, $this->ID);
1412 }
1413 }
1414 }
1415 /***************************
1416 *
1417 * OTHER FUNCTIONS: (from Classic RTE)
1418 *
1419 ***************************/
1420 /**
1421 * @return [type] ...
1422 * @desc
1423 */
1424
1425 function RTEtsConfigParams() {
1426 if($this->is_FE()) {
1427 return '';
1428 } else {
1429 $p = t3lib_BEfunc::getSpecConfParametersFromArray($this->specConf['rte_transform']['parameters']);
1430 return $this->elementParts[0].':'.$this->elementParts[1].':'.$this->elementParts[2].':'.$this->thePid.':'.$this->typeVal.':'.$this->tscPID.':'.$p['imgpath'];
1431 }
1432 }
1433
1434 public function cleanList($str) {
1435 if (strstr($str,'*')) {
1436 $str = '*';
1437 } else {
1438 $str = implode(',',array_unique(t3lib_div::trimExplode(',',$str,1)));
1439 }
1440 return $str;
1441 }
1442
1443 function filterStyleEl($elValue,$matchList) {
1444 $matchParts = t3lib_div::trimExplode(',',$matchList,1);
1445 $styleParts = explode(';',$elValue);
1446 $nStyle=array();
1447 foreach ($styleParts as $k => $p) {
1448 $pp = t3lib_div::trimExplode(':',$p);
1449 if ($pp[0]&&$pp[1]) {
1450 foreach ($matchParts as $el) {
1451 $star=substr($el,-1)=='*';
1452 if (!strcmp($pp[0],$el) || ($star && t3lib_div::isFirstPartOfStr($pp[0],substr($el,0,-1)) )) {
1453 $nStyle[]=$pp[0].':'.$pp[1];
1454 } else unset($styleParts[$k]);
1455 }
1456 } else {
1457 unset($styleParts[$k]);
1458 }
1459 }
1460 return implode('; ',$nStyle);
1461 }
1462
1463 // Hook on lorem_ipsum extension to insert text into the RTE in wysiwyg mode
1464 function loremIpsumInsert($params) {
1465 return "
1466 if (typeof(lorem_ipsum) == 'function' && " . $params['element'] . ".tagName.toLowerCase() == 'textarea' ) lorem_ipsum(" . $params['element'] . ", lipsum_temp_strings[lipsum_temp_pointer]);
1467 ";
1468 }
1469 }
1470 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php'])) {
1471 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']);
1472 }
1473 ?>