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