2 /***************************************************************
5 * (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
6 * (c) 2004 Philipp Borgmann <philipp.borgmann@gmx.de>
7 * (c) 2004-2009 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 // The order of the toolbar: the name is the TYPO3-button name
74 var $defaultToolbarOrder;
76 // Conversion array: TYPO3 button names to htmlArea button names
77 var $convertToolbarForHtmlAreaArray = array (
78 'line' => 'InsertHorizontalRule',
79 'showhelp' => 'ShowHelp',
80 'textindicator' => 'TextIndicator',
83 'linebreak' => 'linebreak',
86 var $pluginButton = array();
87 var $pluginLabel = array();
90 var $RTEdivStyle; // Alternative style for RTE <div> tag.
91 public $httpTypo3Path;
92 var $extHttpPath; // full Path to this extension for http (so no Server path). It ends with "/"
93 var $siteURL; // TYPO3 site url
94 var $hostURL; // TYPO3 host url
95 var $typoVersion; // Typo3 version
98 var $ID = 'rtehtmlarea'; // Identifies the RTE as being the one from the "rte" extension if any external code needs to know...
99 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!)
105 * Reference to parent object, which is an instance of the TCEforms
107 * @var t3lib_TCEforms
119 public $contentTypo3Language;
120 public $contentISOLanguage;
121 public $contentCharset;
122 public $OutputCharset;
125 var $toolbar = array(); // Save the buttons for the toolbar
126 var $toolbar_level_size; // The size for each level in the toolbar:
127 var $toolbarOrderArray = array();
128 protected $pluginEnabledArray = array(); // Array of plugin id's enabled in the current RTE editing area
129 protected $pluginEnabledCumulativeArray = array(); // Cumulative array of plugin id's enabled so far in any of the RTE editing areas of the form
130 public $registeredPlugins = array(); // Array of registered plugins indexed by their plugin Id's
133 * Returns true if the RTE is available. Here you check if the browser requirements are met.
134 * If there are reasons why the RTE cannot be displayed you simply enter them as text in ->errorLog
136 * @return boolean TRUE if this RTE object offers an RTE in the current browser environment
139 function isAvailable() {
140 global $TYPO3_CONF_VARS;
142 $this->client
= $this->clientInfo();
143 $this->errorLog
= array();
144 if (!$this->debugMode
) { // If debug-mode, let any browser through
146 $rteConfBrowser = $this->conf_supported_browser
;
147 if (is_array($rteConfBrowser)) {
148 foreach ($rteConfBrowser as $browser => $browserConf) {
149 if ($browser == $this->client
['BROWSER']) {
150 // Config for Browser found, check it:
151 if (is_array($browserConf)) {
152 foreach ($browserConf as $browserConfNr => $browserConfSub) {
153 if ($browserConfSub['version'] <= $this->client
['VERSION'] ||
empty($browserConfSub['version'])) {
154 // Version is correct
155 if ($browserConfSub['system'] == $this->client
['SYSTEM'] ||
empty($browserConfSub['system'])) {
156 // System is correctly
160 }// End of foreach-BrowserSubpart
162 // no config for this browser found, so all versions or system with this browsers are allow
165 } // End of Browser Check
166 } // foreach: Browser Check
168 // no Browser config for this RTE-Editor, so all Clients are allow
170 if (!$rteIsAvailable) {
171 $this->errorLog
[] = 'rte: Browser not supported. Only msie Version 5 or higher and Mozilla based client 1. and higher.';
173 if (t3lib_div
::int_from_ver(TYPO3_version
) < 4000000) {
175 $this->errorLog
[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.';
178 if ($rteIsAvailable) return true;
182 * Draws the RTE as an iframe
184 * @param object Reference to parent object, which is an instance of the TCEforms.
185 * @param string The table name
186 * @param string The field name
187 * @param array The current row from which field is being rendered
188 * @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.
189 * @param array "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
190 * @param array Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
191 * @param string Record "type" field value.
192 * @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!
193 * @param integer PID value of record (true parent page id)
194 * @return string HTML code for RTE!
197 function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue) {
198 global $BE_USER, $LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
200 $this->TCEform
=& $parentObject;
201 $inline =& $this->TCEform
->inline
;
202 $LANG->includeLLFile('EXT:' . $this->ID
. '/locallang.xml');
203 $this->client
= $this->clientInfo();
204 $this->typoVersion
= t3lib_div
::int_from_ver(TYPO3_version
);
205 $this->userUid
= 'BE_' . $BE_USER->user
['uid'];
207 // Draw form element:
208 if ($this->debugMode
) { // Draws regular text area (debug mode)
209 $item = parent
::drawRTE($this->TCEform
, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
210 } else { // Draw real RTE
212 /* =======================================
213 * INIT THE EDITOR-SETTINGS
214 * =======================================
217 // first get the http-path to typo3:
218 $this->httpTypo3Path
= substr( substr( t3lib_div
::getIndpEnv('TYPO3_SITE_URL'), strlen( t3lib_div
::getIndpEnv('TYPO3_REQUEST_HOST') ) ), 0, -1 );
219 if (strlen($this->httpTypo3Path
) == 1) {
220 $this->httpTypo3Path
= '/';
222 $this->httpTypo3Path
.= '/';
224 // Get the path to this extension:
225 $this->extHttpPath
= $this->httpTypo3Path
. t3lib_extMgm
::siteRelPath($this->ID
);
227 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL');
229 $this->hostURL
= t3lib_div
::getIndpEnv('TYPO3_REQUEST_HOST');
232 $this->elementId
= $PA['itemFormElName']; // Form element name
233 $this->elementParts
= explode('][',ereg_replace('\]$','',ereg_replace('^(TSFE_EDIT\[data\]\[|data\[)','',$this->elementId
)));
235 // Find the page PIDs:
236 list($this->tscPID
,$this->thePid
) = t3lib_BEfunc
::getTSCpid(trim($this->elementParts
[0]),trim($this->elementParts
[1]),$thePidValue);
238 // Record "types" field value:
239 $this->typeVal
= $RTEtypeVal; // TCA "types" value for record
241 // Find "thisConfig" for record/editor:
242 unset($this->RTEsetup
);
243 $this->RTEsetup
= $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($this->tscPID
));
244 $this->thisConfig
= $thisConfig;
246 // Special configuration and default extras:
247 $this->specConf
= $specConf;
249 if ($this->thisConfig
['forceHTTPS']) {
250 $this->httpTypo3Path
= preg_replace('/^(http|https)/', 'https', $this->httpTypo3Path
);
251 $this->extHttpPath
= preg_replace('/^(http|https)/', 'https', $this->extHttpPath
);
252 $this->siteURL
= preg_replace('/^(http|https)/', 'https', $this->siteURL
);
253 $this->hostURL
= preg_replace('/^(http|https)/', 'https', $this->hostURL
);
256 /* =======================================
257 * LANGUAGES & CHARACTER SETS
258 * =======================================
261 // Languages: interface and content
262 $this->language
= $LANG->lang
;
263 if ($this->language
=='default' ||
!$this->language
) {
264 $this->language
='en';
266 $this->contentTypo3Language
= $this->language
;
267 $this->contentISOLanguage
= 'en';
268 $this->contentLanguageUid
= ($row['sys_language_uid'] > 0) ?
$row['sys_language_uid'] : 0;
269 if (t3lib_extMgm
::isLoaded('static_info_tables')) {
270 if ($this->contentLanguageUid
) {
271 $tableA = 'sys_language';
272 $tableB = 'static_languages';
273 $languagesUidsList = $this->contentLanguageUid
;
274 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
275 $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
276 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
277 $whereClause .= t3lib_BEfunc
::BEenableFields($tableA);
278 $whereClause .= t3lib_BEfunc
::deleteClause($tableA);
279 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
280 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
281 $this->contentISOLanguage
= strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?
'_'.trim($languageRow['lg_country_iso_2']):''));
282 $this->contentTypo3Language
= strtolower(trim($languageRow['lg_typo3']));
285 $this->contentISOLanguage
= trim($this->thisConfig
['defaultContentLanguage']) ?
trim($this->thisConfig
['defaultContentLanguage']) : 'en';
286 $selectFields = 'lg_iso_2, lg_typo3';
287 $tableAB = 'static_languages';
288 $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage
), $tableAB);
289 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
290 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
291 $this->contentTypo3Language
= strtolower(trim($languageRow['lg_typo3']));
296 // Character sets: interface and content
297 $this->charset
= $LANG->charSet
;
298 $this->OutputCharset
= $this->charset
;
300 $this->contentCharset
= $LANG->csConvObj
->charSetArray
[$this->contentTypo3Language
];
301 $this->contentCharset
= $this->contentCharset ?
$this->contentCharset
: 'iso-8859-1';
302 $this->origContentCharSet
= $this->contentCharset
;
303 $this->contentCharset
= (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ?
trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset
);
305 /* =======================================
306 * TOOLBAR CONFIGURATION
307 * =======================================
309 $this->initializeToolbarConfiguration();
311 /* =======================================
313 * =======================================
316 $RTEWidth = isset($BE_USER->userTS
['options.']['RTESmallWidth']) ?
$BE_USER->userTS
['options.']['RTESmallWidth'] : '530';
317 $RTEHeight = isset($BE_USER->userTS
['options.']['RTESmallHeight']) ?
$BE_USER->userTS
['options.']['RTESmallHeight'] : '380';
318 $RTEWidth = $RTEWidth +
($this->TCEform
->docLarge ?
(isset($BE_USER->userTS
['options.']['RTELargeWidthIncrement']) ?
$BE_USER->userTS
['options.']['RTELargeWidthIncrement'] : '150') : 0);
319 $RTEWidth -= ($inline->getStructureDepth() > 0 ?
($inline->getStructureDepth()+
1)*$inline->getLevelMargin() : 0);
320 if (isset($this->thisConfig
['RTEWidthOverride'])) {
321 if (strstr($this->thisConfig
['RTEWidthOverride'], '%')) {
322 if ($this->client
['BROWSER'] != 'msie') {
323 $RTEWidth = (intval($this->thisConfig
['RTEWidthOverride']) > 0) ?
$this->thisConfig
['RTEWidthOverride'] : '100%';
326 $RTEWidth = (intval($this->thisConfig
['RTEWidthOverride']) > 0) ?
intval($this->thisConfig
['RTEWidthOverride']) : $RTEWidth;
329 $RTEWidth = strstr($RTEWidth, '%') ?
$RTEWidth : $RTEWidth . 'px';
330 $RTEHeight = $RTEHeight +
($this->TCEform
->docLarge ?
(isset($BE_USER->userTS
['options.']['RTELargeHeightIncrement']) ?
$BE_USER->userTS
['options.']['RTELargeHeightIncrement'] : 0) : 0);
331 $RTEHeightOverride = intval($this->thisConfig
['RTEHeightOverride']);
332 $RTEHeight = ($RTEHeightOverride > 0) ?
$RTEHeightOverride : $RTEHeight;
333 $editorWrapWidth = '99%';
334 $editorWrapHeight = '100%';
335 $this->RTEdivStyle
= 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:'.$RTEWidth.'; border: 1px solid black; padding: 2px 2px 2px 2px;';
337 /* =======================================
338 * LOAD CSS AND JAVASCRIPT
339 * =======================================
341 // Preloading the pageStyle and including RTE skin stylesheets
342 $this->addPageStyle();
345 // Loading JavaScript files and code
346 if ($this->TCEform
->RTEcounter
== 1) {
347 $this->TCEform
->additionalCode_pre
['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform
->RTEcounter
);
348 $this->TCEform
->additionalJS_pre
['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform
->RTEcounter
);
351 /* =======================================
353 * =======================================
357 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
359 // Further content transformation by registered plugins
360 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
361 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "transformContent")) {
362 $value = $plugin->transformContent($value);
365 // Register RTE windows
366 $this->TCEform
->RTEwindows
[] = $PA['itemFormElName'];
367 $textAreaId = htmlspecialchars($PA['itemFormElName']);
369 // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
370 if (basename(PATH_thisScript
) == 'wizard_rte.php') {
371 $height = 'window.innerHeight';
372 $width = 'window.innerWidth';
373 if ($this->client
['BROWSER'] == 'msie') {
374 $height = 'document.body.offsetHeight';
375 $width = 'document.body.offsetWidth';
378 // Subtract the docheader height from the calculated window height
379 $height .= ' - document.getElementById("typo3-docheader").offsetHeight';
381 $editorWrapWidth = '100%';
382 $editorWrapHeight = '100%';
383 $this->RTEdivStyle
= 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
384 $this->TCEform
->additionalJS_post
[] = $this->setRTEsizeByJS('RTEarea' . $textAreaId, $height, $width);
387 // Register RTE in JS:
388 $this->TCEform
->additionalJS_post
[] = $this->registerRTEinJS($this->TCEform
->RTEcounter
, $table, $row['uid'], $field, $textAreaId);
390 // Set the save option for the RTE:
391 $this->TCEform
->additionalJS_submit
[] = $this->setSaveRTE($this->TCEform
->RTEcounter
, $this->TCEform
->formName
, $textAreaId);
392 $this->TCEform
->additionalJS_delete
[] = $this->setDeleteRTE($this->TCEform
->RTEcounter
, $this->TCEform
->formName
, $textAreaId);
395 $visibility = 'hidden';
396 $item = $this->triggerField($PA['itemFormElName']).'
397 <div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
398 <div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
399 <textarea id="RTEarea' . $textAreaId . '" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.t3lib_div
::deHSCentities(htmlspecialchars($this->RTEdivStyle
)).'">'.t3lib_div
::formatForTextarea($value).'</textarea>
400 </div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableDebugMode'] ?
'<div id="HTMLAreaLog"></div>' : '') . '
409 * Add link to content style sheet to document header
413 protected function addPageStyle() {
414 // Get stylesheet file name from Page TSConfig if any
415 $filename = trim($this->thisConfig
['contentCSS']) ?
trim($this->thisConfig
['contentCSS']) : 'EXT:' . $this->ID
. '/res/contentcss/default.css';
416 $this->addStyleSheet(
417 'rtehtmlarea-page-style',
418 $this->getFullFileName($filename),
419 'htmlArea RTE Content CSS',
420 'alternate stylesheet'
425 * Add links to skin style sheet(s) to document header
429 protected function addSkin() {
430 // Get skin file name from Page TSConfig if any
431 $skinFilename = trim($this->thisConfig
['skin']) ?
trim($this->thisConfig
['skin']) : 'EXT:' . $this->ID
. '/htmlarea/skins/default/htmlarea.css';
432 if($this->client
['BROWSER'] == 'gecko' && $this->client
['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:') {
433 $skinFilename = 'EXT:' . $this->ID
. '/htmlarea/skins/default/htmlarea.css';
435 // Skin provided by some extension
436 if (substr($skinFilename,0,4) == 'EXT:') {
437 list($extKey,$local) = explode('/',substr($skinFilename,4),2);
439 if (strcmp($extKey,'') && t3lib_extMgm
::isLoaded($extKey) && strcmp($local,'')) {
440 $skinFilename = $this->httpTypo3Path
. t3lib_extMgm
::siteRelPath($extKey) . $local;
441 $skinDir = $this->siteURL
. t3lib_extMgm
::siteRelPath($extKey) . dirname($local);
443 } elseif (substr($skinFilename,0,1) != '/') {
444 $skinDir = $this->siteURL
.dirname($skinFilename);
445 $skinFilename = $this->siteURL
. $skinFilename;
447 $skinDir = substr($this->siteURL
,0,-1) . dirname($skinFilename);
449 $this->editorCSS
= $skinFilename;
450 // Editing area style sheet
451 $this->editedContentCSS
= $skinDir . '/htmlarea-edited-content.css';
452 $this->addStyleSheet(
453 'rtehtmlarea-editing-area-skin',
454 $this->editedContentCSS
,
455 'htmlArea RTE Editing Area Skin',
456 'alternate stylesheet'
459 $this->addStyleSheet(
464 // Additional icons from registered plugins
465 foreach ($this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
] as $pluginId) {
466 if (is_object($this->registeredPlugins
[$pluginId])) {
467 $pathToSkin = $this->registeredPlugins
[$pluginId]->getPathToSkin();
469 $this->addStyleSheet(
470 'rtehtmlarea-plugin-' . $pluginId . '-skin',
471 $this->httpTypo3Path
. t3lib_extMgm
::siteRelPath($this->registeredPlugins
[$pluginId]->getExtensionKey()) . $pathToSkin
479 * Add style sheet file to document header
481 * @param string $key: some key identifying the style sheet
482 * @param string $href: uri to the style sheet file
483 * @param string $title: value for the title attribute of the link element
484 * @return string $relation: value for the rel attribute of the link element
487 protected function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
488 // If it was not known that an RTE-enabled would be created when the page was first created, the css would not be added to head
489 if (is_object($this->TCEform
->inline
) && $this->TCEform
->inline
->isAjaxCall
) {
490 $this->TCEform
->additionalCode_pre
[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '" title="' . $title. '" />';
492 $this->TCEform
->addStyleSheet($key, $href, $title, $relation);
498 * Initialize toolbar configuration and enable registered plugins
502 protected function initializeToolbarConfiguration() {
504 // Enable registred plugins
505 $this->enableRegisteredPlugins();
510 // Check if some plugins need to be disabled
513 // Merge the list of enabled plugins with the lists from the previous RTE editing areas on the same form
514 $this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
] = $this->pluginEnabledArray
;
515 if ($this->TCEform
->RTEcounter
> 1 && isset($this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
-1]) && is_array($this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
-1])) {
516 $this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
] = array_unique(array_values(array_merge($this->pluginEnabledArray
,$this->pluginEnabledCumulativeArray
[$this->TCEform
->RTEcounter
-1])));
521 * Add registered plugins to the array of enabled plugins
524 function enableRegisteredPlugins() {
525 global $TYPO3_CONF_VARS;
526 // Traverse registered plugins
527 if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['plugins'])) {
528 foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['plugins'] as $pluginId => $pluginObjectConfiguration) {
530 if (is_array($pluginObjectConfiguration) && count($pluginObjectConfiguration)) {
531 $plugin = &t3lib_div
::getUserObj($pluginObjectConfiguration['objectReference']);
533 if (is_object($plugin)) {
534 if ($plugin->main($this)) {
535 $this->registeredPlugins
[$pluginId] = $plugin;
536 // Override buttons from previously registered plugins
537 $pluginButtons = t3lib_div
::trimExplode(',', $plugin->getPluginButtons(), 1);
538 foreach ($this->pluginButton
as $previousPluginId => $buttonList) {
539 $this->pluginButton
[$previousPluginId] = implode(',',array_diff(t3lib_div
::trimExplode(',', $this->pluginButton
[$previousPluginId], 1), $pluginButtons));
541 $this->pluginButton
[$pluginId] = $plugin->getPluginButtons();
542 $pluginLabels = t3lib_div
::trimExplode(',', $plugin->getPluginLabels(), 1);
543 foreach ($this->pluginLabel
as $previousPluginId => $labelList) {
544 $this->pluginLabel
[$previousPluginId] = implode(',',array_diff(t3lib_div
::trimExplode(',', $this->pluginLabel
[$previousPluginId], 1), $pluginLabels));
546 $this->pluginLabel
[$pluginId] = $plugin->getPluginLabels();
547 $this->pluginEnabledArray
[] = $pluginId;
553 $hidePlugins = array();
554 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
555 if ($plugin->addsButtons() && !$this->pluginButton
[$pluginId]) {
556 $hidePlugins[] = $pluginId;
559 $this->pluginEnabledArray
= array_unique(array_diff($this->pluginEnabledArray
, $hidePlugins));
563 * Set the toolbar config (only in this PHP-Object, not in JS):
567 function setToolbar() {
570 if ($this->client
['BROWSER'] == 'msie' ||
$this->client
['BROWSER'] == 'opera' ||
($this->client
['BROWSER'] == 'gecko' && $this->client
['VERSION'] == '1.3')) {
571 $this->thisConfig
['keepButtonGroupTogether'] = 0;
574 $this->defaultToolbarOrder
= 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
575 bar, formattext, bold, strong, italic, emphasis, big, small, insertedtext, deletedtext, citation, code, definition, keyboard, monospaced, quotation, sample, variable, bidioverride, strikethrough, subscript, superscript, underline, span,
576 bar, fontstyle, space, fontsize, bar, formatblock, insertparagraphbefore, insertparagraphafter, blockquote,
577 bar, left, center, right, justifyfull,
578 bar, orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, lefttoright, righttoleft, language, showlanguagemarks,
579 bar, textcolor, bgcolor, textindicator,
580 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,
581 bar, chMode, inserttag, removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
582 ' . ($this->thisConfig
['hideTableOperationsInToolbar'] ?
'': 'bar, toggleborders,') . ' bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
583 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
584 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
586 // Special toolbar for Mozilla Wamcom on Mac OS 9
587 if($this->client
['BROWSER'] == 'gecko' && $this->client
['VERSION'] == '1.3') {
588 $this->defaultToolbarOrder
= $this->TCEform
->docLarge ?
'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
589 bar, fontstyle, space, fontsize, space, formatblock, insertparagraphbefore, insertparagraphafter, blockquote, bar, bold, italic, underline, strikethrough,
590 subscript, superscript, lefttoright, righttoleft, language, showlanguagemarks, bar, left, center, right, justifyfull, linebreak,
591 bar, orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
592 insertcharacter, line, link, unlink, image, table, user, acronym, bar, findreplace, spellcheck, bar, chMode, inserttag,
593 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
594 bar, toggleborders, bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
595 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
596 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge'
597 : 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
598 bar, fontstyle, space, fontsize, space, formatblock, insertparagraphbefore, insertparagraphafter, blockquote, bar, bold, italic, underline, strikethrough,
599 subscript, superscript, linebreak, bar, lefttoright, righttoleft, language, showlanguagemarks, bar, left, center, right, justifyfull,
600 orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
601 insertcharacter, line, link, unlink, image, table, user, acronym, linebreak, bar, findreplace, spellcheck, bar, chMode, inserttag,
602 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
603 bar, toggleborders, bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
604 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
605 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
608 // Additional buttons from registered plugins
609 foreach($this->registeredPlugins
as $pluginId => $plugin) {
610 if ($this->isPluginEnabled($pluginId)) {
611 $this->defaultToolbarOrder
= $plugin->addButtonsToToolbar();
614 $toolbarOrder = $this->thisConfig
['toolbarOrder'] ?
$this->thisConfig
['toolbarOrder'] : $this->defaultToolbarOrder
;
616 // Getting rid of undefined buttons
617 $this->toolbarOrderArray
= array_intersect(t3lib_div
::trimExplode(',', $toolbarOrder, 1), t3lib_div
::trimExplode(',', $this->defaultToolbarOrder
, 1));
618 $toolbarOrder = array_unique(array_values($this->toolbarOrderArray
));
620 // Fetching specConf for field from backend
621 $pList = is_array($this->specConf
['richtext']['parameters']) ?
implode(',',$this->specConf
['richtext']['parameters']) : '';
622 if ($pList != '*') { // If not all
623 $show = is_array($this->specConf
['richtext']['parameters']) ?
$this->specConf
['richtext']['parameters'] : array();
624 if ($this->thisConfig
['showButtons']) {
625 if (!t3lib_div
::inList($this->thisConfig
['showButtons'],'*')) {
626 $show = array_unique(array_merge($show,t3lib_div
::trimExplode(',',$this->thisConfig
['showButtons'],1)));
628 $show = array_unique(array_merge($show, $toolbarOrder));
631 if (is_array($this->thisConfig
['showButtons.'])) {
632 foreach ($this->thisConfig
['showButtons.'] as $buttonId => $value) {
633 if ($value) $show[] = $buttonId;
635 $show = array_unique($show);
638 $show = $toolbarOrder;
641 // Resticting to RTEkeyList for backend user
642 if(is_object($BE_USER)) {
643 $RTEkeyList = isset($BE_USER->userTS
['options.']['RTEkeyList']) ?
$BE_USER->userTS
['options.']['RTEkeyList'] : '*';
644 if ($RTEkeyList != '*') { // If not all
645 $show = array_intersect($show, t3lib_div
::trimExplode(',',$RTEkeyList,1));
649 // Hiding buttons of disabled plugins
650 $hideButtons = array('space', 'bar', 'linebreak');
651 foreach ($this->pluginButton
as $pluginId => $buttonList) {
652 if (!$this->isPluginEnabled($pluginId)) {
653 $buttonArray = t3lib_div
::trimExplode(',',$buttonList,1);
654 foreach ($buttonArray as $button) {
655 $hideButtons[] = $button;
660 // Hiding labels of disabled plugins
661 foreach ($this->pluginLabel
as $pluginId => $label) {
662 if (!$this->isPluginEnabled($pluginId)) {
663 $hideButtons[] = $label;
668 $show = array_diff($show, $this->conf_toolbar_hide
, t3lib_div
::trimExplode(',',$this->thisConfig
['hideButtons'],1));
670 // Apply toolbar constraints from registered plugins
671 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
672 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "applyToolbarConstraints")) {
673 $show = $plugin->applyToolbarConstraints($show);
676 // Getting rid of the buttons for which we have no position
677 $show = array_intersect($show, $toolbarOrder);
678 $this->toolbar
= $show;
682 * Disable some plugins
685 function setPlugins() {
687 // Disabling a plugin that adds buttons if none of its buttons is in the toolbar
688 $hidePlugins = array();
689 foreach ($this->pluginButton
as $pluginId => $buttonList) {
690 if ($this->registeredPlugins
[$pluginId]->addsButtons()) {
692 $buttonArray = t3lib_div
::trimExplode(',', $buttonList, 1);
693 foreach ($buttonArray as $button) {
694 if (in_array($button, $this->toolbar
)) {
699 $hidePlugins[] = $pluginId;
703 $this->pluginEnabledArray
= array_diff($this->pluginEnabledArray
, $hidePlugins);
705 // Hiding labels of disabled plugins
706 $hideLabels = array();
707 foreach ($this->pluginLabel
as $pluginId => $label) {
708 if (!$this->isPluginEnabled($pluginId)) {
709 $hideLabels[] = $label;
712 $this->toolbar
= array_diff($this->toolbar
, $hideLabels);
714 // Adding plugins declared as prerequisites by enabled plugins
715 $requiredPlugins = array();
716 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
717 if ($this->isPluginEnabled($pluginId)) {
718 $requiredPlugins = array_merge($requiredPlugins, t3lib_div
::trimExplode(',', $plugin->getRequiredPlugins(), 1));
721 $requiredPlugins = array_unique($requiredPlugins);
722 foreach ($requiredPlugins as $pluginId) {
723 if (is_object($this->registeredPlugins
[$pluginId]) && !$this->isPluginEnabled($pluginId)) {
724 $this->pluginEnabledArray
[] = $pluginId;
727 $this->pluginEnabledArray
= array_unique($this->pluginEnabledArray
);
729 // Completing the toolbar conversion array for htmlArea
730 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
731 if ($this->isPluginEnabled($pluginId)) {
732 $this->convertToolbarForHtmlAreaArray
= array_unique(array_merge($this->convertToolbarForHtmlAreaArray
, $plugin->getConvertToolbarForHtmlAreaArray()));
738 * Convert the TYPO3 names of buttons into the names for htmlArea RTE
740 * @param string buttonname (typo3-name)
741 * @return string buttonname (htmlarea-name)
744 function convertToolbarForHTMLArea($button) {
745 return $this->convertToolbarForHtmlAreaArray
[$button];
749 * Return the JS-function for setting the RTE size.
751 * @param string DivID-Name
752 * @param int the height for the RTE
753 * @param int the width for the RTE
754 * @return string Loader function in JS
756 function setRTEsizeByJS($divId, $height, $width) {
758 setRTEsizeByJS(\''.$divId.'\','.$height.', '.$width.');
763 * Return the HTML code for loading the Javascript files
765 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
767 * @return string the html code for loading the Javascript Files
769 function loadJSfiles($RTEcounter) {
770 global $TYPO3_CONF_VARS;
773 HTMLArea_plugins = new Array();';
774 foreach ($this->pluginEnabledCumulativeArray
[$RTEcounter] as $pluginId) {
775 $extensionKey = is_object($this->registeredPlugins
[$pluginId]) ?
$this->registeredPlugins
[$pluginId]->getExtensionKey() : $this->ID
;
777 HTMLArea_plugins.push({url : "' . $this->writeTemporaryFile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js', $pluginId) . '", asynchronous : ' . ($this->registeredPlugins
[$pluginId]->requiresSynchronousLoad() ?
'false' : 'true'). ' });';
779 // Avoid re-initialization on AJax call when RTEarea object was already initialized
780 $loadJavascriptCode = '
781 <script type="text/javascript">
783 if (typeof(RTEarea) == "undefined") {
784 RTEarea = new Object();
785 RTEarea.init = function() {
786 if (typeof(HTMLArea) == "undefined") {
787 window.setTimeout("RTEarea.init();", 40);
789 . $loadPluginCode . '
793 RTEarea.initEditor = function(editorNumber) {
794 if (typeof(HTMLArea) == "undefined") {
795 window.setTimeout("RTEarea.initEditor(\'" + editorNumber + "\');", 40);
797 HTMLArea.initEditor(editorNumber);
800 RTEarea[0] = new Object();
801 RTEarea[0].version = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['version'] . '";'
802 . (($this->client
['BROWSER'] == 'msie') ?
('
803 RTEarea[0]["htmlarea-ie"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID
. '/htmlarea/htmlarea-ie.js', "htmlarea-ie") . '";')
805 RTEarea[0]["htmlarea-gecko"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID
. '/htmlarea/htmlarea-gecko.js', "htmlarea-gecko") . '";')) . '
806 _editor_url = "' . $this->extHttpPath
. 'htmlarea";
807 _editor_lang = "' . $this->language
. '";
808 _editor_CSS = "' . $this->editorCSS
. '";
809 _editor_skin = "' . dirname($this->editorCSS
) . '";
810 _editor_edited_content_CSS = "' . $this->editedContentCSS
. '";
811 _typo3_host_url = "' . $this->hostURL
. '";
812 _editor_debug_mode = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableDebugMode'] ?
'true' : 'false') . ';
813 _editor_compressed_scripts = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'true' : 'false') . ';
817 $loadJavascriptCode .= '
818 <script type="text/javascript" src="' . $this->buildJSMainLangFile($RTEcounter) . '"></script>
819 <script type="text/javascript" src="' . $this->writeTemporaryFile('EXT:' . $this->ID
. '/htmlarea/htmlarea.js', "htmlarea") . '"></script>
821 return $loadJavascriptCode;
825 * Return the Javascript code for initializing the RTE
827 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
829 * @return string the Javascript code for initializing the RTE
831 function loadJScode($RTEcounter) {
832 return (!$this->is_FE() ?
'' : '
833 ' . '/*<![CDATA[*/') . '
834 RTEarea.init();' . (!$this->is_FE() ?
'' : '
840 * Return the Javascript code for configuring the RTE
842 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
843 * @param string $table: The table that includes this RTE (optional, necessary for IRRE).
844 * @param string $uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
845 * @param string $field: The field of that record that includes this RTE (optional).
847 * @return string the Javascript code for configuring the RTE
849 function registerRTEinJS($RTEcounter, $table='', $uid='', $field='', $textAreaId = '') {
850 global $TYPO3_CONF_VARS;
852 $configureRTEInJavascriptString = (!$this->is_FE() ?
'' : '
853 ' . '/*<![CDATA[*/') . '
854 if (typeof(configureEditorInstance) == "undefined") {
855 configureEditorInstance = new Object();
857 configureEditorInstance["' . $textAreaId . '"] = function() {
858 if (typeof(RTEarea) == "undefined" || typeof(HTMLArea) == "undefined") {
859 window.setTimeout("configureEditorInstance[\'' . $textAreaId . '\']();", 40);
861 editornumber = "' . $textAreaId . '";
862 RTEarea[editornumber] = new Object();
863 RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
864 RTEarea[editornumber].number = editornumber;
865 RTEarea[editornumber].deleted = false;
866 RTEarea[editornumber].textAreaId = "' . $textAreaId . '";
867 RTEarea[editornumber].id = "RTEarea" + editornumber;
868 RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig
['enableWordClean'])?
'true':'false') . ';
869 RTEarea[editornumber]["htmlRemoveComments"] = ' . (trim($this->thisConfig
['removeComments'])?
'true':'false') . ';
870 RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig
['disableEnterParagraphs'])?
'true':'false') . ';
871 RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig
['disableObjectResizing'])?
'true':'false') . ';
872 RTEarea[editornumber]["removeTrailingBR"] = ' . (trim($this->thisConfig
['removeTrailingBR'])?
'true':'false') . ';
873 RTEarea[editornumber]["useCSS"] = ' . (trim($this->thisConfig
['useCSS'])?
'true':'false') . ';
874 RTEarea[editornumber]["keepButtonGroupTogether"] = ' . (trim($this->thisConfig
['keepButtonGroupTogether'])?
'true':'false') . ';
875 RTEarea[editornumber]["disablePCexamples"] = ' . (trim($this->thisConfig
['disablePCexamples'])?
'true':'false') . ';
876 RTEarea[editornumber]["showTagFreeClasses"] = ' . (trim($this->thisConfig
['showTagFreeClasses'])?
'true':'false') . ';
877 RTEarea[editornumber]["useHTTPS"] = ' . ((trim(stristr($this->siteURL
, 'https')) ||
$this->thisConfig
['forceHTTPS'])?
'true':'false') . ';
878 RTEarea[editornumber].tceformsNested = ' . (is_object($this->TCEform
) && method_exists($this->TCEform
, 'getDynNestedStack') ?
$this->TCEform
->getDynNestedStack(true) : '[]') . ';
879 RTEarea[editornumber].dialogueWindows = new Object();
880 RTEarea[editornumber].dialogueWindows.defaultPositionFromTop = ' . (isset($this->thisConfig
['dialogueWindows.']['defaultPositionFromTop'])?
intval($this->thisConfig
['dialogueWindows.']['defaultPositionFromTop']) : '100') . ';
881 RTEarea[editornumber].dialogueWindows.defaultPositionFromLeft = ' . (isset($this->thisConfig
['dialogueWindows.']['defaultPositionFromLeft'])?
intval($this->thisConfig
['dialogueWindows.']['defaultPositionFromLeft']) : '100') . ';
882 RTEarea[editornumber].dialogueWindows.doNotResize = ' . (trim($this->thisConfig
['dialogueWindows.']['doNotResize'])?
'true':'false') . ';
883 RTEarea[editornumber].dialogueWindows.doNotCenter = ' . (trim($this->thisConfig
['dialogueWindows.']['doNotCenter'])?
'true':'false') . ';';
885 // The following properties apply only to the backend
886 if (!$this->is_FE()) {
887 $configureRTEInJavascriptString .= '
888 RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid
. '";
889 RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language
. '";
890 RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset
. '";
891 RTEarea[editornumber].userUid = "' . $this->userUid
. '";';
894 // Setting the plugin flags
895 $configureRTEInJavascriptString .= '
896 RTEarea[editornumber].plugin = new Object();
897 RTEarea[editornumber].pathToPluginDirectory = new Object();';
898 foreach ($this->pluginEnabledArray
as $pluginId) {
899 $configureRTEInJavascriptString .= '
900 RTEarea[editornumber].plugin.'.$pluginId.' = true;';
901 if (is_object($this->registeredPlugins
[$pluginId])) {
902 $pathToPluginDirectory = $this->registeredPlugins
[$pluginId]->getPathToPluginDirectory();
903 if ($pathToPluginDirectory) {
904 $configureRTEInJavascriptString .= '
905 RTEarea[editornumber].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";';
910 // Setting the buttons configuration
911 $configureRTEInJavascriptString .= '
912 RTEarea[editornumber].buttons = new Object();';
913 if (is_array($this->thisConfig
['buttons.'])) {
914 foreach ($this->thisConfig
['buttons.'] as $buttonIndex => $conf) {
915 $button = substr($buttonIndex, 0, -1);
916 if (in_array($button,$this->toolbar
)) {
917 $configureRTEInJavascriptString .= '
918 RTEarea[editornumber].buttons.'.$button.' = ' . $this->buildNestedJSArray($conf) . ';';
923 // Setting the list of tags to be removed if specified in the RTE config
924 if (trim($this->thisConfig
['removeTags'])) {
925 $configureRTEInJavascriptString .= '
926 RTEarea[editornumber]["htmlRemoveTags"] = /^(' . implode('|', t3lib_div
::trimExplode(',', $this->thisConfig
['removeTags'], 1)) . ')$/i;';
929 // Setting the list of tags to be removed with their contents if specified in the RTE config
930 if (trim($this->thisConfig
['removeTagsAndContents'])) {
931 $configureRTEInJavascriptString .= '
932 RTEarea[editornumber]["htmlRemoveTagsAndContents"] = /^(' . implode('|', t3lib_div
::trimExplode(',', $this->thisConfig
['removeTagsAndContents'], 1)) . ')$/i;';
935 // Process default style configuration
936 $configureRTEInJavascriptString .= '
937 RTEarea[editornumber].defaultPageStyle = "' . $this->hostURL
. $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
939 // Setting the pageStyle
940 $filename = trim($this->thisConfig
['contentCSS']) ?
trim($this->thisConfig
['contentCSS']) : 'EXT:' . $this->ID
. '/res/contentcss/default.css';
941 $configureRTEInJavascriptString .= '
942 RTEarea[editornumber].pageStyle = "' . $this->getFullFileName($filename) .'";';
944 // Process classes configuration
945 $classesConfigurationRequired = false;
946 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
947 if ($this->isPluginEnabled($pluginId)) {
948 $classesConfigurationRequired = $classesConfigurationRequired ||
$plugin->requiresClassesConfiguration();
951 if ($classesConfigurationRequired) {
952 $configureRTEInJavascriptString .= $this->buildJSClassesConfig($RTEcounter);
955 // Add Javascript configuration for registered plugins
956 foreach ($this->registeredPlugins
as $pluginId => $plugin) {
957 if ($this->isPluginEnabled($pluginId)) {
958 $configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
961 // Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call
962 $configureRTEInJavascriptString .= '
963 RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . ';
964 RTEarea[editornumber].convertButtonId = ' . json_encode(array_flip($this->convertToolbarForHtmlAreaArray
)) . ';
965 RTEarea.initEditor(editornumber);
968 configureEditorInstance["' . $textAreaId . '"]();'. (!$this->is_FE() ?
'' : '
970 return $configureRTEInJavascriptString;
974 * Return true, if the plugin can be loaded
976 * @param string $pluginId: The identification string of the plugin
978 * @return boolean true if the plugin can be loaded
981 function isPluginEnabled($pluginId) {
982 return in_array($pluginId, $this->pluginEnabledArray
);
986 * Build the default content style sheet
988 * @return string Style sheet
990 function buildStyleSheet() {
992 if (!trim($this->thisConfig
['ignoreMainStyleOverride'])) {
993 $mainStyle_font = $this->thisConfig
['mainStyle_font'] ?
$this->thisConfig
['mainStyle_font']: 'Verdana,sans-serif';
995 $mainElements = array();
996 $mainElements['P'] = $this->thisConfig
['mainStyleOverride_add.']['P'];
997 $elList = explode(',','H1,H2,H3,H4,H5,H6,PRE');
998 foreach ($elList as $elListName) {
999 if ($this->thisConfig
['mainStyleOverride_add.'][$elListName]) {
1000 $mainElements[$elListName] = $this->thisConfig
['mainStyleOverride_add.'][$elListName];
1004 $addElementCode = '';
1005 foreach ($mainElements as $elListName => $elValue) {
1006 $addElementCode .= strToLower($elListName) . ' {' . $elValue . '}' . chr(10);
1009 $stylesheet = $this->thisConfig
['mainStyleOverride'] ?
$this->thisConfig
['mainStyleOverride'] : chr(10) .
1010 'body.htmlarea-content-body { font-family: ' . $mainStyle_font .
1011 '; font-size: '.($this->thisConfig
['mainStyle_size'] ?
$this->thisConfig
['mainStyle_size'] : '12px') .
1012 '; color: '.($this->thisConfig
['mainStyle_color']?
$this->thisConfig
['mainStyle_color'] : 'black') .
1013 '; background-color: '.($this->thisConfig
['mainStyle_bgcolor'] ?
$this->thisConfig
['mainStyle_bgcolor'] : 'white') .
1014 ';'.$this->thisConfig
['mainStyleOverride_add.']['BODY'].'}' . chr(10) .
1015 'td { ' . $this->thisConfig
['mainStyleOverride_add.']['TD'].'}' . chr(10) .
1016 'div { ' . $this->thisConfig
['mainStyleOverride_add.']['DIV'].'}' . chr(10) .
1017 'pre { ' . $this->thisConfig
['mainStyleOverride_add.']['PRE'].'}' . chr(10) .
1018 'ol { ' . $this->thisConfig
['mainStyleOverride_add.']['OL'].'}' . chr(10) .
1019 'ul { ' . $this->thisConfig
['mainStyleOverride_add.']['UL'].'}' . chr(10) .
1020 'blockquote { ' . $this->thisConfig
['mainStyleOverride_add.']['BLOCKQUOTE'].'}' . chr(10) .
1023 if (is_array($this->thisConfig
['inlineStyle.'])) {
1024 $stylesheet .= chr(10) . implode(chr(10), $this->thisConfig
['inlineStyle.']) . chr(10);
1027 $stylesheet = '/* mainStyleOverride and inlineStyle properties ignored. */';
1033 * Return Javascript configuration of classes
1035 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1037 * @return string Javascript configuration of classes
1039 function buildJSClassesConfig($RTEcounter) {
1040 // Build JS array of lists of classes
1041 $classesTagList = 'classesCharacter, classesParagraph, classesImage, classesTable, classesLinks, classesTD';
1042 $classesTagConvert = array( 'classesCharacter' => 'span', 'classesParagraph' => 'div', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td');
1043 $classesTagArray = t3lib_div
::trimExplode(',' , $classesTagList);
1044 $configureRTEInJavascriptString = '
1045 RTEarea[editornumber]["classesTag"] = new Object();';
1046 foreach ($classesTagArray as $classesTagName) {
1047 $HTMLAreaJSClasses = ($this->thisConfig
[$classesTagName])?
('"' . $this->cleanList($this->thisConfig
[$classesTagName]) . '";'):'null;';
1048 $configureRTEInJavascriptString .= '
1049 RTEarea[editornumber]["classesTag"]["'. $classesTagConvert[$classesTagName] .'"] = '. $HTMLAreaJSClasses;
1052 // Include JS arrays of configured classes
1053 $configureRTEInJavascriptString .= '
1054 RTEarea[editornumber]["classesUrl"] = "' . $this->hostURL
. $this->writeTemporaryFile('', 'classes_'.$LANG->lang
, 'js', $this->buildJSClassesArray()) . '";';
1056 return $configureRTEInJavascriptString;
1060 * Return JS arrays of classes labels and noShow flags
1062 * @return string JS classes arrays
1064 function buildJSClassesArray() {
1065 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1067 if ($this->is_FE()) {
1068 $RTEProperties = $this->RTEsetup
;
1070 $RTEProperties = $this->RTEsetup
['properties'];
1073 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'' : chr(10);
1076 $indexAlternating = 0;
1078 $JSClassesLabelsArray = 'HTMLArea.classesLabels = { ' . $linebreak;
1079 $JSClassesValuesArray = 'HTMLArea.classesValues = { ' . $linebreak;
1080 $JSClassesNoShowArray = 'HTMLArea.classesNoShow = { ' . $linebreak;
1081 $JSClassesAlternatingArray = 'HTMLArea.classesAlternating = { ' . $linebreak;
1082 $JSClassesCountingArray = 'HTMLArea.classesCounting = { ' . $linebreak;
1083 $JSClassesXORArray = 'HTMLArea.classesXOR = { ' . $linebreak;
1085 // Scanning the list of classes if specified in the RTE config
1086 if (is_array($RTEProperties['classes.'])) {
1087 foreach ($RTEProperties['classes.'] as $className => $conf) {
1088 $className = substr($className,0,-1);
1089 $classLabel = $this->getPageConfigLabel($conf['name']);
1090 $JSClassesLabelsArray .= ($index?
',':'') . '"' . $className . '": ' . $classLabel . $linebreak;
1091 $JSClassesValuesArray .= ($index?
',':'') . '"' . $className . '":"' . str_replace('"', '\"', str_replace('\\\'', '\'', $conf['value'])) . '"' . $linebreak;
1092 if ($conf['noShow']) {
1093 $JSClassesNoShowArray .= ($indexNoShow?
',':'') . '"' . $className . '":' . ($conf['noShow']?
'true':'false') . $linebreak;
1096 if (is_array($conf['alternating.'])) {
1097 $JSClassesAlternatingArray .= ($indexAlternating?
',':'') . '"' . $className . '":' . (is_array($conf['alternating.']) ?
$this->buildNestedJSArray($conf['alternating.']) : ' "false"') . $linebreak;
1098 $indexAlternating++
;
1100 if (is_array($conf['counting.'])) {
1101 $JSClassesCountingArray .= ($indexCounting?
',':'') . '"' . $className . '":' . (is_array($conf['counting.']) ?
$this->buildNestedJSArray($conf['counting.']) : ' "false"') . $linebreak;
1107 // Scanning the list of sets of mutually exclusives classes if specified in the RTE config
1109 if (is_array($RTEProperties['mutuallyExclusiveClasses.'])) {
1110 foreach ($RTEProperties['mutuallyExclusiveClasses.'] as $listName => $conf) {
1111 $classArray = t3lib_div
::trimExplode(',', $conf, 1);
1112 $classList = implode(',', $classArray);
1113 foreach ($classArray as $className) {
1114 $JSClassesXORArray .= ($index?
',':'') . '"' . $className . '": /^(' . implode('|', t3lib_div
::trimExplode(',', t3lib_div
::rmFromList($className, $classList), 1)) . ')$/i' . $linebreak;
1119 $JSClassesLabelsArray .= '};' . $linebreak;
1120 $JSClassesValuesArray .= '};' . $linebreak;
1121 $JSClassesNoShowArray .= '};' . $linebreak;
1122 $JSClassesAlternatingArray .= '};' . $linebreak;
1123 $JSClassesCountingArray .= '};' . $linebreak;
1124 $JSClassesXORArray .= '};' . $linebreak;
1126 return $JSClassesLabelsArray . $JSClassesValuesArray . $JSClassesNoShowArray . $JSClassesAlternatingArray . $JSClassesCountingArray . $JSClassesXORArray;
1130 * Translate Page TS Config array in JS nested array definition
1132 * @param array $conf: Page TSConfig configuration array
1134 * @return string nested JS array definition
1136 function buildNestedJSArray($conf) {
1137 $configureRTEInJavascriptString = '{';
1139 if (is_array($conf)) {
1140 foreach ($conf as $propertyName => $conf1) {
1141 $property = $propertyName;
1143 $configureRTEInJavascriptString .= ', ';
1145 if (is_array($conf1)) {
1146 $property = substr($property, 0, -1);
1148 $configureRTEInJavascriptString .= '"'.$property.'" : {';
1149 foreach ($conf1 as $property1Name => $conf2) {
1150 $property1 = $property1Name;
1151 if ($indexProperty) {
1152 $configureRTEInJavascriptString .= ', ';
1154 if (is_array($conf2)) {
1155 $property1 = substr($property1, 0, -1);
1156 $indexProperty1 = 0;
1157 $configureRTEInJavascriptString .= '"'.$property1.'" : {';
1158 foreach ($conf2 as $property2Name => $conf3) {
1159 $property2 = $property2Name;
1160 if ($indexProperty1) {
1161 $configureRTEInJavascriptString .= ', ';
1163 if (is_array($conf3)) {
1164 $property2 = substr($property2, 0, -1);
1165 $indexProperty2 = 0;
1166 $configureRTEInJavascriptString .= '"'.$property2.'" : {';
1167 foreach($conf3 as $property3Name => $conf4) {
1168 $property3 = $property3Name;
1169 if ($indexProperty2) {
1170 $configureRTEInJavascriptString .= ', ';
1172 if (is_array($conf4)) {
1173 $property3 = substr($property3, 0, -1);
1174 $indexProperty3 = 0;
1175 $configureRTEInJavascriptString .= '"'.$property3.'" : {';
1176 foreach($conf4 as $property4Name => $conf5) {
1177 $property4 = $property4Name;
1178 if ($indexProperty3) {
1179 $configureRTEInJavascriptString .= ', ';
1181 if (!is_array($conf5)) {
1182 $configureRTEInJavascriptString .= '"'.$property4.'" : '.($conf5?
'"'.$conf5.'"':'false');
1186 $configureRTEInJavascriptString .= '}';
1188 $configureRTEInJavascriptString .= '"'.$property3.'" : '.($conf4?
'"'.$conf4.'"':'false');
1192 $configureRTEInJavascriptString .= '}';
1194 $configureRTEInJavascriptString .= '"'.$property2.'" : '.($conf3?
'"'.$conf3.'"':'false');
1198 $configureRTEInJavascriptString .= '}';
1200 $configureRTEInJavascriptString .= '"'.$property1.'" : '.($conf2?
'"'.$conf2.'"':'false');
1204 $configureRTEInJavascriptString .= '}';
1206 $configureRTEInJavascriptString .= '"'.$property.'" : '.($conf1?
'"'.$conf1.'"':'false');
1211 $configureRTEInJavascriptString .= '}';
1212 return $configureRTEInJavascriptString;
1216 * Return a Javascript localization array for htmlArea RTE
1218 * @return string Javascript localization array
1220 function buildJSMainLangArray() {
1221 global $TSFE, $LANG, $TYPO3_CONF_VARS;
1223 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'' : chr(10);
1224 $JSLanguageArray .= 'var HTMLArea_langArray = new Object();' . $linebreak;
1225 $JSLanguageArray .= 'HTMLArea_langArray = { ' . $linebreak;
1226 $subArrays = array( 'tooltips', 'msg' , 'dialogs');
1227 $subArraysIndex = 0;
1228 foreach ($subArrays as $labels) {
1229 $JSLanguageArray .= (($subArraysIndex++
)?
',':'') . $labels . ': {' . $linebreak;
1230 if ($this->is_FE()) {
1231 $LOCAL_LANG = t3lib_div
::readLLfile('EXT:' . $this->ID
. '/htmlarea/locallang_' . $labels . '.xml', $this->language
, $this->OutputCharset
);
1233 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm
::extPath($this->ID
).'htmlarea/locallang_' . $labels . '.xml');
1235 if (!empty($LOCAL_LANG[$this->language
])) {
1236 $LOCAL_LANG[$this->language
] = t3lib_div
::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language
]);
1238 $LOCAL_LANG[$this->language
] = $LOCAL_LANG['default'];
1241 foreach ($LOCAL_LANG[$this->language
] as $labelKey => $labelValue ) {
1242 $JSLanguageArray .= (($index++
)?
',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
1244 $JSLanguageArray .= ' }' . chr(10);
1246 $JSLanguageArray .= ' };' . chr(10);
1247 return $JSLanguageArray;
1251 * Writes contents in a file in typo3temp/rtehtmlarea directory and returns the file name
1253 * @param string $sourceFileName: The name of the file from which the contents should be extracted
1254 * @param string $label: A label to insert at the beginning of the name of the file
1255 * @param string $fileExtension: The file extension of the file, defaulting to 'js'
1256 * @param string $contents: The contents to write into the file if no $sourceFileName is provided
1258 * @return string The name of the file writtten to typo3temp/rtehtmlarea
1260 public function writeTemporaryFile($sourceFileName='', $label, $fileExtension='js', $contents='') {
1261 global $TYPO3_CONF_VARS;
1263 if ($sourceFileName) {
1265 $source = t3lib_div
::getFileAbsFileName($sourceFileName);
1266 $output = file_get_contents($source);
1268 $output = $contents;
1270 $compress = $TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['enableCompressedScripts'] && ($fileExtension == 'js') && ($output != '');
1271 $relativeFilename = 'typo3temp/' . $this->ID
. '/' . str_replace('-','_',$label) . '_' . t3lib_div
::shortMD5(($TYPO3_CONF_VARS['EXTCONF'][$this->ID
]['version'] . ($sourceFileName?
$sourceFileName:$output)), 20) . ($compress ?
'_compressed' : '') . '.' . $fileExtension;
1272 $destination = PATH_site
. $relativeFilename;
1273 if(!file_exists($destination)) {
1274 $compressedJavaScript = '';
1276 $compressedJavaScript = t3lib_div
::minifyJavaScript($output);
1278 $failure = t3lib_div
::writeFileToTypo3tempDir($destination, $compressedJavaScript?
$compressedJavaScript:$output);
1283 return ($this->thisConfig
['forceHTTPS']?
$this->siteURL
:$this->httpTypo3Path
) . $relativeFilename;
1287 * Return a file name containing the main JS language array for HTMLArea
1289 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1291 * @return string filename
1294 function buildJSMainLangFile($RTEcounter) {
1295 $contents = $this->buildJSMainLangArray() . chr(10);
1296 foreach ($this->pluginEnabledCumulativeArray
[$RTEcounter] as $pluginId) {
1297 $contents .= $this->buildJSLangArray($pluginId) . chr(10);
1299 return $this->writeTemporaryFile('', $this->language
.'_'.$this->OutputCharset
, 'js', $contents);
1303 * Return a Javascript localization array for the plugin
1305 * @param string $plugin: identification string of the plugin
1307 * @return string Javascript localization array
1310 function buildJSLangArray($plugin) {
1312 $extensionKey = is_object($this->registeredPlugins
[$plugin]) ?
$this->registeredPlugins
[$plugin]->getExtensionKey() : $this->ID
;
1313 $linebreak = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID
]['enableCompressedScripts'] ?
'' : chr(10);
1314 $JSLanguageArray = '';
1316 if ($this->is_FE()) {
1317 $fileRef = 'EXT:' . $extensionKey . '/htmlarea/plugins/' . $plugin . '/locallang.xml';
1319 $fileRef = t3lib_extMgm
::extPath($extensionKey).'htmlarea/plugins/' . $plugin . '/locallang.xml';
1321 $file = t3lib_div
::getFileAbsFileName($fileRef);
1322 if (@is_file
($file)) {
1323 if ($this->is_FE()) {
1324 $LOCAL_LANG = t3lib_div
::readLLfile($fileRef, $this->language
, $this->OutputCharset
);
1326 $LOCAL_LANG = $GLOBALS['LANG']->readLLfile(t3lib_extMgm
::extPath($extensionKey).'htmlarea/plugins/' . $plugin . '/locallang.xml');
1329 if (is_array($LOCAL_LANG)) {
1330 if (!empty($LOCAL_LANG[$this->language
])) {
1331 $LOCAL_LANG[$this->language
] = t3lib_div
::array_merge_recursive_overrule($LOCAL_LANG['default'],$LOCAL_LANG[$this->language
]);
1333 $LOCAL_LANG[$this->language
] = $LOCAL_LANG['default'];
1335 $JSLanguageArray .= 'var ' . $plugin . '_langArray = new Object();' . $linebreak;
1336 $JSLanguageArray .= $plugin . '_langArray = ' . json_encode($LOCAL_LANG[$this->language
]) . ';'. chr(10);
1338 return $JSLanguageArray;
1342 * Return the JS-Code for the Toolbar-Config-Array for HTML-Area
1344 * @return string the JS-Code as an JS-Array
1347 function getJSToolbarArray() {
1348 $toolbar = ''; // The JS-Code for the toolbar
1349 $group = ''; // The TS-Code for the group in the moment, each group are between "bar"s
1350 $group_has_button = false; // True if the group has any enabled buttons
1351 $group_needs_starting_bar = false;
1352 $previous_is_space = false;
1354 // process each button in the order list
1355 foreach ($this->toolbarOrderArray
as $button) {
1356 // check if a new group starts
1357 if (($button == 'bar' ||
$button == 'linebreak') && $group_has_button) {
1359 if ($button == 'linebreak') {
1360 $convertButton = '"' . $this->convertToolbarForHTMLArea('linebreak') . '"';
1361 $group = ($group!='') ?
($group . ', ' . $convertButton) : $convertButton;
1364 $toolbar .= $toolbar ?
(', ' . $group) : ('[[' . $group);
1366 $previous_is_space = false;
1367 $group_has_button = false;
1368 $group_needs_starting_bar = true;
1369 } elseif ($toolbar && $button == 'linebreak' && !$group_has_button) {
1370 // Insert linebreak if no group is opened
1372 $previous_is_space = false;
1373 $group_needs_starting_bar = false;
1374 $toolbar .= ', "' . $this->convertToolbarForHTMLArea($button) . '"';
1375 } elseif ($button == 'bar' && !$group_has_button) {
1376 $group_needs_starting_bar = true;
1377 } elseif ($button == 'space' && $group_has_button && !$previous_is_space) {
1378 $convertButton = $this->convertToolbarForHTMLArea($button);
1379 $convertButton = '"' . $convertButton . '"';
1380 $group .= $group ?
(', ' . $convertButton) : ($group_needs_starting_bar ?
('"' . $this->convertToolbarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
1381 $group_needs_starting_bar = false;
1382 $previous_is_space = true;
1383 } elseif (in_array($button, $this->toolbar
)) {
1384 // Add the button to the group
1385 $convertButton = $this->convertToolbarForHTMLArea($button);
1386 if ($convertButton) {
1387 $convertButton = '"' . $convertButton . '"';
1388 $group .= $group ?
(', ' . $convertButton) : ($group_needs_starting_bar ?
('"' . $this->convertToolbarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
1389 $group_has_button = true;
1390 $group_needs_starting_bar = false;
1391 $previous_is_space = false;
1396 // add the last group
1397 if($group_has_button) $toolbar .= $toolbar ?
(', ' . $group) : ('[[' . $group);
1398 $toolbar = $toolbar . ']]';
1402 public function getLLContent($string) {
1405 $BE_lang = $LANG->lang
;
1406 $BE_charSet = $LANG->charSet
;
1407 $LANG->lang
= $this->contentTypo3Language
;
1408 $LANG->charSet
= $this->contentCharset
;
1409 $LLString = $LANG->JScharCode($LANG->sL($string));
1410 $LANG->lang
= $BE_lang;
1411 $LANG->charSet
= $BE_charSet;
1415 public function getPageConfigLabel($string,$JScharCode=1) {
1416 global $LANG, $TSFE, $TYPO3_CONF_VARS;
1418 if ($this->is_FE()) {
1419 if (strcmp(substr($string,0,4),'LLL:') && $TYPO3_CONF_VARS['BE']['forceCharset']) {
1420 // A pure string coming from Page TSConfig must be in forceCharset, otherwise we just don't know..
1421 $label = $TSFE->csConvObj
->conv($TSFE->sL(trim($string)), $TYPO3_CONF_VARS['BE']['forceCharset'], $this->OutputCharset
);
1423 $label = $TSFE->csConvObj
->conv($TSFE->sL(trim($string)), $this->charset
, $this->OutputCharset
);
1425 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1426 $label = $JScharCode ?
$this->feJScharCode($label) : $label;
1428 if (strcmp(substr($string,0,4),'LLL:')) {
1431 $label = $LANG->sL(trim($string));
1433 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1434 $label = $JScharCode ?
$LANG->JScharCode($label): $label;
1439 function feJScharCode($str) {
1441 // Convert string to UTF-8:
1442 if ($this->OutputCharset
!= 'utf-8') $str = $TSFE->csConvObj
->utf8_encode($str,$this->OutputCharset
);
1443 // Convert the UTF-8 string into a array of char numbers:
1444 $nArr = $TSFE->csConvObj
->utf8_to_numberarray($str);
1445 return 'String.fromCharCode('.implode(',',$nArr).')';
1448 public function getFullFileName($filename) {
1449 if (substr($filename,0,4)=='EXT:') { // extension
1450 list($extKey,$local) = explode('/',substr($filename,4),2);
1452 if (strcmp($extKey,'') && t3lib_extMgm
::isLoaded($extKey) && strcmp($local,'')) {
1453 $newFilename = $this->siteURL
. t3lib_extMgm
::siteRelPath($extKey) . $local;
1455 } elseif (substr($filename,0,1) != '/') {
1456 $newFilename = $this->siteURL
. $filename;
1458 $newFilename = $this->siteURL
. substr($filename,1);
1460 return $newFilename;
1464 * Return the Javascript code for copying the HTML code from the editor into the hidden input field.
1465 * This is for submit function of the form.
1467 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1468 * @param string $formName: the name of the form
1469 * @param string $textareaId: the id of the textarea
1471 * @return string Javascript code
1473 function setSaveRTE($RTEcounter, $formName, $textareaId) {
1474 return 'if (RTEarea["' . $textareaId . '"]) { document.' . $formName . '["' . $textareaId . '"].value = RTEarea["' . $textareaId . '"].editor.getPluginInstance("EditorMode").getHTML(); } else { OK = 0; };';
1478 * Return the Javascript code for copying the HTML code from the editor into the hidden input field.
1479 * This is for submit function of the form.
1481 * @param integer $RTEcounter: The index number of the current RTE editing area within the form.
1482 * @param string $formName: the name of the form
1483 * @param string $textareaId: the id of the textarea
1485 * @return string Javascript code
1487 function setDeleteRTE($RTEcounter, $formName, $textareaId) {
1488 return 'if (RTEarea["' . $textareaId . '"]) { RTEarea["' . $textareaId . '"].deleted = true;}';
1492 * Return true if we are in the FE, but not in the FE editing feature of BE.
1499 return is_object($TSFE) && is_array($this->LOCAL_LANG
) && !strstr($this->elementId
,'TSFE_EDIT');
1503 * Client Browser Information
1507 * @param string Alternative User Agent string (if empty, t3lib_div::getIndpEnv('HTTP_USER_AGENT') is used)
1508 * @return array Parsed information about the HTTP_USER_AGENT in categories BROWSER, VERSION, SYSTEM and FORMSTYLE
1511 function clientInfo($useragent='') {
1512 global $TYPO3_CONF_VARS;
1514 if (!$useragent) $useragent=t3lib_div
::getIndpEnv('HTTP_USER_AGENT');
1518 if (strstr($useragent,'Konqueror')) {
1519 $bInfo['BROWSER']= 'konqu';
1520 } elseif (strstr($useragent,'Opera')) {
1521 $bInfo['BROWSER']= 'opera';
1522 } elseif (strstr($useragent,'MSIE')) {
1523 $bInfo['BROWSER']= 'msie';
1524 } elseif (strstr($useragent,'Gecko/')) {
1525 $bInfo['BROWSER']='gecko';
1526 } elseif (strstr($useragent,'Safari/')) {
1527 $bInfo['BROWSER']='safari';
1528 } elseif (strstr($useragent,'Mozilla/4')) {
1529 $bInfo['BROWSER']='net';
1532 if ($bInfo['BROWSER']) {
1534 switch($bInfo['BROWSER']) {
1536 $bInfo['VERSION']= doubleval(substr($useragent,8));
1537 if (strstr($useragent,'Netscape6/')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape6/'),10));}
1538 if (strstr($useragent,'Netscape/7')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape/7'),9));}
1541 $tmp = strstr($useragent,'rv:');
1542 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
1545 $tmp = strstr($useragent,'MSIE');
1546 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4)));
1549 $tmp = strstr($useragent,'Safari/');
1550 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
1553 $tmp = strstr($useragent,'Opera');
1554 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5)));
1557 $tmp = strstr($useragent,'Konqueror/');
1558 $bInfo['VERSION'] = doubleval(substr($tmp,10));
1563 if (strstr($useragent,'Win')) {
1564 $bInfo['SYSTEM'] = 'win';
1565 } elseif (strstr($useragent,'Mac')) {
1566 $bInfo['SYSTEM'] = 'mac';
1567 } elseif (strstr($useragent,'Linux') ||
strstr($useragent,'X11') ||
strstr($useragent,'SGI') ||
strstr($useragent,' SunOS ') ||
strstr($useragent,' HP-UX ')) {
1568 $bInfo['SYSTEM'] = 'unix';
1572 // Is true if the browser supports css to format forms, especially the width
1573 $bInfo['FORMSTYLE']=($bInfo['BROWSER']=='msie' ||
($bInfo['BROWSER']=='net'&&$bInfo['VERSION']>=5) ||
$bInfo['BROWSER']=='opera' ||
$bInfo['BROWSER']=='konqu');
1577 /***************************
1579 * OTHER FUNCTIONS: (from Classic RTE)
1581 ***************************/
1583 * @return [type] ...
1587 function RTEtsConfigParams() {
1588 if($this->is_FE()) {
1591 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($this->specConf
['rte_transform']['parameters']);
1592 return $this->elementParts
[0].':'.$this->elementParts
[1].':'.$this->elementParts
[2].':'.$this->thePid
.':'.$this->typeVal
.':'.$this->tscPID
.':'.$p['imgpath'];
1596 public function cleanList($str) {
1597 if (strstr($str,'*')) {
1600 $str = implode(',',array_unique(t3lib_div
::trimExplode(',',$str,1)));
1605 function filterStyleEl($elValue,$matchList) {
1606 $matchParts = t3lib_div
::trimExplode(',',$matchList,1);
1607 $styleParts = explode(';',$elValue);
1609 foreach ($styleParts as $k => $p) {
1610 $pp = t3lib_div
::trimExplode(':',$p);
1611 if ($pp[0]&&$pp[1]) {
1612 foreach ($matchParts as $el) {
1613 $star=substr($el,-1)=='*';
1614 if (!strcmp($pp[0],$el) ||
($star && t3lib_div
::isFirstPartOfStr($pp[0],substr($el,0,-1)) )) {
1615 $nStyle[]=$pp[0].':'.$pp[1];
1616 } else unset($styleParts[$k]);
1619 unset($styleParts[$k]);
1622 return implode('; ',$nStyle);
1625 // Hook on lorem_ipsum extension to insert text into the RTE in wysiwyg mode
1626 function loremIpsumInsert($params) {
1628 if (typeof(lorem_ipsum) == 'function' && " . $params['element'] . ".tagName.toLowerCase() == 'textarea' ) lorem_ipsum(" . $params['element'] . ", lipsum_temp_strings[lipsum_temp_pointer]);
1633 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']) {
1634 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']);