00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 require_once(t3lib_extMgm::extPath('rtehtmlarea').'class.tx_rtehtmlarea_base.php');
00036 require_once(PATH_t3lib.'class.t3lib_parsehtml_proc.php');
00037 require_once(PATH_t3lib.'class.t3lib_befunc.php');
00038
00039 class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
00040
00041
00042 var $RTEWrapStyle = '';
00043 var $RTEdivStyle = '';
00044 var $extHttpPath;
00045
00046
00047 var $elementId;
00048 var $elementParts;
00049 var $tscPID;
00050 var $typeVal;
00051 var $thePid;
00052 var $RTEsetup;
00053 var $thisConfig;
00054 var $confValues;
00055 var $language;
00056 var $spellCheckerLanguage;
00057 var $spellCheckerCharset;
00058 var $spellCheckerMode;
00059 var $specConf;
00060 var $LOCAL_LANG;
00061
00077 function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue) {
00078 global $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
00079
00080
00081
00082 $this->TCEform = $pObj;
00083 $this->client = $this->clientInfo();
00084 $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
00085
00086
00087
00088
00089
00090
00091
00092 $this->httpTypo3Path = substr( substr( t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen( t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') ) ), 0, -1 );
00093 if (strlen($this->httpTypo3Path) == 1) {
00094 $this->httpTypo3Path = '/';
00095 } else {
00096 $this->httpTypo3Path .= '/';
00097 }
00098
00099 $this->extHttpPath = $this->httpTypo3Path.t3lib_extMgm::siteRelPath($this->ID);
00100
00101 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
00102
00103 $this->hostURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST');
00104
00105
00106 $this->elementId = $PA['itemFormElName'];
00107 $this->elementParts[0] = $table;
00108 $this->elementParts[1] = $row['uid'];
00109 $this->tscPID = $thePidValue;
00110 $this->thePid = $thePidValue;
00111
00112
00113 $this->typeVal = $RTEtypeVal;
00114
00115 unset($this->RTEsetup);
00116 $pageTSConfig = $TSFE->getPagesTSconfig();
00117 $this->RTEsetup = $pageTSConfig['RTE.'];
00118 $this->thisConfig = $this->RTEsetup['default.'];
00119 $this->thisConfig = $this->thisConfig['FE.'];
00120
00121
00122 $this->specConf = $specConf;
00123
00124 if ($this->thisConfig['forceHTTPS']) {
00125 $this->httpTypo3Path = preg_replace('/^(http|https)/', 'https', $this->httpTypo3Path);
00126 $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
00127 $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
00128 $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
00129 }
00130
00131
00132 $TSFE->initLLvars();
00133 $this->language = $TSFE->lang;
00134 $this->LOCAL_LANG = t3lib_div::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
00135 if ($this->language=='default' || !$this->language) {
00136 $this->language='en';
00137 }
00138
00139 $this->charset = $TSFE->labelsCharset;
00140 $this->OutputCharset = $TSFE->metaCharset ? $TSFE->metaCharset : $TSFE->renderCharset;
00141
00142
00143
00144
00145
00146
00147 $this->pluginEnableArray = array_intersect(t3lib_div::trimExplode(',', $this->pluginList , 1), t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['HTMLAreaPluginList'], 1));
00148 $hidePlugins = array('TYPO3Browsers', 'UserElements', 'Acronym', 'TYPO3HtmlParser');
00149 if ($this->client['BROWSER'] == 'opera') {
00150 $hidePlugins[] = 'ContextMenu';
00151 $this->thisConfig['hideTableOperationsInToolbar'] = 0;
00152 $this->thisConfig['disableEnterParagraphs'] = 1;
00153 }
00154 if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker';
00155 $this->pluginEnableArray = array_diff($this->pluginEnableArray, $hidePlugins);
00156 $this->pluginEnableArrayMultiple = $this->pluginEnableArray;
00157
00158
00159 $this->setToolBar();
00160
00161
00162 $this->setPlugins();
00163
00164
00165
00166
00167
00168
00169 if( $this->isPluginEnable('SpellChecker') ) {
00170
00171 $this->spellCheckerLanguage = $TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['defaultDictionary'];
00172 if($row['sys_language_uid']) {
00173 $tableA = 'sys_language';
00174 $tableB = 'static_languages';
00175 $languagesUidsList = $row['sys_language_uid'];
00176 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
00177 $table = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
00178 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
00179 $whereClause .= $TSFE->cObj->enableFields($tableA);
00180 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $table, $whereClause);
00181 while ( $languageRow = $TYPO3_DB->sql_fetch_assoc($res) ) {
00182 $this->spellCheckerLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):''));
00183 $this->spellCheckerTypo3Language = strtolower(trim($languageRow['lg_typo3']));
00184 }
00185 }
00186 $this->spellCheckerLanguage = $this->spellCheckerLanguage?$this->spellCheckerLanguage:$this->language;
00187 $this->spellCheckerTypo3Language = $this->spellCheckerTypo3Language?$this->spellCheckerTypo3Language:$TSFE->lang;
00188 if ($this->spellCheckerTypo3Language=='default') {
00189 $this->spellCheckerTypo3Language='en';
00190 }
00191
00192
00193 $this->spellCheckerCharset = $TSFE->csConvObj->charSetArray[$this->spellCheckerTypo3Language];
00194 $this->spellCheckerCharset = $this->spellCheckerCharset ? $this->spellCheckerCharset : 'iso-8859-1';
00195 $this->spellCheckerCharset = trim($TSFE->config['config']['metaCharset']) ? trim($TSFE->config['config']['metaCharset']) : $this->spellCheckerCharset;
00196
00197
00198 $this->spellCheckerMode = isset($this->thisConfig['HTMLAreaPspellMode']) ? trim($this->thisConfig['HTMLAreaPspellMode']) : 'normal';
00199 if( !in_array($this->spellCheckerMode, $this->spellCheckerModes)) {
00200 $this->spellCheckerMode = 'normal';
00201 }
00202 }
00203
00204 if( $this->isPluginEnable('QuickTag') && trim($this->thisConfig['hideTags'])) {
00205 $this->quickTagHideTags = implode(',', t3lib_div::trimExplode(',', $this->thisConfig['hideTags'], 1));
00206 }
00207
00208
00209
00210
00211
00212
00213 $RTEWidth = 460+($pObj->docLarge ? 150 : 0);
00214 $RTEHeight = 380;
00215 $editorWrapWidth = $RTEWidth . 'px';
00216 $editorWrapHeight = $RTEHeight . 'px';
00217 $this->RTEWrapStyle = $this->RTEWrapStyle ? $this->RTEWrapStyle : ($this->RTEdivStyle ? $this->RTEdivStyle : ('height:' . ($RTEHeight+2) . 'px; width:'. ($RTEWidth+2) . 'px;'));
00218 $this->RTEdivStyle = $this->RTEdivStyle ? $this->RTEdivStyle : 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:'.$RTEWidth.'px; border: 1px solid black;';
00219 $this->toolbar_level_size = $RTEWidth;
00220
00221
00222
00223
00224
00225
00226 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css';
00227 $additionalCode_loadCSS = '
00228 <link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" />';
00229
00230
00231 $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
00232 if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:') {
00233 $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
00234 }
00235 if (substr($skinFilename,0,4) == 'EXT:') {
00236 list($extKey,$local) = explode('/',substr($skinFilename,4),2);
00237 $skinFilename='';
00238 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
00239 $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey).$local;
00240 $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
00241 }
00242 } elseif (substr($skinFilename,0,1) != '/') {
00243 $skinDir = $this->siteURL.dirname($skinFilename);
00244 $skinFilename = $this->siteURL.$skinFilename;
00245 } else {
00246 $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
00247 }
00248
00249 $this->editorCSS = $skinFilename;
00250 $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
00251 $additionalCode_loadCSS .= '
00252 <link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
00253 $additionalCode_loadCSS .= '
00254 <link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
00255
00256
00257 $TSFE->additionalHeaderData['htmlArea'] = $additionalCode_loadCSS;
00258 $pObj->additionalJS_initial = $this->loadJSfiles($pObj->RTEcounter);
00259 $pObj->additionalJS_pre[] = $this->loadJScode($pObj->RTEcounter);
00260
00261
00262
00263
00264
00265
00266 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
00267 if ($this->client['BROWSER'] == 'gecko') {
00268
00269 $value = preg_replace('/<(\/?)strong/i', "<$1b", $value);
00270
00271 $value = preg_replace('/<(\/?)em([^b>]*>)/i', "<$1i$2", $value);
00272 }
00273
00274
00275 $pObj->RTEwindows[] = $PA['itemFormElName'];
00276
00277
00278 $pObj->additionalJS_post[] = $this->registerRTEinJS($pObj->RTEcounter);
00279
00280
00281 $pObj->additionalJS_submit[] = $this->setSaveRTE($pObj->RTEcounter, $pObj->formName, htmlspecialchars($PA['itemFormElName']));
00282
00283
00284 $visibility = 'hidden';
00285 $item = $this->triggerField($PA['itemFormElName']).'
00286 <div id="pleasewait' . $pObj->RTEcounter . '" class="pleasewait" style="display: none;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait',$this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
00287 <div id="editorWrap' . $pObj->RTEcounter . '" class="editorWrap" style="'. htmlspecialchars($this->RTEWrapStyle). '">
00288 <textarea id="RTEarea'.$pObj->RTEcounter.'" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.htmlspecialchars($this->RTEdivStyle).'">'.t3lib_div::formatForTextarea($value).'</textarea>
00289 </div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
00290 ';
00291 return $item;
00292 }
00293
00300 function setSaveRTE($number, $form, $textarea) {
00301 return '
00302 editornumber = '.$number.';
00303 if (RTEarea[editornumber]) {
00304 fields = document.getElementsByName(\'' . $textarea . '\');
00305 field = fields.item(0);
00306 if(field && field.tagName.toLowerCase() == \'textarea\') field.value = RTEarea[editornumber][\'editor\'].getHTML();
00307 }
00308 else {
00309 OK=0;
00310 }
00311 ';
00312 }
00313
00314 }
00315
00316 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php']) {
00317 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php']);
00318 }
00319
00320 ?>