9dcc707f5423bf06bceb4363ab6d593e87cf50b4
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / class.tx_rtehtmlarea_base.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
6 * (c) 2004 Philipp Borgmann <philipp.borgmann@gmx.de>
7 * (c) 2004, 2005, 2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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 <stanislas.rolland(arobas)fructifor.ca>
34 *
35 * $Id$ *
36 */
37
38 require_once(PATH_t3lib.'class.t3lib_rteapi.php');
39 require_once(PATH_t3lib.'class.t3lib_cs.php');
40
41 class tx_rtehtmlarea_base extends t3lib_rteapi {
42
43 // Configuration of supported browsers
44 var $conf_supported_browser = array (
45 'msie' => array (
46 1 => array (
47 'version' => 5.5,
48 'system' => 'win'
49 )
50 ),
51 'gecko' => array (
52 1 => array (
53 'version' => 1.3
54 )
55 ),
56 'safari' => array (
57 1 => array (
58 'version' => 312
59 )
60 ),
61 'opera' => array (
62 1 => array (
63 'version' => 9
64 )
65 )
66 );
67
68 // Always hide these toolbar buttons (TYPO3 button name)
69 var $conf_toolbar_hide = array (
70 'showhelp', // Has no content yet
71 );
72
73 // Hide these toolbar buttons not implemented in Safari
74 var $conf_toolbar_safari_hide = array (
75 'strikethrough',
76 'line',
77 'orderedlist',
78 'unorderedlist',
79 );
80
81 // Hide these toolbar buttons not implemented in Opera
82 var $conf_toolbar_opera_hide = array (
83 'copy',
84 'cut',
85 'paste',
86 );
87
88 // Always show these toolbar buttons (TYPO3 button name)
89 var $conf_toolbar_show = array (
90 'undo',
91 'redo',
92 //'showhelp',
93 'about',
94 );
95
96 // The order of the toolbar: the name is the TYPO3-button name
97 var $defaultToolbarOrder;
98
99 // The default hotkeys: the name is the TYPO3-button name
100 var $defaultHotKeyList = 'selectall, bold, italic, underline, strikethrough, left, center, right, justifyfull, formatblock, paste, cleanword, undo, redo';
101
102 // Conversion array: TYPO3 button names to htmlArea button names
103 var $conf_toolbar_convert = array (
104 // 'TYPO3 name' => 'htmlArea name'
105 'fontstyle' => 'FontName',
106 'fontsize' => 'FontSize',
107 'textcolor' => 'ForeColor',
108 'bgcolor' => 'HiliteColor',
109 'bold' => 'Bold',
110 'italic' => 'Italic',
111 'underline' => 'Underline',
112 'left' => 'JustifyLeft',
113 'center' => 'JustifyCenter',
114 'right' => 'JustifyRight',
115 'orderedlist' => 'InsertOrderedList',
116 'unorderedlist' => 'InsertUnorderedList',
117 'outdent' => 'Outdent',
118 'indent' => 'Indent',
119 'emoticon' => 'InsertSmiley',
120 'line' => 'InsertHorizontalRule',
121 'link' => 'CreateLink',
122 'table' => 'InsertTable',
123 'image' => 'InsertImage',
124 'cut' => 'Cut',
125 'copy' => 'Copy',
126 'paste' => 'Paste',
127 'formatblock' => 'FormatBlock',
128 'chMode' => 'HtmlMode',
129 'user' => 'UserElements',
130
131 // htmlArea extra buttons
132 'lefttoright' => 'LeftToRight',
133 'righttoleft' => 'RightToLeft',
134 'justifyfull' => 'JustifyFull',
135 'strikethrough' => 'StrikeThrough',
136 'superscript' => 'Superscript',
137 'subscript' => 'Subscript',
138 'showhelp' => 'ShowHelp',
139 'insertcharacter' => 'InsertCharacter',
140 'findreplace' => 'FindReplace',
141 'spellcheck' => 'SpellCheck',
142 'removeformat' => 'RemoveFormat',
143 'inserttag' => 'InsertTag',
144 'acronym' => 'Acronym',
145 'splitblock' => 'SplitBlock',
146 'blockstylelabel' => 'I[style]',
147 'blockstyle' => 'DynamicCSS-class',
148 'textstylelabel' => 'I[text_style]',
149 'textstyle' => 'InlineCSS-class',
150 'toggleborders' => 'TO-toggle-borders',
151 'tableproperties' => 'TO-table-prop',
152 'rowproperties' => 'TO-row-prop',
153 'rowinsertabove' => 'TO-row-insert-above',
154 'rowinsertunder' => 'TO-row-insert-under',
155 'rowdelete' => 'TO-row-delete',
156 'rowsplit' => 'TO-row-split',
157 'columninsertbefore' => 'TO-col-insert-before',
158 'columninsertafter' => 'TO-col-insert-after',
159 'columndelete' => 'TO-col-delete',
160 'columnsplit' => 'TO-col-split',
161 'cellproperties' => 'TO-cell-prop',
162 'cellinsertbefore' => 'TO-cell-insert-before',
163 'cellinsertafter' => 'TO-cell-insert-after',
164 'celldelete' => 'TO-cell-delete',
165 'cellsplit' => 'TO-cell-split',
166 'cellmerge' => 'TO-cell-merge',
167
168 // Toolbar formating
169 'space' => 'space',
170 'bar' => 'separator',
171 'linebreak' => 'linebreak',
172
173 // Always show
174 'undo' => 'Undo',
175 'redo' => 'Redo',
176 'textindicator' => 'TextIndicator',
177 'about' => 'About',
178 );
179
180 var $defaultParagraphs = array(
181 'p' => 'Normal',
182 'h1' => 'Heading 1',
183 'h2' => 'Heading 2',
184 'h3' => 'Heading 3',
185 'h4' => 'Heading 4',
186 'h5' => 'Heading 5',
187 'h6' => 'Heading 6',
188 'pre' => 'Preformatted',
189 'address' => 'Address',
190 );
191
192 var $defaultFontFaces = array(
193 'Arial' => 'Arial,sans-serif',
194 'Arial Black' => 'Arial Black,sans-serif',
195 'Verdana' => 'Verdana,Arial,sans-serif',
196 'Times New Roman' => 'Times New Roman,Times,serif',
197 'Garamond' => 'Garamond',
198 'Lucida Handwriting' => 'Lucida Handwriting',
199 'Courier' => 'Courier',
200 'Webdings' => 'Webdings',
201 'Wingdings' => 'Wingdings',
202 );
203
204 var $defaultFontSizes = array(
205 '1' => '1 (8 pt)',
206 '2' => '2 (10 pt)',
207 '3' => '3 (12 pt)',
208 '4' => '4 (14 pt)',
209 '5' => '5 (18 pt)',
210 '6' => '6 (24 pt)',
211 '7' => '7 (36 pt)',
212 );
213
214 var $defaultFontSizes_safari = array(
215 '1' => 'xx-small',
216 '2' => 'x-small',
217 '3' => 'small',
218 '4' => 'medium',
219 '5' => 'large',
220 '6' => 'x-large',
221 '7' => 'xx-large',
222 );
223
224 var $pluginList = 'TableOperations, ContextMenu, SpellChecker, SelectColor, TYPO3Browsers, InsertSmiley, FindReplace, RemoveFormat, CharacterMap, QuickTag, InlineCSS, DynamicCSS, UserElements, Acronym, TYPO3HtmlParser';
225
226 var $pluginButton = array(
227 'InlineCSS' => 'textstyle',
228 'DynamicCSS' => 'blockstyle',
229 'SpellChecker' => 'spellcheck',
230 'InsertSmiley' => 'emoticon',
231 'FindReplace' => 'findreplace',
232 'RemoveFormat' => 'removeformat',
233 'QuickTag' => 'inserttag',
234 'CharacterMap' => 'insertcharacter',
235 'TableOperations' => 'table, toggleborders, tableproperties, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit,
236 columninsertbefore, columninsertafter, columndelete, columnsplit,
237 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge',
238 'UserElements' => 'user',
239 'Acronym' => 'acronym',
240 );
241
242 var $pluginLabel = array(
243 'InlineCSS' => 'textstylelabel',
244 'DynamicCSS' => 'blockstylelabel',
245 );
246
247 var $spellCheckerModes = array( 'ultra', 'fast', 'normal', 'bad-spellers');
248
249 // External:
250 var $RTEdivStyle; // Alternative style for RTE <div> tag.
251 var $extHttpPath; // full Path to this extension for http (so no Server path). It ends with "/"
252 var $siteURL; // TYPO3 site url
253 var $hostURL; // TYPO3 host url
254 var $typoVersion; // Typo3 version
255
256 // Internal, static:
257 var $ID = 'rtehtmlarea'; // Identifies the RTE as being the one from the "rte" extension if any external code needs to know...
258 var $debugMode = FALSE; // If set, the content goes into a regular TEXT area field - for developing testing of transformations. (Also any browser will load the field!)
259
260 // For the editor
261 var $client;
262
263 /**
264 * Reference to parent object, which is an instance of the TCEforms
265 *
266 * @var t3lib_TCEforms
267 */
268 var $TCEform;
269 var $elementId;
270 var $elementParts;
271 var $tscPID;
272 var $typeVal;
273 var $thePid;
274 var $RTEsetup;
275 var $thisConfig;
276 var $confValues;
277 var $language;
278 var $BECharset;
279 var $OutputCharset;
280 var $editorCSS;
281 var $spellCheckerLanguage;
282 var $spellCheckerCharset;
283 var $spellCheckerMode;
284 var $quickTagHideTags;
285 var $specConf;
286 var $toolBar = array(); // Save the buttons for the toolbar
287 var $toolbar_level_size; // The size for each level in the toolbar:
288 var $toolbarOrderArray = array();
289 var $pluginEnableList;
290 var $pluginEnableArray = array();
291
292 /**
293 * Returns true if the RTE is available. Here you check if the browser requirements are met.
294 * If there are reasons why the RTE cannot be displayed you simply enter them as text in ->errorLog
295 *
296 * @return boolean TRUE if this RTE object offers an RTE in the current browser environment
297 */
298
299 function isAvailable() {
300 global $TYPO3_CONF_VARS;
301
302 $this->client = $this->clientInfo();
303 $this->errorLog = array();
304 if (!$this->debugMode) { // If debug-mode, let any browser through
305 $rteIsAvailable = 0;
306 $rteConfBrowser = $this->conf_supported_browser;
307 if (!$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['enableInOpera9']) unset($rteConfBrowser['opera']);
308 if (is_array($rteConfBrowser)) {
309 reset($rteConfBrowser);
310 while(list ($browser, $browserConf) = each($rteConfBrowser)){
311 if ($browser == $this->client['BROWSER']) {
312 // Config for Browser found, check it:
313 if (is_array($browserConf)) {
314 reset($browserConf);
315 while(list ($browserConfNr, $browserConfSub) = each($browserConf)){
316 if ($browserConfSub['version'] <= $this->client['VERSION'] || empty($browserConfSub['version'])) {
317 // Version is correct
318 if ($browserConfSub['system'] == $this->client['SYSTEM'] || empty($browserConfSub['system'])) {
319 // System is correctly
320 $rteIsAvailable = 1;
321 }// End of System
322 }// End of Version
323 }// End of while-BrowserSubpart
324 } else {
325 // no config for this browser found, so all versions or system with this browsers are allow
326 $rteIsAvailable = 1;
327 }
328 } // End of Browser Check
329 } // while: Browser Check
330 } else {
331 // no Browser config for this RTE-Editor, so all Clients are allow
332 }
333 if (!$rteIsAvailable) {
334 $this->errorLog[] = 'rte: Browser not supported. Only msie Version 5 or higher and Mozilla based client 1. and higher.';
335 }
336 if (t3lib_div::int_from_ver(TYPO3_version) < 3007000) {
337 $rteIsAvailable = 0;
338 $this->errorLog[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.';
339 }
340 }
341 if ($rteIsAvailable) return true;
342 }
343
344 /**
345 * Draws the RTE as an iframe
346 *
347 * @param object Reference to parent object, which is an instance of the TCEforms.
348 * @param string The table name
349 * @param string The field name
350 * @param array The current row from which field is being rendered
351 * @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.
352 * @param array "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
353 * @param array Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
354 * @param string Record "type" field value.
355 * @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!
356 * @param integer PID value of record (true parent page id)
357 * @return string HTML code for RTE!
358 */
359
360 function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue) {
361 global $BE_USER,$LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
362
363 $this->TCEform = $pObj;
364 $inline =& $this->TCEform->inline;
365
366 $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
367 $this->client = $this->clientInfo();
368 $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
369 $this->userUid = 'BE_' . $BE_USER->user['uid'];
370
371 // Draw form element:
372 if ($this->debugMode) { // Draws regular text area (debug mode)
373 $item = parent::drawRTE($pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
374 } else { // Draw real RTE
375
376 /* =======================================
377 * INIT THE EDITOR-SETTINGS
378 * =======================================
379 */
380
381 // first get the http-path to typo3:
382 $this->httpTypo3Path = substr( substr( t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen( t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') ) ), 0, -1 );
383 if (strlen($this->httpTypo3Path) == 1) {
384 $this->httpTypo3Path = '/';
385 } else {
386 $this->httpTypo3Path .= '/';
387 }
388 // Get the path to this extension:
389 $this->extHttpPath = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->ID);
390 // Get the site URL
391 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
392 // Get the host URL
393 $this->hostURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST');
394
395 // Element ID + pid
396 $this->elementId = $PA['itemFormElName']; // Form element name
397 $this->elementParts = explode('][',ereg_replace('\]$','',ereg_replace('^(TSFE_EDIT\[data\]\[|data\[)','',$this->elementId)));
398
399 // Find the page PIDs:
400 list($this->tscPID,$this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]),trim($this->elementParts[1]),$thePidValue);
401
402 // Record "types" field value:
403 $this->typeVal = $RTEtypeVal; // TCA "types" value for record
404
405 // Find "thisConfig" for record/editor:
406 unset($this->RTEsetup);
407 $this->RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($this->tscPID));
408 $this->thisConfig = $thisConfig;
409
410 // Special configuration and default extras:
411 $this->specConf = $specConf;
412
413 if ($this->thisConfig['forceHTTPS']) {
414 $this->httpTypo3Path = preg_replace('/^(http|https)/', 'https', $this->httpTypo3Path);
415 $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
416 $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
417 $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
418 }
419
420 /* =======================================
421 * LANGUAGES & CHARACTER SETS
422 * =======================================
423 */
424
425 // Languages: interface and content
426 $this->language = $LANG->lang;
427 if ($this->language=='default' || !$this->language) {
428 $this->language='en';
429 }
430 $this->contentTypo3Language = $this->language;
431
432 $this->contentLanguageUid = ($row['sys_language_uid'] > 0) ? $row['sys_language_uid'] : 0;
433 if (t3lib_extMgm::isLoaded('static_info_tables')) {
434 if ($this->contentLanguageUid) {
435 $tableA = 'sys_language';
436 $tableB = 'static_languages';
437 $languagesUidsList = $this->contentLanguageUid;
438 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
439 $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
440 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
441 $whereClause .= t3lib_BEfunc::BEenableFields($tableA);
442 $whereClause .= t3lib_BEfunc::deleteClause($tableA);
443 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
444 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
445 $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):''));
446 $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
447 }
448 } else {
449 $this->contentISOLanguage = trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) ? trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) : 'en';
450 $selectFields = 'lg_iso_2, lg_typo3';
451 $tableAB = 'static_languages';
452 $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
453 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
454 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
455 $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
456 }
457 }
458 }
459
460 // Character sets: interface and content
461 $this->charset = $LANG->csConvObj->charSetArray[$this->language];
462 $this->charset = $this->charset ? $this->charset : 'iso-8859-1';
463 $this->BECharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->charset;
464 $this->OutputCharset = $this->BECharset;
465
466 $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
467 $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
468 $this->origContentCharSet = $this->contentCharset;
469 $this->contentCharset = (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset);
470
471 /* =======================================
472 * TOOLBAR CONFIGURATION
473 * =======================================
474 */
475
476 // htmlArea plugins list
477 $this->pluginEnableArray = array_intersect(t3lib_div::trimExplode(',', $this->pluginList , 1), t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['HTMLAreaPluginList'], 1));
478 $hidePlugins = array();
479 if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker';
480 if ($this->client['BROWSER'] == 'msie') $hidePlugins[] = 'Acronym';
481 if ($this->client['BROWSER'] == 'opera') {
482 $hidePlugins[] = 'ContextMenu';
483 $this->thisConfig['hideTableOperationsInToolbar'] = 0;
484 $this->thisConfig['disableEnterParagraphs'] = 1;
485 }
486 $this->pluginEnableArray = array_diff($this->pluginEnableArray, $hidePlugins);
487 $this->pluginEnableArrayMultiple = $this->pluginEnableArray;
488
489 // Toolbar
490 $this->setToolBar();
491
492 // Check if some plugins need to be disabled
493 $this->setPlugins();
494
495 /* =======================================
496 * PLUGIN-SPECIFIC CONFIGURATION
497 * =======================================
498 */
499
500 if ($this->isPluginEnable('SpellChecker')) {
501 // Set the language of the content for the SpellChecker
502 $this->spellCheckerLanguage = $this->contentISOLanguage;
503 $this->spellCheckerTypo3Language = $this->contentTypo3Language;
504
505 // Set the charset of the content for the SpellChecker
506 $this->spellCheckerCharset = $this->contentCharset;
507 $this->spellCheckerCharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->spellCheckerCharset;
508
509 // Set the SpellChecker mode
510 $this->spellCheckerMode = isset($BE_USER->userTS['options.']['HTMLAreaPspellMode']) ? trim($BE_USER->userTS['options.']['HTMLAreaPspellMode']) : 'normal';
511 if( !in_array($this->spellCheckerMode, $this->spellCheckerModes)) {
512 $this->spellCheckerMode = 'normal';
513 }
514
515 // Set the use of personal dictionary
516 $this->spellCheckerPersonalDicts = $this->thisConfig['enablePersonalDicts'] ? (isset($BE_USER->userTS['options.']['enablePersonalDicts']) ? true : false) : false;
517 if (ini_get('safe_mode')) {
518 $this->spellCheckerPersonalDicts = false;
519 }
520 }
521
522 /* =======================================
523 * SET STYLES
524 * =======================================
525 */
526
527 $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530';
528 $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380';
529 $RTEWidth = $RTEWidth + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150') : 0);
530 $RTEWidth -= ($inline->getStructureDepth() > 0 ? ($inline->getStructureDepth()+1)*$inline->getLevelMargin() : 0);
531 $RTEHeight = $RTEHeight + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0) : 0);
532 $editorWrapWidth = $RTEWidth . 'px';
533 $editorWrapHeight = $RTEHeight . 'px';
534 $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:'.$RTEWidth.'px; border: 1px solid black; padding: 2px 0px 2px 2px;';
535 $this->toolbar_level_size = $RTEWidth;
536
537 /* =======================================
538 * LOAD CSS AND JAVASCRIPT
539 * =======================================
540 */
541
542 // Preloading the pageStyle
543 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css';
544 $pObj->additionalCode_pre['loadCSS'] = '
545 <link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" />';
546
547 // Loading the editor skin
548 $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
549 if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:') {
550 $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
551 }
552 if (substr($skinFilename,0,4) == 'EXT:') { // extension
553 list($extKey,$local) = explode('/',substr($skinFilename,4),2);
554 $skinFilename='';
555 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
556 $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local;
557 $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
558 }
559 } elseif (substr($skinFilename,0,1) != '/') {
560 $skinDir = $this->siteURL.dirname($skinFilename);
561 $skinFilename = $this->siteURL . $skinFilename;
562 } else {
563 $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
564 }
565 $this->editorCSS = $skinFilename;
566 $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
567 $pObj->additionalCode_pre['loadCSS'] .= '
568 <link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
569
570 $pObj->additionalCode_pre['loadCSS'] .= '
571 <link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
572
573 // Loading JavaScript files and code
574 $pObj->additionalCode_pre['loadJSfiles'] = $this->loadJSfiles($pObj->RTEcounter);
575 $pObj->additionalJS_pre['loadJScode'] = $this->loadJScode($pObj->RTEcounter);
576
577 /* =======================================
578 * DRAW THE EDITOR
579 * =======================================
580 */
581
582 // Transform value:
583 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
584
585 // Change some tags
586 if ($this->client['BROWSER'] == 'gecko') {
587 // change <strong> to <b>
588 $value = preg_replace('/<(\/?)strong/i', "<$1b", $value);
589 // change <em> to <i>
590 $value = preg_replace('/<(\/?)em([^b>]*>)/i', "<$1i$2", $value);
591 }
592 if ($this->client['BROWSER'] == 'msie') {
593 // change <abbr> to <acronym>
594 $value = preg_replace('/<(\/?)abbr/i', "<$1acronym", $value);
595 }
596
597 // Register RTE windows
598 $pObj->RTEwindows[] = $PA['itemFormElName'];
599
600 // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
601 if (basename(PATH_thisScript) == 'wizard_rte.php') {
602 $height = 'window.innerHeight';
603 $width = 'window.innerWidth';
604 if ($this->client['BROWSER'] == 'msie') {
605 $height = 'document.body.offsetHeight';
606 $width = 'document.body.offsetWidth';
607 }
608 $editorWrapWidth = '100%';
609 $editorWrapHeight = '100%';
610 $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
611 $pObj->additionalJS_post[] = $this->setRTEsizeByJS('RTEarea'.$pObj->RTEcounter, $height, $width);
612 }
613
614 // Register RTE in JS:
615 $pObj->additionalJS_post[] = $this->registerRTEinJS($pObj->RTEcounter, $table, $row['uid'], $field);
616
617 // Set the save option for the RTE:
618 $pObj->additionalJS_submit[] = $this->setSaveRTE($pObj->RTEcounter, $pObj->formName, htmlspecialchars($PA['itemFormElName']));
619
620 // Draw the textarea
621 $visibility = 'hidden';
622 $item = $this->triggerField($PA['itemFormElName']).'
623 <div id="pleasewait' . $pObj->RTEcounter . '" class="pleasewait" style="display: none;" >' . $LANG->getLL('Please wait') . '</div>
624 <div id="editorWrap' . $pObj->RTEcounter . '" class="editorWrap" style="width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
625 <textarea id="RTEarea'.$pObj->RTEcounter.'" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)).'">'.t3lib_div::formatForTextarea($value).'</textarea>
626 </div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
627 ';
628 }
629
630 // Return form item:
631 return $item;
632 }
633
634 /**
635 * Set the toolbar config (only in this PHP-Object, not in JS):
636 *
637 */
638
639 function setToolBar() {
640 global $BE_USER;
641
642 $this->defaultToolbarOrder = 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
643 bar, fontstyle, space, fontsize, space, formatblock,
644 bar, bold, italic, underline, strikethrough, subscript, superscript,
645 bar, lefttoright, righttoleft, bar, left, center, right, justifyfull,
646 bar, orderedlist, unorderedlist, outdent, indent, bar, textcolor, bgcolor, textindicator,
647 bar, emoticon, insertcharacter, line, link, 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,
648 bar, chMode, inserttag, removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
649 ' . ($this->thisConfig['hideTableOperationsInToolbar'] ? '': 'bar, toggleborders,') . ' bar, tableproperties, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
650 columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
651 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
652
653 // Special toolbar for Mozilla Wamcom on Mac OS 9
654 if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3') {
655 $this->defaultToolbarOrder = $this->TCEform->docLarge ? 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
656 bar, fontstyle, space, fontsize, space, formatblock, bar, bold, italic, underline, strikethrough,
657 subscript, superscript, lefttoright, righttoleft, bar, left, center, right, justifyfull, linebreak,
658 bar, orderedlist, unorderedlist, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
659 insertcharacter, line, link, image, table, user, acronym, bar, findreplace, spellcheck, bar, chMode, inserttag,
660 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
661 bar, toggleborders, bar, tableproperties, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
662 columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
663 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge'
664 : 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
665 bar, fontstyle, space, fontsize, space, formatblock, bar, bold, italic, underline, strikethrough,
666 subscript, superscript, linebreak, bar, lefttoright, righttoleft, bar, left, center, right, justifyfull,
667 orderedlist, unorderedlist, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
668 insertcharacter, line, link, image, table, user, acronym, linebreak, bar, findreplace, spellcheck, bar, chMode, inserttag,
669 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
670 bar, toggleborders, bar, tableproperties, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
671 columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
672 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
673 }
674 $toolbarOrder = $this->thisConfig['toolbarOrder'] ? $this->thisConfig['toolbarOrder'] : $this->defaultToolbarOrder;
675
676 // Getting rid of undefined buttons
677 $this->toolbarOrderArray = array_intersect(t3lib_div::trimExplode(',', $toolbarOrder, 1), t3lib_div::trimExplode(',', $this->defaultToolbarOrder, 1));
678 $toolbarOrder = array_unique(array_values($this->toolbarOrderArray));
679
680 // Fetching specConf for field from backend
681 $pList = is_array($this->specConf['richtext']['parameters']) ? implode(',',$this->specConf['richtext']['parameters']) : '';
682 if ($pList != '*') { // If not all
683 $show = is_array($this->specConf['richtext']['parameters']) ? $this->specConf['richtext']['parameters'] : array();
684 if ($this->thisConfig['showButtons']) {
685 if (!t3lib_div::inList($this->thisConfig['showButtons'],'*')) {
686 $show = array_unique(array_merge($show,t3lib_div::trimExplode(',',$this->thisConfig['showButtons'],1)));
687 } else {
688 $show = array_unique(array_merge($show, $toolbarOrder));
689 }
690 }
691 if (is_array($this->thisConfig['showButtons.'])) {
692 reset($this->thisConfig['showButtons.']);
693 while(list($button,$value) = each($this->thisConfig['showButtons.'])) {
694 if ($value) $show[] = $button;
695 }
696 $show = array_unique($show);
697 }
698 } else {
699 $show = $toolbarOrder;
700 }
701
702 // Resticting to RTEkeyList for backend user
703 if(is_object($BE_USER)) {
704 $RTEkeyList = isset($BE_USER->userTS['options.']['RTEkeyList']) ? $BE_USER->userTS['options.']['RTEkeyList'] : '*';
705 if ($RTEkeyList != '*') { // If not all
706 $show = array_intersect($show, t3lib_div::trimExplode(',',$RTEkeyList,1));
707 }
708 }
709
710 // Hiding buttons of disabled plugins
711 $hideButtons = array('space', 'bar', 'linebreak');
712 reset($this->pluginButton);
713 while(list($plugin, $buttonList) = each($this->pluginButton) ) {
714 if(!$this->isPluginEnable($plugin)) {
715 $buttonArray = t3lib_div::trimExplode(',',$buttonList,1);
716 foreach($buttonArray as $button) {
717 $hideButtons[] = $button;
718 }
719 }
720 }
721
722 // Hiding labels of disabled plugins
723 reset($this->pluginLabel);
724 while(list($plugin, $label) = each($this->pluginLabel) ) {
725 if(!$this->isPluginEnable($plugin)) $hideButtons[] = $label;
726 }
727
728 // Hiding buttons not implemented in Safari
729 if ($this->client['BROWSER'] == 'safari') {
730 reset($this->conf_toolbar_safari_hide);
731 while(list(, $button) = each($this->conf_toolbar_safari_hide) ) {
732 $hideButtons[] = $button;
733 }
734 }
735
736 // Hiding buttons not implemented in Opera
737 if ($this->client['BROWSER'] == 'opera') {
738 reset($this->conf_toolbar_opera_hide);
739 while(list(, $button) = each($this->conf_toolbar_opera_hide) ) {
740 $hideButtons[] = $button;
741 }
742 }
743
744 // Hiding the buttons
745 $show = array_diff($show, $this->conf_toolbar_hide, $hideButtons, t3lib_div::trimExplode(',',$this->thisConfig['hideButtons'],1));
746
747 // Adding the always show buttons
748 $show = array_unique(array_merge($show, $this->conf_toolbar_show));
749 $toolbarOrder = array_unique(array_merge($toolbarOrder, $this->conf_toolbar_show));
750 reset($this->conf_toolbar_show);
751 while(list(,$button) = each($this->conf_toolbar_show)) {
752 if(!in_array($button, $this->toolbarOrderArray)) $this->toolbarOrderArray[] = $button;
753 }
754
755 // Getting rid of the buttons for which we have no position
756 $show = array_intersect($show, $toolbarOrder);
757 $this->toolBar = $show;
758 }
759
760 /**
761 * Disable some plugins
762 *
763 */
764
765 function setPlugins() {
766 global $TYPO3_CONF_VARS;
767
768 $hideButtons = array();
769 // Disabling the plugins if their buttons are not in the toolbar
770 $hidePlugins = array();
771 reset($this->pluginButton);
772 while(list($plugin, $buttonList) = each($this->pluginButton) ) {
773 $buttonArray = t3lib_div::trimExplode(',',$buttonList,1);
774 if(!in_array($buttonArray[0],$this->toolBar)) {
775 $hidePlugins[] = $plugin;
776 foreach($buttonArray as $button) {
777 $hideButtons[] = $button;
778 }
779 }
780 }
781
782 if($this->thisConfig['disableContextMenu'] || $this->thisConfig['disableRightClick']) $hidePlugins[] = 'ContextMenu';
783 if($this->thisConfig['disableSelectColor']) $hidePlugins[] = 'SelectColor';
784 if($this->thisConfig['disableTYPO3Browsers']) $hidePlugins[] = 'TYPO3Browsers';
785 if(!$this->thisConfig['enableWordClean'] || !is_array($this->thisConfig['enableWordClean.'])) $hidePlugins[] = 'TYPO3HtmlParser';
786 if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker';
787
788 $this->pluginEnableArray = array_diff($this->pluginEnableArray, $hidePlugins);
789
790 // Hiding labels of disabled plugins
791 reset($this->pluginLabel);
792 while(list($plugin, $label) = each($this->pluginLabel) ) {
793 if(!$this->isPluginEnable($plugin)) $hideButtons[] = $label;
794 }
795 $this->toolBar = array_diff($this->toolBar, $hideButtons);
796
797 // Renaming buttons of replacement plugins
798 if( $this->isPluginEnable('SelectColor') ) {
799 $this->conf_toolbar_convert['textcolor'] = 'CO-forecolor';
800 $this->conf_toolbar_convert['bgcolor'] = 'CO-hilitecolor';
801 }
802 }
803
804 /**
805 * Convert the TYPO3 names of buttons into the names for htmlArea RTE
806 *
807 * @param string buttonname (typo3-name)
808 * @return string buttonname (htmlarea-name)
809 */
810
811 function convertToolBarForHTMLArea($button) {
812 return $this->conf_toolbar_convert[$button];
813 }
814
815 /**
816 * Return the JS-function for setting the RTE size.
817 *
818 * @param string DivID-Name
819 * @param int the height for the RTE
820 * @param int the width for the RTE
821 * @return string Loader function in JS
822 */
823 function setRTEsizeByJS($divId, $height, $width) {
824 return '
825 setRTEsizeByJS(\''.$divId.'\','.$height.', '.$width.');
826 ';
827 }
828
829 /**
830 * Return the HTML-Code for loading the Javascript-Files
831 *
832 * @return string the html-code for loading the Javascript-Files
833 */
834 function loadJSfiles($number) {
835 global $TYPO3_CONF_VARS;
836
837 return '
838 <script type="text/javascript">
839 /*<![CDATA[*/
840 var i=1;
841 while (document.getElementById("pleasewait" + i)) {
842 document.getElementById("pleasewait" + i).style.display = "block";
843 document.getElementById("editorWrap" + i).style.visibility = "hidden";
844 i++;
845 };
846 var RTEarea = new Array();
847 RTEarea[0] = new Object();
848 RTEarea[0]["version"] = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . '";
849 RTEarea[0]["popupwin"] = "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/popupwin' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "popupwin", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '";
850 RTEarea[0]["htmlarea-gecko"] = "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/htmlarea-gecko' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "htmlarea-gecko", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '";
851 RTEarea[0]["htmlarea-ie"] = "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/htmlarea-ie' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "htmlarea-ie", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '";
852 var _editor_url = "' . $this->extHttpPath . 'htmlarea";
853 var _editor_lang = "' . $this->language . '";
854 var _editor_CSS = "' . $this->editorCSS . '";
855 var _editor_skin = "' . dirname($this->editorCSS) . '";
856 var _editor_edited_content_CSS = "' . $this->editedContentCSS . '";
857 var _typo3_host_url = "' . $this->hostURL . '";
858 var _editor_debug_mode = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? 'true' : 'false') . ';
859 var _editor_compressed_scripts = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? 'true' : 'false') . ';
860 var _editor_mozAllowClipboard_url = "' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardUrl'] ? $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardUrl'] : '') . '";
861 var _spellChecker_lang = "' . $this->spellCheckerLanguage . '";
862 var _spellChecker_charset = "' . $this->spellCheckerCharset . '";
863 var _spellChecker_mode = "' . $this->spellCheckerMode . '";
864 /*]]>*/
865 </script>
866 <script type="text/javascript" src="' . $this->buildJSMainLangFile($number) . '"></script>
867 <script type="text/javascript" src="' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/htmlarea' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "htmlarea", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '"></script>
868 ';
869 }
870
871 /**
872 * Return the JS-Code to initialize the Editor
873 *
874 * @return string the html-code for loading the Javascript-Files
875 */
876
877 function loadJScode($number) {
878 global $TSFE, $TYPO3_CONF_VARS;
879
880 $loadPluginCode = '';
881 $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
882 while( list(,$plugin) = each($pluginArray) ) {
883 if ($this->isPluginEnable($plugin) || (intval($number) > 1 && in_array($plugin, $this->pluginEnableArrayMultiple))) {
884 $loadPluginCode .= '
885 HTMLArea.loadPlugin("' . $plugin . '", true, "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/plugins/' . $plugin . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $plugin)) . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', $plugin, $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '");';
886 }
887 }
888 return (!is_object($TSFE) ? '' : '
889 ' . '/*<![CDATA[*/') . (is_object($TSFE) ? '' : '
890 RTEarea[0]["RTEtsConfigParams"] = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
891 RTEarea[0]["pathAcronymModule"] = "../../mod2/acronym.php";
892 RTEarea[0]["pathLinkModule"] = "../../mod3/browse_links.php";
893 RTEarea[0]["pathImageModule"] = "../../mod4/select_image.php";
894 RTEarea[0]["pathUserModule"] = "../../mod5/user.php";
895 RTEarea[0]["pathParseHtmlModule"] = "' . $this->extHttpPath . 'mod6/parse_html.php";')
896 . $loadPluginCode . '
897 HTMLArea.init();' . (!is_object($TSFE) ? '' : '
898 /*]]>*/
899 ');
900 }
901
902 /**
903 * Return the JS-Code for Register the RTE in JS
904 *
905 * @param integer $number: The index number of the RTE.
906 * @param string $table: The table that includes this RTE (optional, necessary for IRRE).
907 * @param string $uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
908 * @param string $field: The field of that record that includes this RTE (optional).
909 *
910 * @return string the JS-Code for Register the RTE in JS
911 */
912
913 function registerRTEinJS($number, $table='', $uid='', $field='') {
914 global $TSFE, $TYPO3_CONF_VARS;
915
916 $registerRTEinJSString = (!is_object($TSFE) ? '' : '
917 ' . '/*<![CDATA[*/') . '
918 RTEarea['.$number.'] = new Object();
919 RTEarea['.$number.']["RTEtsConfigParams"] = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
920 RTEarea['.$number.']["number"] = '.$number.';
921 RTEarea['.$number.']["id"] = "RTEarea'.$number.'";
922 RTEarea['.$number.']["enableWordClean"] = ' . (trim($this->thisConfig['enableWordClean'])?'true':'false') . ';
923 RTEarea['.$number.']["htmlRemoveComments"] = ' . (trim($this->thisConfig['removeComments'])?'true':'false') . ';
924 RTEarea['.$number.']["disableEnterParagraphs"] = ' . (trim($this->thisConfig['disableEnterParagraphs'])?'true':'false') . ';
925 RTEarea['.$number.']["removeTrailingBR"] = ' . (trim($this->thisConfig['removeTrailingBR'])?'true':'false') . ';
926 RTEarea['.$number.']["useCSS"] = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . ';
927 RTEarea['.$number.']["keepButtonGroupTogether"] = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . ';
928 RTEarea['.$number.']["disablePCexamples"] = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . ';
929 RTEarea['.$number.']["statusBar"] = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
930 RTEarea['.$number.']["showTagFreeClasses"] = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
931 RTEarea['.$number.']["useHTTPS"] = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
932 RTEarea['.$number.']["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';
933 RTEarea['.$number.']["tceformsNested"] = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(true) : '[]') . ';';
934
935 // The following properties apply only to the backend
936 if (!is_object($TSFE)) {
937 $registerRTEinJSString .= '
938 RTEarea['.$number.']["sys_language_content"] = "' . $this->contentLanguageUid . '";
939 RTEarea['.$number.']["typo3ContentLanguage"] = "' . $this->contentTypo3Language . '";
940 RTEarea['.$number.']["typo3ContentCharset"] = "' . $this->contentCharset . '";
941 RTEarea['.$number.']["enablePersonalDicts"] = ' . ($this->spellCheckerPersonalDicts ? 'true' : 'false') . ';
942 RTEarea['.$number.']["userUid"] = "' . $this->userUid . '";';
943 }
944 // Setting the plugin flags
945 $registerRTEinJSString .= '
946 RTEarea['.$number.']["plugin"] = new Object();';
947
948 $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
949 reset($pluginArray);
950 while( list(,$plugin) = each($pluginArray) ) {
951 if ($this->isPluginEnable($plugin)) {
952 $registerRTEinJSString .= '
953 RTEarea['.$number.']["plugin"]["'.$plugin.'"] = true;';
954 }
955 }
956
957 // Setting the buttons configuration
958 $registerRTEinJSString .= '
959 RTEarea['.$number.']["buttons"] = new Object();';
960 if (is_array($this->thisConfig['buttons.'])) {
961 reset($this->thisConfig['buttons.']);
962 while( list($buttonIndex,$conf) = each($this->thisConfig['buttons.']) ) {
963 $button = substr($buttonIndex, 0, -1);
964 if (in_array($button,$this->toolBar)) {
965 $indexButton = 0;
966 $registerRTEinJSString .= '
967 RTEarea['.$number.']["buttons"]["'.$button.'"] = {';
968 if (is_array($conf)) {
969 reset($conf);
970 while (list($propertyName,$conf1) = each($conf)) {
971 $property = $propertyName;
972 if ($indexButton) {
973 $registerRTEinJSString .= ', ';
974 }
975 if (is_array($conf1)) {
976 $property = substr($property, 0, -1);
977 $indexProperty = 0;
978 $registerRTEinJSString .= '"'.$property.'" : {';
979 reset($conf1);
980 while (list($property1Name,$conf2) = each($conf1)) {
981 $property1 = $property1Name;
982 if ($indexProperty) {
983 $registerRTEinJSString .= ', ';
984 }
985 if (is_array($conf2)) {
986 $property1 = substr($property1, 0, -1);
987 $indexProperty1 = 0;
988 $registerRTEinJSString .= '"'.$property1.'" : {';
989 reset($conf2);
990 while (list($property2Name,$conf3) = each($conf2)) {
991 $property2 = $property2Name;
992 if ($indexProperty1) {
993 $registerRTEinJSString .= ', ';
994 }
995 if (is_array($conf3)) {
996 $property2 = substr($property2, 0, -1);
997 $indexProperty2 = 0;
998 $registerRTEinJSString .= '"'.$property2.'" : {';
999 reset($conf3);
1000 while (list($property3Name,$conf4) = each($conf3)) {
1001 $property3 = $property3Name;
1002 if ($indexProperty2) {
1003 $registerRTEinJSString .= ', ';
1004 }
1005 if (!is_array($conf4)) {
1006 $registerRTEinJSString .= '"'.$property3.'" : '.($conf4?'"'.$conf4.'"':'false');
1007 }
1008 $indexProperty2++;
1009 }
1010 $registerRTEinJSString .= '}';
1011 } else {
1012 $registerRTEinJSString .= '"'.$property2.'" : '.($conf3?'"'.$conf3.'"':'false');
1013 }
1014 $indexProperty1++;
1015 }
1016 $registerRTEinJSString .= '}';
1017 } else {
1018 $registerRTEinJSString .= '"'.$property1.'" : '.($conf2?'"'.$conf2.'"':'false');
1019 }
1020 $indexProperty++;
1021 }
1022 $registerRTEinJSString .= '}';
1023 } else {
1024 $registerRTEinJSString .= '"'.$property.'" : '.($conf1?'"'.$conf1.'"':'false');
1025 }
1026 $indexButton++;
1027 }
1028 }
1029 $registerRTEinJSString .= '};';
1030 }
1031 }
1032 }
1033
1034 // Deprecated inserttag button configuration
1035 if (in_array('inserttag', $this->toolBar) && trim($this->thisConfig['hideTags'])) {
1036 if (!is_array($this->thisConfig['buttons.']['inserttag.'])) {
1037 $registerRTEinJSString .= '
1038 RTEarea['.$number.']["buttons"]["inserttag"] = new Object();
1039 RTEarea['.$number.']["buttons"]["inserttag"]["denyTags"] = "'.implode(',', t3lib_div::trimExplode(',', $this->thisConfig['hideTags'], 1)).'";';
1040 } elseif (!$this->thisConfig['buttons.']['inserttag.']['denyTags']) {
1041 $registerRTEinJSString .= '
1042 RTEarea['.$number.']["buttons"]["inserttag"]["denyTags"] = "'.implode(',', t3lib_div::trimExplode(',', $this->thisConfig['hideTags'], 1)).'";';
1043 }
1044 }
1045
1046 // Setting the list of tags to be removed if specified in the RTE config
1047 if (trim($this->thisConfig['removeTags'])) {
1048 $registerRTEinJSString .= '
1049 RTEarea['.$number.']["htmlRemoveTags"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;';
1050 }
1051
1052 // Setting the list of tags to be removed with their contents if specified in the RTE config
1053 if (trim($this->thisConfig['removeTagsAndContents'])) {
1054 $registerRTEinJSString .= '
1055 RTEarea['.$number.']["htmlRemoveTagsAndContents"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;';
1056 }
1057
1058 // Process default style configuration
1059 $registerRTEinJSString .= '
1060 RTEarea['.$number.']["defaultPageStyle"] = "' . $this->hostURL . $this->buildJSFile('css', $this->buildStyleSheet(), 'css') . '";';
1061
1062 // Setting the pageStyle
1063 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css';
1064 $registerRTEinJSString .= '
1065 RTEarea['.$number.']["pageStyle"] = "' . $this->getFullFileName($filename) .'";';
1066
1067 // Process colors configuration
1068 if ( $this->isPluginEnable('SelectColor') ) {
1069 $registerRTEinJSString .= $this->buildJSColorsConfig($number);
1070 }
1071
1072 // Process classes configuration
1073 if ($this->isPluginEnable('InlineCSS') || $this->isPluginEnable('DynamicCSS')) {
1074 $registerRTEinJSString .= $this->buildJSClassesConfig($number);
1075 }
1076
1077 // Process font faces configuration
1078 $registerRTEinJSString .= $this->buildJSFontFacesConfig($number);
1079
1080 // Process paragraphs configuration
1081 $registerRTEinJSString .= $this->buildJSParagraphsConfig($number);
1082
1083 // Process font sizes configuration
1084 $registerRTEinJSString .= $this->buildJSFontSizesConfig($number);
1085
1086 if ($this->isPluginEnable('TableOperations')) {
1087 $registerRTEinJSString .= '
1088 RTEarea['.$number.']["hideTableOperationsInToolbar"] = ' . (trim($this->thisConfig['hideTableOperationsInToolbar']) ? 'true' : 'false') . ';
1089 RTEarea['.$number.']["disableLayoutFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableLayoutFieldsetInTableOperations'])?'true':'false') . ';
1090 RTEarea['.$number.']["disableAlignmentFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableAlignmentFieldsetInTableOperations'])?'true':'false') . ';
1091 RTEarea['.$number.']["disableSpacingFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableSpacingFieldsetInTableOperations'])?'true':'false') . ';
1092 RTEarea['.$number.']["disableBordersFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableBordersFieldsetInTableOperations'])?'true':'false') . ';
1093 RTEarea['.$number.']["disableColorFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableColorFieldsetInTableOperations'])?'true':'false') . ';';
1094 // // Deprecated toggleborders button configuration
1095 if (in_array('toggleborders',$this->toolBar) && $this->thisConfig['keepToggleBordersInToolbar']) {
1096 if (!is_array($this->thisConfig['buttons.']['toggleborders.'])) {
1097 $registerRTEinJSString .= '
1098 RTEarea['.$number.']["buttons"]["toggleborders"] = new Object();
1099 RTEarea['.$number.']["buttons"]["toggleborders"]["keepInToolbar"] = true;';
1100 } elseif (!$this->thisConfig['buttons.']['toggleborders.']['keepInToolbar']) {
1101 $registerRTEinJSString .= '
1102 RTEarea['.$number.']["buttons"]["toggleborders"]["keepInToolbar"] = true;';
1103 }
1104 }
1105 }
1106
1107 if ($this->isPluginEnable('Acronym')) {
1108 $registerRTEinJSString .= '
1109 RTEarea['.$number.']["acronymUrl"] = "' . $this->buildJSFile('acronym_'.$this->contentLanguageUid, $this->buildJSAcronymArray()) . '";';
1110 }
1111
1112 if ($this->isPluginEnable('TYPO3Browsers')) {
1113 $registerRTEinJSString .= $this->buildJSClassesAnchorConfig($number);
1114 }
1115
1116 $registerRTEinJSString .= '
1117 RTEarea['.$number.']["toolbar"] = '.$this->getJSToolbarArray().';
1118 HTMLArea.initEditor('.$number.');' . (!is_object($TSFE) ? '' : '
1119 /*]]>*/');
1120 return $registerRTEinJSString;
1121 }
1122
1123 /**
1124 * Return ture, if the plugin can loaded
1125 *
1126 * @return boolean 1 if the plugin can be loaded
1127 */
1128
1129 function isPluginEnable($plugin) {
1130 return in_array($plugin, $this->pluginEnableArray);
1131 }
1132
1133
1134 /**
1135 * Return JS configuration of font sizes
1136 *
1137 * @return string JS font sizes configuration
1138 */
1139 function buildJSFontSizesConfig($number) {
1140 global $LANG, $TSFE;
1141 $registerRTEinJSString = '';
1142
1143 // Builing JS array of default font sizes
1144 $HTMLAreaFontSizes = array();
1145 if (is_object($TSFE)) {
1146 $HTMLAreaFontSizes[0] = $TSFE->csConvObj->conv($TSFE->getLLL('No size',$this->LOCAL_LANG), $TSFE->labelsCharset, $TSFE->renderCharset);
1147 } else {
1148 $HTMLAreaFontSizes[0] = $LANG->getLL('No size');
1149 }
1150
1151 reset($this->defaultFontSizes);
1152 while( list($FontSizeItem,$FontSizeLabel) = each($this->defaultFontSizes)) {
1153 if ($this->client['BROWSER'] == 'safari') {
1154 $HTMLAreaFontSizes[$this->defaultFontSizes_safari[$FontSizeItem]] = $FontSizeLabel;
1155 } else {
1156 $HTMLAreaFontSizes[$FontSizeItem] = $FontSizeLabel;
1157 }
1158 }
1159 if ($this->thisConfig['hideFontSizes'] ) {
1160 $hideFontSizes = t3lib_div::trimExplode(',', $this->cleanList($this->thisConfig['hideFontSizes']), 1);
1161 foreach($hideFontSizes as $item) {
1162 if ($HTMLAreaFontSizes[strtolower($item)]) {
1163 if ($this->client['BROWSER'] == 'safari') {
1164 unset($HTMLAreaFontSizes[$this->defaultFontSizes_safari[strtolower($item)]]);
1165 } else {
1166 unset($HTMLAreaFontSizes[strtolower($item)]);
1167 }
1168 } else {
1169
1170 }
1171 }
1172 }
1173
1174 $HTMLAreaJSFontSize = '{';
1175 if ($this->cleanList($this->thisConfig['hideFontSizes']) != '*') {
1176 reset($HTMLAreaFontSizes);
1177 $HTMLAreaParagraphIndex = 0;
1178 while( list($FontSizeItem,$FontSizeLabel) = each($HTMLAreaFontSizes)) {
1179 if($HTMLAreaFontSizeIndex) {
1180 $HTMLAreaJSFontSize .= ',';
1181 }
1182 $HTMLAreaJSFontSize .= '
1183 "' . $FontSizeLabel . '" : "' . ($FontSizeItem?$FontSizeItem:'') . '"';
1184 $HTMLAreaFontSizeIndex++;
1185 }
1186 }
1187 $HTMLAreaJSFontSize .= '};';
1188 $registerRTEinJSString .= '
1189 RTEarea['.$number.']["fontsize"] = '. $HTMLAreaJSFontSize;
1190
1191 return $registerRTEinJSString;
1192 }
1193 /**
1194 * Return JS configuration of paragraphs
1195 *
1196 * @return string JS paragraphs configuration
1197 */
1198 function buildJSParagraphsConfig($number) {
1199 global $TSFE, $LANG;
1200 $registerRTEinJSString = '';
1201
1202 // Paragraphs
1203 $HTMLAreaParagraphs = $this->defaultParagraphs;
1204 if ($this->thisConfig['hidePStyleItems']) {
1205 $hidePStyleItems = t3lib_div::trimExplode(',', $this->cleanList($this->thisConfig['hidePStyleItems']), 1);
1206 foreach($hidePStyleItems as $item) unset($HTMLAreaParagraphs[strtolower($item)]);
1207 }
1208 $HTMLAreaJSParagraph = '{';
1209 if ($this->cleanList($this->thisConfig['hidePStyleItems']) != '*') {
1210 reset($HTMLAreaParagraphs);
1211 $HTMLAreaParagraphIndex = 0;
1212 while( list($PStyleItem,$PStyleLabel) = each($HTMLAreaParagraphs)) {
1213 if($HTMLAreaParagraphIndex) {
1214 $HTMLAreaJSParagraph .= ',';
1215 }
1216 if (is_object($TSFE)) {
1217 $HTMLAreaJSParagraph .= '
1218 "' . $TSFE->csConvObj->conv($TSFE->getLLL($PStyleLabel,$this->LOCAL_LANG), $TSFE->labelsCharset, $TSFE->renderCharset) . '" : "' . $PStyleItem . '"';
1219
1220 } else {
1221 $HTMLAreaJSParagraph .= '
1222 "' . $LANG->getLL($PStyleLabel) . '" : "' . $PStyleItem . '"';
1223 }
1224 $HTMLAreaParagraphIndex++;
1225 }
1226 }
1227 $HTMLAreaJSParagraph .= '};';
1228 $registerRTEinJSString .= '
1229 RTEarea['.$number.']["paragraphs"] = '. $HTMLAreaJSParagraph;
1230
1231 return $registerRTEinJSString;
1232 }
1233
1234 /**
1235 * Return JS configuration of font faces
1236 *
1237 * @return string JS font faces configuration
1238 */
1239 function buildJSFontfacesConfig($number) {
1240 global $TSFE, $LANG;
1241
1242 if (is_object($TSFE)) {
1243 $RTEProperties = $this->RTEsetup;
1244 } else {
1245 $RTEProperties = $this->RTEsetup['properties'];
1246 }
1247
1248 $registerRTEinJSString = '';
1249
1250 // Builing JS array of default font faces
1251 $HTMLAreaFontname = array();
1252 $HTMLAreaFontname['nofont'] = '
1253 "' . $fontName . '" : "' . $this->cleanList($fontValue) . '"';
1254 $defaultFontFacesList = 'nofont,';
1255 if (is_object($TSFE)) {
1256 $HTMLAreaFontname['nofont'] = '
1257 "' . $TSFE->csConvObj->conv($TSFE->getLLL('No font',$this->LOCAL_LANG), $TSFE->labelsCharset, $TSFE->renderCharset) . '" : ""';
1258 } else {
1259 $HTMLAreaFontname['nofont'] = '
1260 "' . $LANG->getLL('No font') . '" : ""';
1261 }
1262
1263 $hideFontFaces = $this->cleanList($this->thisConfig['hideFontFaces']);
1264 if ($hideFontFaces != '*') {
1265 $index = 0;
1266 reset($this->defaultFontFaces);
1267 while (list($fontName,$fontValue) = each($this->defaultFontFaces)) {
1268 if (!t3lib_div::inList($hideFontFaces, $index+1)) {
1269 $HTMLAreaFontname[$fontName] = '
1270 "' . $fontName . '" : "' . $this->cleanList($fontValue) . '"';
1271 $defaultFontFacesList .= $fontName . ',';
1272 }
1273 $index++;
1274 }
1275 }
1276
1277 // Adding configured font faces
1278 if (is_array($RTEProperties['fonts.'])) {
1279 reset($RTEProperties['fonts.']);
1280 while(list($fontName,$conf)=each($RTEProperties['fonts.'])) {
1281 $fontName=substr($fontName,0,-1);
1282 if (is_object($TSFE)) {
1283 $string = $TSFE->sL($conf['name']);
1284 } else {
1285 $string = $LANG->sL($conf['name']);
1286 }
1287 $HTMLAreaFontname[$fontName] = '
1288 "' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . '" : "' . $this->cleanList($conf['value']) . '"';
1289 }
1290 }
1291
1292 // Setting the list of font faces
1293 $HTMLAreaJSFontface = '{';
1294 $HTMLAreaFontface = t3lib_div::trimExplode(',' , $this->cleanList($defaultFontFacesList . ',' . $this->thisConfig['fontFace']));
1295 reset($HTMLAreaFontface);
1296 $HTMLAreaFontfaceIndex = 0;
1297 while( list(,$fontName) = each($HTMLAreaFontface)) {
1298 if($HTMLAreaFontfaceIndex) {
1299 $HTMLAreaJSFontface .= ',';
1300 }
1301 $HTMLAreaJSFontface .= $HTMLAreaFontname[$fontName];
1302 $HTMLAreaFontfaceIndex++;
1303 }
1304 $HTMLAreaJSFontface .= '};';
1305
1306 $registerRTEinJSString .= '
1307 RTEarea['.$number.']["fontname"] = '. $HTMLAreaJSFontface;
1308
1309 return $registerRTEinJSString;
1310 }
1311
1312 /**
1313 * Return JS configuration of colors
1314 *
1315 * @return string JS colors configuration
1316 */
1317 function buildJSColorsConfig($number) {
1318 global $TSFE, $LANG;
1319
1320 if (is_object($TSFE)) {
1321 $RTEProperties = $this->RTEsetup;
1322 } else {
1323 $RTEProperties = $this->RTEsetup['properties'];
1324 }
1325
1326 $registerRTEinJSString = '';
1327
1328 if(trim($this->thisConfig['disableColorPicker'])) {
1329 $registerRTEinJSString .= '
1330 RTEarea['.$number.']["disableColorPicker"] = true;';
1331 } else {
1332 $registerRTEinJSString .= '
1333 RTEarea['.$number.']["disableColorPicker"] = false;';
1334 }
1335
1336 // Building JS array of configured colors
1337 if (is_array($RTEProperties['colors.']) ) {
1338 $HTMLAreaColorname = array();
1339 reset($RTEProperties['colors.']);
1340 while(list($colorName,$conf)=each($RTEProperties['colors.'])) {
1341 $colorName=substr($colorName,0,-1);
1342 if (is_object($TSFE)) {
1343 $string = $TSFE->csConvObj->conv($TSFE->sL(trim($conf['name'])), $TSFE->renderCharset, $TSFE->metaCharset);
1344 $string = str_replace('"', '\"', str_replace('\\\'', '\'', $string));
1345 $string = $this->feJScharCode($string);
1346 } else {
1347 $string = $this->getLLContent(trim($conf['name']));
1348 }
1349 $HTMLAreaColorname[$colorName] = '
1350 [' . $string . ' , "' . $conf['value'] . '"]';
1351 }
1352 }
1353
1354 // Setting the list of colors if specified in the RTE config
1355 if ($this->thisConfig['colors'] ) {
1356 $HTMLAreaJSColors = '[';
1357 $HTMLAreaColors = t3lib_div::trimExplode(',' , $this->cleanList($this->thisConfig['colors']));
1358 reset($HTMLAreaColors);
1359 $HTMLAreaColorsIndex = 0;
1360 while( list(,$colorName) = each($HTMLAreaColors)) {
1361 if($HTMLAreaColorsIndex && $HTMLAreaColorname[$colorName]) {
1362 $HTMLAreaJSColors .= ',';
1363 }
1364 $HTMLAreaJSColors .= $HTMLAreaColorname[$colorName];
1365 $HTMLAreaColorsIndex++;
1366 }
1367 $HTMLAreaJSColors .= '];';
1368 $registerRTEinJSString .= '
1369 RTEarea['.$number.']["colors"] = '. $HTMLAreaJSColors;
1370 }
1371
1372 return $registerRTEinJSString;
1373 }
1374
1375 /**
1376 * Build the default content style sheet
1377 *
1378 * @return string Style sheet
1379 */
1380 function buildStyleSheet() {
1381
1382 if (!trim($this->thisConfig['ignoreMainStyleOverride'])) {
1383 $mainStyle_font = $this->thisConfig['mainStyle_font'] ? $this->thisConfig['mainStyle_font']: 'Verdana,sans-serif';
1384
1385 $mainElements = array();
1386 $mainElements['P'] = $this->thisConfig['mainStyleOverride_add.']['P'];
1387 $elList = explode(',','H1,H2,H3,H4,H5,H6,PRE');
1388 reset($elList);
1389 while(list(,$elListName)=each($elList)) {
1390 if ($this->thisConfig['mainStyleOverride_add.'][$elListName]) {
1391 $mainElements[$elListName] = $this->thisConfig['mainStyleOverride_add.'][$elListName];
1392 }
1393 }
1394
1395 $addElementCode = '';
1396 reset($mainElements);
1397 while(list($elListName,$elValue)=each($mainElements)) {
1398 $addElementCode .= strToLower($elListName) . ' {' . $elValue . '}' . chr(10);
1399 }
1400
1401 $stylesheet = $this->thisConfig['mainStyleOverride'] ? $this->thisConfig['mainStyleOverride'] : chr(10) .
1402 'body.htmlarea-content-body { font-family: ' . $mainStyle_font .
1403 '; font-size: '.($this->thisConfig['mainStyle_size'] ? $this->thisConfig['mainStyle_size'] : '12px') .
1404 '; color: '.($this->thisConfig['mainStyle_color']?$this->thisConfig['mainStyle_color'] : 'black') .
1405 '; background-color: '.($this->thisConfig['mainStyle_bgcolor'] ? $this->thisConfig['mainStyle_bgcolor'] : 'white') .
1406 ';'.$this->thisConfig['mainStyleOverride_add.']['BODY'].'}' . chr(10) .
1407 'td { ' . $this->thisConfig['mainStyleOverride_add.']['TD'].'}' . chr(10) .
1408 'div { ' . $this->thisConfig['mainStyleOverride_add.']['DIV'].'}' . chr(10) .
1409 'pre { ' . $this->thisConfig['mainStyleOverride_add.']['PRE'].'}' . chr(10) .
1410 'ol { ' . $this->thisConfig['mainStyleOverride_add.']['OL'].'}' . chr(10) .
1411 'ul { ' . $this->thisConfig['mainStyleOverride_add.']['UL'].'}' . chr(10) .
1412 'blockquote { ' . $this->thisConfig['mainStyleOverride_add.']['BLOCKQUOTE'].'}' . chr(10) .
1413 $addElementCode;
1414
1415 if (is_array($this->thisConfig['inlineStyle.'])) {
1416 $stylesheet .= chr(10) . implode(chr(10), $this->thisConfig['inlineStyle.']) . chr(10);
1417 }
1418 } else {
1419 $stylesheet = '/* mainStyleOverride and inlineStyle properties ignored. */';
1420 }
1421 return $stylesheet;
1422 }
1423
1424 /**
1425 * Return JS configuration of classes
1426 *
1427 * @return string JS classes configuration
1428 */
1429 function buildJSClassesConfig($number) {
1430
1431 // Build JS array of lists of classes
1432 $classesTagList = 'classesCharacter, classesParagraph, classesImage, classesTable, classesLinks, classesTD';
1433 $classesTagConvert = array( 'classesCharacter' => 'span', 'classesParagraph' => 'p', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td');
1434 $classesTagArray = t3lib_div::trimExplode(',' , $classesTagList);
1435 $registerRTEinJSString = '
1436 RTEarea['.$number.']["classesTag"] = new Object();';
1437 while( list(,$classesTagName) = each($classesTagArray)) {
1438 $HTMLAreaJSClasses = ($this->thisConfig[$classesTagName])?('"' . $this->cleanList($this->thisConfig[$classesTagName]) . '";'):'null;';
1439 $registerRTEinJSString .= '
1440 RTEarea['.$number.']["classesTag"]["'. $classesTagConvert[$classesTagName] .'"] = '. $HTMLAreaJSClasses;
1441 }
1442
1443 // Include JS arrays of configured classes
1444 $registerRTEinJSString .= '
1445 RTEarea['.$number.']["classesUrl"] = "' . $this->hostURL . $this->buildJSFile('classes_'.$this->contentLanguageUid, $this->buildJSClassesArray()) . '";';
1446
1447 return $registerRTEinJSString;
1448 }
1449
1450 /**
1451 * Return JS arrays of classes labels and noShow flags
1452 *
1453 * @return string JS classes arrays
1454 */
1455 function buildJSClassesArray() {
1456 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1457
1458 if (is_object($TSFE)) {
1459 $RTEProperties = $this->RTEsetup;
1460 } else {
1461 $RTEProperties = $this->RTEsetup['properties'];
1462 }
1463
1464 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
1465 $index = 0;
1466 $JSClassesLabelsArray = 'HTMLArea.classesLabels = { ' . $linebreak;
1467 $JSClassesValuesArray = 'HTMLArea.classesValues = { ' . $linebreak;
1468 $JSClassesNoShowArray = 'HTMLArea.classesNoShow = { ' . $linebreak;
1469
1470 // Scanning the list of classes if specified in the RTE config
1471 if (is_array($RTEProperties['classes.'])) {
1472 $stylesheet = '';
1473 reset($RTEProperties['classes.']);
1474 while(list($className,$conf)=each($RTEProperties['classes.'])) {
1475 $className = substr($className,0,-1);
1476 if (is_object($TSFE)) {
1477 $string = $TSFE->csConvObj->conv($TSFE->sL(trim($conf['name'])), $TSFE->renderCharset, $TSFE->metaCharset);
1478 $string = str_replace('"', '\"', str_replace('\\\'', '\'', $string));
1479 $string = $this->feJScharCode($string);
1480 } else {
1481 $string = $this->getLLContent(trim($conf['name']));
1482 }
1483 $JSClassesLabelsArray .= (($index)?',':'') . '"' . $className . '": ' . $string . $linebreak;
1484 $JSClassesValuesArray .= (($index)?',':'') . '"' . $className . '":"' . str_replace('"', '\"', str_replace('\\\'', '\'', $conf['value'])) . '"' . $linebreak;
1485 $JSClassesNoShowArray .= (($index)?',':'') . '"' . $className . '":' . ($conf['noShow']?'true':'false') . $linebreak;
1486 $index++;
1487 }
1488 }
1489 $JSClassesLabelsArray .= '};' . $linebreak;
1490 $JSClassesValuesArray .= '};' . $linebreak;
1491 $JSClassesNoShowArray .= '};' . $linebreak;
1492
1493 return $JSClassesLabelsArray . $JSClassesValuesArray . $JSClassesNoShowArray;
1494 }
1495
1496 /**
1497 * Return a JS language array for htmlArea RTE
1498 *
1499 * @return string JS language array
1500 */
1501 function buildJSMainLangArray() {
1502 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1503
1504 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
1505 $JSLanguageArray .= 'var HTMLArea_langArray = new Object();' . $linebreak;
1506 $JSLanguageArray .= 'HTMLArea_langArray = { ' . $linebreak;
1507 if(is_object($TSFE)) {
1508 $JSLanguageArray = $TSFE->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
1509 } else {
1510 $JSLanguageArray = $LANG->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
1511 }
1512
1513 $subArrays = array( 'tooltips', 'msg' , 'dialogs');
1514 $subArraysIndex = 0;
1515 foreach($subArrays as $labels) {
1516 $JSLanguageArray .= (($subArraysIndex++)?',':'') . $labels . ': {' . $linebreak;
1517 if(is_object($TSFE)) {
1518 $LOCAL_LANG = $TSFE->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/locallang_' . $labels . '.xml', $this->language);
1519 $TSFE->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
1520 if(!empty($LOCAL_LANG[$this->language])) $TSFE->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
1521 } else {
1522 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/locallang_' . $labels . '.xml');
1523 $LANG->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
1524 if(!empty($LOCAL_LANG[$this->language])) $LANG->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
1525 }
1526 if(!empty($LOCAL_LANG[$this->language])) {
1527 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language]);
1528 } else {
1529 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
1530 }
1531 $index = 0;
1532 foreach ( $LOCAL_LANG[$this->language] as $labelKey => $labelValue ) {
1533 $JSLanguageArray .= (($index++)?',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
1534 }
1535 if(is_object($TSFE)) {
1536 $JSLanguageArray .= $TSFE->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
1537 } else {
1538 $JSLanguageArray .= $LANG->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
1539 }
1540 }
1541
1542 if(is_object($TSFE)) {
1543 $JSLanguageArray .= $TSFE->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
1544 } else {
1545 $JSLanguageArray .= $LANG->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
1546 }
1547 return $JSLanguageArray;
1548 }
1549
1550 /**
1551 * Return an acronym array for the Acronym plugin
1552 *
1553 * @return string acronym array
1554 */
1555
1556 function buildJSAcronymArray() {
1557 global $TYPO3_CONF_VARS, $TYPO3_DB;
1558
1559 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
1560 $acronymIndex = 0;
1561 $abbraviationIndex = 0;
1562 $JSAcronymArray .= 'acronyms = { ' . $linebreak;
1563 $JSAbbreviationArray .= 'abbreviations = { ' . $linebreak;
1564 $table = 'tx_rtehtmlarea_acronym';
1565 if($this->contentLanguageUid > -1) {
1566 $whereClause = '(sys_language_uid="'.$this->contentLanguageUid . '" OR sys_language_uid="-1")';
1567 } else {
1568 $whereClause = '1 = 1';
1569 }
1570 $whereClause .= t3lib_BEfunc::BEenableFields($table);
1571 $whereClause .= t3lib_BEfunc::deleteClause($table);
1572 $res = $TYPO3_DB->exec_SELECTquery('type,term,acronym', $table, $whereClause);
1573 while($acronymRow = $TYPO3_DB->sql_fetch_assoc($res)) {
1574 if($acronymRow['type'] == 1) $JSAcronymArray .= (($acronymIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
1575 if($acronymRow['type'] == 2) $JSAbbreviationArray .= (($AbbreviationIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
1576 }
1577 $JSAcronymArray .= '};' . $linebreak;
1578 $JSAbbreviationArray .= '};' . $linebreak;
1579
1580 return $JSAcronymArray . $JSAbbreviationArray;
1581 }
1582
1583 /**
1584 * Return JS configuration of special anchor classes
1585 *
1586 * @return string JS special anchor classes configuration
1587 */
1588 function buildJSClassesAnchorConfig($number) {
1589 global $TSFE;
1590
1591 if (is_object($TSFE)) {
1592 $RTEProperties = $this->RTEsetup;
1593 } else {
1594 $RTEProperties = $this->RTEsetup['properties'];
1595 }
1596
1597 $registerRTEinJSString = '';
1598 if (is_array($RTEProperties['classesAnchor.'])) {
1599 $registerRTEinJSString .= '
1600 RTEarea['.$number.']["classesAnchorUrl"] = "' . $this->buildJSFile('classesAnchor_'.$this->contentLanguageUid, $this->buildJSClassesAnchorArray()) . '";';
1601 }
1602 return $registerRTEinJSString;
1603 }
1604
1605 /**
1606 * Return a JS array for special anchor classes
1607 *
1608 * @return string classesAnchor array definition
1609 */
1610 function buildJSClassesAnchorArray() {
1611 global $LANG, $TYPO3_CONF_VARS;
1612
1613 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
1614 $JSClassesAnchorArray .= 'editor.classesAnchorSetup = [ ' . $linebreak;
1615 $classesAnchorIndex = 0;
1616 reset($this->RTEsetup['properties']['classesAnchor.']);
1617 while(list($label,$conf)=each($this->RTEsetup['properties']['classesAnchor.'])) {
1618 if (is_array($conf) && $conf['class']) {
1619 $JSClassesAnchorArray .= (($classesAnchorIndex++)?',':'') . ' { ' . $linebreak;
1620 $index = 0;
1621 $JSClassesAnchorArray .= (($index++)?',':'') . 'name : "' . $conf['class'] . '"' . $linebreak;
1622 if ($conf['type']) {
1623 $JSClassesAnchorArray .= (($index++)?',':'') . 'type : "' . $conf['type'] . '"' . $linebreak;
1624 }
1625 if (trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) {
1626 $JSClassesAnchorArray .= (($index++)?',':'') . 'image : "' . $this->getFullFileName(trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) . '"' . $linebreak;
1627 }
1628 if (trim($conf['altText'])) {
1629 $string = $this->getLLContent(trim($conf['altText']));
1630 $JSClassesAnchorArray .= (($index++)?',':'') . 'altText : ' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . $linebreak;
1631 }
1632 if (trim($conf['titleText'])) {
1633 $string = $this->getLLContent(trim($conf['titleText']));
1634 $JSClassesAnchorArray .= (($index++)?',':'') . 'titleText : ' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . $linebreak;
1635 }
1636 $JSClassesAnchorArray .= '}' . $linebreak;
1637 }
1638 }
1639 $JSClassesAnchorArray .= '];' . $linebreak;
1640 return $JSClassesAnchorArray;
1641 }
1642
1643 /**
1644 * Return a file name built with the label and containing the specified contents
1645 *
1646 * @return string filename
1647 */
1648
1649 function buildJSFile($label,$contents,$ext='js') {
1650 $relFilename = 'typo3temp/' . $this->ID . '_' . $label . '_' . md5($contents) . '.' . $ext;
1651 $outputFilename = PATH_site . $relFilename;
1652 if(!file_exists($outputFilename)) {
1653 $outputHandle = fopen($outputFilename,'wb');
1654 fwrite($outputHandle, $contents);
1655 fclose($outputHandle);
1656 t3lib_div::fixPermissions($outputFilename);
1657 }
1658 return $this->httpTypo3Path . $relFilename;
1659 }
1660
1661 /**
1662 * Return a file name built with the label and containing a cached copy of the specified file
1663 *
1664 * @return string filename
1665 */
1666
1667 function writeJSFileToTypo3tempDir($JSFile,$label,$compressed=FALSE,$ext='js') {
1668 global $TYPO3_CONF_VARS;
1669
1670 $source = t3lib_div::getFileAbsFileName($JSFile);
1671 $relFilename = 'typo3temp/' . $this->ID . '_' . $label . '_' . md5($JSFile . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version']) . ($compressed ? '-compressed' : '') . '.' . $ext;
1672 $destination = PATH_site . $relFilename;
1673 if(!file_exists($destination)) {
1674 @copy($source,$destination);
1675 t3lib_div::fixPermissions($destination);
1676 }
1677 return ($this->thisConfig['forceHTTPS']?$this->siteURL:$this->httpTypo3Path) . $relFilename;
1678 }
1679
1680 /**
1681 * Return a file name containing the main JS language array for HTMLArea
1682 *
1683 * @return string filename
1684 */
1685
1686 function buildJSMainLangFile($number) {
1687 $contents = $this->buildJSMainLangArray() . chr(10);
1688 $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
1689 while( list(,$plugin) = each($pluginArray) ) {
1690 if ($this->isPluginEnable($plugin) || (intval($number) > 1 && in_array($plugin, $this->pluginEnableArrayMultiple))) {
1691 $contents .= $this->buildJSLangArray($plugin) . chr(10);
1692 }
1693 }
1694 return $this->buildJSFile($this->language.'_'.$this->OutputCharset,$contents);
1695 }
1696
1697 /**
1698 * Return a JS language array for the plugin
1699 *
1700 * @return string JS language array
1701 */
1702
1703 function buildJSLangArray($plugin) {
1704 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1705
1706 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
1707 if(is_object($TSFE)) {
1708 $LOCAL_LANG = $TSFE->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/plugins/' . $plugin . '/locallang.xml', $this->language);
1709 if(!empty($LOCAL_LANG['default'])) $TSFE->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
1710 if(!empty($LOCAL_LANG[$this->language])) $TSFE->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
1711 } else {
1712 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/plugins/' . $plugin . '/locallang.xml');
1713 if(!empty($LOCAL_LANG['default'])) $LANG->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
1714 if(!empty($LOCAL_LANG[$this->language])) $LANG->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
1715 }
1716
1717 if(!empty($LOCAL_LANG[$this->language])) {
1718 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'],$LOCAL_LANG[$this->language]);
1719 } else {
1720 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
1721 }
1722
1723 $JSLanguageArray .= 'var ' . $plugin . '_langArray = new Object();' . $linebreak;
1724 $JSLanguageArray .= $plugin . '_langArray = {' . $linebreak;
1725 if(is_object($TSFE)) {
1726 $JSLanguageArray = $TSFE->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
1727 } else {
1728 $JSLanguageArray = $LANG->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
1729 }
1730
1731 $index = 0;
1732 foreach ( $LOCAL_LANG[$this->language] as $labelKey => $labelValue ) {
1733 $JSLanguageArray .= (($index++)?',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
1734 }
1735
1736 if(is_object($TSFE)) {
1737 $JSLanguageArray .= $TSFE->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
1738 } else {
1739 $JSLanguageArray .= $LANG->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
1740 }
1741
1742 return $JSLanguageArray;
1743 }
1744
1745 /**
1746 * Return the JS-Code for the Toolbar-Config-Array for HTML-Area
1747 *
1748 * @return string the JS-Code as an JS-Array
1749 */
1750
1751 function getJSToolbarArray() {
1752 $toolbar = ''; // The JS-Code for the toolbar
1753 $group = ''; // The TS-Code for the group in the moment, each group are between "bar"s
1754 $group_has_button = false; // True if the group has any enabled buttons
1755 $group_needs_starting_bar = false;
1756 $previous_is_space = false;
1757
1758 // process each button in the order list
1759 reset($this->toolbarOrderArray);
1760 while (list(, $button) = each($this->toolbarOrderArray) ) {
1761 // check if a new group starts
1762 if (($button == 'bar' || $button == 'linebreak') && $group_has_button) {
1763 // New line
1764 if ($button == 'linebreak') {
1765 $convertButton = '"' . $this->convertToolBarForHTMLArea('linebreak') . '"';
1766 $group = ($group!='') ? ($group . ', ' . $convertButton) : $convertButton;
1767 }
1768 // New group
1769 $toolbar .= $toolbar ? (', ' . $group) : ('[[' . $group);
1770 $group = '';
1771 $previous_is_space = false;
1772 $group_has_button = false;
1773 $group_needs_starting_bar = true;
1774 } elseif ($toolbar && $button == 'linebreak' && !$group_has_button) {
1775 // Insert linebreak if no group is opened
1776 $group = '';
1777 $previous_is_space = false;
1778 $group_needs_starting_bar = false;
1779 $toolbar .= ', "' . $this->convertToolBarForHTMLArea($button) . '"';
1780 } elseif ($button == 'bar' && !$group_has_button) {
1781 $group_needs_starting_bar = true;
1782 } elseif ($button == 'space' && $group_has_button && !$previous_is_space) {
1783 $convertButton = $this->convertToolBarForHTMLArea($button);
1784 $convertButton = '"' . $convertButton . '"';
1785 $group .= $group ? (', ' . $convertButton) : ($group_needs_starting_bar ? ('"' . $this->convertToolBarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
1786 $group_needs_starting_bar = false;
1787 $previous_is_space = true;
1788 } elseif (in_array($button, $this->toolBar)) {
1789 // Add the button to the group
1790 $convertButton = $this->convertToolBarForHTMLArea($button);
1791 if ($convertButton) {
1792 $convertButton = '"' . $convertButton . '"';
1793 $group .= $group ? (', ' . $convertButton) : ($group_needs_starting_bar ? ('"' . $this->convertToolBarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
1794 $group_has_button = true;
1795 $group_needs_starting_bar = false;
1796 $previous_is_space = false;
1797 }
1798 }
1799 // else ignore
1800 }
1801 // add the last group
1802 if($group_has_button) $toolbar .= $toolbar ? (', ' . $group) : ('[[' . $group);
1803 $toolbar = $toolbar . ']]';
1804 return $toolbar;
1805 }
1806
1807 function getLLContent($string) {
1808 global $LANG;
1809
1810 $BE_lang = $LANG->lang;
1811 $BE_origCharset = $LANG->origCharSet;
1812 $BE_charSet = $LANG->charSet;
1813 $LANG->lang = $this->contentTypo3Language;
1814 $LANG->origCharSet = $this->origContentCharSet;
1815 $LANG->charSet = $this->contentCharset;
1816 $LLString = $LANG->JScharCode($LANG->sL($string));
1817 $LANG->lang = $BE_lang;
1818 $LANG->origCharSet = $BE_origCharset;
1819 $LANG->charSet = $BE_charSet;
1820 return $LLString;
1821 }
1822
1823 function feJScharCode($str) {
1824 global $TSFE;
1825 // Convert string to UTF-8:
1826 if ($this->OutputCharset != 'utf-8') $str = $TSFE->csConvObj->utf8_encode($str,$this->OutputCharset);
1827 // Convert the UTF-8 string into a array of char numbers:
1828 $nArr = $TSFE->csConvObj->utf8_to_numberarray($str);
1829 return 'String.fromCharCode('.implode(',',$nArr).')';
1830 }
1831
1832 function getFullFileName($filename) {
1833 if (substr($filename,0,4)=='EXT:') { // extension
1834 list($extKey,$local) = explode('/',substr($filename,4),2);
1835 $newFilename = '';
1836 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
1837 $newFilename = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . $local;
1838 }
1839 } elseif (substr($filename,0,1) != '/') {
1840 $newFilename = $this->siteURL . $filename;
1841 } else {
1842 $newFilename = $this->siteURL . substr($filename,1);
1843 }
1844 return $newFilename;
1845 }
1846
1847 /**
1848 * Return the JS-Code to copy the HTML-Code from the editor in the hidden input field.
1849 * This is for submit function from the form.
1850 *
1851 * @return string the JS-Code
1852 */
1853
1854 function setSaveRTE($number, $form, $textarea) {
1855 return '
1856 editornumber = '.$number.';
1857 if (RTEarea[editornumber]) {
1858 document.'.$form.'["'.$textarea.'"].value = RTEarea[editornumber]["editor"].getHTML();
1859 }
1860 else {
1861 OK=0;
1862 }
1863 ';
1864 }
1865
1866 /**
1867 * Client Browser Information
1868 *
1869 * Usage: 4
1870 *
1871 * @param string Alternative User Agent string (if empty, t3lib_div::getIndpEnv('HTTP_USER_AGENT') is used)
1872 * @return array Parsed information about the HTTP_USER_AGENT in categories BROWSER, VERSION, SYSTEM and FORMSTYLE
1873 */
1874
1875 function clientInfo($useragent='') {
1876 global $TYPO3_CONF_VARS;
1877
1878 if (!$useragent) $useragent=t3lib_div::getIndpEnv('HTTP_USER_AGENT');
1879
1880 $bInfo=array();
1881 // Which browser?
1882 if (strstr($useragent,'Konqueror')) {
1883 $bInfo['BROWSER']= 'konqu';
1884 } elseif (strstr($useragent,'Opera')) {
1885 $bInfo['BROWSER']= 'opera';
1886 } elseif (strstr($useragent,'MSIE')) {
1887 $bInfo['BROWSER']= 'msie';
1888 } elseif (strstr($useragent,'Gecko/')) {
1889 $bInfo['BROWSER']='gecko';
1890 } elseif (strstr($useragent,'Safari/') && $TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['safari_test'] == 1) {
1891 $bInfo['BROWSER']='safari';
1892 } elseif (strstr($useragent,'Mozilla/4')) {
1893 $bInfo['BROWSER']='net';
1894 }
1895
1896 if ($bInfo['BROWSER']) {
1897 // Browser version
1898 switch($bInfo['BROWSER']) {
1899 case 'net':
1900 $bInfo['VERSION']= doubleval(substr($useragent,8));
1901 if (strstr($useragent,'Netscape6/')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape6/'),10));}
1902 if (strstr($useragent,'Netscape/7')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape/7'),9));}
1903 break;
1904 case 'gecko':
1905 $tmp = strstr($useragent,'rv:');
1906 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
1907 break;
1908 case 'msie':
1909 $tmp = strstr($useragent,'MSIE');
1910 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4)));
1911 break;
1912 case 'safari':
1913 $tmp = strstr($useragent,'Safari/');
1914 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
1915 break;
1916 case 'opera':
1917 $tmp = strstr($useragent,'Opera');
1918 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5)));
1919 break;
1920 case 'konqu':
1921 $tmp = strstr($useragent,'Konqueror/');
1922 $bInfo['VERSION'] = doubleval(substr($tmp,10));
1923 break;
1924 }
1925
1926 // Client system
1927 if (strstr($useragent,'Win')) {
1928 $bInfo['SYSTEM'] = 'win';
1929 } elseif (strstr($useragent,'Mac')) {
1930 $bInfo['SYSTEM'] = 'mac';
1931 } elseif (strstr($useragent,'Linux') || strstr($useragent,'X11') || strstr($useragent,'SGI') || strstr($useragent,' SunOS ') || strstr($useragent,' HP-UX ')) {
1932 $bInfo['SYSTEM'] = 'unix';
1933 }
1934 }
1935
1936 // Is true if the browser supports css to format forms, especially the width
1937 $bInfo['FORMSTYLE']=($bInfo['BROWSER']=='msie' || ($bInfo['BROWSER']=='net'&&$bInfo['VERSION']>=5) || $bInfo['BROWSER']=='opera' || $bInfo['BROWSER']=='konqu');
1938 return $bInfo;
1939 }
1940
1941 /***************************
1942 *
1943 * OTHER FUNCTIONS: (from Classic RTE)
1944 *
1945 ***************************/
1946 /**
1947 * @return [type] ...
1948 * @desc
1949 */
1950
1951 function RTEtsConfigParams() {
1952 global $TSFE;
1953 if(is_object($TSFE)) {
1954 return '';
1955 } else {
1956 $p = t3lib_BEfunc::getSpecConfParametersFromArray($this->specConf['rte_transform']['parameters']);
1957 return $this->elementParts[0].':'.$this->elementParts[1].':'.$this->elementParts[2].':'.$this->thePid.':'.$this->typeVal.':'.$this->tscPID.':'.$p['imgpath'];
1958 }
1959 }
1960
1961 function cleanList($str) {
1962 if (strstr($str,'*')) {
1963 $str = '*';
1964 } else {
1965 $str = implode(',',array_unique(t3lib_div::trimExplode(',',$str,1)));
1966 }
1967 return $str;
1968 }
1969
1970 function filterStyleEl($elValue,$matchList) {
1971 $matchParts = t3lib_div::trimExplode(',',$matchList,1);
1972 $styleParts = explode(';',$elValue);
1973 $nStyle=array();
1974 while(list($k,$p)=each($styleParts)) {
1975 $pp = t3lib_div::trimExplode(':',$p);
1976 if ($pp[0]&&$pp[1]) {
1977 reset($matchParts);
1978 while(list(,$el)=each($matchParts)) {
1979 $star=substr($el,-1)=='*';
1980 if (!strcmp($pp[0],$el) || ($star && t3lib_div::isFirstPartOfStr($pp[0],substr($el,0,-1)) )) {
1981 $nStyle[]=$pp[0].':'.$pp[1];
1982 } else unset($styleParts[$k]);
1983 }
1984 } else {
1985 unset($styleParts[$k]);
1986 }
1987 }
1988 return implode('; ',$nStyle);
1989 }
1990
1991 // Hook on lorem_ipsum extension to insert text into the RTE in wysiwyg mode
1992 function loremIpsumInsert($params) {
1993 return "
1994 if (typeof(lorem_ipsum) == 'function' && " . $params['element'] . ".tagName.toLowerCase() == 'textarea' ) lorem_ipsum(" . $params['element'] . ", lipsum_temp_strings[lipsum_temp_pointer]);
1995 ";
1996 }
1997 }
1998
1999 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']) {
2000 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']);
2001 }
2002
2003 ?>