|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2004-2011 Kasper Skårhøj (kasper@typo3.com) 00006 * (c) 2004-2011 Philipp Borgmann <philipp.borgmann@gmx.de> 00007 * (c) 2004-2011 Stanislas Rolland <typo3(arobas)sjbr.ca> 00008 * All rights reserved 00009 * 00010 * This script is part of the TYPO3 project. The TYPO3 project is 00011 * free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * The GNU General Public License can be found at 00017 * http://www.gnu.org/copyleft/gpl.html. 00018 * A copy is found in the textfile GPL.txt and important notices to the license 00019 * from the author is found in LICENSE.txt distributed with these scripts. 00020 * 00021 * 00022 * This script is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU General Public License for more details. 00026 * 00027 * This copyright notice MUST APPEAR in all copies of the script! 00028 ***************************************************************/ 00029 /** 00030 * A RTE using the htmlArea editor 00031 * 00032 * @author Philipp Borgmann <philipp.borgmann@gmx.de> 00033 * @author Stanislas Rolland <typo3(arobas)sjbr.ca> 00034 * 00035 * $Id: class.tx_rtehtmlarea_base.php 10512 2011-02-21 02:04:08Z stan $ * 00036 */ 00037 00038 class tx_rtehtmlarea_base extends t3lib_rteapi { 00039 // Configuration of supported browsers 00040 var $conf_supported_browser = array ( 00041 'msie' => array ( 00042 array ( 00043 'version' => 6.0, 00044 'system' => array( 00045 'allowed' => array( 00046 'winNT', 00047 'win98', 00048 'win95', 00049 ), 00050 ), 00051 ), 00052 ), 00053 'gecko' => array ( 00054 array ( 00055 'version' => 1.8, 00056 ), 00057 ), 00058 'webkit' => array ( 00059 array ( 00060 'version' => 523, 00061 'system' => array( 00062 'disallowed' => array( 00063 'iOS', 00064 'android', 00065 ), 00066 ), 00067 ), 00068 ), 00069 'opera' => array ( 00070 array ( 00071 'version' => 9.62, 00072 'system' => array( 00073 'disallowed' => array( 00074 'iOS', 00075 'android', 00076 ), 00077 ), 00078 ), 00079 ) 00080 ); 00081 00082 // Always hide these toolbar buttons (TYPO3 button name) 00083 var $conf_toolbar_hide = array ( 00084 'showhelp', // Has no content yet 00085 ); 00086 00087 // The order of the toolbar: the name is the TYPO3-button name 00088 var $defaultToolbarOrder; 00089 00090 // Conversion array: TYPO3 button names to htmlArea button names 00091 var $convertToolbarForHtmlAreaArray = array ( 00092 'showhelp' => 'ShowHelp', 00093 'space' => 'space', 00094 'bar' => 'separator', 00095 'linebreak' => 'linebreak', 00096 ); 00097 00098 var $pluginButton = array(); 00099 var $pluginLabel = array(); 00100 // Alternative style for RTE <div> tag. 00101 public $RTEdivStyle; 00102 // Relative path to this extension. It ends with "/" 00103 public $extHttpPath; 00104 public $backPath = ''; 00105 // TYPO3 site url 00106 public $siteURL; 00107 // TYPO3 host url 00108 public $hostURL; 00109 // Typo3 version 00110 public $typoVersion; 00111 // Identifies the RTE as being the one from the "rtehtmlarea" extension if any external code needs to know 00112 var $ID = 'rtehtmlarea'; 00113 // If set, the content goes into a regular TEXT area field - for developing testing of transformations. 00114 var $debugMode = FALSE; 00115 // For the editor 00116 var $client; 00117 00118 /** 00119 * Reference to parent object, which is an instance of the TCEforms 00120 * 00121 * @var t3lib_TCEforms 00122 */ 00123 var $TCEform; 00124 var $elementId; 00125 var $elementParts; 00126 var $tscPID; 00127 var $typeVal; 00128 var $thePid; 00129 var $RTEsetup; 00130 var $thisConfig; 00131 var $confValues; 00132 public $language; 00133 public $contentTypo3Language; 00134 public $contentISOLanguage; 00135 public $contentCharset; 00136 public $OutputCharset; 00137 var $editorCSS; 00138 var $specConf; 00139 var $toolbar = array(); // Save the buttons for the toolbar 00140 var $toolbarOrderArray = array(); 00141 protected $pluginEnabledArray = array(); // Array of plugin id's enabled in the current RTE editing area 00142 protected $pluginEnabledCumulativeArray = array(); // Cumulative array of plugin id's enabled so far in any of the RTE editing areas of the form 00143 protected $cumulativeScripts = array(); 00144 public $registeredPlugins = array(); // Array of registered plugins indexed by their plugin Id's 00145 protected $fullScreen = false; 00146 00147 /** 00148 * Returns true if the RTE is available. Here you check if the browser requirements are met. 00149 * If there are reasons why the RTE cannot be displayed you simply enter them as text in ->errorLog 00150 * 00151 * @return boolean TRUE if this RTE object offers an RTE in the current browser environment 00152 */ 00153 function isAvailable() { 00154 00155 $this->client = $this->clientInfo(); 00156 $this->errorLog = array(); 00157 if (!$this->debugMode) { // If debug-mode, let any browser through 00158 $rteIsAvailable = FALSE; 00159 $rteConfBrowser = $this->conf_supported_browser; 00160 if (is_array($rteConfBrowser)) { 00161 foreach ($rteConfBrowser as $browser => $browserConf) { 00162 if ($browser == $this->client['browser']) { 00163 // Config for Browser found, check it: 00164 if (is_array($browserConf)) { 00165 foreach ($browserConf as $browserConfSub) { 00166 if ($browserConfSub['version'] <= $this->client['version'] || empty($browserConfSub['version'])) { 00167 // Version is supported 00168 if (is_array($browserConfSub['system'])) { 00169 // Check against allowed systems 00170 if (is_array($browserConfSub['system']['allowed'])) { 00171 foreach ($browserConfSub['system']['allowed'] as $system) { 00172 if (in_array($system, $this->client['all_systems'])) { 00173 $rteIsAvailable = TRUE; 00174 break; 00175 } 00176 } 00177 } else { 00178 // All allowed 00179 $rteIsAvailable = TRUE; 00180 } 00181 // Check against disallowed systems 00182 if (is_array($browserConfSub['system']['disallowed'])) { 00183 foreach ($browserConfSub['system']['disallowed'] as $system) { 00184 if (in_array($system, $this->client['all_systems'])) { 00185 $rteIsAvailable = FALSE; 00186 break; 00187 } 00188 } 00189 } 00190 } else { 00191 // No system config: system is supported 00192 $rteIsAvailable = TRUE; 00193 break; 00194 }// End of System 00195 }// End of Version 00196 }// End of foreach-BrowserSubpart 00197 } else { 00198 // no config for this browser found, so all versions or system with this browsers are allow 00199 $rteIsAvailable = TRUE; 00200 break; 00201 } 00202 } // End of Browser Check 00203 } // foreach: Browser Check 00204 } else { 00205 // no Browser config for this RTE-Editor, so all Clients are allow 00206 } 00207 if (!$rteIsAvailable) { 00208 $this->errorLog[] = 'RTE: Browser not supported.'; 00209 } 00210 if (t3lib_div::int_from_ver(TYPO3_version) < 4000000) { 00211 $rteIsAvailable = FALSE; 00212 $this->errorLog[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.'; 00213 } 00214 } 00215 return $rteIsAvailable; 00216 } 00217 00218 /** 00219 * Draws the RTE as an iframe 00220 * 00221 * @param object Reference to parent object, which is an instance of the TCEforms. 00222 * @param string The table name 00223 * @param string The field name 00224 * @param array The current row from which field is being rendered 00225 * @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. 00226 * @param array "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array. 00227 * @param array Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc. 00228 * @param string Record "type" field value. 00229 * @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! 00230 * @param integer PID value of record (true parent page id) 00231 * @return string HTML code for RTE! 00232 */ 00233 00234 function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue) { 00235 global $BE_USER, $LANG, $TYPO3_DB, $TYPO3_CONF_VARS; 00236 00237 $this->TCEform = $parentObject; 00238 $inline = $this->TCEform->inline; 00239 $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml'); 00240 $this->client = $this->clientInfo(); 00241 $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version); 00242 $this->userUid = 'BE_' . $BE_USER->user['uid']; 00243 00244 // Draw form element: 00245 if ($this->debugMode) { // Draws regular text area (debug mode) 00246 $item = parent::drawRTE($this->TCEform, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue); 00247 } else { // Draw real RTE 00248 00249 /* ======================================= 00250 * INIT THE EDITOR-SETTINGS 00251 * ======================================= 00252 */ 00253 // Set backPath 00254 $this->backPath = $this->TCEform->backPath; 00255 // Get the path to this extension: 00256 $this->extHttpPath = $this->backPath . t3lib_extMgm::extRelPath($this->ID); 00257 // Get the site URL 00258 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); 00259 // Get the host URL 00260 $this->hostURL = $this->siteURL . TYPO3_mainDir; 00261 // Element ID + pid 00262 $this->elementId = $PA['itemFormElName']; // Form element name 00263 $this->elementParts = explode('][',preg_replace('/\]$/','',preg_replace('/^(TSFE_EDIT\[data\]\[|data\[)/','',$this->elementId))); 00264 // Find the page PIDs: 00265 list($this->tscPID,$this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]),trim($this->elementParts[1]),$thePidValue); 00266 00267 // Record "types" field value: 00268 $this->typeVal = $RTEtypeVal; // TCA "types" value for record 00269 00270 // Find "thisConfig" for record/editor: 00271 unset($this->RTEsetup); 00272 $this->RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($this->tscPID)); 00273 $this->thisConfig = $thisConfig; 00274 00275 // Special configuration and default extras: 00276 $this->specConf = $specConf; 00277 00278 if ($this->thisConfig['forceHTTPS']) { 00279 $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath); 00280 $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL); 00281 $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL); 00282 } 00283 // Register RTE windows 00284 $this->TCEform->RTEwindows[] = $PA['itemFormElName']; 00285 $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']); 00286 $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)); 00287 00288 /* ======================================= 00289 * LANGUAGES & CHARACTER SETS 00290 * ======================================= 00291 */ 00292 00293 // Languages: interface and content 00294 $this->language = $LANG->lang; 00295 if ($this->language=='default' || !$this->language) { 00296 $this->language='en'; 00297 } 00298 $this->contentTypo3Language = $this->language; 00299 $this->contentISOLanguage = 'en'; 00300 $this->contentLanguageUid = ($row['sys_language_uid'] > 0) ? $row['sys_language_uid'] : 0; 00301 if (t3lib_extMgm::isLoaded('static_info_tables')) { 00302 if ($this->contentLanguageUid) { 00303 $tableA = 'sys_language'; 00304 $tableB = 'static_languages'; 00305 $languagesUidsList = $this->contentLanguageUid; 00306 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3'; 00307 $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid'; 00308 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') '; 00309 $whereClause .= t3lib_BEfunc::BEenableFields($tableA); 00310 $whereClause .= t3lib_BEfunc::deleteClause($tableA); 00311 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause); 00312 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) { 00313 $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):'')); 00314 $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3'])); 00315 } 00316 } else { 00317 $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ? trim($this->thisConfig['defaultContentLanguage']) : 'en'; 00318 $selectFields = 'lg_iso_2, lg_typo3'; 00319 $tableAB = 'static_languages'; 00320 $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB); 00321 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause); 00322 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) { 00323 $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3'])); 00324 } 00325 } 00326 } 00327 00328 // Character sets: interface and content 00329 $this->charset = $LANG->charSet; 00330 $this->OutputCharset = $this->charset; 00331 00332 $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language]; 00333 $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1'; 00334 $this->origContentCharSet = $this->contentCharset; 00335 $this->contentCharset = (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset); 00336 00337 /* ======================================= 00338 * TOOLBAR CONFIGURATION 00339 * ======================================= 00340 */ 00341 $this->initializeToolbarConfiguration(); 00342 00343 /* ======================================= 00344 * SET STYLES 00345 * ======================================= 00346 */ 00347 // Check if wizard_rte called this for fullscreen edtition 00348 if (basename(PATH_thisScript) == 'wizard_rte.php') { 00349 $this->fullScreen = TRUE; 00350 $RTEWidth = '100%'; 00351 $RTEHeight = '100%'; 00352 $RTEPaddingRight = '0'; 00353 $editorWrapWidth = '100%'; 00354 } else { 00355 $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530'; 00356 $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380'; 00357 $RTEWidth = $RTEWidth + ($this->TCEform->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150') : 0); 00358 $RTEWidth -= ($inline->getStructureDepth() > 0 ? ($inline->getStructureDepth()+1)*$inline->getLevelMargin() : 0); 00359 $RTEWidthOverride = (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth'])) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride']); 00360 if ($RTEWidthOverride) { 00361 if (strstr($RTEWidthOverride, '%')) { 00362 if ($this->client['browser'] != 'msie') { 00363 $RTEWidth = (intval($RTEWidthOverride) > 0) ? $RTEWidthOverride : '100%'; 00364 } 00365 } else { 00366 $RTEWidth = (intval($RTEWidthOverride) > 0) ? intval($RTEWidthOverride) : $RTEWidth; 00367 } 00368 } 00369 $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px'; 00370 $RTEHeight = $RTEHeight + ($this->TCEform->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0) : 0); 00371 $RTEHeightOverride = (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && intval($GLOBALS['BE_USER']->uc['rteHeight'])) ? intval($GLOBALS['BE_USER']->uc['rteHeight']) : intval($this->thisConfig['RTEHeightOverride']); 00372 $RTEHeight = ($RTEHeightOverride > 0) ? $RTEHeightOverride : $RTEHeight; 00373 $RTEPaddingRight = '2px'; 00374 $editorWrapWidth = '99%'; 00375 } 00376 $editorWrapHeight = '100%'; 00377 $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px ' . $RTEPaddingRight . ' 2px 2px;'; 00378 /* ======================================= 00379 * LOAD CSS AND JAVASCRIPT 00380 * ======================================= 00381 */ 00382 // Preloading the pageStyle and including RTE skin stylesheets 00383 $this->addPageStyle(); 00384 $this->addSkin(); 00385 // Re-initialize the scripts array so that only the cumulative set of plugins of the last RTE on the page is used 00386 $this->cumulativeScripts[$this->TCEform->RTEcounter] = array(); 00387 $this->includeScriptFiles($this->TCEform->RTEcounter); 00388 $this->buildJSMainLangFile($this->TCEform->RTEcounter); 00389 // Register RTE in JS: 00390 $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId); 00391 // Set the save option for the RTE: 00392 $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId, $PA['itemFormElName']); 00393 $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId); 00394 // Loading JavaScript files and code 00395 if ($this->TCEform->RTEcounter == 1) { 00396 $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter); 00397 } 00398 $this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter); 00399 $pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer(); 00400 $pageRenderer->enableExtJSQuickTips(); 00401 if (!$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts']) { 00402 $pageRenderer->enableExtJsDebug(); 00403 } 00404 $pageRenderer->addJsFile('../t3lib/js/extjs/notifications.js'); 00405 /* ======================================= 00406 * DRAW THE EDITOR 00407 * ======================================= 00408 */ 00409 00410 // Transform value: 00411 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue); 00412 00413 // Further content transformation by registered plugins 00414 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00415 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "transformContent")) { 00416 $value = $plugin->transformContent($value); 00417 } 00418 } 00419 // Draw the textarea 00420 $visibility = 'hidden'; 00421 $item = $this->triggerField($PA['itemFormElName']).' 00422 <div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div> 00423 <div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';"> 00424 <textarea id="RTEarea' . $textAreaId . '" name="'.htmlspecialchars($PA['itemFormElName']).'" rows="0" cols="0" style="'.t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)).'">'.t3lib_div::formatForTextarea($value).'</textarea> 00425 </div>' . LF; 00426 } 00427 00428 // Return form item: 00429 return $item; 00430 } 00431 00432 /** 00433 * Add link to content style sheet to document header 00434 * 00435 * @return void 00436 */ 00437 protected function addPageStyle() { 00438 // Get stylesheet file name from Page TSConfig if any 00439 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css'; 00440 $this->addStyleSheet( 00441 'rtehtmlarea-page-style', 00442 $this->getFullFileName($filename), 00443 'htmlArea RTE Content CSS', 00444 'alternate stylesheet' 00445 ); 00446 } 00447 00448 /** 00449 * Add links to skin style sheet(s) to document header 00450 * 00451 * @return void 00452 */ 00453 protected function addSkin() { 00454 // Get skin file name from Page TSConfig if any 00455 $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css'; 00456 $this->editorCSS = $this->getFullFileName($skinFilename); 00457 $skinDir = dirname($this->editorCSS); 00458 // Editing area style sheet 00459 $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css'; 00460 $this->addStyleSheet( 00461 'rtehtmlarea-editing-area-skin', 00462 $this->editedContentCSS 00463 ); 00464 // Main skin 00465 $this->addStyleSheet( 00466 'rtehtmlarea-skin', 00467 $this->editorCSS 00468 ); 00469 // Additional icons from registered plugins 00470 foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) { 00471 if (is_object($this->registeredPlugins[$pluginId])) { 00472 $pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin(); 00473 if ($pathToSkin) { 00474 $key = $this->registeredPlugins[$pluginId]->getExtensionKey(); 00475 $this->addStyleSheet( 00476 'rtehtmlarea-plugin-' . $pluginId . '-skin', 00477 ($this->is_FE() ? t3lib_extMgm::siteRelPath($key) : $this->backPath . t3lib_extMgm::extRelPath($key)) . $pathToSkin 00478 ); 00479 } 00480 } 00481 } 00482 } 00483 00484 /** 00485 * Add style sheet file to document header 00486 * 00487 * @param string $key: some key identifying the style sheet 00488 * @param string $href: uri to the style sheet file 00489 * @param string $title: value for the title attribute of the link element 00490 * @return string $relation: value for the rel attribute of the link element 00491 * @return void 00492 */ 00493 protected function addStyleSheet($key, $href, $title='', $relation='stylesheet') { 00494 // 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 00495 if (is_object($this->TCEform->inline) && $this->TCEform->inline->isAjaxCall) { 00496 $this->TCEform->additionalCode_pre[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '" title="' . $title. '" />'; 00497 } else { 00498 $pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer(); 00499 $pageRenderer->addCssFile($href, $relation, 'screen', $title); 00500 } 00501 } 00502 00503 /** 00504 * Initialize toolbar configuration and enable registered plugins 00505 * 00506 * @return void 00507 */ 00508 protected function initializeToolbarConfiguration() { 00509 00510 // Enable registred plugins 00511 $this->enableRegisteredPlugins(); 00512 00513 // Configure toolbar 00514 $this->setToolbar(); 00515 00516 // Check if some plugins need to be disabled 00517 $this->setPlugins(); 00518 00519 // Merge the list of enabled plugins with the lists from the previous RTE editing areas on the same form 00520 $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = $this->pluginEnabledArray; 00521 if ($this->TCEform->RTEcounter > 1 && isset($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1]) && is_array($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1])) { 00522 $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = array_unique(array_values(array_merge($this->pluginEnabledArray,$this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1]))); 00523 } 00524 } 00525 00526 /** 00527 * Add registered plugins to the array of enabled plugins 00528 * 00529 */ 00530 function enableRegisteredPlugins() { 00531 global $TYPO3_CONF_VARS; 00532 // Traverse registered plugins 00533 if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'])) { 00534 foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'] as $pluginId => $pluginObjectConfiguration) { 00535 $plugin = false; 00536 if (is_array($pluginObjectConfiguration) && count($pluginObjectConfiguration)) { 00537 $plugin = t3lib_div::getUserObj($pluginObjectConfiguration['objectReference']); 00538 } 00539 if (is_object($plugin)) { 00540 if ($plugin->main($this)) { 00541 $this->registeredPlugins[$pluginId] = $plugin; 00542 // Override buttons from previously registered plugins 00543 $pluginButtons = t3lib_div::trimExplode(',', $plugin->getPluginButtons(), 1); 00544 foreach ($this->pluginButton as $previousPluginId => $buttonList) { 00545 $this->pluginButton[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginButton[$previousPluginId], 1), $pluginButtons)); 00546 } 00547 $this->pluginButton[$pluginId] = $plugin->getPluginButtons(); 00548 $pluginLabels = t3lib_div::trimExplode(',', $plugin->getPluginLabels(), 1); 00549 foreach ($this->pluginLabel as $previousPluginId => $labelList) { 00550 $this->pluginLabel[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginLabel[$previousPluginId], 1), $pluginLabels)); 00551 } 00552 $this->pluginLabel[$pluginId] = $plugin->getPluginLabels(); 00553 $this->pluginEnabledArray[] = $pluginId; 00554 } 00555 } 00556 } 00557 } 00558 // Process overrides 00559 $hidePlugins = array(); 00560 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00561 if ($plugin->addsButtons() && !$this->pluginButton[$pluginId]) { 00562 $hidePlugins[] = $pluginId; 00563 } 00564 } 00565 $this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins)); 00566 } 00567 00568 /** 00569 * Set the toolbar config (only in this PHP-Object, not in JS): 00570 * 00571 */ 00572 00573 function setToolbar() { 00574 global $BE_USER; 00575 00576 if ($this->client['browser'] == 'msie' || $this->client['browser'] == 'opera') { 00577 $this->thisConfig['keepButtonGroupTogether'] = 0; 00578 } 00579 00580 $this->defaultToolbarOrder = 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak, 00581 bar, formattext, bold, strong, italic, emphasis, big, small, insertedtext, deletedtext, citation, code, definition, keyboard, monospaced, quotation, sample, variable, bidioverride, strikethrough, subscript, superscript, underline, span, 00582 bar, fontstyle, space, fontsize, bar, formatblock, insertparagraphbefore, insertparagraphafter, blockquote, line, 00583 bar, left, center, right, justifyfull, 00584 bar, orderedlist, unorderedlist, definitionlist, definitionitem, outdent, indent, bar, lefttoright, righttoleft, language, showlanguagemarks, 00585 bar, textcolor, bgcolor, textindicator, 00586 bar, editelement, emoticon, insertcharacter, 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, 00587 bar, chMode, inserttag, removeformat, bar, copy, cut, paste, pastetoggle, pastebehaviour, bar, undo, redo, bar, showhelp, about, linebreak, 00588 ' . ($this->thisConfig['hideTableOperationsInToolbar'] ? '': 'bar, toggleborders,') . ' bar, tableproperties, tablerestyle, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar, 00589 columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit, bar, 00590 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge'; 00591 00592 // Additional buttons from registered plugins 00593 foreach($this->registeredPlugins as $pluginId => $plugin) { 00594 if ($this->isPluginEnabled($pluginId)) { 00595 $this->defaultToolbarOrder = $plugin->addButtonsToToolbar(); 00596 } 00597 } 00598 $toolbarOrder = $this->thisConfig['toolbarOrder'] ? $this->thisConfig['toolbarOrder'] : $this->defaultToolbarOrder; 00599 00600 // Getting rid of undefined buttons 00601 $this->toolbarOrderArray = array_intersect(t3lib_div::trimExplode(',', $toolbarOrder, 1), t3lib_div::trimExplode(',', $this->defaultToolbarOrder, 1)); 00602 $toolbarOrder = array_unique(array_values($this->toolbarOrderArray)); 00603 00604 // Fetching specConf for field from backend 00605 $pList = is_array($this->specConf['richtext']['parameters']) ? implode(',',$this->specConf['richtext']['parameters']) : ''; 00606 if ($pList != '*') { // If not all 00607 $show = is_array($this->specConf['richtext']['parameters']) ? $this->specConf['richtext']['parameters'] : array(); 00608 if ($this->thisConfig['showButtons']) { 00609 if (!t3lib_div::inList($this->thisConfig['showButtons'],'*')) { 00610 $show = array_unique(array_merge($show,t3lib_div::trimExplode(',',$this->thisConfig['showButtons'],1))); 00611 } else { 00612 $show = array_unique(array_merge($show, $toolbarOrder)); 00613 } 00614 } 00615 if (is_array($this->thisConfig['showButtons.'])) { 00616 foreach ($this->thisConfig['showButtons.'] as $buttonId => $value) { 00617 if ($value) $show[] = $buttonId; 00618 } 00619 $show = array_unique($show); 00620 } 00621 } else { 00622 $show = $toolbarOrder; 00623 } 00624 00625 // Resticting to RTEkeyList for backend user 00626 if(is_object($BE_USER)) { 00627 $RTEkeyList = isset($BE_USER->userTS['options.']['RTEkeyList']) ? $BE_USER->userTS['options.']['RTEkeyList'] : '*'; 00628 if ($RTEkeyList != '*') { // If not all 00629 $show = array_intersect($show, t3lib_div::trimExplode(',',$RTEkeyList,1)); 00630 } 00631 } 00632 00633 // Hiding buttons of disabled plugins 00634 $hideButtons = array('space', 'bar', 'linebreak'); 00635 foreach ($this->pluginButton as $pluginId => $buttonList) { 00636 if (!$this->isPluginEnabled($pluginId)) { 00637 $buttonArray = t3lib_div::trimExplode(',',$buttonList,1); 00638 foreach ($buttonArray as $button) { 00639 $hideButtons[] = $button; 00640 } 00641 } 00642 } 00643 00644 // Hiding labels of disabled plugins 00645 foreach ($this->pluginLabel as $pluginId => $label) { 00646 if (!$this->isPluginEnabled($pluginId)) { 00647 $hideButtons[] = $label; 00648 } 00649 } 00650 00651 // Hiding buttons 00652 $show = array_diff($show, $this->conf_toolbar_hide, t3lib_div::trimExplode(',',$this->thisConfig['hideButtons'],1)); 00653 00654 // Apply toolbar constraints from registered plugins 00655 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00656 if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "applyToolbarConstraints")) { 00657 $show = $plugin->applyToolbarConstraints($show); 00658 } 00659 } 00660 // Getting rid of the buttons for which we have no position 00661 $show = array_intersect($show, $toolbarOrder); 00662 $this->toolbar = $show; 00663 } 00664 00665 /** 00666 * Disable some plugins 00667 * 00668 */ 00669 function setPlugins() { 00670 00671 // Disabling a plugin that adds buttons if none of its buttons is in the toolbar 00672 $hidePlugins = array(); 00673 foreach ($this->pluginButton as $pluginId => $buttonList) { 00674 if ($this->registeredPlugins[$pluginId]->addsButtons()) { 00675 $showPlugin = false; 00676 $buttonArray = t3lib_div::trimExplode(',', $buttonList, 1); 00677 foreach ($buttonArray as $button) { 00678 if (in_array($button, $this->toolbar)) { 00679 $showPlugin = true; 00680 } 00681 } 00682 if (!$showPlugin) { 00683 $hidePlugins[] = $pluginId; 00684 } 00685 } 00686 } 00687 $this->pluginEnabledArray = array_diff($this->pluginEnabledArray, $hidePlugins); 00688 00689 // Hiding labels of disabled plugins 00690 $hideLabels = array(); 00691 foreach ($this->pluginLabel as $pluginId => $label) { 00692 if (!$this->isPluginEnabled($pluginId)) { 00693 $hideLabels[] = $label; 00694 } 00695 } 00696 $this->toolbar = array_diff($this->toolbar, $hideLabels); 00697 00698 // Adding plugins declared as prerequisites by enabled plugins 00699 $requiredPlugins = array(); 00700 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00701 if ($this->isPluginEnabled($pluginId)) { 00702 $requiredPlugins = array_merge($requiredPlugins, t3lib_div::trimExplode(',', $plugin->getRequiredPlugins(), 1)); 00703 } 00704 } 00705 $requiredPlugins = array_unique($requiredPlugins); 00706 foreach ($requiredPlugins as $pluginId) { 00707 if (is_object($this->registeredPlugins[$pluginId]) && !$this->isPluginEnabled($pluginId)) { 00708 $this->pluginEnabledArray[] = $pluginId; 00709 } 00710 } 00711 $this->pluginEnabledArray = array_unique($this->pluginEnabledArray); 00712 00713 // Completing the toolbar conversion array for htmlArea 00714 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00715 if ($this->isPluginEnabled($pluginId)) { 00716 $this->convertToolbarForHtmlAreaArray = array_unique(array_merge($this->convertToolbarForHtmlAreaArray, $plugin->getConvertToolbarForHtmlAreaArray())); 00717 } 00718 } 00719 } 00720 00721 /** 00722 * Convert the TYPO3 names of buttons into the names for htmlArea RTE 00723 * 00724 * @param string buttonname (typo3-name) 00725 * @return string buttonname (htmlarea-name) 00726 */ 00727 00728 function convertToolbarForHTMLArea($button) { 00729 return $this->convertToolbarForHtmlAreaArray[$button]; 00730 } 00731 /** 00732 * Return the HTML code for loading the Javascript files 00733 * 00734 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 00735 * 00736 * @return void 00737 */ 00738 protected function includeScriptFiles($RTEcounter) { 00739 $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea.js', 'htmlarea', 'js', '', TRUE); 00740 if ($this->client['browser'] == 'msie') { 00741 $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-ie.js', 'htmlarea-ie', 'js', '', TRUE); 00742 } else { 00743 $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-gecko.js', 'htmlarea-gecko', 'js', '', TRUE); 00744 } 00745 foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) { 00746 $extensionKey = is_object($this->registeredPlugins[$pluginId]) ? $this->registeredPlugins[$pluginId]->getExtensionKey() : $this->ID; 00747 $this->writeTemporaryFile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js', $pluginId, 'js', '', TRUE); 00748 } 00749 } 00750 /** 00751 * Return the HTML code for loading the Javascript files 00752 * 00753 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 00754 * 00755 * @return string the html code for loading the Javascript Files 00756 */ 00757 protected function loadJSfiles($RTEcounter) { 00758 $loadJavascriptCode = '<script type="text/javascript" src="' . $this->doConcatenate($RTEcounter) . '"></script>' . LF; 00759 $loadJavascriptCode .= t3lib_div::wrapJS(' 00760 if (typeof(RTEarea) == "undefined") { 00761 RTEarea = new Object(); 00762 RTEarea[0] = new Object(); 00763 RTEarea[0].version = "' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['version'] . '"; 00764 RTEarea[0].editorUrl = "' . $this->extHttpPath . 'htmlarea/"; 00765 RTEarea[0].editorCSS = "' . t3lib_div::createVersionNumberedFilename($this->editorCSS) . '"; 00766 RTEarea[0].editorSkin = "' . dirname($this->editorCSS) . '/"; 00767 RTEarea[0].editedContentCSS = "' . t3lib_div::createVersionNumberedFilename($this->editedContentCSS) . '"; 00768 RTEarea[0].hostUrl = "' . $this->hostURL . '"; 00769 RTEarea.init = function() { 00770 if (typeof(HTMLArea) == "undefined" || !Ext.isReady) { 00771 window.setTimeout("RTEarea.init();", 40); 00772 } else { 00773 Ext.QuickTips.init(); 00774 HTMLArea.init(); 00775 } 00776 }; 00777 RTEarea.initEditor = function(editorNumber) { 00778 if (typeof(HTMLArea) == "undefined") { 00779 RTEarea.initEditor.defer(40, null, [editorNumber]); 00780 } else { 00781 HTMLArea.initEditor(editorNumber); 00782 } 00783 }; 00784 }' 00785 ); 00786 return $loadJavascriptCode; 00787 } 00788 00789 /** 00790 * Return the Javascript code for initializing the RTE 00791 * 00792 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 00793 * 00794 * @return string the Javascript code for initializing the RTE 00795 */ 00796 function loadJScode($RTEcounter) { 00797 return TAB . 'RTEarea.init();'; 00798 } 00799 00800 /** 00801 * Return the Javascript code for configuring the RTE 00802 * 00803 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 00804 * @param string $table: The table that includes this RTE (optional, necessary for IRRE). 00805 * @param string $uid: The uid of that table that includes this RTE (optional, necessary for IRRE). 00806 * @param string $field: The field of that record that includes this RTE (optional). 00807 * 00808 * @return string the Javascript code for configuring the RTE 00809 */ 00810 function registerRTEinJS($RTEcounter, $table='', $uid='', $field='', $textAreaId = '') { 00811 $configureRTEInJavascriptString = ' 00812 if (typeof(configureEditorInstance) == "undefined") { 00813 configureEditorInstance = new Object(); 00814 } 00815 configureEditorInstance["' . $textAreaId . '"] = function() { 00816 if (typeof(RTEarea) == "undefined" || typeof(HTMLArea) == "undefined") { 00817 window.setTimeout("configureEditorInstance[\'' . $textAreaId . '\']();", 40); 00818 } else { 00819 editornumber = "' . $textAreaId . '"; 00820 RTEarea[editornumber] = new Object(); 00821 RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '"; 00822 RTEarea[editornumber].number = editornumber; 00823 RTEarea[editornumber].deleted = false; 00824 RTEarea[editornumber].textAreaId = "' . $textAreaId . '"; 00825 RTEarea[editornumber].id = "RTEarea" + editornumber; 00826 RTEarea[editornumber].RTEWidthOverride = "' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth'])) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride'])) . '"; 00827 RTEarea[editornumber].RTEHeightOverride = "' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && intval($GLOBALS['BE_USER']->uc['rteHeight'])) ? intval($GLOBALS['BE_USER']->uc['rteHeight']) : intval($this->thisConfig['RTEHeightOverride'])) . '"; 00828 RTEarea[editornumber].resizable = ' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteResize']) && $GLOBALS['BE_USER']->uc['rteResize']) ? 'true' : (trim($this->thisConfig['rteResize']) ? 'true' : 'false')) . '; 00829 RTEarea[editornumber].maxHeight = "' . ((is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteMaxHeight']) && intval($GLOBALS['BE_USER']->uc['rteMaxHeight'])) ? trim($GLOBALS['BE_USER']->uc['rteMaxHeight']) : (intval($this->thisConfig['rteMaxHeight']) ? intval($this->thisConfig['rteMaxHeight']) : '2000')) . '"; 00830 RTEarea[editornumber].fullScreen = ' . ($this->fullScreen ? 'true' : 'false') . '; 00831 RTEarea[editornumber].showStatusBar = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . '; 00832 RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig['enableWordClean'])?'true':'false') . '; 00833 RTEarea[editornumber].htmlRemoveComments = ' . (trim($this->thisConfig['removeComments'])?'true':'false') . '; 00834 RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig['disableEnterParagraphs'])?'true':'false') . '; 00835 RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig['disableObjectResizing'])?'true':'false') . '; 00836 RTEarea[editornumber].removeTrailingBR = ' . (trim($this->thisConfig['removeTrailingBR'])?'true':'false') . '; 00837 RTEarea[editornumber].useCSS = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . '; 00838 RTEarea[editornumber].keepButtonGroupTogether = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . '; 00839 RTEarea[editornumber].disablePCexamples = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . '; 00840 RTEarea[editornumber].showTagFreeClasses = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . '; 00841 RTEarea[editornumber].useHTTPS = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . '; 00842 RTEarea[editornumber].tceformsNested = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(true) : '[]') . '; 00843 RTEarea[editornumber].dialogueWindows = new Object();'; 00844 if (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromTop'])) { 00845 $configureRTEInJavascriptString .= ' 00846 RTEarea[editornumber].dialogueWindows.positionFromTop = ' . intval($this->thisConfig['dialogueWindows.']['defaultPositionFromTop']) . ';'; 00847 } 00848 if (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft'])) { 00849 $configureRTEInJavascriptString .= ' 00850 RTEarea[editornumber].dialogueWindows.positionFromLeft = ' . intval($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft']) . ';'; 00851 } 00852 // The following properties apply only to the backend 00853 if (!$this->is_FE()) { 00854 $configureRTEInJavascriptString .= ' 00855 RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid . '"; 00856 RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language . '"; 00857 RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset . '"; 00858 RTEarea[editornumber].userUid = "' . $this->userUid . '";'; 00859 } 00860 00861 // Setting the plugin flags 00862 $configureRTEInJavascriptString .= ' 00863 RTEarea[editornumber].plugin = new Object(); 00864 RTEarea[editornumber].pathToPluginDirectory = new Object();'; 00865 foreach ($this->pluginEnabledArray as $pluginId) { 00866 $configureRTEInJavascriptString .= ' 00867 RTEarea[editornumber].plugin.'.$pluginId.' = true;'; 00868 if (is_object($this->registeredPlugins[$pluginId])) { 00869 $pathToPluginDirectory = $this->registeredPlugins[$pluginId]->getPathToPluginDirectory(); 00870 if ($pathToPluginDirectory) { 00871 $configureRTEInJavascriptString .= ' 00872 RTEarea[editornumber].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";'; 00873 } 00874 } 00875 } 00876 00877 // Setting the buttons configuration 00878 $configureRTEInJavascriptString .= ' 00879 RTEarea[editornumber].buttons = new Object();'; 00880 if (is_array($this->thisConfig['buttons.'])) { 00881 foreach ($this->thisConfig['buttons.'] as $buttonIndex => $conf) { 00882 $button = substr($buttonIndex, 0, -1); 00883 if (is_array($conf)) { 00884 $configureRTEInJavascriptString .= ' 00885 RTEarea[editornumber].buttons.'.$button.' = ' . $this->buildNestedJSArray($conf) . ';'; 00886 } 00887 } 00888 } 00889 00890 // Setting the list of tags to be removed if specified in the RTE config 00891 if (trim($this->thisConfig['removeTags'])) { 00892 $configureRTEInJavascriptString .= ' 00893 RTEarea[editornumber].htmlRemoveTags = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;'; 00894 } 00895 00896 // Setting the list of tags to be removed with their contents if specified in the RTE config 00897 if (trim($this->thisConfig['removeTagsAndContents'])) { 00898 $configureRTEInJavascriptString .= ' 00899 RTEarea[editornumber].htmlRemoveTagsAndContents = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;'; 00900 } 00901 // Process default style configuration 00902 $configureRTEInJavascriptString .= ' 00903 RTEarea[editornumber].defaultPageStyle = "' . $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";'; 00904 // Setting the pageStyle 00905 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css'; 00906 $configureRTEInJavascriptString .= ' 00907 RTEarea[editornumber].pageStyle = "' . t3lib_div::createVersionNumberedFilename($this->getFullFileName($filename)) .'";'; 00908 // Process classes configuration 00909 $classesConfigurationRequired = false; 00910 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00911 if ($this->isPluginEnabled($pluginId)) { 00912 $classesConfigurationRequired = $classesConfigurationRequired || $plugin->requiresClassesConfiguration(); 00913 } 00914 } 00915 if ($classesConfigurationRequired) { 00916 $configureRTEInJavascriptString .= $this->buildJSClassesConfig($RTEcounter); 00917 } 00918 // Add Javascript configuration for registered plugins 00919 foreach ($this->registeredPlugins as $pluginId => $plugin) { 00920 if ($this->isPluginEnabled($pluginId)) { 00921 $configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber'); 00922 } 00923 } 00924 // Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call 00925 $configureRTEInJavascriptString .= ' 00926 RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . '; 00927 RTEarea[editornumber].convertButtonId = ' . json_encode(array_flip($this->convertToolbarForHtmlAreaArray)) . '; 00928 RTEarea.initEditor(editornumber); 00929 } 00930 }; 00931 configureEditorInstance["' . $textAreaId . '"]();'; 00932 return $configureRTEInJavascriptString; 00933 } 00934 00935 /** 00936 * Return true, if the plugin can be loaded 00937 * 00938 * @param string $pluginId: The identification string of the plugin 00939 * 00940 * @return boolean true if the plugin can be loaded 00941 */ 00942 00943 function isPluginEnabled($pluginId) { 00944 return in_array($pluginId, $this->pluginEnabledArray); 00945 } 00946 00947 /** 00948 * Build the default content style sheet 00949 * 00950 * @return string Style sheet 00951 */ 00952 function buildStyleSheet() { 00953 00954 if (!trim($this->thisConfig['ignoreMainStyleOverride'])) { 00955 $mainStyle_font = $this->thisConfig['mainStyle_font'] ? $this->thisConfig['mainStyle_font']: 'Verdana,sans-serif'; 00956 00957 $mainElements = array(); 00958 $mainElements['P'] = $this->thisConfig['mainStyleOverride_add.']['P']; 00959 $elList = explode(',','H1,H2,H3,H4,H5,H6,PRE'); 00960 foreach ($elList as $elListName) { 00961 if ($this->thisConfig['mainStyleOverride_add.'][$elListName]) { 00962 $mainElements[$elListName] = $this->thisConfig['mainStyleOverride_add.'][$elListName]; 00963 } 00964 } 00965 00966 $addElementCode = ''; 00967 foreach ($mainElements as $elListName => $elValue) { 00968 $addElementCode .= strToLower($elListName) . ' {' . $elValue . '}' . LF; 00969 } 00970 00971 $stylesheet = $this->thisConfig['mainStyleOverride'] ? $this->thisConfig['mainStyleOverride'] : LF . 00972 'body.htmlarea-content-body { font-family: ' . $mainStyle_font . 00973 '; font-size: '.($this->thisConfig['mainStyle_size'] ? $this->thisConfig['mainStyle_size'] : '12px') . 00974 '; color: '.($this->thisConfig['mainStyle_color']?$this->thisConfig['mainStyle_color'] : 'black') . 00975 '; background-color: '.($this->thisConfig['mainStyle_bgcolor'] ? $this->thisConfig['mainStyle_bgcolor'] : 'white') . 00976 ';'.$this->thisConfig['mainStyleOverride_add.']['BODY'].'}' . LF . 00977 'td { ' . $this->thisConfig['mainStyleOverride_add.']['TD'].'}' . LF . 00978 'div { ' . $this->thisConfig['mainStyleOverride_add.']['DIV'].'}' . LF . 00979 'pre { ' . $this->thisConfig['mainStyleOverride_add.']['PRE'].'}' . LF . 00980 'ol { ' . $this->thisConfig['mainStyleOverride_add.']['OL'].'}' . LF . 00981 'ul { ' . $this->thisConfig['mainStyleOverride_add.']['UL'].'}' . LF . 00982 'blockquote { ' . $this->thisConfig['mainStyleOverride_add.']['BLOCKQUOTE'].'}' . LF . 00983 $addElementCode; 00984 00985 if (is_array($this->thisConfig['inlineStyle.'])) { 00986 $stylesheet .= LF . implode(LF, $this->thisConfig['inlineStyle.']) . LF; 00987 } 00988 } else { 00989 $stylesheet = '/* mainStyleOverride and inlineStyle properties ignored. */'; 00990 } 00991 return $stylesheet; 00992 } 00993 00994 /** 00995 * Return Javascript configuration of classes 00996 * 00997 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 00998 * 00999 * @return string Javascript configuration of classes 01000 */ 01001 function buildJSClassesConfig($RTEcounter) { 01002 // Build JS array of lists of classes 01003 $classesTagList = 'classesCharacter, classesParagraph, classesImage, classesTable, classesLinks, classesTD'; 01004 $classesTagConvert = array( 'classesCharacter' => 'span', 'classesParagraph' => 'div', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td'); 01005 $classesTagArray = t3lib_div::trimExplode(',' , $classesTagList); 01006 $configureRTEInJavascriptString = ' 01007 RTEarea[editornumber].classesTag = new Object();'; 01008 foreach ($classesTagArray as $classesTagName) { 01009 $HTMLAreaJSClasses = ($this->thisConfig[$classesTagName])?('"' . $this->cleanList($this->thisConfig[$classesTagName]) . '";'):'null;'; 01010 $configureRTEInJavascriptString .= ' 01011 RTEarea[editornumber].classesTag.'. $classesTagConvert[$classesTagName] .' = '. $HTMLAreaJSClasses; 01012 } 01013 // Include JS arrays of configured classes 01014 $configureRTEInJavascriptString .= ' 01015 RTEarea[editornumber].classesUrl = "' . $this->writeTemporaryFile('', 'classes_' . $this->language, 'js', $this->buildJSClassesArray(), TRUE) . '";'; 01016 return $configureRTEInJavascriptString; 01017 } 01018 01019 /** 01020 * Return JS arrays of classes configuration 01021 * 01022 * @return string JS classes arrays 01023 */ 01024 function buildJSClassesArray() { 01025 if ($this->is_FE()) { 01026 $RTEProperties = $this->RTEsetup; 01027 } else { 01028 $RTEProperties = $this->RTEsetup['properties']; 01029 } 01030 $classesArray = array('labels' => array(), 'values' => array(), 'noShow' => array(), 'alternating' => array(), 'counting' => array(), 'XOR' => array()); 01031 $JSClassesArray = ''; 01032 // Scanning the list of classes if specified in the RTE config 01033 if (is_array($RTEProperties['classes.'])) { 01034 foreach ($RTEProperties['classes.'] as $className => $conf) { 01035 $className = rtrim($className, '.'); 01036 $classesArray['labels'][$className] = $this->getPageConfigLabel($conf['name'], FALSE); 01037 $classesArray['values'][$className] = str_replace('\\\'', '\'', $conf['value']); 01038 if (isset($conf['noShow'])) { 01039 $classesArray['noShow'][$className] = $conf['noShow']; 01040 } 01041 if (is_array($conf['alternating.'])) { 01042 $classesArray['alternating'][$className] = $conf['alternating.']; 01043 } 01044 if (is_array($conf['counting.'])) { 01045 $classesArray['counting'][$className] = $conf['counting.']; 01046 } 01047 } 01048 } 01049 // Scanning the list of sets of mutually exclusives classes if specified in the RTE config 01050 if (is_array($RTEProperties['mutuallyExclusiveClasses.'])) { 01051 foreach ($RTEProperties['mutuallyExclusiveClasses.'] as $listName => $conf) { 01052 $classSet = t3lib_div::trimExplode(',', $conf, 1); 01053 $classList = implode(',', $classSet); 01054 foreach ($classSet as $className) { 01055 $classesArray['XOR'][$className] = '/^(' . implode('|', t3lib_div::trimExplode(',', t3lib_div::rmFromList($className, $classList), 1)) . ')$/'; 01056 } 01057 } 01058 } 01059 foreach ($classesArray as $key => $subArray) { 01060 $JSClassesArray .= 'HTMLArea.classes' . ucfirst($key) . ' = ' . $this->buildNestedJSArray($subArray) . ';' . LF; 01061 } 01062 return $JSClassesArray; 01063 } 01064 01065 /** 01066 * Translate Page TS Config array in JS nested array definition 01067 * Replace 0 values with false 01068 * Unquote regular expression values 01069 * Replace empty arrays with empty objects 01070 * 01071 * @param array $conf: Page TSConfig configuration array 01072 * 01073 * @return string nested JS array definition 01074 */ 01075 function buildNestedJSArray($conf) { 01076 $convertedConf = t3lib_div::removeDotsFromTS($conf); 01077 if ($this->is_FE()) { 01078 $GLOBALS['TSFE']->csConvObj->convArray($convertedConf, ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : 'iso-8859-1'), 'utf-8'); 01079 } else { 01080 $GLOBALS['LANG']->csConvObj->convArray($convertedConf, $GLOBALS['LANG']->charSet, 'utf-8'); 01081 } 01082 return str_replace(array(':"0"', ':"\/^(', ')$\/i"', ':"\/^(', ')$\/"', '[]'), array(':false', ':/^(', ')$/i', ':/^(', ')$/', '{}'), json_encode($convertedConf)); 01083 } 01084 01085 /** 01086 * Return a Javascript localization array for htmlArea RTE 01087 * 01088 * @return string Javascript localization array 01089 */ 01090 function buildJSMainLangArray() { 01091 $JSLanguageArray = 'HTMLArea.I18N = new Object();' . LF; 01092 $labelsArray = array('tooltips' => array(), 'msg' => array(), 'dialogs' => array()); 01093 foreach ($labelsArray as $labels => $subArray) { 01094 $LOCAL_LANG = t3lib_div::readLLfile('EXT:' . $this->ID . '/htmlarea/locallang_' . $labels . '.xml', $this->language, 'utf-8'); 01095 if (!empty($LOCAL_LANG[$this->language])) { 01096 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language]); 01097 } else { 01098 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default']; 01099 } 01100 $labelsArray[$labels] = $LOCAL_LANG[$this->language]; 01101 } 01102 $JSLanguageArray .= 'HTMLArea.I18N = ' . json_encode($labelsArray) . ';' . LF; 01103 return $JSLanguageArray; 01104 } 01105 01106 /** 01107 * Writes contents in a file in typo3temp/rtehtmlarea directory and returns the file name 01108 * 01109 * @param string $sourceFileName: The name of the file from which the contents should be extracted 01110 * @param string $label: A label to insert at the beginning of the name of the file 01111 * @param string $fileExtension: The file extension of the file, defaulting to 'js' 01112 * @param string $contents: The contents to write into the file if no $sourceFileName is provided 01113 * 01114 * @return string The name of the file writtten to typo3temp/rtehtmlarea 01115 */ 01116 public function writeTemporaryFile($sourceFileName='', $label, $fileExtension='js', $contents='', $concatenate = FALSE) { 01117 global $TYPO3_CONF_VARS; 01118 01119 if ($sourceFileName) { 01120 $output = ''; 01121 $source = t3lib_div::getFileAbsFileName($sourceFileName); 01122 $output = file_get_contents($source); 01123 } else { 01124 $output = $contents; 01125 } 01126 $compress = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] && ($fileExtension == 'js') && ($output != ''); 01127 $relativeFilename = 'typo3temp/' . $this->ID . '/' . str_replace('-','_',$label) . '_' . t3lib_div::shortMD5(($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . ($sourceFileName ? $sourceFileName : $output)), 20) . ($compress ? '_compressed' : '') . '.' . $fileExtension; 01128 $destination = PATH_site . $relativeFilename; 01129 if(!file_exists($destination)) { 01130 $compressedJavaScript = ''; 01131 if ($compress && $fileExtension == 'js') { 01132 $compressedJavaScript = t3lib_div::minifyJavaScript($output); 01133 } 01134 $failure = t3lib_div::writeFileToTypo3tempDir($destination, $compressedJavaScript ? $compressedJavaScript : $output); 01135 if ($failure) { 01136 die($failure); 01137 } 01138 } 01139 if ($concatenate && $fileExtension == 'js') { 01140 $this->cumulativeScripts[$this->TCEform->RTEcounter][] = $destination; 01141 } 01142 if ($this->is_FE()) { 01143 $filename = ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . t3lib_div::createVersionNumberedFilename($relativeFilename); 01144 } else { 01145 $filename = t3lib_div::createVersionNumberedFilename(($this->isFrontendEditActive() ? '' : ($this->backPath . '../')) . $relativeFilename); 01146 } 01147 return t3lib_div::resolveBackPath($filename); 01148 } 01149 /** 01150 * Concatenates all accumulated scripts in a file in typo3temp/rtehtmlarea directory and returns the file name 01151 * 01152 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 01153 * 01154 * @return string The name of the file writtten to typo3temp/rtehtmlarea 01155 */ 01156 protected function doConcatenate($RTEcounter) { 01157 $fileExtension = 'js'; 01158 $compress = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts']; 01159 $token = implode('|', $this->cumulativeScripts[$RTEcounter]); 01160 $relativeFilename = 'typo3temp/' . $this->ID . '/' . 'htmlarea_cumulative' . '_' . t3lib_div::shortMD5(($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . $token ), 20) . ($compress ? '_compressed' : '') . '.' . $fileExtension; 01161 $destination = PATH_site . $relativeFilename; 01162 if (!file_exists($destination)) { 01163 foreach ($this->cumulativeScripts[$RTEcounter] as $fileName) { 01164 $contents = file_get_contents($fileName); 01165 if (!file_exists($destination)) { 01166 $failure = t3lib_div::writeFileToTypo3tempDir($destination, $contents); 01167 if ($failure) { 01168 die($failure); 01169 } 01170 } else { 01171 $success = file_put_contents($destination, $contents, FILE_APPEND); 01172 if (!$success) { 01173 die('Could not append script' + $fileName); 01174 } 01175 } 01176 } 01177 } 01178 if ($this->is_FE()) { 01179 $filename = ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . t3lib_div::createVersionNumberedFilename($relativeFilename); 01180 } else { 01181 if ($compress) { 01182 $compressor = t3lib_div::makeInstance('t3lib_Compressor'); 01183 $filename = $compressor->compressJsFile(($this->isFrontendEditActive() ? '' : $this->backPath) . '../' . $relativeFilename); 01184 if ($this->isFrontendEditActive()) { 01185 $filename = preg_replace('/^..\//', '', $filename); 01186 } 01187 } else { 01188 $filename = t3lib_div::createVersionNumberedFilename(($this->isFrontendEditActive() ? '' : ($this->backPath . '../')) . $relativeFilename); 01189 } 01190 } 01191 return t3lib_div::resolveBackPath($filename); 01192 } 01193 01194 /** 01195 * Return a file name containing the main JS language array for HTMLArea 01196 * 01197 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 01198 * 01199 * @return string filename 01200 */ 01201 function buildJSMainLangFile($RTEcounter) { 01202 $contents = $this->buildJSMainLangArray() . LF; 01203 foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) { 01204 $contents .= $this->buildJSLangArray($pluginId) . LF; 01205 } 01206 return $this->writeTemporaryFile('', $this->language.'_'.$this->OutputCharset, 'js', $contents, TRUE); 01207 } 01208 01209 /** 01210 * Return a Javascript localization array for the plugin 01211 * 01212 * @param string $plugin: identification string of the plugin 01213 * 01214 * @return string Javascript localization array 01215 */ 01216 01217 function buildJSLangArray($plugin) { 01218 $LOCAL_LANG = FALSE; 01219 $extensionKey = is_object($this->registeredPlugins[$plugin]) ? $this->registeredPlugins[$plugin]->getExtensionKey() : $this->ID; 01220 $LOCAL_LANG = t3lib_div::readLLfile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $plugin . '/locallang.xml', $this->language, 'utf-8', 1); 01221 $linebreak = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : LF; 01222 $JSLanguageArray = 'HTMLArea.I18N["' . $plugin . '"] = new Object();' . $linebreak; 01223 if (is_array($LOCAL_LANG)) { 01224 if (!empty($LOCAL_LANG[$this->language])) { 01225 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'],$LOCAL_LANG[$this->language]); 01226 } else { 01227 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default']; 01228 } 01229 $JSLanguageArray .= 'HTMLArea.I18N["' . $plugin . '"] = ' . json_encode($LOCAL_LANG[$this->language]) . ';'. LF; 01230 } 01231 return $JSLanguageArray; 01232 } 01233 01234 /** 01235 * Return the JS code of the toolbar configuration for the HTMLArea editor 01236 * 01237 * @return string the JS code as nested JS arrays 01238 */ 01239 protected function getJSToolbarArray() { 01240 // The toolbar array 01241 $toolbar = array(); 01242 // The current row; a "linebreak" ends the current row 01243 $row = array(); 01244 // The current group; each group is between "bar"s; a "linebreak" ends the current group 01245 $group = array(); 01246 // Process each toolbar item in the toolbar order list 01247 foreach ($this->toolbarOrderArray as $item) { 01248 switch ($item) { 01249 case 'linebreak': 01250 // Add row to toolbar if not empty 01251 if (!empty($group)) { 01252 $row[] = $group; 01253 $group = array(); 01254 } 01255 if (!empty($row)) { 01256 $toolbar[] = $row; 01257 $row = array(); 01258 } 01259 break; 01260 case 'bar': 01261 // Add group to row if not empty 01262 if (!empty($group)) { 01263 $row[] = $group; 01264 $group = array(); 01265 } 01266 break; 01267 case 'space': 01268 if (end($group) != $this->convertToolbarForHTMLArea($item)) { 01269 $group[] = $this->convertToolbarForHTMLArea($item); 01270 } 01271 break; 01272 default: 01273 if (in_array($item, $this->toolbar)) { 01274 // Add the item to the group 01275 $convertedItem = $this->convertToolbarForHTMLArea($item); 01276 if ($convertedItem) { 01277 $group[] = $convertedItem; 01278 } 01279 } 01280 break; 01281 } 01282 } 01283 // Add the last group and last line, if not empty 01284 if (!empty($group)) { 01285 $row[] = $group; 01286 } 01287 if (!empty($row)) { 01288 $toolbar[] = $row; 01289 } 01290 return json_encode($toolbar); 01291 } 01292 01293 public function getLLContent($string) { 01294 global $LANG; 01295 01296 $BE_lang = $LANG->lang; 01297 $BE_charSet = $LANG->charSet; 01298 $LANG->lang = $this->contentTypo3Language; 01299 $LANG->charSet = $this->contentCharset; 01300 $LLString = $LANG->JScharCode($LANG->sL($string)); 01301 $LANG->lang = $BE_lang; 01302 $LANG->charSet = $BE_charSet; 01303 return $LLString; 01304 } 01305 01306 public function getPageConfigLabel($string,$JScharCode=1) { 01307 global $LANG, $TSFE, $TYPO3_CONF_VARS; 01308 01309 if ($this->is_FE()) { 01310 if (strcmp(substr($string,0,4),'LLL:') && $TYPO3_CONF_VARS['BE']['forceCharset']) { 01311 // A pure string coming from Page TSConfig must be in forceCharset, otherwise we just don't know.. 01312 $label = $TSFE->csConvObj->conv($TSFE->sL(trim($string)), $TYPO3_CONF_VARS['BE']['forceCharset'], $this->OutputCharset); 01313 } else { 01314 $label = $TSFE->csConvObj->conv($TSFE->sL(trim($string)), $this->charset, $this->OutputCharset); 01315 } 01316 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label)); 01317 $label = $JScharCode ? $this->feJScharCode($label) : $label; 01318 } else { 01319 if (strcmp(substr($string,0,4),'LLL:')) { 01320 $label = $string; 01321 } else { 01322 $label = $LANG->sL(trim($string)); 01323 } 01324 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label)); 01325 $label = $JScharCode ? $LANG->JScharCode($label): $label; 01326 } 01327 return $label; 01328 } 01329 01330 function feJScharCode($str) { 01331 global $TSFE; 01332 // Convert string to UTF-8: 01333 if ($this->OutputCharset != 'utf-8') $str = $TSFE->csConvObj->utf8_encode($str,$this->OutputCharset); 01334 // Convert the UTF-8 string into a array of char numbers: 01335 $nArr = $TSFE->csConvObj->utf8_to_numberarray($str); 01336 return 'String.fromCharCode('.implode(',',$nArr).')'; 01337 } 01338 01339 public function getFullFileName($filename) { 01340 if (substr($filename,0,4)=='EXT:') { // extension 01341 list($extKey,$local) = explode('/',substr($filename,4),2); 01342 $newFilename = ''; 01343 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) { 01344 $newFilename = (($this->is_FE() || $this->isFrontendEditActive()) ? t3lib_extMgm::siteRelPath($extKey) : $this->backPath . t3lib_extMgm::extRelPath($extKey)) . $local; 01345 } 01346 } elseif (substr($filename,0,1) != '/') { 01347 $newFilename = (($this->is_FE() || $this->isFrontendEditActive()) ? '' : ($this->backPath . '../')) . $filename; 01348 } else { 01349 $newFilename = (($this->is_FE() || $this->isFrontendEditActive()) ? '' : ($this->backPath . '../')) . substr($filename, 1); 01350 } 01351 return t3lib_div::resolveBackPath($newFilename); 01352 } 01353 01354 /** 01355 * Return the Javascript code for copying the HTML code from the editor into the hidden input field. 01356 * This is for submit function of the form. 01357 * 01358 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 01359 * @param string $formName: the name of the form 01360 * @param string $textareaId: the id of the textarea 01361 * @param string $textareaName: the name of the textarea 01362 * 01363 * @return string Javascript code 01364 */ 01365 function setSaveRTE($RTEcounter, $formName, $textareaId, $textareaName) { 01366 return 'if (RTEarea["' . $textareaId . '"]) { document.' . $formName . '["' . $textareaName . '"].value = RTEarea["' . $textareaId . '"].editor.getHTML(); } else { OK = 0; };'; 01367 } 01368 01369 /** 01370 * Return the Javascript code for copying the HTML code from the editor into the hidden input field. 01371 * This is for submit function of the form. 01372 * 01373 * @param integer $RTEcounter: The index number of the current RTE editing area within the form. 01374 * @param string $formName: the name of the form 01375 * @param string $textareaId: the id of the textarea 01376 * 01377 * @return string Javascript code 01378 */ 01379 function setDeleteRTE($RTEcounter, $formName, $textareaId) { 01380 return 'if (RTEarea["' . $textareaId . '"]) { RTEarea["' . $textareaId . '"].deleted = true;}'; 01381 } 01382 01383 /** 01384 * Return true if we are in the FE, but not in the FE editing feature of BE. 01385 * 01386 * @return boolean 01387 */ 01388 01389 function is_FE() { 01390 return is_object($GLOBALS['TSFE']) && !$this->isFrontendEditActive() && TYPO3_MODE=='FE'; 01391 } 01392 01393 /** 01394 * Checks whether frontend editing is active. 01395 * 01396 * @return boolean 01397 */ 01398 public function isFrontendEditActive() { 01399 return is_object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->beUserLogin && ($GLOBALS['BE_USER']->frontendEdit instanceof t3lib_frontendedit); 01400 } 01401 /** 01402 * Client Browser Information 01403 * 01404 * @param string $userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT') 01405 * @return array Contains keys "useragent", "browser", "version", "system" 01406 * where "browser" is limited to the engines 01407 * and where "version" is a floating number 01408 */ 01409 function clientInfo ($userAgent='') { 01410 if (!$userAgent) { 01411 $userAgent = t3lib_div::getIndpEnv('HTTP_USER_AGENT'); 01412 } 01413 $browserInfo = t3lib_utility_Client::getBrowserInfo($userAgent); 01414 // Known engines: order is not irrelevant! 01415 $knownEngines = array('opera', 'msie', 'gecko', 'webkit'); 01416 if (is_array($browserInfo['all'])) { 01417 foreach ($knownEngines as $engine) { 01418 if ($browserInfo['all'][$engine]) { 01419 $browserInfo['browser'] = $engine; 01420 $browserInfo['version'] = t3lib_utility_Client::getVersion($browserInfo['all'][$engine]); 01421 break; 01422 } 01423 } 01424 } 01425 return $browserInfo; 01426 } 01427 /*************************** 01428 * 01429 * OTHER FUNCTIONS: (from Classic RTE) 01430 * 01431 ***************************/ 01432 /** 01433 * @return [type] ... 01434 * @desc 01435 */ 01436 01437 function RTEtsConfigParams() { 01438 if($this->is_FE()) { 01439 return ''; 01440 } else { 01441 $p = t3lib_BEfunc::getSpecConfParametersFromArray($this->specConf['rte_transform']['parameters']); 01442 return $this->elementParts[0].':'.$this->elementParts[1].':'.$this->elementParts[2].':'.$this->thePid.':'.$this->typeVal.':'.$this->tscPID.':'.$p['imgpath']; 01443 } 01444 } 01445 01446 public function cleanList($str) { 01447 if (strstr($str,'*')) { 01448 $str = '*'; 01449 } else { 01450 $str = implode(',',array_unique(t3lib_div::trimExplode(',',$str,1))); 01451 } 01452 return $str; 01453 } 01454 01455 function filterStyleEl($elValue,$matchList) { 01456 $matchParts = t3lib_div::trimExplode(',',$matchList,1); 01457 $styleParts = explode(';',$elValue); 01458 $nStyle=array(); 01459 foreach ($styleParts as $k => $p) { 01460 $pp = t3lib_div::trimExplode(':',$p); 01461 if ($pp[0]&&$pp[1]) { 01462 foreach ($matchParts as $el) { 01463 $star=substr($el,-1)=='*'; 01464 if (!strcmp($pp[0],$el) || ($star && t3lib_div::isFirstPartOfStr($pp[0],substr($el,0,-1)) )) { 01465 $nStyle[]=$pp[0].':'.$pp[1]; 01466 } else unset($styleParts[$k]); 01467 } 01468 } else { 01469 unset($styleParts[$k]); 01470 } 01471 } 01472 return implode('; ',$nStyle); 01473 } 01474 01475 // Hook on lorem_ipsum extension to insert text into the RTE in wysiwyg mode 01476 function loremIpsumInsert($params) { 01477 return " 01478 if (typeof(lorem_ipsum) == 'function' && " . $params['element'] . ".tagName.toLowerCase() == 'textarea' ) lorem_ipsum(" . $params['element'] . ", lipsum_temp_strings[lipsum_temp_pointer]); 01479 "; 01480 } 01481 } 01482 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php'])) { 01483 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']); 01484 } 01485 ?>
1.8.0