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
00027
00028
00038 require_once(PATH_t3lib.'class.t3lib_rteapi.php');
00039 require_once(PATH_t3lib.'class.t3lib_cs.php');
00040
00041 class tx_rtehtmlarea_base extends t3lib_rteapi {
00042
00043
00044 var $conf_supported_browser = array (
00045 'msie' => array (
00046 1 => array (
00047 'version' => 5.5,
00048 'system' => 'win'
00049 )
00050 ),
00051 'gecko' => array (
00052 1 => array (
00053 'version' => 1.3
00054 )
00055 ),
00056 'safari' => array (
00057 1 => array (
00058 'version' => 312
00059 )
00060 ),
00061 'opera' => array (
00062 1 => array (
00063 'version' => 9
00064 )
00065 )
00066 );
00067
00068
00069 var $conf_toolbar_hide = array (
00070 'showhelp',
00071 );
00072
00073
00074 var $conf_toolbar_safari_hide = array (
00075 'strikethrough',
00076 'line',
00077 'orderedlist',
00078 'unorderedlist',
00079 );
00080
00081
00082 var $conf_toolbar_opera_hide = array (
00083 'copy',
00084 'cut',
00085 'paste',
00086 );
00087
00088
00089 var $conf_toolbar_show = array (
00090 'undo',
00091 'redo',
00092
00093 'about',
00094 );
00095
00096
00097 var $defaultToolbarOrder;
00098
00099
00100 var $defaultHotKeyList = 'selectall, bold, italic, underline, strikethrough, left, center, right, justifyfull, formatblock, paste, cleanword, undo, redo';
00101
00102
00103 var $conf_toolbar_convert = array (
00104
00105 'fontstyle' => 'FontName',
00106 'fontsize' => 'FontSize',
00107 'textcolor' => 'ForeColor',
00108 'bgcolor' => 'HiliteColor',
00109 'bold' => 'Bold',
00110 'italic' => 'Italic',
00111 'underline' => 'Underline',
00112 'left' => 'JustifyLeft',
00113 'center' => 'JustifyCenter',
00114 'right' => 'JustifyRight',
00115 'orderedlist' => 'InsertOrderedList',
00116 'unorderedlist' => 'InsertUnorderedList',
00117 'outdent' => 'Outdent',
00118 'indent' => 'Indent',
00119 'emoticon' => 'InsertSmiley',
00120 'line' => 'InsertHorizontalRule',
00121 'link' => 'CreateLink',
00122 'table' => 'InsertTable',
00123 'image' => 'InsertImage',
00124 'cut' => 'Cut',
00125 'copy' => 'Copy',
00126 'paste' => 'Paste',
00127 'formatblock' => 'FormatBlock',
00128 'chMode' => 'HtmlMode',
00129 'user' => 'UserElements',
00130
00131
00132 'lefttoright' => 'LeftToRight',
00133 'righttoleft' => 'RightToLeft',
00134 'justifyfull' => 'JustifyFull',
00135 'strikethrough' => 'StrikeThrough',
00136 'superscript' => 'Superscript',
00137 'subscript' => 'Subscript',
00138 'showhelp' => 'ShowHelp',
00139 'insertcharacter' => 'InsertCharacter',
00140 'findreplace' => 'FindReplace',
00141 'spellcheck' => 'SpellCheck',
00142 'removeformat' => 'RemoveFormat',
00143 'inserttag' => 'InsertTag',
00144 'acronym' => 'Acronym',
00145 'splitblock' => 'SplitBlock',
00146 'blockstylelabel' => 'I[style]',
00147 'blockstyle' => 'DynamicCSS-class',
00148 'textstylelabel' => 'I[text_style]',
00149 'textstyle' => 'InlineCSS-class',
00150 'toggleborders' => 'TO-toggle-borders',
00151 'tableproperties' => 'TO-table-prop',
00152 'rowproperties' => 'TO-row-prop',
00153 'rowinsertabove' => 'TO-row-insert-above',
00154 'rowinsertunder' => 'TO-row-insert-under',
00155 'rowdelete' => 'TO-row-delete',
00156 'rowsplit' => 'TO-row-split',
00157 'columninsertbefore' => 'TO-col-insert-before',
00158 'columninsertafter' => 'TO-col-insert-after',
00159 'columndelete' => 'TO-col-delete',
00160 'columnsplit' => 'TO-col-split',
00161 'cellproperties' => 'TO-cell-prop',
00162 'cellinsertbefore' => 'TO-cell-insert-before',
00163 'cellinsertafter' => 'TO-cell-insert-after',
00164 'celldelete' => 'TO-cell-delete',
00165 'cellsplit' => 'TO-cell-split',
00166 'cellmerge' => 'TO-cell-merge',
00167
00168
00169 'space' => 'space',
00170 'bar' => 'separator',
00171 'linebreak' => 'linebreak',
00172
00173
00174 'undo' => 'Undo',
00175 'redo' => 'Redo',
00176 'textindicator' => 'TextIndicator',
00177 'about' => 'About',
00178 );
00179
00180 var $defaultParagraphs = array(
00181 'p' => 'Normal',
00182 'h1' => 'Heading 1',
00183 'h2' => 'Heading 2',
00184 'h3' => 'Heading 3',
00185 'h4' => 'Heading 4',
00186 'h5' => 'Heading 5',
00187 'h6' => 'Heading 6',
00188 'pre' => 'Preformatted',
00189 'address' => 'Address',
00190 );
00191
00192 var $defaultFontFaces = array(
00193 'Arial' => 'Arial,sans-serif',
00194 'Arial Black' => 'Arial Black,sans-serif',
00195 'Verdana' => 'Verdana,Arial,sans-serif',
00196 'Times New Roman' => 'Times New Roman,Times,serif',
00197 'Garamond' => 'Garamond',
00198 'Lucida Handwriting' => 'Lucida Handwriting',
00199 'Courier' => 'Courier',
00200 'Webdings' => 'Webdings',
00201 'Wingdings' => 'Wingdings',
00202 );
00203
00204 var $defaultFontSizes = array(
00205 '1' => '1 (8 pt)',
00206 '2' => '2 (10 pt)',
00207 '3' => '3 (12 pt)',
00208 '4' => '4 (14 pt)',
00209 '5' => '5 (18 pt)',
00210 '6' => '6 (24 pt)',
00211 '7' => '7 (36 pt)',
00212 );
00213
00214 var $defaultFontSizes_safari = array(
00215 '1' => 'xx-small',
00216 '2' => 'x-small',
00217 '3' => 'small',
00218 '4' => 'medium',
00219 '5' => 'large',
00220 '6' => 'x-large',
00221 '7' => 'xx-large',
00222 );
00223
00224 var $pluginList = 'TableOperations, ContextMenu, SpellChecker, SelectColor, TYPO3Browsers, InsertSmiley, FindReplace, RemoveFormat, CharacterMap, QuickTag, InlineCSS, DynamicCSS, UserElements, Acronym, TYPO3HtmlParser';
00225
00226 var $pluginButton = array(
00227 'InlineCSS' => 'textstyle',
00228 'DynamicCSS' => 'blockstyle',
00229 'SpellChecker' => 'spellcheck',
00230 'InsertSmiley' => 'emoticon',
00231 'FindReplace' => 'findreplace',
00232 'RemoveFormat' => 'removeformat',
00233 'QuickTag' => 'inserttag',
00234 'CharacterMap' => 'insertcharacter',
00235 'TableOperations' => 'table, toggleborders, tableproperties, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit,
00236 columninsertbefore, columninsertafter, columndelete, columnsplit,
00237 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge',
00238 'UserElements' => 'user',
00239 'Acronym' => 'acronym',
00240 );
00241
00242 var $pluginLabel = array(
00243 'InlineCSS' => 'textstylelabel',
00244 'DynamicCSS' => 'blockstylelabel',
00245 );
00246
00247 var $spellCheckerModes = array( 'ultra', 'fast', 'normal', 'bad-spellers');
00248
00249
00250 var $RTEdivStyle;
00251 var $extHttpPath;
00252 var $siteURL;
00253 var $hostURL;
00254 var $typoVersion;
00255
00256
00257 var $ID = 'rtehtmlarea';
00258 var $debugMode = FALSE;
00259
00260
00261 var $client;
00262 var $TCEform;
00263 var $elementId;
00264 var $elementParts;
00265 var $tscPID;
00266 var $typeVal;
00267 var $thePid;
00268 var $RTEsetup;
00269 var $thisConfig;
00270 var $confValues;
00271 var $language;
00272 var $BECharset;
00273 var $OutputCharset;
00274 var $editorCSS;
00275 var $spellCheckerLanguage;
00276 var $spellCheckerCharset;
00277 var $spellCheckerMode;
00278 var $quickTagHideTags;
00279 var $specConf;
00280 var $toolBar = array();
00281 var $toolbar_level_size;
00282 var $toolbarOrderArray = array();
00283 var $pluginEnableList;
00284 var $pluginEnableArray = array();
00285
00293 function isAvailable() {
00294 global $TYPO3_CONF_VARS;
00295
00296 $this->client = $this->clientInfo();
00297 $this->errorLog = array();
00298 if (!$this->debugMode) {
00299 $rteIsAvailable = 0;
00300 $rteConfBrowser = $this->conf_supported_browser;
00301 if (!$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['enableInOpera9']) unset($rteConfBrowser['opera']);
00302 if (is_array($rteConfBrowser)) {
00303 reset($rteConfBrowser);
00304 while(list ($browser, $browserConf) = each($rteConfBrowser)){
00305 if ($browser == $this->client['BROWSER']) {
00306
00307 if (is_array($browserConf)) {
00308 reset($browserConf);
00309 while(list ($browserConfNr, $browserConfSub) = each($browserConf)){
00310 if ($browserConfSub['version'] <= $this->client['VERSION'] || empty($browserConfSub['version'])) {
00311
00312 if ($browserConfSub['system'] == $this->client['SYSTEM'] || empty($browserConfSub['system'])) {
00313
00314 $rteIsAvailable = 1;
00315 }
00316 }
00317 }
00318 } else {
00319
00320 $rteIsAvailable = 1;
00321 }
00322 }
00323 }
00324 } else {
00325
00326 }
00327 if (!$rteIsAvailable) {
00328 $this->errorLog[] = 'rte: Browser not supported. Only msie Version 5 or higher and Mozilla based client 1. and higher.';
00329 }
00330 if (t3lib_div::int_from_ver(TYPO3_version) < 3007000) {
00331 $rteIsAvailable = 0;
00332 $this->errorLog[] = 'rte: This version of htmlArea RTE cannot run under this version of TYPO3.';
00333 }
00334 }
00335 if ($rteIsAvailable) return true;
00336 }
00337
00354 function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue) {
00355 global $BE_USER,$LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
00356
00357 $this->TCEform = $pObj;
00358 $inline =& $this->TCEform->inline;
00359
00360 $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
00361 $this->client = $this->clientInfo();
00362 $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
00363 $this->userUid = 'BE_' . $BE_USER->user['uid'];
00364
00365
00366 if ($this->debugMode) {
00367 $item = parent::drawRTE($pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
00368 } else {
00369
00370
00371
00372
00373
00374
00375
00376 $this->httpTypo3Path = substr( substr( t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen( t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') ) ), 0, -1 );
00377 if (strlen($this->httpTypo3Path) == 1) {
00378 $this->httpTypo3Path = '/';
00379 } else {
00380 $this->httpTypo3Path .= '/';
00381 }
00382
00383 $this->extHttpPath = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->ID);
00384
00385 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
00386
00387 $this->hostURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST');
00388
00389
00390 $this->elementId = $PA['itemFormElName'];
00391 $this->elementParts = explode('][',ereg_replace('\]$','',ereg_replace('^(TSFE_EDIT\[data\]\[|data\[)','',$this->elementId)));
00392
00393
00394 list($this->tscPID,$this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]),trim($this->elementParts[1]),$thePidValue);
00395
00396
00397 $this->typeVal = $RTEtypeVal;
00398
00399
00400 unset($this->RTEsetup);
00401 $this->RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($this->tscPID));
00402 $this->thisConfig = $thisConfig;
00403
00404
00405 $this->specConf = $specConf;
00406
00407 if ($this->thisConfig['forceHTTPS']) {
00408 $this->httpTypo3Path = preg_replace('/^(http|https)/', 'https', $this->httpTypo3Path);
00409 $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
00410 $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
00411 $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
00412 }
00413
00414
00415
00416
00417
00418
00419
00420 $this->language = $LANG->lang;
00421 if ($this->language=='default' || !$this->language) {
00422 $this->language='en';
00423 }
00424 $this->contentTypo3Language = $this->language;
00425
00426 $this->contentLanguageUid = ($row['sys_language_uid'] > 0) ? $row['sys_language_uid'] : 0;
00427 if (t3lib_extMgm::isLoaded('static_info_tables')) {
00428 if ($this->contentLanguageUid) {
00429 $tableA = 'sys_language';
00430 $tableB = 'static_languages';
00431 $languagesUidsList = $this->contentLanguageUid;
00432 $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
00433 $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
00434 $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
00435 $whereClause .= t3lib_BEfunc::BEenableFields($tableA);
00436 $whereClause .= t3lib_BEfunc::deleteClause($tableA);
00437 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
00438 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
00439 $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']).(trim($languageRow['lg_country_iso_2'])?'_'.trim($languageRow['lg_country_iso_2']):''));
00440 $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
00441 }
00442 } else {
00443 $this->contentISOLanguage = trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) ? trim($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['defaultDictionary']) : 'en';
00444 $selectFields = 'lg_iso_2, lg_typo3';
00445 $tableAB = 'static_languages';
00446 $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
00447 $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
00448 while($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
00449 $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
00450 }
00451 }
00452 }
00453
00454
00455 $this->charset = $LANG->csConvObj->charSetArray[$this->language];
00456 $this->charset = $this->charset ? $this->charset : 'iso-8859-1';
00457 $this->BECharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->charset;
00458 $this->OutputCharset = $this->BECharset;
00459
00460 $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
00461 $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
00462 $this->origContentCharSet = $this->contentCharset;
00463 $this->contentCharset = (trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset);
00464
00465
00466
00467
00468
00469
00470
00471 $this->pluginEnableArray = array_intersect(t3lib_div::trimExplode(',', $this->pluginList , 1), t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['HTMLAreaPluginList'], 1));
00472 $hidePlugins = array();
00473 if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker';
00474 if ($this->client['BROWSER'] == 'msie') $hidePlugins[] = 'Acronym';
00475 if ($this->client['BROWSER'] == 'opera') {
00476 $hidePlugins[] = 'ContextMenu';
00477 $this->thisConfig['hideTableOperationsInToolbar'] = 0;
00478 $this->thisConfig['disableEnterParagraphs'] = 1;
00479 }
00480 $this->pluginEnableArray = array_diff($this->pluginEnableArray, $hidePlugins);
00481 $this->pluginEnableArrayMultiple = $this->pluginEnableArray;
00482
00483
00484 $this->setToolBar();
00485
00486
00487 $this->setPlugins();
00488
00489
00490
00491
00492
00493
00494 if ($this->isPluginEnable('SpellChecker')) {
00495
00496 $this->spellCheckerLanguage = $this->contentISOLanguage;
00497 $this->spellCheckerTypo3Language = $this->contentTypo3Language;
00498
00499
00500 $this->spellCheckerCharset = $this->contentCharset;
00501 $this->spellCheckerCharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->spellCheckerCharset;
00502
00503
00504 $this->spellCheckerMode = isset($BE_USER->userTS['options.']['HTMLAreaPspellMode']) ? trim($BE_USER->userTS['options.']['HTMLAreaPspellMode']) : 'normal';
00505 if( !in_array($this->spellCheckerMode, $this->spellCheckerModes)) {
00506 $this->spellCheckerMode = 'normal';
00507 }
00508
00509
00510 $this->spellCheckerPersonalDicts = $this->thisConfig['enablePersonalDicts'] ? (isset($BE_USER->userTS['options.']['enablePersonalDicts']) ? true : false) : false;
00511 if (ini_get('safe_mode')) {
00512 $this->spellCheckerPersonalDicts = false;
00513 }
00514 }
00515
00516
00517
00518
00519
00520
00521 $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530';
00522 $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380';
00523 $RTEWidth = $RTEWidth + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150') : 0);
00524 $RTEWidth -= ($inline->getStructureDepth() > 0 ? ($inline->getStructureDepth()+1)*$inline->getLevelMargin() : 0);
00525 $RTEHeight = $RTEHeight + ($pObj->docLarge ? (isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0) : 0);
00526 $editorWrapWidth = $RTEWidth . 'px';
00527 $editorWrapHeight = $RTEHeight . 'px';
00528 $this->RTEdivStyle = $this->RTEdivStyle ? $this->RTEdivStyle : 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:'.$RTEWidth.'px; border: 1px solid black; padding: 2px 0px 2px 2px;';
00529 $this->toolbar_level_size = $RTEWidth;
00530
00531
00532
00533
00534
00535
00536
00537 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css';
00538 $pObj->additionalCode_pre['loadCSS'] = '
00539 <link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" />';
00540
00541
00542 $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
00543 if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:') {
00544 $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
00545 }
00546 if (substr($skinFilename,0,4) == 'EXT:') {
00547 list($extKey,$local) = explode('/',substr($skinFilename,4),2);
00548 $skinFilename='';
00549 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
00550 $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local;
00551 $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
00552 }
00553 } elseif (substr($skinFilename,0,1) != '/') {
00554 $skinDir = $this->siteURL.dirname($skinFilename);
00555 $skinFilename = $this->siteURL . $skinFilename;
00556 } else {
00557 $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
00558 }
00559 $this->editorCSS = $skinFilename;
00560 $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
00561 $pObj->additionalCode_pre['loadCSS'] .= '
00562 <link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
00563
00564 $pObj->additionalCode_pre['loadCSS'] .= '
00565 <link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
00566
00567
00568 $pObj->additionalCode_pre['loadJSfiles'] = $this->loadJSfiles($pObj->RTEcounter);
00569 $pObj->additionalJS_pre['loadJScode'] = $this->loadJScode($pObj->RTEcounter);
00570
00571
00572
00573
00574
00575
00576
00577 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
00578
00579
00580 if ($this->client['BROWSER'] == 'gecko') {
00581
00582 $value = preg_replace('/<(\/?)strong/i', "<$1b", $value);
00583
00584 $value = preg_replace('/<(\/?)em([^b>]*>)/i', "<$1i$2", $value);
00585 }
00586 if ($this->client['BROWSER'] == 'msie') {
00587
00588 $value = preg_replace('/<(\/?)abbr/i', "<$1acronym", $value);
00589 }
00590
00591
00592 $pObj->RTEwindows[] = $PA['itemFormElName'];
00593
00594
00595 if (basename(PATH_thisScript) == 'wizard_rte.php') {
00596 $height = 'window.innerHeight';
00597 $width = 'window.innerWidth';
00598 if ($this->client['BROWSER'] == 'msie') {
00599 $height = 'document.body.offsetHeight';
00600 $width = 'document.body.offsetWidth';
00601 }
00602 $editorWrapWidth = '100%';
00603 $editorWrapHeight = '100%';
00604 $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
00605 $pObj->additionalJS_post[] = $this->setRTEsizeByJS('RTEarea'.$pObj->RTEcounter, $height, $width);
00606 }
00607
00608
00609 $pObj->additionalJS_post[] = $this->registerRTEinJS($pObj->RTEcounter, $table, $row['uid'], $field);
00610
00611
00612 $pObj->additionalJS_submit[] = $this->setSaveRTE($pObj->RTEcounter, $pObj->formName, htmlspecialchars($PA['itemFormElName']));
00613
00614
00615 $visibility = 'hidden';
00616 $item = $this->triggerField($PA['itemFormElName']).'
00617 <div id="pleasewait' . $pObj->RTEcounter . '" class="pleasewait" style="display: none;" >' . $LANG->getLL('Please wait') . '</div>
00618 <div id="editorWrap' . $pObj->RTEcounter . '" class="editorWrap" style="width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
00619 <textarea id="RTEarea'.$pObj->RTEcounter.'" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)).'">'.t3lib_div::formatForTextarea($value).'</textarea>
00620 </div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
00621 ';
00622 }
00623
00624
00625 return $item;
00626 }
00627
00633 function setToolBar() {
00634 global $BE_USER;
00635
00636 $this->defaultToolbarOrder = 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
00637 bar, fontstyle, space, fontsize, space, formatblock,
00638 bar, bold, italic, underline, strikethrough, subscript, superscript,
00639 bar, lefttoright, righttoleft, bar, left, center, right, justifyfull,
00640 bar, orderedlist, unorderedlist, outdent, indent, bar, textcolor, bgcolor, textindicator,
00641 bar, emoticon, insertcharacter, line, link, 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,
00642 bar, chMode, inserttag, removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
00643 ' . ($this->thisConfig['hideTableOperationsInToolbar'] ? '': 'bar, toggleborders,') . ' bar, tableproperties, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
00644 columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
00645 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
00646
00647
00648 if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3') {
00649 $this->defaultToolbarOrder = $this->TCEform->docLarge ? 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
00650 bar, fontstyle, space, fontsize, space, formatblock, bar, bold, italic, underline, strikethrough,
00651 subscript, superscript, lefttoright, righttoleft, bar, left, center, right, justifyfull, linebreak,
00652 bar, orderedlist, unorderedlist, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
00653 insertcharacter, line, link, image, table, user, acronym, bar, findreplace, spellcheck, bar, chMode, inserttag,
00654 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
00655 bar, toggleborders, bar, tableproperties, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
00656 columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
00657 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge'
00658 : 'bar, blockstylelabel, blockstyle, space, textstylelabel, textstyle, linebreak,
00659 bar, fontstyle, space, fontsize, space, formatblock, bar, bold, italic, underline, strikethrough,
00660 subscript, superscript, linebreak, bar, lefttoright, righttoleft, bar, left, center, right, justifyfull,
00661 orderedlist, unorderedlist, outdent, indent, bar, textcolor, bgcolor, textindicator, bar, emoticon,
00662 insertcharacter, line, link, image, table, user, acronym, linebreak, bar, findreplace, spellcheck, bar, chMode, inserttag,
00663 removeformat, bar, copy, cut, paste, bar, undo, redo, bar, showhelp, about, linebreak,
00664 bar, toggleborders, bar, tableproperties, bar, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, bar,
00665 columninsertbefore, columninsertafter, columndelete, columnsplit, bar,
00666 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
00667 }
00668 $toolbarOrder = $this->thisConfig['toolbarOrder'] ? $this->thisConfig['toolbarOrder'] : $this->defaultToolbarOrder;
00669
00670
00671 $this->toolbarOrderArray = array_intersect(t3lib_div::trimExplode(',', $toolbarOrder, 1), t3lib_div::trimExplode(',', $this->defaultToolbarOrder, 1));
00672 $toolbarOrder = array_unique(array_values($this->toolbarOrderArray));
00673
00674
00675 $pList = is_array($this->specConf['richtext']['parameters']) ? implode(',',$this->specConf['richtext']['parameters']) : '';
00676 if ($pList != '*') {
00677 $show = is_array($this->specConf['richtext']['parameters']) ? $this->specConf['richtext']['parameters'] : array();
00678 if ($this->thisConfig['showButtons']) {
00679 if (!t3lib_div::inList($this->thisConfig['showButtons'],'*')) {
00680 $show = array_unique(array_merge($show,t3lib_div::trimExplode(',',$this->thisConfig['showButtons'],1)));
00681 } else {
00682 $show = array_unique(array_merge($show, $toolbarOrder));
00683 }
00684 }
00685 if (is_array($this->thisConfig['showButtons.'])) {
00686 reset($this->thisConfig['showButtons.']);
00687 while(list($button,$value) = each($this->thisConfig['showButtons.'])) {
00688 if ($value) $show[] = $button;
00689 }
00690 $show = array_unique($show);
00691 }
00692 } else {
00693 $show = $toolbarOrder;
00694 }
00695
00696
00697 if(is_object($BE_USER)) {
00698 $RTEkeyList = isset($BE_USER->userTS['options.']['RTEkeyList']) ? $BE_USER->userTS['options.']['RTEkeyList'] : '*';
00699 if ($RTEkeyList != '*') {
00700 $show = array_intersect($show, t3lib_div::trimExplode(',',$RTEkeyList,1));
00701 }
00702 }
00703
00704
00705 $hideButtons = array('space', 'bar', 'linebreak');
00706 reset($this->pluginButton);
00707 while(list($plugin, $buttonList) = each($this->pluginButton) ) {
00708 if(!$this->isPluginEnable($plugin)) {
00709 $buttonArray = t3lib_div::trimExplode(',',$buttonList,1);
00710 foreach($buttonArray as $button) {
00711 $hideButtons[] = $button;
00712 }
00713 }
00714 }
00715
00716
00717 reset($this->pluginLabel);
00718 while(list($plugin, $label) = each($this->pluginLabel) ) {
00719 if(!$this->isPluginEnable($plugin)) $hideButtons[] = $label;
00720 }
00721
00722
00723 if ($this->client['BROWSER'] == 'safari') {
00724 reset($this->conf_toolbar_safari_hide);
00725 while(list(, $button) = each($this->conf_toolbar_safari_hide) ) {
00726 $hideButtons[] = $button;
00727 }
00728 }
00729
00730
00731 if ($this->client['BROWSER'] == 'opera') {
00732 reset($this->conf_toolbar_opera_hide);
00733 while(list(, $button) = each($this->conf_toolbar_opera_hide) ) {
00734 $hideButtons[] = $button;
00735 }
00736 }
00737
00738
00739 $show = array_diff($show, $this->conf_toolbar_hide, $hideButtons, t3lib_div::trimExplode(',',$this->thisConfig['hideButtons'],1));
00740
00741
00742 $show = array_unique(array_merge($show, $this->conf_toolbar_show));
00743 $toolbarOrder = array_unique(array_merge($toolbarOrder, $this->conf_toolbar_show));
00744 reset($this->conf_toolbar_show);
00745 while(list(,$button) = each($this->conf_toolbar_show)) {
00746 if(!in_array($button, $this->toolbarOrderArray)) $this->toolbarOrderArray[] = $button;
00747 }
00748
00749
00750 $show = array_intersect($show, $toolbarOrder);
00751 $this->toolBar = $show;
00752 }
00753
00759 function setPlugins() {
00760 global $TYPO3_CONF_VARS;
00761
00762 $hideButtons = array();
00763
00764 $hidePlugins = array();
00765 reset($this->pluginButton);
00766 while(list($plugin, $buttonList) = each($this->pluginButton) ) {
00767 $buttonArray = t3lib_div::trimExplode(',',$buttonList,1);
00768 if(!in_array($buttonArray[0],$this->toolBar)) {
00769 $hidePlugins[] = $plugin;
00770 foreach($buttonArray as $button) {
00771 $hideButtons[] = $button;
00772 }
00773 }
00774 }
00775
00776 if($this->thisConfig['disableContextMenu'] || $this->thisConfig['disableRightClick']) $hidePlugins[] = 'ContextMenu';
00777 if($this->thisConfig['disableSelectColor']) $hidePlugins[] = 'SelectColor';
00778 if($this->thisConfig['disableTYPO3Browsers']) $hidePlugins[] = 'TYPO3Browsers';
00779 if(!$this->thisConfig['enableWordClean'] || !is_array($this->thisConfig['enableWordClean.'])) $hidePlugins[] = 'TYPO3HtmlParser';
00780 if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker';
00781
00782 $this->pluginEnableArray = array_diff($this->pluginEnableArray, $hidePlugins);
00783
00784
00785 reset($this->pluginLabel);
00786 while(list($plugin, $label) = each($this->pluginLabel) ) {
00787 if(!$this->isPluginEnable($plugin)) $hideButtons[] = $label;
00788 }
00789 $this->toolBar = array_diff($this->toolBar, $hideButtons);
00790
00791
00792 if( $this->isPluginEnable('SelectColor') ) {
00793 $this->conf_toolbar_convert['textcolor'] = 'CO-forecolor';
00794 $this->conf_toolbar_convert['bgcolor'] = 'CO-hilitecolor';
00795 }
00796 }
00797
00805 function convertToolBarForHTMLArea($button) {
00806 return $this->conf_toolbar_convert[$button];
00807 }
00808
00817 function setRTEsizeByJS($divId, $height, $width) {
00818 return '
00819 setRTEsizeByJS(\''.$divId.'\','.$height.', '.$width.');
00820 ';
00821 }
00822
00828 function loadJSfiles($number) {
00829 global $TYPO3_CONF_VARS;
00830
00831 return '
00832 <script type="text/javascript">
00833
00834 var i=1;
00835 while (document.getElementById("pleasewait" + i)) {
00836 document.getElementById("pleasewait" + i).style.display = "block";
00837 document.getElementById("editorWrap" + i).style.visibility = "hidden";
00838 i++;
00839 };
00840 var RTEarea = new Array();
00841 RTEarea[0] = new Object();
00842 RTEarea[0]["version"] = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . '";
00843 RTEarea[0]["popupwin"] = "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/popupwin' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "popupwin", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '";
00844 RTEarea[0]["htmlarea-gecko"] = "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/htmlarea-gecko' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "htmlarea-gecko", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '";
00845 RTEarea[0]["htmlarea-ie"] = "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/htmlarea-ie' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "htmlarea-ie", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '";
00846 var _editor_url = "' . $this->extHttpPath . 'htmlarea";
00847 var _editor_lang = "' . $this->language . '";
00848 var _editor_CSS = "' . $this->editorCSS . '";
00849 var _editor_skin = "' . dirname($this->editorCSS) . '";
00850 var _editor_edited_content_CSS = "' . $this->editedContentCSS . '";
00851 var _typo3_host_url = "' . $this->hostURL . '";
00852 var _editor_debug_mode = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? 'true' : 'false') . ';
00853 var _editor_compressed_scripts = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? 'true' : 'false') . ';
00854 var _editor_mozAllowClipboard_url = "' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardUrl'] ? $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardUrl'] : '') . '";
00855 var _spellChecker_lang = "' . $this->spellCheckerLanguage . '";
00856 var _spellChecker_charset = "' . $this->spellCheckerCharset . '";
00857 var _spellChecker_mode = "' . $this->spellCheckerMode . '";
00858
00859 </script>
00860 <script type="text/javascript" src="' . $this->buildJSMainLangFile($number) . '"></script>
00861 <script type="text/javascript" src="' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/htmlarea' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', "htmlarea", $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '"></script>
00862 ';
00863 }
00864
00871 function loadJScode($number) {
00872 global $TSFE, $TYPO3_CONF_VARS;
00873
00874 $loadPluginCode = '';
00875 $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
00876 while( list(,$plugin) = each($pluginArray) ) {
00877 if ($this->isPluginEnable($plugin) || (intval($number) > 1 && in_array($plugin, $this->pluginEnableArrayMultiple))) {
00878 $loadPluginCode .= '
00879 HTMLArea.loadPlugin("' . $plugin . '", true, "' . $this->writeJSFileToTypo3tempDir('EXT:' . $this->ID . '/htmlarea/plugins/' . $plugin . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $plugin)) . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']?'-compressed':'') .'.js', $plugin, $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts']) . '");';
00880 }
00881 }
00882 return (!is_object($TSFE) ? '' : '
00883 ' . '') . (is_object($TSFE) ? '' : '
00884 RTEarea[0]["RTEtsConfigParams"] = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
00885 RTEarea[0]["pathAcronymModule"] = "../../mod2/acronym.php";
00886 RTEarea[0]["pathLinkModule"] = "../../mod3/browse_links.php";
00887 RTEarea[0]["pathImageModule"] = "../../mod4/select_image.php";
00888 RTEarea[0]["pathUserModule"] = "../../mod5/user.php";
00889 RTEarea[0]["pathParseHtmlModule"] = "' . $this->extHttpPath . 'mod6/parse_html.php";')
00890 . $loadPluginCode . '
00891 HTMLArea.init();' . (!is_object($TSFE) ? '' : '
00892
00893 ');
00894 }
00895
00907 function registerRTEinJS($number, $table='', $uid='', $field='') {
00908 global $TSFE, $TYPO3_CONF_VARS;
00909
00910
00911 if ($this->TCEform->inline->inlineNames['object']) {
00912 $tceformsInlineObject = $this->TCEform->inline->inlineNames['object'].'['.$table.']['.$uid.']_fields';
00913 }
00914
00915 $registerRTEinJSString = (!is_object($TSFE) ? '' : '
00916 ' . '') . '
00917 RTEarea['.$number.'] = new Object();
00918 RTEarea['.$number.']["number"] = '.$number.';
00919 RTEarea['.$number.']["id"] = "RTEarea'.$number.'";
00920 RTEarea['.$number.']["enableWordClean"] = ' . (trim($this->thisConfig['enableWordClean'])?'true':'false') . ';
00921 RTEarea['.$number.']["htmlRemoveComments"] = ' . (trim($this->thisConfig['removeComments'])?'true':'false') . ';
00922 RTEarea['.$number.']["disableEnterParagraphs"] = ' . (trim($this->thisConfig['disableEnterParagraphs'])?'true':'false') . ';
00923 RTEarea['.$number.']["removeTrailingBR"] = ' . (trim($this->thisConfig['removeTrailingBR'])?'true':'false') . ';
00924 RTEarea['.$number.']["useCSS"] = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . ';
00925 RTEarea['.$number.']["keepButtonGroupTogether"] = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . ';
00926 RTEarea['.$number.']["disablePCexamples"] = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . ';
00927 RTEarea['.$number.']["statusBar"] = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
00928 RTEarea['.$number.']["showTagFreeClasses"] = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
00929 RTEarea['.$number.']["useHTTPS"] = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
00930 RTEarea['.$number.']["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';
00931 RTEarea['.$number.']["tceformsInlineObject"] = "' . $tceformsInlineObject . '";
00932 RTEarea['.$number.']["tceformsDynTabs"] = "' . $this->TCEform->getDynTabLevelState('-DIV') . '";';
00933
00934
00935 if (!is_object($TSFE)) {
00936 $registerRTEinJSString .= '
00937 RTEarea['.$number.']["sys_language_content"] = "' . $this->contentLanguageUid . '";
00938 RTEarea['.$number.']["typo3ContentLanguage"] = "' . $this->contentTypo3Language . '";
00939 RTEarea['.$number.']["typo3ContentCharset"] = "' . $this->contentCharset . '";
00940 RTEarea['.$number.']["enablePersonalDicts"] = ' . ($this->spellCheckerPersonalDicts ? 'true' : 'false') . ';
00941 RTEarea['.$number.']["userUid"] = "' . $this->userUid . '";';
00942 }
00943
00944
00945 $registerRTEinJSString .= '
00946 RTEarea['.$number.']["plugin"] = new Object();';
00947
00948 $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
00949 reset($pluginArray);
00950 while( list(,$plugin) = each($pluginArray) ) {
00951 if ($this->isPluginEnable($plugin)) {
00952 $registerRTEinJSString .= '
00953 RTEarea['.$number.']["plugin"]["'.$plugin.'"] = true;';
00954 }
00955 }
00956
00957
00958 $registerRTEinJSString .= '
00959 RTEarea['.$number.']["buttons"] = new Object();';
00960 if (is_array($this->thisConfig['buttons.'])) {
00961 reset($this->thisConfig['buttons.']);
00962 while( list($buttonIndex,$conf) = each($this->thisConfig['buttons.']) ) {
00963 $button = substr($buttonIndex, 0, -1);
00964 if (in_array($button,$this->toolBar)) {
00965 $indexButton = 0;
00966 $registerRTEinJSString .= '
00967 RTEarea['.$number.']["buttons"]["'.$button.'"] = {';
00968 if (is_array($conf)) {
00969 reset($conf);
00970 while (list($propertyName,$conf1) = each($conf)) {
00971 $property = $propertyName;
00972 if ($indexButton) {
00973 $registerRTEinJSString .= ', ';
00974 }
00975 if (is_array($conf1)) {
00976 $property = substr($property, 0, -1);
00977 $indexProperty = 0;
00978 $registerRTEinJSString .= '"'.$property.'" : {';
00979 reset($conf1);
00980 while (list($property1Name,$conf2) = each($conf1)) {
00981 $property1 = $property1Name;
00982 if ($indexProperty) {
00983 $registerRTEinJSString .= ', ';
00984 }
00985 if (is_array($conf2)) {
00986 $property1 = substr($property1, 0, -1);
00987 $indexProperty1 = 0;
00988 $registerRTEinJSString .= '"'.$property1.'" : {';
00989 reset($conf2);
00990 while (list($property2Name,$conf3) = each($conf2)) {
00991 $property2 = $property2Name;
00992 if ($indexProperty1) {
00993 $registerRTEinJSString .= ', ';
00994 }
00995 if (is_array($conf3)) {
00996 $property2 = substr($property2, 0, -1);
00997 $indexProperty2 = 0;
00998 $registerRTEinJSString .= '"'.$property2.'" : {';
00999 reset($conf3);
01000 while (list($property3Name,$conf4) = each($conf3)) {
01001 $property3 = $property3Name;
01002 if ($indexProperty2) {
01003 $registerRTEinJSString .= ', ';
01004 }
01005 if (!is_array($conf4)) {
01006 $registerRTEinJSString .= '"'.$property3.'" : '.($conf4?'"'.$conf4.'"':'false');
01007 }
01008 $indexProperty2++;
01009 }
01010 $registerRTEinJSString .= '}';
01011 } else {
01012 $registerRTEinJSString .= '"'.$property2.'" : '.($conf3?'"'.$conf3.'"':'false');
01013 }
01014 $indexProperty1++;
01015 }
01016 $registerRTEinJSString .= '}';
01017 } else {
01018 $registerRTEinJSString .= '"'.$property1.'" : '.($conf2?'"'.$conf2.'"':'false');
01019 }
01020 $indexProperty++;
01021 }
01022 $registerRTEinJSString .= '}';
01023 } else {
01024 $registerRTEinJSString .= '"'.$property.'" : '.($conf1?'"'.$conf1.'"':'false');
01025 }
01026 $indexButton++;
01027 }
01028 }
01029 $registerRTEinJSString .= '};';
01030 }
01031 }
01032 }
01033
01034
01035 if (in_array('inserttag', $this->toolBar) && trim($this->thisConfig['hideTags'])) {
01036 if (!is_array($this->thisConfig['buttons.']['inserttag.'])) {
01037 $registerRTEinJSString .= '
01038 RTEarea['.$number.']["buttons"]["inserttag"] = new Object();
01039 RTEarea['.$number.']["buttons"]["inserttag"]["denyTags"] = "'.implode(',', t3lib_div::trimExplode(',', $this->thisConfig['hideTags'], 1)).'";';
01040 } elseif (!$this->thisConfig['buttons.']['inserttag.']['denyTags']) {
01041 $registerRTEinJSString .= '
01042 RTEarea['.$number.']["buttons"]["inserttag"]["denyTags"] = "'.implode(',', t3lib_div::trimExplode(',', $this->thisConfig['hideTags'], 1)).'";';
01043 }
01044 }
01045
01046
01047 if (trim($this->thisConfig['removeTags'])) {
01048 $registerRTEinJSString .= '
01049 RTEarea['.$number.']["htmlRemoveTags"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;';
01050 }
01051
01052
01053 if (trim($this->thisConfig['removeTagsAndContents'])) {
01054 $registerRTEinJSString .= '
01055 RTEarea['.$number.']["htmlRemoveTagsAndContents"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;';
01056 }
01057
01058
01059 $registerRTEinJSString .= '
01060 RTEarea['.$number.']["defaultPageStyle"] = "' . $this->hostURL . $this->buildJSFile('css', $this->buildStyleSheet(), 'css') . '";';
01061
01062
01063 $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css';
01064 $registerRTEinJSString .= '
01065 RTEarea['.$number.']["pageStyle"] = "' . $this->getFullFileName($filename) .'";';
01066
01067
01068 if ( $this->isPluginEnable('SelectColor') ) {
01069 $registerRTEinJSString .= $this->buildJSColorsConfig($number);
01070 }
01071
01072
01073 if ($this->isPluginEnable('InlineCSS') || $this->isPluginEnable('DynamicCSS')) {
01074 $registerRTEinJSString .= $this->buildJSClassesConfig($number);
01075 }
01076
01077
01078 $registerRTEinJSString .= $this->buildJSFontFacesConfig($number);
01079
01080
01081 $registerRTEinJSString .= $this->buildJSParagraphsConfig($number);
01082
01083
01084 $registerRTEinJSString .= $this->buildJSFontSizesConfig($number);
01085
01086 if ($this->isPluginEnable('TableOperations')) {
01087 $registerRTEinJSString .= '
01088 RTEarea['.$number.']["hideTableOperationsInToolbar"] = ' . (trim($this->thisConfig['hideTableOperationsInToolbar']) ? 'true' : 'false') . ';
01089 RTEarea['.$number.']["disableLayoutFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableLayoutFieldsetInTableOperations'])?'true':'false') . ';
01090 RTEarea['.$number.']["disableAlignmentFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableAlignmentFieldsetInTableOperations'])?'true':'false') . ';
01091 RTEarea['.$number.']["disableSpacingFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableSpacingFieldsetInTableOperations'])?'true':'false') . ';
01092 RTEarea['.$number.']["disableBordersFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableBordersFieldsetInTableOperations'])?'true':'false') . ';
01093 RTEarea['.$number.']["disableColorFieldsetInTableOperations"] = ' . (trim($this->thisConfig['disableColorFieldsetInTableOperations'])?'true':'false') . ';';
01094
01095 if (in_array('toggleborders',$this->toolBar) && $this->thisConfig['keepToggleBordersInToolbar']) {
01096 if (!is_array($this->thisConfig['buttons.']['toggleborders.'])) {
01097 $registerRTEinJSString .= '
01098 RTEarea['.$number.']["buttons"]["toggleborders"] = new Object();
01099 RTEarea['.$number.']["buttons"]["toggleborders"]["keepInToolbar"] = true;';
01100 } elseif (!$this->thisConfig['buttons.']['toggleborders.']['keepInToolbar']) {
01101 $registerRTEinJSString .= '
01102 RTEarea['.$number.']["buttons"]["toggleborders"]["keepInToolbar"] = true;';
01103 }
01104 }
01105 }
01106
01107 if ($this->isPluginEnable('Acronym')) {
01108 $registerRTEinJSString .= '
01109 RTEarea['.$number.']["acronymUrl"] = "' . $this->buildJSFile('acronym_'.$this->contentLanguageUid, $this->buildJSAcronymArray()) . '";';
01110 }
01111
01112 if ($this->isPluginEnable('TYPO3Browsers')) {
01113 $registerRTEinJSString .= $this->buildJSClassesAnchorConfig($number);
01114 }
01115
01116 $registerRTEinJSString .= '
01117 RTEarea['.$number.']["toolbar"] = '.$this->getJSToolbarArray().';
01118 HTMLArea.initEditor('.$number.');' . (!is_object($TSFE) ? '' : '
01119 ');
01120 return $registerRTEinJSString;
01121 }
01122
01129 function isPluginEnable($plugin) {
01130 return in_array($plugin, $this->pluginEnableArray);
01131 }
01132
01133
01139 function buildJSFontSizesConfig($number) {
01140 global $LANG, $TSFE;
01141 $registerRTEinJSString = '';
01142
01143
01144 $HTMLAreaFontSizes = array();
01145 if (is_object($TSFE)) {
01146 $HTMLAreaFontSizes[0] = $TSFE->csConvObj->conv($TSFE->getLLL('No size',$this->LOCAL_LANG), $TSFE->labelsCharset, $TSFE->renderCharset);
01147 } else {
01148 $HTMLAreaFontSizes[0] = $LANG->getLL('No size');
01149 }
01150
01151 reset($this->defaultFontSizes);
01152 while( list($FontSizeItem,$FontSizeLabel) = each($this->defaultFontSizes)) {
01153 if ($this->client['BROWSER'] == 'safari') {
01154 $HTMLAreaFontSizes[$this->defaultFontSizes_safari[$FontSizeItem]] = $FontSizeLabel;
01155 } else {
01156 $HTMLAreaFontSizes[$FontSizeItem] = $FontSizeLabel;
01157 }
01158 }
01159 if ($this->thisConfig['hideFontSizes'] ) {
01160 $hideFontSizes = t3lib_div::trimExplode(',', $this->cleanList($this->thisConfig['hideFontSizes']), 1);
01161 foreach($hideFontSizes as $item) {
01162 if ($HTMLAreaFontSizes[strtolower($item)]) {
01163 if ($this->client['BROWSER'] == 'safari') {
01164 unset($HTMLAreaFontSizes[$this->defaultFontSizes_safari[strtolower($item)]]);
01165 } else {
01166 unset($HTMLAreaFontSizes[strtolower($item)]);
01167 }
01168 } else {
01169
01170 }
01171 }
01172 }
01173
01174 $HTMLAreaJSFontSize = '{';
01175 if ($this->cleanList($this->thisConfig['hideFontSizes']) != '*') {
01176 reset($HTMLAreaFontSizes);
01177 $HTMLAreaParagraphIndex = 0;
01178 while( list($FontSizeItem,$FontSizeLabel) = each($HTMLAreaFontSizes)) {
01179 if($HTMLAreaFontSizeIndex) {
01180 $HTMLAreaJSFontSize .= ',';
01181 }
01182 $HTMLAreaJSFontSize .= '
01183 "' . $FontSizeLabel . '" : "' . ($FontSizeItem?$FontSizeItem:'') . '"';
01184 $HTMLAreaFontSizeIndex++;
01185 }
01186 }
01187 $HTMLAreaJSFontSize .= '};';
01188 $registerRTEinJSString .= '
01189 RTEarea['.$number.']["fontsize"] = '. $HTMLAreaJSFontSize;
01190
01191 return $registerRTEinJSString;
01192 }
01198 function buildJSParagraphsConfig($number) {
01199 global $TSFE, $LANG;
01200 $registerRTEinJSString = '';
01201
01202
01203 $HTMLAreaParagraphs = $this->defaultParagraphs;
01204 if ($this->thisConfig['hidePStyleItems']) {
01205 $hidePStyleItems = t3lib_div::trimExplode(',', $this->cleanList($this->thisConfig['hidePStyleItems']), 1);
01206 foreach($hidePStyleItems as $item) unset($HTMLAreaParagraphs[strtolower($item)]);
01207 }
01208 $HTMLAreaJSParagraph = '{';
01209 if ($this->cleanList($this->thisConfig['hidePStyleItems']) != '*') {
01210 reset($HTMLAreaParagraphs);
01211 $HTMLAreaParagraphIndex = 0;
01212 while( list($PStyleItem,$PStyleLabel) = each($HTMLAreaParagraphs)) {
01213 if($HTMLAreaParagraphIndex) {
01214 $HTMLAreaJSParagraph .= ',';
01215 }
01216 if (is_object($TSFE)) {
01217 $HTMLAreaJSParagraph .= '
01218 "' . $TSFE->csConvObj->conv($TSFE->getLLL($PStyleLabel,$this->LOCAL_LANG), $TSFE->labelsCharset, $TSFE->renderCharset) . '" : "' . $PStyleItem . '"';
01219
01220 } else {
01221 $HTMLAreaJSParagraph .= '
01222 "' . $LANG->getLL($PStyleLabel) . '" : "' . $PStyleItem . '"';
01223 }
01224 $HTMLAreaParagraphIndex++;
01225 }
01226 }
01227 $HTMLAreaJSParagraph .= '};';
01228 $registerRTEinJSString .= '
01229 RTEarea['.$number.']["paragraphs"] = '. $HTMLAreaJSParagraph;
01230
01231 return $registerRTEinJSString;
01232 }
01233
01239 function buildJSFontfacesConfig($number) {
01240 global $TSFE, $LANG;
01241
01242 if (is_object($TSFE)) {
01243 $RTEProperties = $this->RTEsetup;
01244 } else {
01245 $RTEProperties = $this->RTEsetup['properties'];
01246 }
01247
01248 $registerRTEinJSString = '';
01249
01250
01251 $HTMLAreaFontname = array();
01252 $HTMLAreaFontname['nofont'] = '
01253 "' . $fontName . '" : "' . $this->cleanList($fontValue) . '"';
01254 $defaultFontFacesList = 'nofont,';
01255 if (is_object($TSFE)) {
01256 $HTMLAreaFontname['nofont'] = '
01257 "' . $TSFE->csConvObj->conv($TSFE->getLLL('No font',$this->LOCAL_LANG), $TSFE->labelsCharset, $TSFE->renderCharset) . '" : ""';
01258 } else {
01259 $HTMLAreaFontname['nofont'] = '
01260 "' . $LANG->getLL('No font') . '" : ""';
01261 }
01262
01263 $hideFontFaces = $this->cleanList($this->thisConfig['hideFontFaces']);
01264 if ($hideFontFaces != '*') {
01265 $index = 0;
01266 reset($this->defaultFontFaces);
01267 while (list($fontName,$fontValue) = each($this->defaultFontFaces)) {
01268 if (!t3lib_div::inList($hideFontFaces, $index+1)) {
01269 $HTMLAreaFontname[$fontName] = '
01270 "' . $fontName . '" : "' . $this->cleanList($fontValue) . '"';
01271 $defaultFontFacesList .= $fontName . ',';
01272 }
01273 $index++;
01274 }
01275 }
01276
01277
01278 if (is_array($RTEProperties['fonts.'])) {
01279 reset($RTEProperties['fonts.']);
01280 while(list($fontName,$conf)=each($RTEProperties['fonts.'])) {
01281 $fontName=substr($fontName,0,-1);
01282 if (is_object($TSFE)) {
01283 $string = $TSFE->sL($conf['name']);
01284 } else {
01285 $string = $LANG->sL($conf['name']);
01286 }
01287 $HTMLAreaFontname[$fontName] = '
01288 "' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . '" : "' . $this->cleanList($conf['value']) . '"';
01289 }
01290 }
01291
01292
01293 $HTMLAreaJSFontface = '{';
01294 $HTMLAreaFontface = t3lib_div::trimExplode(',' , $this->cleanList($defaultFontFacesList . ',' . $this->thisConfig['fontFace']));
01295 reset($HTMLAreaFontface);
01296 $HTMLAreaFontfaceIndex = 0;
01297 while( list(,$fontName) = each($HTMLAreaFontface)) {
01298 if($HTMLAreaFontfaceIndex) {
01299 $HTMLAreaJSFontface .= ',';
01300 }
01301 $HTMLAreaJSFontface .= $HTMLAreaFontname[$fontName];
01302 $HTMLAreaFontfaceIndex++;
01303 }
01304 $HTMLAreaJSFontface .= '};';
01305
01306 $registerRTEinJSString .= '
01307 RTEarea['.$number.']["fontname"] = '. $HTMLAreaJSFontface;
01308
01309 return $registerRTEinJSString;
01310 }
01311
01317 function buildJSColorsConfig($number) {
01318 global $TSFE, $LANG;
01319
01320 if (is_object($TSFE)) {
01321 $RTEProperties = $this->RTEsetup;
01322 } else {
01323 $RTEProperties = $this->RTEsetup['properties'];
01324 }
01325
01326 $registerRTEinJSString = '';
01327
01328 if(trim($this->thisConfig['disableColorPicker'])) {
01329 $registerRTEinJSString .= '
01330 RTEarea['.$number.']["disableColorPicker"] = true;';
01331 } else {
01332 $registerRTEinJSString .= '
01333 RTEarea['.$number.']["disableColorPicker"] = false;';
01334 }
01335
01336
01337 if (is_array($RTEProperties['colors.']) ) {
01338 $HTMLAreaColorname = array();
01339 reset($RTEProperties['colors.']);
01340 while(list($colorName,$conf)=each($RTEProperties['colors.'])) {
01341 $colorName=substr($colorName,0,-1);
01342 if (is_object($TSFE)) {
01343 $string = $TSFE->csConvObj->conv($TSFE->sL(trim($conf['name'])), $TSFE->renderCharset, $TSFE->metaCharset);
01344 $string = str_replace('"', '\"', str_replace('\\\'', '\'', $string));
01345 $string = $this->feJScharCode($string);
01346 } else {
01347 $string = $this->getLLContent(trim($conf['name']));
01348 }
01349 $HTMLAreaColorname[$colorName] = '
01350 [' . $string . ' , "' . $conf['value'] . '"]';
01351 }
01352 }
01353
01354
01355 if ($this->thisConfig['colors'] ) {
01356 $HTMLAreaJSColors = '[';
01357 $HTMLAreaColors = t3lib_div::trimExplode(',' , $this->cleanList($this->thisConfig['colors']));
01358 reset($HTMLAreaColors);
01359 $HTMLAreaColorsIndex = 0;
01360 while( list(,$colorName) = each($HTMLAreaColors)) {
01361 if($HTMLAreaColorsIndex && $HTMLAreaColorname[$colorName]) {
01362 $HTMLAreaJSColors .= ',';
01363 }
01364 $HTMLAreaJSColors .= $HTMLAreaColorname[$colorName];
01365 $HTMLAreaColorsIndex++;
01366 }
01367 $HTMLAreaJSColors .= '];';
01368 $registerRTEinJSString .= '
01369 RTEarea['.$number.']["colors"] = '. $HTMLAreaJSColors;
01370 }
01371
01372 return $registerRTEinJSString;
01373 }
01374
01380 function buildStyleSheet() {
01381
01382 if (!trim($this->thisConfig['ignoreMainStyleOverride'])) {
01383 $mainStyle_font = $this->thisConfig['mainStyle_font'] ? $this->thisConfig['mainStyle_font']: 'Verdana,sans-serif';
01384
01385 $mainElements = array();
01386 $mainElements['P'] = $this->thisConfig['mainStyleOverride_add.']['P'];
01387 $elList = explode(',','H1,H2,H3,H4,H5,H6,PRE');
01388 reset($elList);
01389 while(list(,$elListName)=each($elList)) {
01390 if ($this->thisConfig['mainStyleOverride_add.'][$elListName]) {
01391 $mainElements[$elListName] = $this->thisConfig['mainStyleOverride_add.'][$elListName];
01392 }
01393 }
01394
01395 $addElementCode = '';
01396 reset($mainElements);
01397 while(list($elListName,$elValue)=each($mainElements)) {
01398 $addElementCode .= strToLower($elListName) . ' {' . $elValue . '}' . chr(10);
01399 }
01400
01401 $stylesheet = $this->thisConfig['mainStyleOverride'] ? $this->thisConfig['mainStyleOverride'] : chr(10) .
01402 'body.htmlarea-content-body { font-family: ' . $mainStyle_font .
01403 '; font-size: '.($this->thisConfig['mainStyle_size'] ? $this->thisConfig['mainStyle_size'] : '12px') .
01404 '; color: '.($this->thisConfig['mainStyle_color']?$this->thisConfig['mainStyle_color'] : 'black') .
01405 '; background-color: '.($this->thisConfig['mainStyle_bgcolor'] ? $this->thisConfig['mainStyle_bgcolor'] : 'white') .
01406 ';'.$this->thisConfig['mainStyleOverride_add.']['BODY'].'}' . chr(10) .
01407 'td { ' . $this->thisConfig['mainStyleOverride_add.']['TD'].'}' . chr(10) .
01408 'div { ' . $this->thisConfig['mainStyleOverride_add.']['DIV'].'}' . chr(10) .
01409 'pre { ' . $this->thisConfig['mainStyleOverride_add.']['PRE'].'}' . chr(10) .
01410 'ol { ' . $this->thisConfig['mainStyleOverride_add.']['OL'].'}' . chr(10) .
01411 'ul { ' . $this->thisConfig['mainStyleOverride_add.']['UL'].'}' . chr(10) .
01412 'blockquote { ' . $this->thisConfig['mainStyleOverride_add.']['BLOCKQUOTE'].'}' . chr(10) .
01413 $addElementCode;
01414
01415 if (is_array($this->thisConfig['inlineStyle.'])) {
01416 $stylesheet .= chr(10) . implode(chr(10), $this->thisConfig['inlineStyle.']) . chr(10);
01417 }
01418 } else {
01419 $stylesheet = '';
01420 }
01421 return $stylesheet;
01422 }
01423
01429 function buildJSClassesConfig($number) {
01430
01431
01432 $classesTagList = 'classesCharacter, classesParagraph, classesImage, classesTable, classesLinks, classesTD';
01433 $classesTagConvert = array( 'classesCharacter' => 'span', 'classesParagraph' => 'p', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td');
01434 $classesTagArray = t3lib_div::trimExplode(',' , $classesTagList);
01435 $registerRTEinJSString = '
01436 RTEarea['.$number.']["classesTag"] = new Object();';
01437 while( list(,$classesTagName) = each($classesTagArray)) {
01438 $HTMLAreaJSClasses = ($this->thisConfig[$classesTagName])?('"' . $this->cleanList($this->thisConfig[$classesTagName]) . '";'):'null;';
01439 $registerRTEinJSString .= '
01440 RTEarea['.$number.']["classesTag"]["'. $classesTagConvert[$classesTagName] .'"] = '. $HTMLAreaJSClasses;
01441 }
01442
01443 // Include JS arrays of configured classes
01444 $registerRTEinJSString .= '
01445 RTEarea['.$number.']["classesUrl"] = "' . $this->hostURL . $this->buildJSFile('classes_'.$this->contentLanguageUid, $this->buildJSClassesArray()) . '";';
01446
01447 return $registerRTEinJSString;
01448 }
01449
01455 function buildJSClassesArray() {
01456 global $TSFE, $LANG, $TYPO3_CONF_VARS;
01457
01458 if (is_object($TSFE)) {
01459 $RTEProperties = $this->RTEsetup;
01460 } else {
01461 $RTEProperties = $this->RTEsetup['properties'];
01462 }
01463
01464 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
01465 $index = 0;
01466 $JSClassesLabelsArray = 'HTMLArea.classesLabels = { ' . $linebreak;
01467 $JSClassesValuesArray = 'HTMLArea.classesValues = { ' . $linebreak;
01468 $JSClassesNoShowArray = 'HTMLArea.classesNoShow = { ' . $linebreak;
01469
01470 // Scanning the list of classes if specified in the RTE config
01471 if (is_array($RTEProperties['classes.'])) {
01472 $stylesheet = '';
01473 reset($RTEProperties['classes.']);
01474 while(list($className,$conf)=each($RTEProperties['classes.'])) {
01475 $className = substr($className,0,-1);
01476 if (is_object($TSFE)) {
01477 $string = $TSFE->csConvObj->conv($TSFE->sL(trim($conf['name'])), $TSFE->renderCharset, $TSFE->metaCharset);
01478 $string = str_replace('"', '\"', str_replace('\\\'', '\'', $string));
01479 $string = $this->feJScharCode($string);
01480 } else {
01481 $string = $this->getLLContent(trim($conf['name']));
01482 }
01483 $JSClassesLabelsArray .= (($index)?',':'') . '"' . $className . '": ' . $string . $linebreak;
01484 $JSClassesValuesArray .= (($index)?',':'') . '"' . $className . '":"' . str_replace('"', '\"', str_replace('\\\'', '\'', $conf['value'])) . '"' . $linebreak;
01485 $JSClassesNoShowArray .= (($index)?',':'') . '"' . $className . '":' . ($conf['noShow']?'true':'false') . $linebreak;
01486 $index++;
01487 }
01488 }
01489 $JSClassesLabelsArray .= '};' . $linebreak;
01490 $JSClassesValuesArray .= '};' . $linebreak;
01491 $JSClassesNoShowArray .= '};' . $linebreak;
01492
01493 return $JSClassesLabelsArray . $JSClassesValuesArray . $JSClassesNoShowArray;
01494 }
01495
01501 function buildJSMainLangArray() {
01502 global $TSFE, $LANG, $TYPO3_CONF_VARS;
01503
01504 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
01505 $JSLanguageArray .= 'var HTMLArea_langArray = new Object();' . $linebreak;
01506 $JSLanguageArray .= 'HTMLArea_langArray = { ' . $linebreak;
01507 if(is_object($TSFE)) {
01508 $JSLanguageArray = $TSFE->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
01509 } else {
01510 $JSLanguageArray = $LANG->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
01511 }
01512
01513 $subArrays = array( 'tooltips', 'msg' , 'dialogs');
01514 $subArraysIndex = 0;
01515 foreach($subArrays as $labels) {
01516 $JSLanguageArray .= (($subArraysIndex++)?',':'') . $labels . ': {' . $linebreak;
01517 if(is_object($TSFE)) {
01518 $LOCAL_LANG = $TSFE->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/locallang_' . $labels . '.xml', $this->language);
01519 $TSFE->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
01520 if(!empty($LOCAL_LANG[$this->language])) $TSFE->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
01521 } else {
01522 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/locallang_' . $labels . '.xml');
01523 $LANG->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
01524 if(!empty($LOCAL_LANG[$this->language])) $LANG->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
01525 }
01526 if(!empty($LOCAL_LANG[$this->language])) {
01527 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language]);
01528 } else {
01529 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
01530 }
01531 $index = 0;
01532 foreach ( $LOCAL_LANG[$this->language] as $labelKey => $labelValue ) {
01533 $JSLanguageArray .= (($index++)?',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
01534 }
01535 if(is_object($TSFE)) {
01536 $JSLanguageArray .= $TSFE->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
01537 } else {
01538 $JSLanguageArray .= $LANG->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
01539 }
01540 }
01541
01542 if(is_object($TSFE)) {
01543 $JSLanguageArray .= $TSFE->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
01544 } else {
01545 $JSLanguageArray .= $LANG->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
01546 }
01547 return $JSLanguageArray;
01548 }
01549
01556 function buildJSAcronymArray() {
01557 global $TYPO3_CONF_VARS, $TYPO3_DB;
01558
01559 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
01560 $acronymIndex = 0;
01561 $abbraviationIndex = 0;
01562 $JSAcronymArray .= 'acronyms = { ' . $linebreak;
01563 $JSAbbreviationArray .= 'abbreviations = { ' . $linebreak;
01564 $table = 'tx_rtehtmlarea_acronym';
01565 if($this->contentLanguageUid > -1) {
01566 $whereClause = '(sys_language_uid="'.$this->contentLanguageUid . '" OR sys_language_uid="-1")';
01567 } else {
01568 $whereClause = '1 = 1';
01569 }
01570 $whereClause .= t3lib_BEfunc::BEenableFields($table);
01571 $whereClause .= t3lib_BEfunc::deleteClause($table);
01572 $res = $TYPO3_DB->exec_SELECTquery('type,term,acronym', $table, $whereClause);
01573 while($acronymRow = $TYPO3_DB->sql_fetch_assoc($res)) {
01574 if($acronymRow['type'] == 1) $JSAcronymArray .= (($acronymIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
01575 if($acronymRow['type'] == 2) $JSAbbreviationArray .= (($AbbreviationIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
01576 }
01577 $JSAcronymArray .= '};' . $linebreak;
01578 $JSAbbreviationArray .= '};' . $linebreak;
01579
01580 return $JSAcronymArray . $JSAbbreviationArray;
01581 }
01582
01588 function buildJSClassesAnchorConfig($number) {
01589 global $TSFE;
01590
01591 if (is_object($TSFE)) {
01592 $RTEProperties = $this->RTEsetup;
01593 } else {
01594 $RTEProperties = $this->RTEsetup['properties'];
01595 }
01596
01597 $registerRTEinJSString = '';
01598 if (is_array($RTEProperties['classesAnchor.'])) {
01599 $registerRTEinJSString .= '
01600 RTEarea['.$number.']["classesAnchorUrl"] = "' . $this->buildJSFile('classesAnchor_'.$this->contentLanguageUid, $this->buildJSClassesAnchorArray()) . '";';
01601 }
01602 return $registerRTEinJSString;
01603 }
01604
01610 function buildJSClassesAnchorArray() {
01611 global $LANG, $TYPO3_CONF_VARS;
01612
01613 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
01614 $JSClassesAnchorArray .= 'editor.classesAnchorSetup = [ ' . $linebreak;
01615 $classesAnchorIndex = 0;
01616 reset($this->RTEsetup['properties']['classesAnchor.']);
01617 while(list($label,$conf)=each($this->RTEsetup['properties']['classesAnchor.'])) {
01618 if (is_array($conf) && $conf['class']) {
01619 $JSClassesAnchorArray .= (($classesAnchorIndex++)?',':'') . ' { ' . $linebreak;
01620 $index = 0;
01621 $JSClassesAnchorArray .= (($index++)?',':'') . 'name : "' . $conf['class'] . '"' . $linebreak;
01622 if ($conf['type']) {
01623 $JSClassesAnchorArray .= (($index++)?',':'') . 'type : "' . $conf['type'] . '"' . $linebreak;
01624 }
01625 if (trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) {
01626 $JSClassesAnchorArray .= (($index++)?',':'') . 'image : "' . $this->getFullFileName(trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) . '"' . $linebreak;
01627 }
01628 if (trim($conf['altText'])) {
01629 $string = $this->getLLContent(trim($conf['altText']));
01630 $JSClassesAnchorArray .= (($index++)?',':'') . 'altText : ' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . $linebreak;
01631 }
01632 if (trim($conf['titleText'])) {
01633 $string = $this->getLLContent(trim($conf['titleText']));
01634 $JSClassesAnchorArray .= (($index++)?',':'') . 'titleText : ' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . $linebreak;
01635 }
01636 $JSClassesAnchorArray .= '}' . $linebreak;
01637 }
01638 }
01639 $JSClassesAnchorArray .= '];' . $linebreak;
01640 return $JSClassesAnchorArray;
01641 }
01642
01649 function buildJSFile($label,$contents,$ext='js') {
01650 $relFilename = 'typo3temp/' . $this->ID . '_' . $label . '_' . md5($contents) . '.' . $ext;
01651 $outputFilename = PATH_site . $relFilename;
01652 if(!file_exists($outputFilename)) {
01653 $outputHandle = fopen($outputFilename,'wb');
01654 fwrite($outputHandle, $contents);
01655 fclose($outputHandle);
01656 t3lib_div::fixPermissions($outputFilename);
01657 }
01658 return $this->httpTypo3Path . $relFilename;
01659 }
01660
01667 function writeJSFileToTypo3tempDir($JSFile,$label,$compressed=FALSE,$ext='js') {
01668 global $TYPO3_CONF_VARS;
01669
01670 $source = t3lib_div::getFileAbsFileName($JSFile);
01671 $relFilename = 'typo3temp/' . $this->ID . '_' . $label . '_' . md5($JSFile . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version']) . ($compressed ? '-compressed' : '') . '.' . $ext;
01672 $destination = PATH_site . $relFilename;
01673 if(!file_exists($destination)) {
01674 @copy($source,$destination);
01675 t3lib_div::fixPermissions($destination);
01676 }
01677 return ($this->thisConfig['forceHTTPS']?$this->siteURL:$this->httpTypo3Path) . $relFilename;
01678 }
01679
01686 function buildJSMainLangFile($number) {
01687 $contents = $this->buildJSMainLangArray() . chr(10);
01688 $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
01689 while( list(,$plugin) = each($pluginArray) ) {
01690 if ($this->isPluginEnable($plugin) || (intval($number) > 1 && in_array($plugin, $this->pluginEnableArrayMultiple))) {
01691 $contents .= $this->buildJSLangArray($plugin) . chr(10);
01692 }
01693 }
01694 return $this->buildJSFile($this->language.'_'.$this->OutputCharset,$contents);
01695 }
01696
01703 function buildJSLangArray($plugin) {
01704 global $TSFE, $LANG, $TYPO3_CONF_VARS;
01705
01706 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? '' : chr(10);
01707 if(is_object($TSFE)) {
01708 $LOCAL_LANG = $TSFE->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/plugins/' . $plugin . '/locallang.xml', $this->language);
01709 if(!empty($LOCAL_LANG['default'])) $TSFE->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
01710 if(!empty($LOCAL_LANG[$this->language])) $TSFE->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
01711 } else {
01712 $LOCAL_LANG = $LANG->readLLfile(t3lib_extMgm::extPath($this->ID).'htmlarea/plugins/' . $plugin . '/locallang.xml');
01713 if(!empty($LOCAL_LANG['default'])) $LANG->csConvObj->convArray($LOCAL_LANG['default'], 'iso-8859-1', $this->OutputCharset);
01714 if(!empty($LOCAL_LANG[$this->language])) $LANG->csConvObj->convArray($LOCAL_LANG[$this->language], $this->charset, $this->OutputCharset);
01715 }
01716
01717 if(!empty($LOCAL_LANG[$this->language])) {
01718 $LOCAL_LANG[$this->language] = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG['default'],$LOCAL_LANG[$this->language]);
01719 } else {
01720 $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
01721 }
01722
01723 $JSLanguageArray .= 'var ' . $plugin . '_langArray = new Object();' . $linebreak;
01724 $JSLanguageArray .= $plugin . '_langArray = {' . $linebreak;
01725 if(is_object($TSFE)) {
01726 $JSLanguageArray = $TSFE->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
01727 } else {
01728 $JSLanguageArray = $LANG->csConvObj->conv($JSLanguageArray, 'iso-8859-1', $this->OutputCharset);
01729 }
01730
01731 $index = 0;
01732 foreach ( $LOCAL_LANG[$this->language] as $labelKey => $labelValue ) {
01733 $JSLanguageArray .= (($index++)?',':'') . '"' . $labelKey . '":"' . str_replace('"', '\"', $labelValue) . '"' . $linebreak;
01734 }
01735
01736 if(is_object($TSFE)) {
01737 $JSLanguageArray .= $TSFE->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
01738 } else {
01739 $JSLanguageArray .= $LANG->csConvObj->conv(' }' . chr(10), 'iso-8859-1', $this->OutputCharset);
01740 }
01741
01742 return $JSLanguageArray;
01743 }
01744
01751 function getJSToolbarArray() {
01752 $toolbar = '';
01753 $group = '';
01754 $group_has_button = false;
01755 $group_needs_starting_bar = false;
01756 $previous_is_space = false;
01757
01758
01759 reset($this->toolbarOrderArray);
01760 while (list(, $button) = each($this->toolbarOrderArray) ) {
01761
01762 if (($button == 'bar' || $button == 'linebreak') && $group_has_button) {
01763
01764 if ($button == 'linebreak') {
01765 $convertButton = '"' . $this->convertToolBarForHTMLArea('linebreak') . '"';
01766 $group = ($group!='') ? ($group . ', ' . $convertButton) : $convertButton;
01767 }
01768
01769 $toolbar .= $toolbar ? (', ' . $group) : ('[[' . $group);
01770 $group = '';
01771 $previous_is_space = false;
01772 $group_has_button = false;
01773 $group_needs_starting_bar = true;
01774 } elseif ($toolbar && $button == 'linebreak' && !$group_has_button) {
01775
01776 $group = '';
01777 $previous_is_space = false;
01778 $group_needs_starting_bar = false;
01779 $toolbar .= ', "' . $this->convertToolBarForHTMLArea($button) . '"';
01780 } elseif ($button == 'bar' && !$group_has_button) {
01781 $group_needs_starting_bar = true;
01782 } elseif ($button == 'space' && $group_has_button && !$previous_is_space) {
01783 $convertButton = $this->convertToolBarForHTMLArea($button);
01784 $convertButton = '"' . $convertButton . '"';
01785 $group .= $group ? (', ' . $convertButton) : ($group_needs_starting_bar ? ('"' . $this->convertToolBarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
01786 $group_needs_starting_bar = false;
01787 $previous_is_space = true;
01788 } elseif (in_array($button, $this->toolBar)) {
01789 // Add the button to the group
01790 $convertButton = $this->convertToolBarForHTMLArea($button);
01791 if ($convertButton) {
01792 $convertButton = '"' . $convertButton . '"';
01793 $group .= $group ? (', ' . $convertButton) : ($group_needs_starting_bar ? ('"' . $this->convertToolBarForHTMLArea('bar') . '", ' . $convertButton) : $convertButton);
01794 $group_has_button = true;
01795 $group_needs_starting_bar = false;
01796 $previous_is_space = false;
01797 }
01798 }
01799 // else ignore
01800 }
01801 // add the last group
01802 if($group_has_button) $toolbar .= $toolbar ? (', ' . $group) : ('[[' . $group);
01803 $toolbar = $toolbar . ']]';
01804 return $toolbar;
01805 }
01806
01807 function getLLContent($string) {
01808 global $LANG;
01809
01810 $BE_lang = $LANG->lang;
01811 $BE_origCharset = $LANG->origCharSet;
01812 $BE_charSet = $LANG->charSet;
01813 $LANG->lang = $this->contentTypo3Language;
01814 $LANG->origCharSet = $this->origContentCharSet;
01815 $LANG->charSet = $this->contentCharset;
01816 $LLString = $LANG->JScharCode($LANG->sL($string));
01817 $LANG->lang = $BE_lang;
01818 $LANG->origCharSet = $BE_origCharset;
01819 $LANG->charSet = $BE_charSet;
01820 return $LLString;
01821 }
01822
01823 function feJScharCode($str) {
01824 global $TSFE;
01825 // Convert string to UTF-8:
01826 if ($this->OutputCharset != 'utf-8') $str = $TSFE->csConvObj->utf8_encode($str,$this->OutputCharset);
01827 // Convert the UTF-8 string into a array of char numbers:
01828 $nArr = $TSFE->csConvObj->utf8_to_numberarray($str);
01829 return 'String.fromCharCode('.implode(',',$nArr).')';
01830 }
01831
01832 function getFullFileName($filename) {
01833 if (substr($filename,0,4)=='EXT:') { // extension
01834 list($extKey,$local) = explode('/',substr($filename,4),2);
01835 $newFilename = '';
01836 if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
01837 $newFilename = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . $local;
01838 }
01839 } elseif (substr($filename,0,1) != '/') {
01840 $newFilename = $this->siteURL . $filename;
01841 } else {
01842 $newFilename = $this->siteURL . substr($filename,1);
01843 }
01844 return $newFilename;
01845 }
01846
01854 function setSaveRTE($number, $form, $textarea) {
01855 return '
01856 editornumber = '.$number.';
01857 if (RTEarea[editornumber]) {
01858 document.'.$form.'["'.$textarea.'"].value = RTEarea[editornumber]["editor"].getHTML();
01859 }
01860 else {
01861 OK=0;
01862 }
01863 ';
01864 }
01865
01875 function clientInfo($useragent='') {
01876 global $TYPO3_CONF_VARS;
01877
01878 if (!$useragent) $useragent=t3lib_div::getIndpEnv('HTTP_USER_AGENT');
01879
01880 $bInfo=array();
01881 // Which browser?
01882 if (strstr($useragent,'Konqueror')) {
01883 $bInfo['BROWSER']= 'konqu';
01884 } elseif (strstr($useragent,'Opera')) {
01885 $bInfo['BROWSER']= 'opera';
01886 } elseif (strstr($useragent,'MSIE')) {
01887 $bInfo['BROWSER']= 'msie';
01888 } elseif (strstr($useragent,'Gecko/')) {
01889 $bInfo['BROWSER']='gecko';
01890 } elseif (strstr($useragent,'Safari/') && $TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['safari_test'] == 1) {
01891 $bInfo['BROWSER']='safari';
01892 } elseif (strstr($useragent,'Mozilla/4')) {
01893 $bInfo['BROWSER']='net';
01894 }
01895
01896 if ($bInfo['BROWSER']) {
01897 // Browser version
01898 switch($bInfo['BROWSER']) {
01899 case 'net':
01900 $bInfo['VERSION']= doubleval(substr($useragent,8));
01901 if (strstr($useragent,'Netscape6/')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape6/'),10));}
01902 if (strstr($useragent,'Netscape/7')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape/7'),9));}
01903 break;
01904 case 'gecko':
01905 $tmp = strstr($useragent,'rv:');
01906 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
01907 break;
01908 case 'msie':
01909 $tmp = strstr($useragent,'MSIE');
01910 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4)));
01911 break;
01912 case 'safari':
01913 $tmp = strstr($useragent,'Safari/');
01914 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,3)));
01915 break;
01916 case 'opera':
01917 $tmp = strstr($useragent,'Opera');
01918 $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5)));
01919 break;
01920 case 'konqu':
01921 $tmp = strstr($useragent,'Konqueror/');
01922 $bInfo['VERSION'] = doubleval(substr($tmp,10));
01923 break;
01924 }
01925
01926 // Client system
01927 if (strstr($useragent,'Win')) {
01928 $bInfo['SYSTEM'] = 'win';
01929 } elseif (strstr($useragent,'Mac')) {
01930 $bInfo['SYSTEM'] = 'mac';
01931 } elseif (strstr($useragent,'Linux') || strstr($useragent,'X11') || strstr($useragent,'SGI') || strstr($useragent,' SunOS ') || strstr($useragent,' HP-UX ')) {
01932 $bInfo['SYSTEM'] = 'unix';
01933 }
01934 }
01935
01936 // Is true if the browser supports css to format forms, especially the width
01937 $bInfo['FORMSTYLE']=($bInfo['BROWSER']=='msie' || ($bInfo['BROWSER']=='net'&&$bInfo['VERSION']>=5) || $bInfo['BROWSER']=='opera' || $bInfo['BROWSER']=='konqu');
01938 return $bInfo;
01939 }
01940
01941 /***************************
01942 *
01943 * OTHER FUNCTIONS: (from Classic RTE)
01944 *
01945 ***************************/
01951 function RTEtsConfigParams() {
01952 global $TSFE;
01953 if(is_object($TSFE)) {
01954 return '';
01955 } else {
01956 $p = t3lib_BEfunc::getSpecConfParametersFromArray($this->specConf['rte_transform']['parameters']);
01957 return $this->elementParts[0].':'.$this->elementParts[1].':'.$this->elementParts[2].':'.$this->thePid.':'.$this->typeVal.':'.$this->tscPID.':'.$p['imgpath'];
01958 }
01959 }
01960
01961 function cleanList($str) {
01962 if (strstr($str,'*')) {
01963 $str = '*';
01964 } else {
01965 $str = implode(',',array_unique(t3lib_div::trimExplode(',',$str,1)));
01966 }
01967 return $str;
01968 }
01969
01970 function filterStyleEl($elValue,$matchList) {
01971 $matchParts = t3lib_div::trimExplode(',',$matchList,1);
01972 $styleParts = explode(';',$elValue);
01973 $nStyle=array();
01974 while(list($k,$p)=each($styleParts)) {
01975 $pp = t3lib_div::trimExplode(':',$p);
01976 if ($pp[0]&&$pp[1]) {
01977 reset($matchParts);
01978 while(list(,$el)=each($matchParts)) {
01979 $star=substr($el,-1)=='*';
01980 if (!strcmp($pp[0],$el) || ($star && t3lib_div::isFirstPartOfStr($pp[0],substr($el,0,-1)) )) {
01981 $nStyle[]=$pp[0].':'.$pp[1];
01982 } else unset($styleParts[$k]);
01983 }
01984 } else {
01985 unset($styleParts[$k]);
01986 }
01987 }
01988 return implode('; ',$nStyle);
01989 }
01990
01991 // Hook on lorem_ipsum extension to insert text into the RTE in wysiwyg mode
01992 function loremIpsumInsert($params) {
01993 return "
01994 if (typeof(lorem_ipsum) == 'function' && " . $params['element'] . ".tagName.toLowerCase() == 'textarea' ) lorem_ipsum(" . $params['element'] . ", lipsum_temp_strings[lipsum_temp_pointer]);
01995 ";
01996 }
01997 }
01998
01999 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']) {
02000 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/class.tx_rtehtmlarea_base.php']);
02001 }
02002
02003 ?>