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