📄 class.tx_rtehtmlarea_base.php
字号:
if (is_array($browserConf)) { reset($browserConf); while(list ($browserConfNr, $browserConfSub) = each($browserConf)){ if ($browserConfSub['version'] <= $this->client['VERSION'] || empty($browserConfSub['version'])) { // Version is correct if ($browserConfSub['system'] == $this->client['SYSTEM'] || empty($browserConfSub['system'])) { // System is correctly $rteIsAvailable = 1; }// End of System }// End of Version }// End of while-BrowserSubpart } else { // no config for this browser found, so all versions or system with this browsers are allow $rteIsAvailable = 1; } } // End of Browser Check } // while: Browser Check } else { // no Browser config for this RTE-Editor, so all Clients are allow } if (!$rteIsAvailable) { $this->errorLog[] = 'rte: Browser not supported. Only msie Version 5 or higher and Mozilla based client 1. and higher.'; } if (t3lib_div::int_from_ver(TYPO3_version) < 3007000) { $rteIsAvailable = 0; $this->errorLog[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.'; } } if ($rteIsAvailable) return true; } /** * Draws the RTE as an iframe * * @param object Reference to parent object, which is an instance of the TCEforms. * @param string The table name * @param string The field name * @param array The current row from which field is being rendered * @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. * @param array "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array. * @param array Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc. * @param string Record "type" field value. * @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! * @param integer PID value of record (true parent page id) * @return string HTML code for RTE! */ function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue) { global $BE_USER,$LANG, $TYPO3_DB, $TYPO3_CONF_VARS; $this->TCEform = $pObj; $inline =& $this->TCEform->inline; $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml'); $this->client = $this->clientInfo(); $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version); $this->userUid = 'BE_' . $BE_USER->user['uid']; // Draw form element: if ($this->debugMode) { // Draws regular text area (debug mode) $item = parent::drawRTE($pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue); } else { // Draw real RTE /* ======================================= * INIT THE EDITOR-SETTINGS * ======================================= */ // first get the http-path to typo3: $this->httpTypo3Path = substr( substr( t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen( t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') ) ), 0, -1 ); if (strlen($this->httpTypo3Path) == 1) { $this->httpTypo3Path = '/'; } else { $this->httpTypo3Path .= '/'; } // Get the path to this extension: $this->extHttpPath = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->ID); // Get the site URL $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Get the host URL $this->hostURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'); // Element ID + pid $this->elementId = $PA['itemFormElName']; // Form element name $this->elementParts = explode('][',ereg_replace('\]$','',ereg_replace('^(TSFE_EDIT\[data\]\[|data\[)','',$this->elementId))); // Find the page PIDs: list($this->tscPID,$this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]),trim($this->elementParts[1]),$thePidValue); // Record "types" field value: $this->typeVal = $RTEtypeVal; // TCA "types" value for record // Find "thisConfig" for record/editor: unset($this->RTEsetup); $this->RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($this->tscPID)); $this->thisConfig = $thisConfig; // Special configuration and default extras: $this->specConf = $specConf; if ($this->thisConfig['forceHTTPS']) { $this->httpTypo3Path = preg_replace('/^(http|https)/', 'https', $this->httpTypo3Path); $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath); $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL); $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL); } /* ======================================= * LANGUAGES & CHARACTER SETS * ======================================= */ // Languages: interface and content $this->language = $LANG->lang; if ($this->language=='default' || !$this->language) { $this->language='en'; } $this->contentTypo3Language = $this->language; $this->contentLanguageUid = ($row['sys_language_uid'] > 0) ? $row['sys_language_uid'] : 0; if (t3lib_extMgm::isLoaded('static_info_tables')) { if ($this->contentLanguageUid) { $tableA = 'sys_language'; $tableB = 'static_languages'; $languagesUidsList = $this->contentLanguageUid; $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3'; $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid'; $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') '; $whereClause .= t3lib_BEfunc::BEenableFields($tableA); $whereClause .= t3lib_BEfunc::deleteClause($tableA); $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause); while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) { $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):'')); $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3'])); } } else { $this->contentISOLanguage = trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) ? trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) : 'en'; $selectFields = 'lg_iso_2, lg_typo3'; $tableAB = 'static_languages'; $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB); $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause); while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) { $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3'])); } } } // Character sets: interface and content $this->charset = $LANG->csConvObj->charSetArray[$this->language]; $this->charset = $this->charset ? $this->charset : 'iso-8859-1'; $this->BECharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->charset; $this->OutputCharset = $this->BECharset; $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language]; $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1'; $this->origContentCharSet = $this->contentCharset; $this->contentCharset = (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset); /* ======================================= * TOOLBAR CONFIGURATION * ======================================= */ // htmlArea plugins list $this->pluginEnableArray = array_intersect(t3lib_div::trimExplode(',', $this->pluginList , 1), t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['HTMLAreaPluginList'], 1)); $hidePlugins = array(); if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker'; if ($this->client['BROWSER'] == 'msie') $hidePlugins[] = 'Acronym'; if ($this->client['BROWSER'] == 'opera') { $hidePlugins[] = 'ContextMenu'; $this->thisConfig['hideTableOperationsInToolbar'] = 0; $this->thisConfig['disableEnterParagraphs'] = 1; } $this->pluginEnableArray = array_diff($this->pluginEnableArray, $hidePlugins); $this->pluginEnableArrayMultiple = $this->pluginEnableArray; // Toolbar $this->setToolBar(); // Check if some plugins need to be disabled $this->setPlugins(); /* ======================================= * PLUGIN-SPECIFIC CONFIGURATION * ======================================= */ if ($this->isPluginEnable('SpellChecker')) { // Set the language of the content for the SpellChecker $this->spellCheckerLanguage = $this->contentISOLanguage; $this->spellCheckerTypo3Language = $this->contentTypo3Language; // Set the charset of the content for the SpellChecker $this->spellCheckerCharset = $this->contentCharset; $this->spellCheckerCharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->spellCheckerCharset; // Set the SpellChecker mode $this->spellCheckerMode = isset($BE_USER->userTS['options.']['HTMLAreaPspellMode']) ? trim($BE_USER->userTS['options.']['HTMLAreaPspellMode']) : 'normal'; if( !in_array($this->spellCheckerMode, $this->spellCheckerModes)) { $this->spellCheckerMode = 'normal'; } // Set the use of personal dictionary $this->spellCheckerPersonalDicts = $this->thisConfig['enablePersonalDicts'] ? ((isset($BE_USER->userTS['options.']['enablePersonalDicts']) && $BE_USER->userTS['options.']['enablePersonalDicts']) ? true : false) : false; if (ini_get('safe_mode')) { $this->spellCheckerPersonalDicts = false; } } /* ======================================= * SET STYLES * ======================================= */ $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530'; $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380'; $RTEWidth = $RTEWidth + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150') : 0); $RTEWidth -= ($inline->getStructureDepth() > 0 ? ($inline->getStructureDepth()+1)*$inline->getLevelMargin() : 0); $RTEHeight = $RTEHeight + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0) : 0); $editorWrapWidth = $RTEWidth . 'px'; $editorWrapHeight = $RTEHeight . 'px'; $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:'.$RTEWidth.'px; border: 1px solid black; padding: 2px 0px 2px 2px;'; $this->toolbar_level_size = $RTEWidth; /* ======================================= * LOAD CSS AND JAVASCRIPT * ======================================= */ // Preloading the pageStyle $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css'; if ($pObj->RTEcounter == 1) { $pObj->additionalCode_pre['loadCSS'] = "\n\t\t".'<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" />'; } // Loading the editor skin $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css'; if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:') { $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css'; } if (substr($skinFilename,0,4) == 'EXT:') { // extension list($extKey,$local) = explode('/',substr($skinFilename,4),2); $skinFilename=''; if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) { $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local; $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local); } } elseif (substr($skinFilename,0,1) != '/') { $skinDir = $this->siteURL.dirname($skinFilename); $skinFilename = $this->siteURL . $skinFilename; } else { $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename); } $this->editorCSS = $skinFilename; $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css'; if ($pObj->RTEcounter == 1) { $pObj->additionalCode_pre['loadCSS'] .= "\n\t\t".'<link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />'; $pObj->additionalCode_pre['loadCSS'] .= "\n\t\t".'<link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />'; // Loading JavaScript files and code $pObj->additionalCode_pre['loadJSfiles'] = $this->loadJSfiles($pObj->RTEcounter); $pObj->additionalJS_pre['loadJScode'] = $this->loadJScode($pObj->RTEcounter); } /* ======================================= * DRAW THE EDITOR * ======================================= */ // Transform value: $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue); // Change some tags if ($this->client['BROWSER'] == 'gecko') { // change <strong> to <b> $value = preg_replace('/<(\/?)strong/i', "<$1b", $value); // change <em> to <i> $value = preg_replace('/<(\/?)em([^b>]*>)/i', "<$1i$2", $value); } if ($this->client['BROWSER'] == 'msie') { // change <abbr> to <acronym> $value = preg_replace('/<(\/?)abbr/i', "<$1acronym", $value); } // Register RTE windows $pObj->RTEwindows[] = $PA['itemFormElName']; // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS if (basename(PATH_thisScript) == 'wizard_rte.php') { $height = 'window.innerHeight'; $width = 'window.innerWidth'; if ($this->client['BROWSER'] == 'msie') { $height = 'document.body.offsetHeight'; $width = 'document.body.offsetWidth'; } $editorWrapWidth = '100%'; $editorWrapHeight = '100%'; $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;'; $pObj->additionalJS_post[] = $this->setRTEsizeByJS('RTEarea'.$pObj->RTEcounter, $height, $width); } // Register RTE in JS: $pObj->additionalJS_post[] = $this->registerRTEinJS($pObj->RTEcounter, $table, $row['uid'], $field); // Set the save option for the RTE:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -