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