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