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