2 /***************************************************************
5 * (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
6 * (c) 2004 Philipp Borgmann <philipp.borgmann@gmx.de>
7 * (c) 2004-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
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.
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.
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.
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
30 * A RTE using the htmlArea editor
32 * @author Philipp Borgmann <philipp.borgmann@gmx.de>
33 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
38 require_once(PATH_t3lib
.'class.t3lib_rteapi.php');
39 require_once(PATH_t3lib
.'class.t3lib_cs.php');
41 class tx_rtehtmlarea_base
extends t3lib_rteapi
{
43 // Configuration of supported browsers
44 var $conf_supported_browser = array (
68 // Always hide these toolbar buttons (TYPO3 button name)
69 var $conf_toolbar_hide = array (
70 'showhelp', // Has no content yet
73 // Always show these toolbar buttons (TYPO3 button name)
74 var $conf_toolbar_show = array (
81 // The order of the toolbar: the name is the TYPO3-button name
82 var $defaultToolbarOrder;
84 // Conversion array: TYPO3 button names to htmlArea button names
85 var $convertToolbarForHtmlAreaArray = array (
86 'line' => 'InsertHorizontalRule',
87 'chMode' => 'HtmlMode',
88 'showhelp' => 'ShowHelp',
89 'textindicator' => 'TextIndicator',
92 'linebreak' => 'linebreak',
96 var $pluginButton = array();
97 var $pluginLabel = array();
100 var $RTEdivStyle; // Alternative style for RTE <div> tag.
101 public $httpTypo3Path;
102 var $extHttpPath; // full Path to this extension for http (so no Server path). It ends with "/"
103 var $siteURL; // TYPO3 site url
104 var $hostURL; // TYPO3 host url
105 var $typoVersion; // Typo3 version
108 var $ID = 'rtehtmlarea'; // Identifies the RTE as being the one from the "rte" extension if any external code needs to know...
109 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!)
115 * Reference to parent object, which is an instance of the TCEforms
117 * @var t3lib_TCEforms
129 public $contentTypo3Language;
130 public $contentISOLanguage;
131 public $contentCharset;
132 public $OutputCharset;
135 var $toolbar = array(); // Save the buttons for the toolbar
136 var $toolbar_level_size; // The size for each level in the toolbar:
137 var $toolbarOrderArray = array();
138 protected $pluginEnabledArray = array(); // Array of plugin id's enabled in the current RTE editing area
139 protected $pluginEnabledCumulativeArray = array(); // Cumulative array of plugin id's enabled so far in any of the RTE editing areas of the form
140 public $registeredPlugins = array(); // Array of registered plugins indexed by their plugin Id's
143 * Returns true if the RTE is available. Here you check if the browser requirements are met.
144 * If there are reasons why the RTE cannot be displayed you simply enter them as text in ->errorLog
146 * @return boolean TRUE if this RTE object offers an RTE in the current browser environment
149 function isAvailable() {
150 global $TYPO3_CONF_VARS;
152 $this->client
= $this->clientInfo();
153 $this->errorLog
= array();
154 if (!$this->debugMode
) { // If debug-mode, let any browser through
156 $rteConfBrowser = $this->conf_supported_browser
;
157 if (!$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['enableInOpera9']) unset($rteConfBrowser['opera']);
158 if (is_array($rteConfBrowser)) {
159 foreach ($rteConfBrowser as $browser => $browserConf) {
160 if ($browser == $this->client
['BROWSER']) {
161 // Config for Browser found, check it:
162 if (is_array($browserConf)) {
163 foreach ($browserConf as $browserConfNr => $browserConfSub) {
164 if ($browserConfSub['version'] <= $this->client
['VERSION'] ||
empty($browserConfSub['version'])) {
165 // Version is correct
166 if ($browserConfSub['system'] == $this->client
['SYSTEM'] ||
empty($browserConfSub['system'])) {
167 // System is correctly
171 }// End of foreach-BrowserSubpart
173 // no config for this browser found, so all versions or system with this browsers are allow
176 } // End of Browser Check
177 } // foreach: Browser Check
179 // no Browser config for this RTE-Editor, so all Clients are allow
181 if (!$rteIsAvailable) {
182 $this->errorLog
[] = 'rte: Browser not supported. Only msie Version 5 or higher and Mozilla based client 1. and higher.';
184 if (t3lib_div
::int_from_ver(TYPO3_version
) < 4000000) {
186 $this->errorLog
[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.';
189 if ($rteIsAvailable) return true;
193 * Draws the RTE as an iframe
195 * @param object Reference to parent object, which is an instance of the TCEforms.
196 * @param string The table name
197 * @param string The field name
198 * @param array The current row from which field is being rendered
199 * @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.
200 * @param array "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
201 * @param array Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
202 * @param string Record "type" field value.
203 * @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!
204 * @param integer PID value of record (true parent page id)
205 * @return string HTML code for RTE!
208 function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue) {
209 global $BE_USER, $LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
211 $this->TCEform
=& $parentObject;
212 $inline =& $this->TCEform
->inline
;
213 $LANG->includeLLFile('EXT:' . $this->ID
. '/locallang.xml');
214 $this->client
= $this->clientInfo();
215 $this->typoVersion
= t3lib_div
::int_from_ver(TYPO3_version
);
216 $this->userUid
= 'BE_' . $BE_USER->user
['uid'];
218 // Draw form element:
219 if ($this->debugMode
) { // Draws regular text area (debug mode)
220 $item = parent
::drawRTE($this->TCEform
, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
221 } else { // Draw real RTE
223 /* =======================================
224 * INIT THE EDITOR-SETTINGS
225 * =======================================
228 // first get the http-path to typo3:
229 $this->httpTypo3Path
= substr( substr( t3lib_div
::getIndpEnv('TYPO3_SITE_URL'), strlen( t3lib_div
::getIndpEnv('TYPO3_REQUEST_HOST') ) ), 0, -1 );
230 if (strlen($this->httpTypo3Path
) == 1) {
231 $this->httpTypo3Path
= '/';
233 $this->httpTypo3Path
.= '/';
235 // Get the path to this extension:
236 $this->extHttpPath
= $this->httpTypo3Path
. t3lib_extMgm
::siteRelPath($this->ID
);
238 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL');
240 $this->hostURL
= t3lib_div
::getIndpEnv('TYPO3_REQUEST_HOST');
243 $this->elementId
= $PA['itemFormElName']; // Form element name
244 $this->elementParts
= explode('][',ereg_replace('\]$','',ereg_replace('^(TSFE_EDIT\[data\]\[|data\[)','',$this->elementId
)));
246 // Find the page PIDs:
247 list($this->tscPID
,$this->thePid
) = t3lib_BEfunc
::getTSCpid(trim($this->elementParts
[0]),trim($this->elementParts
[1]),$thePidValue);
249 // Record "types" field value:
250 $this->typeVal
= $RTEtypeVal; // TCA "types" value for record
252 // Find "thisConfig" for record/editor:
253 unset($this->RTEsetup
);
254 $this->RTEsetup
= $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($this->tscPID
));
255 $this->thisConfig
= $thisConfig;
257 // Special configuration and default extras:
258 $this->specConf
= $specConf;
260 if ($this->thisConfig
['forceHTTPS']) {
261 $this->httpTypo3Path
= preg_replace('/^(http|https)/', 'https', $this->httpTypo3Path
);
262 $this->extHttpPath
= preg_replace('/^(http|https)/', 'https', $this->extHttpPath
);
263 $this->siteURL
= preg_replace('/^(http|https)/', 'https', $this->siteURL
);
264 $this->hostURL
= preg_replace('/^(http|https)/', 'https', $this->hostURL
);
267 /* =======================================
268 * LANGUAGES & CHARACTER SETS
269 * =======================================
272 // Languages: interface and content
273 $this->language
= $LANG->lang
;
274 if ($this->language
=='default' ||
!$this->language
) {
275 $this->language
='en';
277 $this->contentTypo3Language
= $this->language
;
279 $this->contentLanguageUid
= ($row['sys_language_uid'] > 0) ?
$row['sys_language_uid'] : 0;
280 if (t3lib_extMgm
::isLoaded('static_info_tables')) {
281 if ($this->contentLanguageUid
) {
282 $tableA = 'sys_language';
283 $tableB = 'static_languages';
284 $languagesUidsList = $this->contentLanguageUid
;
285 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
286 $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
287 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
288 $whereClause .= t3lib_BEfunc
::BEenableFields($tableA);
289 $whereClause .= t3lib_BEfunc
::deleteClause($tableA);
290 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
291 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
292 $this->contentISOLanguage
= strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?
'_'.trim($languageRow['lg_country_iso_2']):''));
293 $this->contentTypo3Language
= strtolower(trim($languageRow['lg_typo3']));
296 $this->contentISOLanguage
= trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['defaultDictionary']) ?
trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['defaultDictionary']) : 'en';
297 $selectFields = 'lg_iso_2, lg_typo3';
298 $tableAB = 'static_languages';
299 $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage
), $tableAB);
300 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
301 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
302 $this->contentTypo3Language
= strtolower(trim($languageRow['lg_typo3']));
307 // Character sets: interface and content
308 $this->charset
= $LANG->charSet
;
309 $this->OutputCharset
= $this->charset
;
311 $this->contentCharset
= $LANG->csConvObj
->charSetArray
[$this->contentTypo3Language
];
312 $this->contentCharset
= $this->contentCharset ?
$this->contentCharset
: 'iso-8859-1';
313 $this->origContentCharSet
= $this->contentCharset
;
314 $this->contentCharset
= (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ?
trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset
);
316 /* =======================================
317 * TOOLBAR CONFIGURATION
318 * =======================================
321 // htmlArea plugins list
322 $this->pluginEnabledArray
= t3lib_div
::trimExplode(',', $this->pluginList
, 1);
323 $this->enableRegisteredPlugins();
325 if ($this->client
['BROWSER'] == 'msie') {
326 $this->thisConfig
['keepButtonGroupTogether'] = 0;
328 if ($this->client
['BROWSER'] == 'opera') {
329 $this->thisConfig
['keepButtonGroupTogether'] = 0;
331 if ($this->client
['BROWSER'] == 'gecko' && $this->client
['VERSION'] == '1.3') {
332 $this->thisConfig
['keepButtonGroupTogether'] = 0;
338 // Check if some plugins need to be disabled
341 // Merge the list of enabled plugins with the lists from the previous RTE editing areas on the same form
342 $this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
] = $this->pluginEnabledArray
;
343 if ($this->TCEform
->RTEcounter
> 1 && isset($this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
-1]) && is_array($this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
-1])) {
344 $this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
] = array_unique(array_values(array_merge($this->pluginEnabledArray
,$this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
-1])));
347 /* =======================================
349 * =======================================
352 $RTEWidth = isset($BE_USER->userTS
['options.']['RTESmallWidth']) ?
$BE_USER->userTS
['options.']['RTESmallWidth'] : '530';
353 $RTEHeight = isset($BE_USER->userTS
['options.']['RTESmallHeight']) ?
$BE_USER->userTS
['options.']['RTESmallHeight'] : '380';
354 $RTEWidth = $RTEWidth +
($this->TCEform
->docLarge ?
(isset($BE_USER->userTS
['options.']['RTELargeWidthIncrement']) ?
$BE_USER->userTS
['options.']['RTELargeWidthIncrement'] : '150') : 0);
355 $RTEWidth -= ($inline->getStructureDepth() > 0 ?
($inline->getStructureDepth()+
1)*$inline->getLevelMargin() : 0);
356 $RTEHeight = $RTEHeight +
($this->TCEform
->docLarge ?
(isset($BE_USER->userTS
['options.']['RTELargeHeightIncrement']) ?
$BE_USER->userTS
['options.']['RTELargeHeightIncrement'] : 0) : 0);
357 $RTEHeightOverride = intval($this->thisConfig
['RTEHeightOverride']);
358 $RTEHeight = ($RTEHeightOverride > 0) ?
$RTEHeightOverride : $RTEHeight;
359 $editorWrapWidth = $RTEWidth . 'px';
360 $editorWrapHeight = $RTEHeight . 'px';
361 $this->RTEdivStyle
= 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:'.$RTEWidth.'px; border: 1px solid black; padding: 2px 0px 2px 2px;';
362 $this->toolbar_level_size
= $RTEWidth;
364 /* =======================================
365 * LOAD CSS AND JAVASCRIPT
366 * =======================================
369 // Preloading the pageStyle
370 $filename = trim($this->thisConfig
['contentCSS']) ?
trim($this->thisConfig
['contentCSS']) : 'EXT:' . $this->ID
. '/res/contentcss/default.css';
371 $this->TCEform
->additionalCode_pre
['loadCSS'] = '
372 <link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
374 // Loading the editor skin
375 $skinFilename = trim($this->thisConfig
['skin']) ?
trim($this->thisConfig
['skin']) : 'EXT:' . $this->ID
. '/htmlarea/skins/default/htmlarea.css';
376 if($this->client
['BROWSER'] == 'gecko' && $this->client
['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:') {
377 $skinFilename = 'EXT:' . $this->ID
. '/htmlarea/skins/default/htmlarea.css';
379 if (substr($skinFilename,0,4) == 'EXT:') { // extension
380 list($extKey,$local) = explode('/',substr($skinFilename,4),2);
382 if (strcmp($extKey,'') && t3lib_extMgm
::isLoaded($extKey) && strcmp($local,'')) {
383 $skinFilename = $this->httpTypo3Path
. t3lib_extMgm
::siteRelPath($extKey) . $local;
384 $skinDir = $this->siteURL
. t3lib_extMgm
::siteRelPath($extKey) . dirname($local);
386 } elseif (substr($skinFilename,0,1) != '/') {
387 $skinDir = $this->siteURL
.dirname($skinFilename);
388 $skinFilename = $this->siteURL
. $skinFilename;
390 $skinDir = substr($this->siteURL
,0,-1) . dirname($skinFilename);
392 $this->editorCSS
= $skinFilename;
393 $this->editedContentCSS
= $skinDir . '/htmlarea-edited-content.css';
394 $this->TCEform
->additionalCode_pre
['loadCSS'] .= '
395 <link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS
. '" />';
398 $this->TCEform
->additionalCode_pre
['loadCSS'] .= '
399 <link rel="stylesheet" type="text/css" href="' . $this->editorCSS
. '" />';
401 // Additional icons from registered plugins
402 foreach ($this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
] as $pluginId) {
403 if (is_object($this->registeredPlugins
[$pluginId])) {
404 $pathToSkin = $this->registeredPlugins
[$pluginId]->getPathToSkin();
406 $this->TCEform
->additionalCode_pre
['loadCSS'] .= '
407 <link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path
. t3lib_extMgm
::siteRelPath($this->registeredPlugins
[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
412 // Loading JavaScript files and code
413 if ($this->TCEform
->RTEcounter
== 1) {
414 $this->TCEform
->additionalCode_pre
['loadJSfiles'] = $this->loadJSfiles($this->TCEform
->RTEcounter
);
415 $this->TCEform
->additionalJS_pre
['loadJScode'] = $this->loadJScode($this->TCEform
->RTEcounter
);
418 /* =======================================
420 * =======================================
424 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
426 // Further content transformation by registered plugins
427 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
428 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "transformContent")) {
429 $value = $plugin->transformContent($value);
432 // Register RTE windows
433 $this->TCEform
->RTEwindows
[] = $PA['itemFormElName'];
434 $textAreaId = htmlspecialchars($PA['itemFormElName']);
436 // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
437 if (basename(PATH_thisScript
) == 'wizard_rte.php') {
438 $height = 'window.innerHeight';
439 $width = 'window.innerWidth';
440 if ($this->client
['BROWSER'] == 'msie') {
441 $height = 'document.body.offsetHeight';
442 $width = 'document.body.offsetWidth';
444 $editorWrapWidth = '100%';
445 $editorWrapHeight = '100%';
446 $this->RTEdivStyle
= 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
447 $this->TCEform
->additionalJS_post
[] = $this->setRTEsizeByJS('RTEarea' . $textAreaId, $height, $width);
450 // Register RTE in JS:
451 $this->TCEform
->additionalJS_post
[] = $this->registerRTEinJS($this->TCEform
->RTEcounter
, $table, $row['uid'], $field, $textAreaId);
453 // Set the save option for the RTE:
454 $this->TCEform
->additionalJS_submit
[] = $this->setSaveRTE($this->TCEform
->RTEcounter
, $this->TCEform
->formName
, $textAreaId);
455 $this->TCEform
->additionalJS_delete
[] = $this->setDeleteRTE($this->TCEform
->RTEcounter
, $this->TCEform
->formName
, $textAreaId);
458 $visibility = 'hidden';
459 $unuqid = uniqid('rte');
460 $item = $this->triggerField($PA['itemFormElName']).'
461 <div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
462 <div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
463 <textarea id="RTEarea' . $textAreaId . '" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.t3lib_div
::deHSCentities(htmlspecialchars($this->RTEdivStyle
)).'">'.t3lib_div
::formatForTextarea($value).'</textarea>
464 </div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableDebugMode'] ?
'<div id="HTMLAreaLog"></div>' : '') . '
473 * Add registered plugins to the array of enabled plugins
476 function enableRegisteredPlugins() {
477 global $TYPO3_CONF_VARS;
478 // Traverse registered plugins
479 if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['plugins'])) {
480 foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['plugins'] as $pluginId => $pluginObjectConfiguration) {
482 if (is_array($pluginObjectConfiguration) && count($pluginObjectConfiguration)) {
483 $plugin = &t3lib_div
::getUserObj($pluginObjectConfiguration['objectReference']);
485 if (is_object($plugin)) {
486 if ($plugin->main($this)) {
487 $this->registeredPlugins
[$pluginId] = $plugin;
488 // Override buttons from previously registered plugins
489 $pluginButtons = t3lib_div
::trimExplode(',', $plugin->getPluginButtons(), 1);
490 foreach ($this->pluginButton
as $previousPluginId => $buttonList) {
491 $this->pluginButton
[$previousPluginId] = implode(',',array_diff(t3lib_div
::trimExplode(',', $this->pluginButton
[$previousPluginId], 1), $pluginButtons));
493 $this->pluginButton
[$pluginId] = $plugin->getPluginButtons();
494 $pluginLabels = t3lib_div
::trimExplode(',', $plugin->getPluginLabels(), 1);
495 foreach ($this->pluginLabel
as $previousPluginId => $labelList) {
496 $this->pluginLabel
[$previousPluginId] = implode(',',array_diff(t3lib_div
::trimExplode(',', $this->pluginLabel
[$previousPluginId], 1), $pluginLabels));
498 $this->pluginLabel
[$pluginId] = $plugin->getPluginLabels();
499 $this->pluginEnabledArray
[] = $pluginId;
505 $hidePlugins = array();
506 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
507 if ($plugin->addsButtons() && !$this->pluginButton
[$pluginId]) {
508 $hidePlugins[] = $pluginId;
511 $this->pluginEnabledArray
= array_diff($this->pluginEnabledArray
, $hidePlugins);
515 * Set the toolbar config (only in this PHP-Object, not in JS):
519 function setToolbar() {
522 $this->defaultToolbarOrder
= 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
523 bar, formattext, bold, strong, italic, emphasis, big, small, insertedtext, deletedtext, citation, code, definition, keyboard, monospaced, quotation, sample, variable, bidioverride, strikethrough, subscript, superscript, underline, span,
524 bar, fontstyle, space, fontsize, bar, formatblock, insertparagraphbefore, insertparagraphafter, blockquote,
525 bar, left, center, right, justifyfull,
526 bar, orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, lefttoright, righttoleft,
527 bar, textcolor, bgcolor, textindicator,
528 bar, emoticon, insertcharacter, line, link, unlink, image, table,' . (($this->thisConfig
['hideTableOperationsInToolbar'] && is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['toggleborders.']) && $this->thisConfig
['buttons.']['toggleborders.']['keepInToolbar']) ?
' toggleborders,': '') . ' user, acronym, bar, findreplace, spellcheck,
529 bar, chMode, inserttag, removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
530 ' . ($this->thisConfig
['hideTableOperationsInToolbar'] ?
'': 'bar, toggleborders,') . ' bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
531 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
532 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
534 // Special toolbar for Mozilla Wamcom on Mac OS 9
535 if($this->client
['BROWSER'] == 'gecko' && $this->client
['VERSION'] == '1.3') {
536 $this->defaultToolbarOrder
= $this->TCEform
->docLarge ?
'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
537 bar, fontstyle, space, fontsize, space, formatblock, insertparagraphbefore, insertparagraphafter, blockquote, bar, bold, italic, underline, strikethrough,
538 subscript, superscript, lefttoright, righttoleft, bar, left, center, right, justifyfull, linebreak,
539 bar, orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
540 insertcharacter, line, link, unlink, image, table, user, acronym, bar, findreplace, spellcheck, bar, chMode, inserttag,
541 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
542 bar, toggleborders, bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
543 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
544 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge'
545 : 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
546 bar, fontstyle, space, fontsize, space, formatblock, insertparagraphbefore, insertparagraphafter, blockquote, bar, bold, italic, underline, strikethrough,
547 subscript, superscript, linebreak, bar, lefttoright, righttoleft, bar, left, center, right, justifyfull,
548 orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
549 insertcharacter, line, link, unlink, image, table, user, acronym, linebreak, bar, findreplace, spellcheck, bar, chMode, inserttag,
550 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
551 bar, toggleborders, bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
552 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
553 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
556 // Additional buttons from registered plugins
557 foreach($this->registeredPlugins
as $pluginId => $plugin) {
558 if ($this->isPluginEnabled($pluginId)) {
559 $this->defaultToolbarOrder
= $plugin->addButtonsToToolbar();
562 $toolbarOrder = $this->thisConfig
['toolbarOrder'] ?
$this->thisConfig
['toolbarOrder'] : $this->defaultToolbarOrder
;
564 // Getting rid of undefined buttons
565 $this->toolbarOrderArray
= array_intersect(t3lib_div
::trimExplode(',', $toolbarOrder, 1), t3lib_div
::trimExplode(',', $this->defaultToolbarOrder
, 1));
566 $toolbarOrder = array_unique(array_values($this->toolbarOrderArray
));
568 // Fetching specConf for field from backend
569 $pList = is_array($this->specConf
['richtext']['parameters']) ?
implode(',',$this->specConf
['richtext']['parameters']) : '';
570 if ($pList != '*') { // If not all
571 $show = is_array($this->specConf
['richtext']['parameters']) ?
$this->specConf
['richtext']['parameters'] : array();
572 if ($this->thisConfig
['showButtons']) {
573 if (!t3lib_div
::inList($this->thisConfig
['showButtons'],'*')) {
574 $show = array_unique(array_merge($show,t3lib_div
::trimExplode(',',$this->thisConfig
['showButtons'],1)));
576 $show = array_unique(array_merge($show, $toolbarOrder));
579 if (is_array($this->thisConfig
['showButtons.'])) {
580 foreach ($this->thisConfig
['showButtons.'] as $buttonId => $value) {
581 if ($value) $show[] = $buttonId;
583 $show = array_unique($show);
586 $show = $toolbarOrder;
589 // Resticting to RTEkeyList for backend user
590 if(is_object($BE_USER)) {
591 $RTEkeyList = isset($BE_USER->userTS
['options.']['RTEkeyList']) ?
$BE_USER->userTS
['options.']['RTEkeyList'] : '*';
592 if ($RTEkeyList != '*') { // If not all
593 $show = array_intersect($show, t3lib_div
::trimExplode(',',$RTEkeyList,1));
597 // Hiding buttons of disabled plugins
598 $hideButtons = array('space', 'bar', 'linebreak');
599 foreach ($this->pluginButton
as $pluginId => $buttonList) {
600 if (!$this->isPluginEnabled($pluginId)) {
601 $buttonArray = t3lib_div
::trimExplode(',',$buttonList,1);
602 foreach ($buttonArray as $button) {
603 $hideButtons[] = $button;
608 // Hiding labels of disabled plugins
609 foreach ($this->pluginLabel
as $pluginId => $label) {
610 if (!$this->isPluginEnabled($pluginId)) {
611 $hideButtons[] = $label;
616 $show = array_diff($show, $this->conf_toolbar_hide
, t3lib_div
::trimExplode(',',$this->thisConfig
['hideButtons'],1));
618 // Apply toolbar constraints from registered plugins
619 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
620 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "applyToolbarConstraints")) {
621 $show = $plugin->applyToolbarConstraints($show);
624 // Adding the always show buttons
625 $show = array_unique(array_merge($show, $this->conf_toolbar_show
));
626 $toolbarOrder = array_unique(array_merge($toolbarOrder, $this->conf_toolbar_show
));
627 foreach ($this->conf_toolbar_show
as $buttonId) {
628 if (!in_array($buttonId, $this->toolbarOrderArray
)) $this->toolbarOrderArray
[] = $buttonId;
631 // Getting rid of the buttons for which we have no position
632 $show = array_intersect($show, $toolbarOrder);
633 $this->toolbar
= $show;
637 * Disable some plugins
640 function setPlugins() {
642 // Disabling a plugin that adds buttons if none of its buttons is in the toolbar
643 $hidePlugins = array();
644 foreach ($this->pluginButton
as $pluginId => $buttonList) {
645 if ($this->registeredPlugins
[$pluginId]->addsButtons()) {
647 $buttonArray = t3lib_div
::trimExplode(',', $buttonList, 1);
648 foreach ($buttonArray as $button) {
649 if (in_array($button, $this->toolbar
)) {
654 $hidePlugins[] = $pluginId;
658 $this->pluginEnabledArray
= array_diff($this->pluginEnabledArray
, $hidePlugins);
660 // Hiding labels of disabled plugins
661 $hideLabels = array();
662 foreach ($this->pluginLabel
as $pluginId => $label) {
663 if (!$this->isPluginEnabled($pluginId)) {
664 $hideLabels[] = $label;
667 $this->toolbar
= array_diff($this->toolbar
, $hideLabels);
669 // Adding plugins declared as prerequisites by enabled plugins
670 $requiredPlugins = array();
671 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
672 if ($this->isPluginEnabled($pluginId)) {
673 $requiredPlugins = array_merge($requiredPlugins, t3lib_div
::trimExplode(',', $plugin->getRequiredPlugins(), 1));
676 $requiredPlugins = array_unique($requiredPlugins);
677 foreach ($requiredPlugins as $pluginId) {
678 if (is_object($this->registeredPlugins
[$pluginId]) && !$this->isPluginEnabled($pluginId)) {
679 $this->pluginEnabledArray
[] = $pluginId;
683 // Completing the toolbar converion array for htmlArea
684 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
685 if ($this->isPluginEnabled($pluginId)) {
686 $this->convertToolbarForHtmlAreaArray
= array_unique(array_merge($this->convertToolbarForHtmlAreaArray
, $plugin->getConvertToolbarForHtmlAreaArray()));
692 * Convert the TYPO3 names of buttons into the names for htmlArea RTE
694 * @param string buttonname (typo3-name)
695 * @return string buttonname (htmlarea-name)
698 function convertToolbarForHTMLArea($button) {
699 return $this->convertToolbarForHtmlAreaArray
[$button];
703 * Return the JS-function for setting the RTE size.
705 * @param string DivID-Name
706 * @param int the height for the RTE
707 * @param int the width for the RTE
708 * @return string Loader function in JS
710 function setRTEsizeByJS($divId, $height, $width) {
712 setRTEsizeByJS(\''.$divId.'\','.$height.', '.$width.');
717 * Return the HTML code for loading the Javascript files
719 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
721 * @return string the html code for loading the Javascript Files
723 function loadJSfiles($RTEcounter) {
724 global $TYPO3_CONF_VARS;
726 $loadJavascriptCode = '
727 <script type="text/javascript">
729 function rteHtmlAreaGetElementsByClassName(className) {
730 var allElements = document.getElementsByTagName("*");
731 var result = new Array();
733 for (var i = 0; i < allElements.length; i++) {
734 var c = " " + allElements[i].className + " ";
735 if (c.indexOf(" " + className + " ") != -1) {
736 result[result.length] = allElements[i];
742 wait_elements = rteHtmlAreaGetElementsByClassName("pleasewait");
743 wrap_elements = rteHtmlAreaGetElementsByClassName("editorWrap");
744 for (i = 0; i < wait_elements.length; i++) {
745 wait_elements[i].style.display = "block";
746 wrap_elements[i].style.visibility = "hidden";
748 RTEarea = new Array();
749 RTEarea[0] = new Object();
750 RTEarea[0]["version"] = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['version'] . '";'
751 . (($this->client
['BROWSER'] == 'msie') ?
('
752 RTEarea[0]["htmlarea-ie"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID
. '/htmlarea/htmlarea-ie.js', "htmlarea-ie") . '";')
754 RTEarea[0]["htmlarea-gecko"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID
. '/htmlarea/htmlarea-gecko.js', "htmlarea-gecko") . '";')) . '
755 _editor_url = "' . $this->extHttpPath
. 'htmlarea";
756 _editor_lang = "' . $this->language
. '";
757 _editor_CSS = "' . $this->editorCSS
. '";
758 _editor_skin = "' . dirname($this->editorCSS
) . '";
759 _editor_edited_content_CSS = "' . $this->editedContentCSS
. '";
760 _typo3_host_url = "' . $this->hostURL
. '";
761 _editor_debug_mode = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableDebugMode'] ?
'true' : 'false') . ';
762 _editor_compressed_scripts = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'true' : 'false') . ';'
763 . (($this->client
['BROWSER'] == 'gecko') ?
('
764 _editor_mozAllowClipboard_url = "' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['mozAllowClipboardURL'] ?
$TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['mozAllowClipboardURL'] : '') . '";')
768 $loadJavascriptCode .= '
769 <script type="text/javascript" src="' . $this->buildJSMainLangFile($RTEcounter) . '"></script>
770 <script type="text/javascript" src="' . $this->writeTemporaryFile('EXT:' . $this->ID
. '/htmlarea/htmlarea.js', "htmlarea") . '"></script>
772 return $loadJavascriptCode;
776 * Return the inline Javascript code for initializing the RTE
778 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
780 * @return string the inline Javascript code for initializing the RTE
783 function loadJScode($RTEcounter) {
784 global $TYPO3_CONF_VARS;
786 $loadPluginCode = '';
787 foreach ($this->pluginEnabledCumulativeArray
[$RTEcounter] as $pluginId) {
788 $extensionKey = is_object($this->registeredPlugins
[$pluginId]) ?
$this->registeredPlugins
[$pluginId]->getExtensionKey() : $this->ID
;
790 HTMLArea.loadPlugin("' . $pluginId . '", "' . $this->writeTemporaryFile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js', $pluginId) . '", '. ($this->registeredPlugins
[$pluginId]->requiresSynchronousLoad()?
'false':'true'). ');';
792 return (!$this->is_FE() ?
'' : '
793 ' . '/*<![CDATA[*/') . ($this->is_FE() ?
'' : '
794 RTEarea[0]["RTEtsConfigParams"] = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";')
795 . $loadPluginCode . '
796 HTMLArea.init();' . (!$this->is_FE() ?
'' : '
802 * Return the Javascript code for configuring the RTE
804 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
805 * @param string $table: The table that includes this RTE (optional, necessary for IRRE).
806 * @param string $uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
807 * @param string $field: The field of that record that includes this RTE (optional).
809 * @return string the Javascript code for configuring the RTE
811 function registerRTEinJS($RTEcounter, $table='', $uid='', $field='', $textAreaId = '') {
812 global $TYPO3_CONF_VARS;
814 $configureRTEInJavascriptString = (!$this->is_FE() ?
'' : '
815 ' . '/*<![CDATA[*/') . '
816 editornumber = RTEarea.length;
817 document.getElementById("pleasewait' . $textAreaId . '").id = "pleasewait" + editornumber;
818 document.getElementById("editorWrap' . $textAreaId . '").id = "editorWrap" + editornumber;
819 document.getElementById("RTEarea' . $textAreaId . '").id = "RTEarea" + editornumber;
820 RTEarea[editornumber] = new Object();
821 RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
822 RTEarea[editornumber].number = editornumber;
823 RTEarea[editornumber].deleted = false;
824 RTEarea[editornumber].textAreaId = "' . $textAreaId . '";
825 RTEarea[editornumber].id = "RTEarea" + editornumber;
826 RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig
['enableWordClean'])?
'true':'false') . ';
827 RTEarea[editornumber]["htmlRemoveComments"] = ' . (trim($this->thisConfig
['removeComments'])?
'true':'false') . ';
828 RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig
['disableEnterParagraphs'])?
'true':'false') . ';
829 RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig
['disableObjectResizing'])?
'true':'false') . ';
830 RTEarea[editornumber]["removeTrailingBR"] = ' . (trim($this->thisConfig
['removeTrailingBR'])?
'true':'false') . ';
831 RTEarea[editornumber]["useCSS"] = ' . (trim($this->thisConfig
['useCSS'])?
'true':'false') . ';
832 RTEarea[editornumber]["keepButtonGroupTogether"] = ' . (trim($this->thisConfig
['keepButtonGroupTogether'])?
'true':'false') . ';
833 RTEarea[editornumber]["disablePCexamples"] = ' . (trim($this->thisConfig
['disablePCexamples'])?
'true':'false') . ';
834 RTEarea[editornumber]["statusBar"] = ' . (trim($this->thisConfig
['showStatusBar'])?
'true':'false') . ';
835 RTEarea[editornumber]["showTagFreeClasses"] = ' . (trim($this->thisConfig
['showTagFreeClasses'])?
'true':'false') . ';
836 RTEarea[editornumber]["useHTTPS"] = ' . ((trim(stristr($this->siteURL
, 'https')) ||
$this->thisConfig
['forceHTTPS'])?
'true':'false') . ';
837 RTEarea[editornumber]["enableMozillaExtension"] = ' . (($this->client
['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableMozillaExtension'])?
'true':'false') . ';
838 RTEarea[editornumber]["tceformsNested"] = ' . (is_object($this->TCEform
) && method_exists($this->TCEform
, 'getDynNestedStack') ?
$this->TCEform
->getDynNestedStack(true) : '[]') . ';
839 RTEarea[editornumber].dialogueWindows = new Object();
840 RTEarea[editornumber].dialogueWindows.defaultPositionFromTop = ' . (isset($this->thisConfig
['dialogueWindows.']['defaultPositionFromTop'])?
intval($this->thisConfig
['dialogueWindows.']['defaultPositionFromTop']) : '100') . ';
841 RTEarea[editornumber].dialogueWindows.defaultPositionFromLeft = ' . (isset($this->thisConfig
['dialogueWindows.']['defaultPositionFromLeft'])?
intval($this->thisConfig
['dialogueWindows.']['defaultPositionFromLeft']) : '100') . ';
842 RTEarea[editornumber].dialogueWindows.doNotResize = ' . (trim($this->thisConfig
['dialogueWindows.']['doNotResize'])?
'true':'false') . ';
843 RTEarea[editornumber].dialogueWindows.doNotCenter = ' . (trim($this->thisConfig
['dialogueWindows.']['doNotCenter'])?
'true':'false') . ';';
845 // The following properties apply only to the backend
846 if (!$this->is_FE()) {
847 $configureRTEInJavascriptString .= '
848 RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid
. '";
849 RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language
. '";
850 RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset
. '";
851 RTEarea[editornumber].userUid = "' . $this->userUid
. '";';
854 // Setting the plugin flags
855 $configureRTEInJavascriptString .= '
856 RTEarea[editornumber].plugin = new Object();
857 RTEarea[editornumber].pathToPluginDirectory = new Object();';
858 foreach ($this->pluginEnabledArray
as $pluginId) {
859 $configureRTEInJavascriptString .= '
860 RTEarea[editornumber].plugin.'.$pluginId.' = true;';
861 if (is_object($this->registeredPlugins
[$pluginId])) {
862 $pathToPluginDirectory = $this->registeredPlugins
[$pluginId]->getPathToPluginDirectory();
863 if ($pathToPluginDirectory) {
864 $configureRTEInJavascriptString .= '
865 RTEarea[editornumber].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";';
870 // Setting the buttons configuration
871 $configureRTEInJavascriptString .= '
872 RTEarea[editornumber].buttons = new Object();';
873 if (is_array($this->thisConfig
['buttons.'])) {
874 foreach ($this->thisConfig
['buttons.'] as $buttonIndex => $conf) {
875 $button = substr($buttonIndex, 0, -1);
876 if (in_array($button,$this->toolbar
)) {
877 $configureRTEInJavascriptString .= '
878 RTEarea[editornumber].buttons.'.$button.' = ' . $this->buildNestedJSArray($conf) . ';';
883 // Setting the list of tags to be removed if specified in the RTE config
884 if (trim($this->thisConfig
['removeTags'])) {
885 $configureRTEInJavascriptString .= '
886 RTEarea[editornumber]["htmlRemoveTags"] = /^(' . implode('|', t3lib_div
::trimExplode(',', $this->thisConfig
['removeTags'], 1)) . ')$/i;';
889 // Setting the list of tags to be removed with their contents if specified in the RTE config
890 if (trim($this->thisConfig
['removeTagsAndContents'])) {
891 $configureRTEInJavascriptString .= '
892 RTEarea[editornumber]["htmlRemoveTagsAndContents"] = /^(' . implode('|', t3lib_div
::trimExplode(',', $this->thisConfig
['removeTagsAndContents'], 1)) . ')$/i;';
895 // Process default style configuration
896 $configureRTEInJavascriptString .= '
897 RTEarea[editornumber].defaultPageStyle = "' . $this->hostURL
. $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
899 // Setting the pageStyle
900 $filename = trim($this->thisConfig
['contentCSS']) ?
trim($this->thisConfig
['contentCSS']) : 'EXT:' . $this->ID
. '/res/contentcss/default.css';
901 $configureRTEInJavascriptString .= '
902 RTEarea[editornumber].pageStyle = "' . $this->getFullFileName($filename) .'";';
904 // Process classes configuration
905 $classesConfigurationRequired = false;
906 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
907 if ($this->isPluginEnabled($pluginId)) {
908 $classesConfigurationRequired = $classesConfigurationRequired ||
$plugin->requiresClassesConfiguration();
911 if ($classesConfigurationRequired) {
912 $configureRTEInJavascriptString .= $this->buildJSClassesConfig($RTEcounter);
915 // Add Javascript configuration for registered plugins
916 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
917 if ($this->isPluginEnabled($pluginId)) {
918 $configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
922 $configureRTEInJavascriptString .= '
923 RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . ';
924 RTEarea[editornumber].convertButtonId = ' . t3lib_div
::array2json(array_flip($this->convertToolbarForHtmlAreaArray
)) .';
925 HTMLArea.initEditor(editornumber);' . (!$this->is_FE() ?
'' : '
927 return $configureRTEInJavascriptString;
931 * Return true, if the plugin can be loaded
933 * @param string $pluginId: The identification string of the plugin
935 * @return boolean true if the plugin can be loaded
938 function isPluginEnabled($pluginId) {
939 return in_array($pluginId, $this->pluginEnabledArray
);
943 * Build the default content style sheet
945 * @return string Style sheet
947 function buildStyleSheet() {
949 if (!trim($this->thisConfig
['ignoreMainStyleOverride'])) {
950 $mainStyle_font = $this->thisConfig
['mainStyle_font'] ?
$this->thisConfig
['mainStyle_font']: 'Verdana,sans-serif';
952 $mainElements = array();
953 $mainElements['P'] = $this->thisConfig
['mainStyleOverride_add.']['P'];
954 $elList = explode(',','H1,H2,H3,H4,H5,H6,PRE');
955 foreach ($elList as $elListName) {
956 if ($this->thisConfig
['mainStyleOverride_add.'][$elListName]) {
957 $mainElements[$elListName] = $this->thisConfig
['mainStyleOverride_add.'][$elListName];
961 $addElementCode = '';
962 foreach ($mainElements as $elListName => $elValue) {
963 $addElementCode .= strToLower($elListName) . ' {' . $elValue . '}' . chr(10);
966 $stylesheet = $this->thisConfig
['mainStyleOverride'] ?
$this->thisConfig
['mainStyleOverride'] : chr(10) .
967 'body.htmlarea-content-body { font-family: ' . $mainStyle_font .
968 '; font-size: '.($this->thisConfig
['mainStyle_size'] ?
$this->thisConfig
['mainStyle_size'] : '12px') .
969 '; color: '.($this->thisConfig
['mainStyle_color']?
$this->thisConfig
['mainStyle_color'] : 'black') .
970 '; background-color: '.($this->thisConfig
['mainStyle_bgcolor'] ?
$this->thisConfig
['mainStyle_bgcolor'] : 'white') .
971 ';'.$this->thisConfig
['mainStyleOverride_add.']['BODY'].'}' . chr(10) .
972 'td { ' . $this->thisConfig
['mainStyleOverride_add.']['TD'].'}' . chr(10) .
973 'div { ' . $this->thisConfig
['mainStyleOverride_add.']['DIV'].'}' . chr(10) .
974 'pre { ' . $this->thisConfig
['mainStyleOverride_add.']['PRE'].'}' . chr(10) .
975 'ol { ' . $this->thisConfig
['mainStyleOverride_add.']['OL'].'}' . chr(10) .
976 'ul { ' . $this->thisConfig
['mainStyleOverride_add.']['UL'].'}' . chr(10) .
977 'blockquote { ' . $this->thisConfig
['mainStyleOverride_add.']['BLOCKQUOTE'].'}' . chr(10) .
980 if (is_array($this->thisConfig
['inlineStyle.'])) {
981 $stylesheet .= chr(10) . implode(chr(10), $this->thisConfig
['inlineStyle.']) . chr(10);
984 $stylesheet = '/* mainStyleOverride and inlineStyle properties ignored. */';
990 * Return Javascript configuration of classes
992 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
994 * @return string Javascript configuration of classes
996 function buildJSClassesConfig($RTEcounter) {
997 // Build JS array of lists of classes
998 $classesTagList = 'classesCharacter, classesParagraph, classesImage, classesTable, classesLinks, classesTD';
999 $classesTagConvert = array( 'classesCharacter' => 'span', 'classesParagraph' => 'div', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td');
1000 $classesTagArray = t3lib_div
::trimExplode(',' , $classesTagList);
1001 $configureRTEInJavascriptString = '
1002 RTEarea[editornumber]["classesTag"] = new Object();';
1003 foreach ($classesTagArray as $classesTagName) {
1004 $HTMLAreaJSClasses = ($this->thisConfig
[$classesTagName])?
('"' . $this->cleanList($this->thisConfig
[$classesTagName]) . '";'):'null;';
1005 $configureRTEInJavascriptString .= '
1006 RTEarea[editornumber]["classesTag"]["'. $classesTagConvert[$classesTagName] .'"] = '. $HTMLAreaJSClasses;
1009 // Include JS arrays of configured classes
1010 $configureRTEInJavascriptString .= '
1011 RTEarea[editornumber]["classesUrl"] = "' . $this->hostURL
. $this->writeTemporaryFile('', 'classes_'.$LANG->lang
, 'js', $this->buildJSClassesArray()) . '";';
1013 return $configureRTEInJavascriptString;
1017 * Return JS arrays of classes labels and noShow flags
1019 * @return string JS classes arrays
1021 function buildJSClassesArray() {
1022 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1024 if ($this->is_FE()) {
1025 $RTEProperties = $this->RTEsetup
;
1027 $RTEProperties = $this->RTEsetup
['properties'];
1030 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'' : chr(10);
1033 $indexAlternating = 0;
1035 $JSClassesLabelsArray = 'HTMLArea.classesLabels = { ' . $linebreak;
1036 $JSClassesValuesArray = 'HTMLArea.classesValues = { ' . $linebreak;
1037 $JSClassesNoShowArray = 'HTMLArea.classesNoShow = { ' . $linebreak;
1038 $JSClassesAlternatingArray = 'HTMLArea.classesAlternating = { ' . $linebreak;
1039 $JSClassesCountingArray = 'HTMLArea.classesCounting = { ' . $linebreak;
1040 $JSClassesXORArray = 'HTMLArea.classesXOR = { ' . $linebreak;
1042 // Scanning the list of classes if specified in the RTE config
1043 if (is_array($RTEProperties['classes.'])) {
1044 foreach ($RTEProperties['classes.'] as $className => $conf) {
1045 $className = substr($className,0,-1);
1046 $classLabel = $this->getPageConfigLabel($conf['name']);
1047 $JSClassesLabelsArray .= ($index?
',':'') . '"' . $className . '": ' . $classLabel . $linebreak;
1048 $JSClassesValuesArray .= ($index?
',':'') . '"' . $className . '":"' . str_replace('"', '\"', str_replace('\\\'', '\'', $conf['value'])) . '"' . $linebreak;
1049 if ($conf['noShow']) {
1050 $JSClassesNoShowArray .= ($indexNoShow?
',':'') . '"' . $className . '":' . ($conf['noShow']?
'true':'false') . $linebreak;
1053 if (is_array($conf['alternating.'])) {
1054 $JSClassesAlternatingArray .= ($indexAlternating?
',':'') . '"' . $className . '":' . (is_array($conf['alternating.']) ?
$this->buildNestedJSArray($conf['alternating.']) : ' "false"') . $linebreak;
1055 $indexAlternating++
;
1057 if (is_array($conf['counting.'])) {
1058 $JSClassesCountingArray .= ($indexCounting?
',':'') . '"' . $className . '":' . (is_array($conf['counting.']) ?
$this->buildNestedJSArray($conf['counting.']) : ' "false"') . $linebreak;
1064 // Scanning the list of sets of mutually exclusives classes if specified in the RTE config
1066 if (is_array($RTEProperties['mutuallyExclusiveClasses.'])) {
1067 foreach ($RTEProperties['mutuallyExclusiveClasses.'] as $listName => $conf) {
1068 $classArray = t3lib_div
::trimExplode(',', $conf, 1);
1069 $classList = implode(',', $classArray);
1070 foreach ($classArray as $className) {
1071 $JSClassesXORArray .= ($index?
',':'') . '"' . $className . '": /^(' . implode('|', t3lib_div
::trimExplode(',', t3lib_div
::rmFromList($className, $classList), 1)) . ')$/i' . $linebreak;
1076 $JSClassesLabelsArray .= '};' . $linebreak;
1077 $JSClassesValuesArray .= '};' . $linebreak;
1078 $JSClassesNoShowArray .= '};' . $linebreak;
1079 $JSClassesAlternatingArray .= '};' . $linebreak;
1080 $JSClassesCountingArray .= '};' . $linebreak;
1081 $JSClassesXORArray .= '};' . $linebreak;
1083 return $JSClassesLabelsArray . $JSClassesValuesArray . $JSClassesNoShowArray . $JSClassesAlternatingArray . $JSClassesCountingArray . $JSClassesXORArray;
1087 * Translate Page TS Config array in JS nested array definition
1089 * @param array $conf: Page TSConfig configuration array
1091 * @return string nested JS array definition
1093 function buildNestedJSArray($conf) {
1094 $configureRTEInJavascriptString = '{';
1096 if (is_array($conf)) {
1097 foreach ($conf as $propertyName => $conf1) {
1098 $property = $propertyName;
1100 $configureRTEInJavascriptString .= ', ';
1102 if (is_array($conf1)) {
1103 $property = substr($property, 0, -1);
1105 $configureRTEInJavascriptString .= '"'.$property.'" : {';
1106 foreach ($conf1 as $property1Name => $conf2) {
1107 $property1 = $property1Name;
1108 if ($indexProperty) {
1109 $configureRTEInJavascriptString .= ', ';
1111 if (is_array($conf2)) {
1112 $property1 = substr($property1, 0, -1);
1113 $indexProperty1 = 0;
1114 $configureRTEInJavascriptString .= '"'.$property1.'" : {';
1115 foreach ($conf2 as $property2Name => $conf3) {
1116 $property2 = $property2Name;
1117 if ($indexProperty1) {
1118 $configureRTEInJavascriptString .= ', ';
1120 if (is_array($conf3)) {
1121 $property2 = substr($property2, 0, -1);
1122 $indexProperty2 = 0;
1123 $configureRTEInJavascriptString .= '"'.$property2.'" : {';
1124 foreach($conf3 as $property3Name => $conf4) {
1125 $property3 = $property3Name;
1126 if ($indexProperty2) {
1127 $configureRTEInJavascriptString .= ', ';
1129 if (!is_array($conf4)) {
1130 $configureRTEInJavascriptString .= '"'.$property3.'" : '.($conf4?
'"'.$conf4.'"':'false');
1134 $configureRTEInJavascriptString .= '}';
1136 $configureRTEInJavascriptString .= '"'.$property2.'" : '.($conf3?
'"'.$conf3.'"':'false');
1140 $configureRTEInJavascriptString .= '}';
1142 $configureRTEInJavascriptString .= '"'.$property1.'" : '.($conf2?
'"'.$conf2.'"':'false');
1146 $configureRTEInJavascriptString .= '}';
1148 $configureRTEInJavascriptString .= '"'.$property.'" : '.($conf1?
'"'.$conf1.'"':'false');
1153 $configureRTEInJavascriptString .= '}';
1154 return $configureRTEInJavascriptString;
1158 * Return a Javascript localization array for htmlArea RTE
1160 * @return string Javascript localization array
1162 function buildJSMainLangArray() {
1163 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1165 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'' : chr(10);
1166 $JSLanguageArray .= 'var HTMLArea_langArray = new Object();' . $linebreak;
1167 $JSLanguageArray .= 'HTMLArea_langArray = { ' . $linebreak;
1168 $subArrays = array( 'tooltips', 'msg' , 'dialogs');
1169 $subArraysIndex = 0;
1170 foreach ($subArrays as $labels) {
1171 $JSLanguageArray .= (($subArraysIndex++
)?
',':'') . $labels . ': {' . $linebreak;
1172 if ($this->is_FE()) {
1173 $LOCAL_LANG = t3lib_div
::readLLfile('EXT:' . $this->ID
. '/htmlarea/locallang_' . $labels . '.xml', $this->language
, $this->OutputCharset
);
1175 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm
::extPath($this->ID
).'htmlarea/locallang_' . $labels . '.xml');
1177 if (!empty($LOCAL_LANG[$this->language
])) {
1178 $LOCAL_LANG[$this->language
] = t3lib_div
::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language
]);
1180 $LOCAL_LANG[$this->language
] = $LOCAL_LANG['default'];
1183 foreach ($LOCAL_LANG[$this->language
] as $labelKey => $labelValue ) {
1184 $JSLanguageArray .= (($index++
)?
',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
1186 $JSLanguageArray .= ' }' . chr(10);
1188 $JSLanguageArray .= ' };' . chr(10);
1189 return $JSLanguageArray;
1193 * Writes contents in a file in typo3temp/rtehtmlarea directory and returns the file name
1195 * @param string $sourceFileName: The name of the file from which the contents should be extracted
1196 * @param string $label: A label to insert at the beginning of the name of the file
1197 * @param string $fileExtension: The file extension of the file, defaulting to 'js'
1198 * @param string $contents: The contents to write into the file if no $sourceFileName is provided
1200 * @return string The name of the file writtten to typo3temp/rtehtmlarea
1202 public function writeTemporaryFile($sourceFileName='', $label, $fileExtension='js', $contents='') {
1203 global $TYPO3_CONF_VARS;
1205 if ($sourceFileName) {
1207 $source = t3lib_div
::getFileAbsFileName($sourceFileName);
1208 $output = file_get_contents($source);
1210 $output = $contents;
1212 $compress = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] && ($fileExtension == 'js') && ($output != '');
1213 $relativeFilename = 'typo3temp/' . $this->ID
. '/' . str_replace('-','_',$label) . '_' . t3lib_div
::shortMD5(($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['version'] . ($sourceFileName?
$sourceFileName:$output)), 20) . ($compress ?
'_compressed' : '') . '.' . $fileExtension;
1214 $destination = PATH_site
. $relativeFilename;
1215 if(!file_exists($destination)) {
1216 $compressedJavaScript = '';
1218 $compressedJavaScript = t3lib_div
::minifyJavaScript($output);
1220 $failure = t3lib_div
::writeFileToTypo3tempDir($destination, $compressedJavaScript?
$compressedJavaScript:$output);
1225 return ($this->thisConfig
['forceHTTPS']?
$this->siteURL
:$this->httpTypo3Path
) . $relativeFilename;
1229 * Return a file name containing the main JS language array for HTMLArea
1231 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1233 * @return string filename
1236 function buildJSMainLangFile($RTEcounter) {
1237 $contents = $this->buildJSMainLangArray() . chr(10);
1238 foreach ($this->pluginEnabledCumulativeArray
[$RTEcounter] as $pluginId) {
1239 $contents .= $this->buildJSLangArray($pluginId) . chr(10);
1241 return $this->writeTemporaryFile('', $this->language
.'_'.$this->OutputCharset
, 'js', $contents);
1245 * Return a Javascript localization array for the plugin
1247 * @param string $plugin: identification string of the plugin
1249 * @return string Javascript localization array
1252 function buildJSLangArray($plugin) {
1253 global $LANG, $TYPO3_CONF_VARS;
1255 $extensionKey = is_object($this->registeredPlugins
[$plugin]) ?
$this->registeredPlugins
[$plugin]->getExtensionKey() : $this->ID
;
1257 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'' : chr(10);
1258 if($this->is_FE()) {
1259 $LOCAL_LANG = t3lib_div
::readLLfile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $plugin . '/locallang.xml', $this->language
, $this->OutputCharset
);
1261 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm
::extPath($extensionKey).'htmlarea/plugins/' . $plugin . '/locallang.xml');
1264 if (!empty($LOCAL_LANG[$this->language
])) {
1265 $LOCAL_LANG[$this->language
] = t3lib_div
::array_merge_recursive_overrule($LOCAL_LANG['default'],$LOCAL_LANG[$this->language
]);
1267 $LOCAL_LANG[$this->language
] = $LOCAL_LANG['default'];
1270 $JSLanguageArray .= 'var ' . $plugin . '_langArray = new Object();' . $linebreak;
1271 $JSLanguageArray .= $plugin . '_langArray = {' . $linebreak;
1273 foreach ($LOCAL_LANG[$this->language
] as $labelKey => $labelValue ) {
1274 $JSLanguageArray .= (($index++
)?
',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
1276 $JSLanguageArray .= ' };' . chr(10);
1278 return $JSLanguageArray;
1282 * Return the JS-Code for the Toolbar-Config-Array for HTML-Area
1284 * @return string the JS-Code as an JS-Array
1287 function getJSToolbarArray() {
1288 $toolbar = ''; // The JS-Code for the toolbar
1289 $group = ''; // The TS-Code for the group in the moment, each group are between "bar"s
1290 $group_has_button = false; // True if the group has any enabled buttons
1291 $group_needs_starting_bar = false;
1292 $previous_is_space = false;
1294 // process each button in the order list
1295 foreach ($this->toolbarOrderArray
as $button) {
1296 // check if a new group starts
1297 if (($button == 'bar' ||
$button == 'linebreak') && $group_has_button) {
1299 if ($button == 'linebreak') {
1300 $convertButton = '"' . $this->convertToolbarForHTMLArea('linebreak') . '"';
1301 $group = ($group!='') ?
($group . ', ' . $convertButton) : $convertButton;
1304 $toolbar .= $toolbar ?
(', ' . $group) : ('[[' . $group);
1306 $previous_is_space = false;
1307 $group_has_button = false;
1308 $group_needs_starting_bar = true;
1309 } elseif ($toolbar && $button == 'linebreak' && !$group_has_button) {
1310 // Insert linebreak if no group is opened
1312 $previous_is_space = false;
1313 $group_needs_starting_bar = false;
1314 $toolbar .= ', "' . $this->convertToolbarForHTMLArea($button) . '"';
1315 } elseif ($button == 'bar' && !$group_has_button) {
1316 $group_needs_starting_bar = true;
1317 } elseif ($button == 'space' && $group_has_button && !$previous_is_space) {
1318 $convertButton = $this->convertToolbarForHTMLArea($button);
1319 $convertButton = '"' . $convertButton . '"';
1320 $group .= $group ?
(', ' . $convertButton) : ($group_needs_starting_bar ?
('"' . $this->convertToolbarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
1321 $group_needs_starting_bar = false;
1322 $previous_is_space = true;
1323 } elseif (in_array($button, $this->toolbar
)) {
1324 // Add the button to the group
1325 $convertButton = $this->convertToolbarForHTMLArea($button);
1326 if ($convertButton) {
1327 $convertButton = '"' . $convertButton . '"';
1328 $group .= $group ?
(', ' . $convertButton) : ($group_needs_starting_bar ?
('"' . $this->convertToolbarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
1329 $group_has_button = true;
1330 $group_needs_starting_bar = false;
1331 $previous_is_space = false;
1336 // add the last group
1337 if($group_has_button) $toolbar .= $toolbar ?
(', ' . $group) : ('[[' . $group);
1338 $toolbar = $toolbar . ']]';
1342 public function getLLContent($string) {
1345 $BE_lang = $LANG->lang
;
1346 $BE_charSet = $LANG->charSet
;
1347 $LANG->lang
= $this->contentTypo3Language
;
1348 $LANG->charSet
= $this->contentCharset
;
1349 $LLString = $LANG->JScharCode($LANG->sL($string));
1350 $LANG->lang
= $BE_lang;
1351 $LANG->charSet
= $BE_charSet;
1355 public function getPageConfigLabel($string,$JScharCode=1) {
1356 global $LANG, $TSFE, $TYPO3_CONF_VARS;
1358 if ($this->is_FE()) {
1359 if (strcmp(substr($string,0,4),'LLL:') && $TYPO3_CONF_VARS['BE']['forceCharset']) {
1360 // A pure string coming from Page TSConfig must be in forceCharset, otherwise we just don't know..
1361 $label = $TSFE->csConvObj
->conv($TSFE->sL(trim($string)), $TYPO3_CONF_VARS['BE']['forceCharset'], $this->OutputCharset
);
1363 $label = $TSFE->csConvObj
->conv($TSFE->sL(trim($string)), $this->charset
, $this->OutputCharset
);
1365 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1366 $label = $JScharCode ?
$this->feJScharCode($label) : $label;
1368 if (strcmp(substr($string,0,4),'LLL:')) {
1371 $label = $LANG->sL(trim($string));
1373 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1374 $label = $JScharCode ?
$LANG->JScharCode($label): $label;
1379 function feJScharCode($str) {
1381 // Convert string to UTF-8:
1382 if ($this->OutputCharset
!= 'utf-8') $str = $TSFE->csConvObj
->utf8_encode($str,$this->OutputCharset
);
1383 // Convert the UTF-8 string into a array of char numbers:
1384 $nArr = $TSFE->csConvObj
->utf8_to_numberarray($str);
1385 return 'String.fromCharCode('.implode(',',$nArr).')';
1388 public function getFullFileName($filename) {
1389 if (substr($filename,0,4)=='EXT:') { // extension
1390 list($extKey,$local) = explode('/',substr($filename,4),2);
1392 if (strcmp($extKey,'') && t3lib_extMgm
::isLoaded($extKey) && strcmp($local,'')) {
1393 $newFilename = $this->siteURL
. t3lib_extMgm
::siteRelPath($extKey) . $local;
1395 } elseif (substr($filename,0,1) != '/') {
1396 $newFilename = $this->siteURL
. $filename;
1398 $newFilename = $this->siteURL
. substr($filename,1);
1400 return $newFilename;
1404 * Return the Javascript code for copying the HTML code from the editor into the hidden input field.
1405 * This is for submit function of the form.
1407 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1408 * @param string $formName: the name of the form
1409 * @param string $textareaId: the id of the textarea
1411 * @return string Javascript code
1413 function setSaveRTE($RTEcounter, $formName, $textareaId) {
1416 for (editornumber = 1; editornumber < RTEarea.length; editornumber++) {
1417 if (RTEarea[editornumber].textAreaId == "' . $textareaId . '") {
1418 if (!RTEarea[editornumber].deleted) {
1419 document.'.$formName.'["'.$textareaId.'"].value = RTEarea[editornumber]["editor"].getHTML();
1432 * Return the Javascript code for copying the HTML code from the editor into the hidden input field.
1433 * This is for submit function of the form.
1435 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1436 * @param string $formName: the name of the form
1437 * @param string $textareaId: the id of the textarea
1439 * @return string Javascript code
1441 function setDeleteRTE($RTEcounter, $formName, $textareaId) {
1443 for (editornumber = 1; editornumber < RTEarea.length; editornumber++) {
1444 if (RTEarea[editornumber].textAreaId == "' . $textareaId . '") {
1445 if (RTEarea[editornumber]) {
1446 RTEarea[editornumber].deleted = true;
1455 * Return true if we are in the FE, but not in the FE editing feature of BE.
1462 return is_object($TSFE) && is_array($this->LOCAL_LANG
) && !strstr($this->elementId
,'TSFE_EDIT');
1466 * Client Browser Information
1470 * @param string Alternative User Agent string (if empty, t3lib_div::getIndpEnv('HTTP_USER_AGENT') is used)
1471 * @return array Parsed information about the HTTP_USER_AGENT in categories BROWSER, VERSION, SYSTEM and FORMSTYLE
1474 function clientInfo($useragent='') {
1475 global $TYPO3_CONF_VARS;
1477 if (!$useragent) $useragent=t3lib_div
::getIndpEnv('HTTP_USER_AGENT');
1481 if (strstr($useragent,'Konqueror')) {
1482 $bInfo['BROWSER']= 'konqu';
1483 } elseif (strstr($useragent,'Opera')) {
1484 $bInfo['BROWSER']= 'opera';
1485 } elseif (strstr($useragent,'MSIE')) {
1486 $bInfo['BROWSER']= 'msie';
1487 } elseif (strstr($useragent,'Gecko/')) {
1488 $bInfo['BROWSER']='gecko';
1489 } elseif (strstr($useragent,'Safari/')) {
1490 $bInfo['BROWSER']='safari';
1491 } elseif (strstr($useragent,'Mozilla/4')) {
1492 $bInfo['BROWSER']='net';
1495 if ($bInfo['BROWSER']) {
1497 switch($bInfo['BROWSER']) {
1499 $bInfo['VERSION']= doubleval(substr($useragent,8));
1500 if (strstr($useragent,'Netscape6/')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape6/'),10));}
1501 if (strstr($useragent,'Netscape/7')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape/7'),9));}
1504 $tmp = strstr($useragent,'rv:');
1505 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
1508 $tmp = strstr($useragent,'MSIE');
1509 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4)));
1512 $tmp = strstr($useragent,'Safari/');
1513 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
1516 $tmp = strstr($useragent,'Opera');
1517 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5)));
1520 $tmp = strstr($useragent,'Konqueror/');
1521 $bInfo['VERSION'] = doubleval(substr($tmp,10));
1526 if (strstr($useragent,'Win')) {
1527 $bInfo['SYSTEM'] = 'win';
1528 } elseif (strstr($useragent,'Mac')) {
1529 $bInfo['SYSTEM'] = 'mac';
1530 } elseif (strstr($useragent,'Linux') ||
strstr($useragent,'X11') ||
strstr($useragent,'SGI') ||
strstr($useragent,' SunOS ') ||
strstr($useragent,' HP-UX ')) {
1531 $bInfo['SYSTEM'] = 'unix';
1535 // Is true if the browser supports css to format forms, especially the width
1536 $bInfo['FORMSTYLE']=($bInfo['BROWSER']=='msie' ||
($bInfo['BROWSER']=='net'&&$bInfo['VERSION']>=5) ||
$bInfo['BROWSER']=='opera' ||
$bInfo['BROWSER']=='konqu');
1540 /***************************
1542 * OTHER FUNCTIONS: (from Classic RTE)
1544 ***************************/
1546 * @return [type] ...
1550 function RTEtsConfigParams() {
1551 if($this->is_FE()) {
1554 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($this->specConf
['rte_transform']['parameters']);
1555 return $this->elementParts
[0].':'.$this->elementParts
[1].':'.$this->elementParts
[2].':'.$this->thePid
.':'.$this->typeVal
.':'.$this->tscPID
.':'.$p['imgpath'];
1559 public function cleanList($str) {
1560 if (strstr($str,'*')) {
1563 $str = implode(',',array_unique(t3lib_div
::trimExplode(',',$str,1)));
1568 function filterStyleEl($elValue,$matchList) {
1569 $matchParts = t3lib_div
::trimExplode(',',$matchList,1);
1570 $styleParts = explode(';',$elValue);
1572 foreach ($styleParts as $k => $p) {
1573 $pp = t3lib_div
::trimExplode(':',$p);
1574 if ($pp[0]&&$pp[1]) {
1575 foreach ($matchParts as $el) {
1576 $star=substr($el,-1)=='*';
1577 if (!strcmp($pp[0],$el) ||
($star && t3lib_div
::isFirstPartOfStr($pp[0],substr($el,0,-1)) )) {
1578 $nStyle[]=$pp[0].':'.$pp[1];
1579 } else unset($styleParts[$k]);
1582 unset($styleParts[$k]);
1585 return implode('; ',$nStyle);
1588 // Hook on lorem_ipsum extension to insert text into the RTE in wysiwyg mode
1589 function loremIpsumInsert($params) {
1591 if (typeof(lorem_ipsum) == 'function' && " . $params['element'] . ".tagName.toLowerCase() == 'textarea' ) lorem_ipsum(" . $params['element'] . ", lipsum_temp_strings[lipsum_temp_pointer]);
1596 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']) {
1597 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']);