/** * Load typoscript from flexValue , parse, and return conf - array * * @param string $script * @return array typoscript configuration array */ public function scriptParser($script = "") { // get constants $this->_constParser->parse(implode("\n", $GLOBALS['TSFE']->tmpl->constants), $this->_matchCondition); // recursive substitution of constants (up to 10 nested levels) for ($i = 0; $i < 10; $i++) { $old_script = $script; $script = preg_replace_callback('/\\{\\$(.[^}]*)\\}/', array($this, 'substituteConstantsCallBack'), $script); if ($old_script == $script) { break; } } if (is_array($GLOBALS['TSFE']->tmpl->setup)) { foreach ($GLOBALS['TSFE']->tmpl->setup as $tsObjectKey => $tsObjectValue) { if ($tsObjectKey !== intval($tsObjectKey)) { $this->_parser->setup[$tsObjectKey] = $tsObjectValue; } } } $script = $this->_parser->checkIncludeLines($script); $this->_parser->parse($script, $this->_matchCondition); return $this->_parser->setup; }
/** * Parses the string in each value of the input array for include-commands * * @param array Array with TypoScript in each value * @return array Same array but where the values has been parsed for include-commands */ function checkIncludeLines_array($array) { foreach ($array as $k => $v) { $array[$k] = t3lib_TSparser::checkIncludeLines($array[$k]); } return $array; }
/** * Searching TypoScript code text (for constants, config (Setup) and editorcfg) * for include instructions and does the inclusion of external TypoScript files * if needed. * * @return void * @see t3lib_TSparser, generateConfig() */ public function processIncludes() { $files = array(); foreach ($this->constants as &$value) { $includeData = t3lib_TSparser::checkIncludeLines($value, 1, true); $files = array_merge($files, $includeData['files']); $value = $includeData['typoscript']; } foreach ($this->config as &$value) { $includeData = t3lib_TSparser::checkIncludeLines($value, 1, true); $files = array_merge($files, $includeData['files']); $value = $includeData['typoscript']; } foreach ($this->editorcfg as &$value) { $includeData = t3lib_TSparser::checkIncludeLines($value, 1, true); $files = array_merge($files, $includeData['files']); $value = $includeData['typoscript']; } if (count($files)) { $files = array_unique($files); foreach ($files as $file) { $this->rowSum[] = array($file, filemtime($file)); } } }
/** * Process template row after loading * * @param array $tplRow: template row * @return array preprocessed template row * @author Fabrizio Branca <*****@*****.**> */ function processTemplateRowAfterLoading(array $tplRow) { if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) { // Let the recursion detection counter start at 91, so that only 10 recursive calls will be resolved // Otherwise the editor will be bloated with way to many lines making it hard the break the cyclic recursion. $tplRow['config'] = t3lib_TSparser::checkIncludeLines($tplRow['config'], 91); $tplRow['constants'] = t3lib_TSparser::checkIncludeLines($tplRow['constants'], 91); } return $tplRow; }
/** * initial all the values for the RTE * * @param array config to use * @param array rteId (a counter) * @return array initiated config */ function init($thisConfig, $rteId = 1, $PA = array()) { global $LANG; if (TYPO3_MODE == 'BE') { global $BE_USER; } if (TYPO3_branch == 4.1 && !t3lib_extMgm::isLoaded('tinymce_rte_patch41')) { die('for TYPO3 4.1 you need to install the extension tinymce_rte_patch41'); } // get the language (also checks if lib is called from FE or BE, which might of use later.) // $LANG = (TYPO3_MODE == 'FE') ? $GLOBALS['TSFE'] : $GLOBALS['LANG']; if (TYPO3_MODE == 'FE') { $LANG = t3lib_div::makeInstance('language'); $LANG->init($GLOBALS['TSFE']->tmpl->setup['config.']['language']); $LANG->includeLLFile('typo3conf/ext/tinymce_rte/mod1/locallang_browse_links.xml'); } else { $LANG = $GLOBALS['LANG']; } $this->language = $LANG->lang; // language conversion from TLD to iso631 if (is_array($LANG->csConvObj->isoArray) && array_key_exists($this->language, $LANG->csConvObj->isoArray)) { $this->language = $LANG->csConvObj->isoArray[$this->language]; } // check if TinyMCE language file exists $langpath = t3lib_extmgm::isLoaded($thisConfig['languagesExtension']) ? t3lib_extMgm::siteRelPath($thisConfig['languagesExtension']) : t3lib_extMgm::siteRelPath('tinymce_rte') . 'res/'; if (!is_file(PATH_site . $langpath . 'tiny_mce/langs/' . $this->language . '.js')) { $this->language = 'en'; } if (!is_array($BE_USER->userTS['RTE.'])) { $BE_USER->userTS['RTE.'] = array(); } $config = array('init.' => array('language' => $this->language, 'document_base_url' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'), 'elements' => 'RTEarea' . $rteId)); if (!$this->cfgOrder) { $this->cfgOrder = array('default'); } // override with loadConfig if (is_file($this->getpath($thisConfig['loadConfig'], 1))) { $tsparser = t3lib_div::makeInstance('t3lib_tsparser'); $loadConfig = t3lib_TSparser::checkIncludeLines(file_get_contents($this->getpath($thisConfig['loadConfig'], 1))); $tsparser->parse($loadConfig); $thisConfig = $this->array_merge_recursive_override($tsparser->setup['RTE.']['default.'], $thisConfig); // override with userConfig $thisConfig = $this->array_merge_recursive_override($thisConfig, $BE_USER->userTS['RTE.']['default.']); $pageTs = t3lib_BEfunc::getPagesTSconfig($this->currentPage); // Merge configs foreach ($this->cfgOrder as $order) { $order = explode('.', $order); // Only use this when order[0] matches tablename contained in $PA['itemFormElName'] // otherwise all configurations delivered by the hook would be merged if (preg_match('/' . $order[0] . '/', $PA['itemFormElName']) || $order[0] == 'default') { // Added even cases , since we do not know what ext developers return using the hook // Do we need higher cases, since we do not know what will come from the hook? switch (count($order)) { case 5: $tsc = $pageTs['RTE.'][$order[0] . '.'][$order[1] . '.'][$order[2] . '.'][$order[3] . '.'][$order[4] . '.']; $utsc = $BE_USER->userTS['RTE.'][$order[0] . '.'][$order[1] . '.'][$order[2] . '.'][$order[3] . '.'][$order[4] . '.']; break; case 4: $tsc = $pageTs['RTE.'][$order[0] . '.'][$order[1] . '.'][$order[2] . '.'][$order[3] . '.']; $utsc = $BE_USER->userTS['RTE.'][$order[0] . '.'][$order[1] . '.'][$order[2] . '.'][$order[3] . '.']; break; case 3: $tsc = $pageTs['RTE.'][$order[0] . '.'][$order[1] . '.'][$order[2] . '.']; $utsc = $BE_USER->userTS['RTE.'][$order[0] . '.'][$order[1] . '.'][$order[2] . '.']; break; case 2: $tsc = $pageTs['RTE.'][$order[0] . '.'][$order[1] . '.']; $utsc = $BE_USER->userTS['RTE.'][$order[0] . '.'][$order[1] . '.']; break; default: $tsc = $pageTs['RTE.'][$order[0] . '.']; $utsc = $BE_USER->userTS['RTE.'][$order[0] . '.']; break; } } if (isset($tsc)) { $thisConfig = $this->array_merge_recursive_override($thisConfig, $tsc); } if (isset($utsc)) { $thisConfig = $this->array_merge_recursive_override($thisConfig, $utsc); } } unset($thisConfig['field.']); unset($thisConfig['lang.']); } $config = $this->array_merge_recursive_override($config, $thisConfig); // resolve EXT pathes for these values $config['init.']['spellchecker_rpc_url'] = $this->getPath($config['init.']['spellchecker_rpc_url']); $config['tiny_mcePath'] = $this->getPath($config['tiny_mcePath']); $config['tiny_mceGzipPath'] = $this->getPath($config['tiny_mceGzipPath']); // defines if you want to force UTF8 on every config entry $this->forceUTF8 = $config['forceUTF8'] ? true : false; return $config; }
function main() { // Initializes the module. Done in this function because we may need to re-initialize if data is submitted! global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS; global $tmpl, $tplRow, $theConstants, $rootLine; // ************************** // Checking for more than one template an if, set a menu... // ************************** $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS["templatesOnPage"]; } // ************************** // Main // ************************** // BUGBUG: Should we check if the uset may at all read and write template-records??? $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize if ($existTemplate) { $theOutput .= $this->pObj->doc->divider(5); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('currentTemplate', true), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . $this->pObj->linkWrapTemplateTitle($tplRow["title"]) . '</strong>' . htmlspecialchars(trim($tplRow["sitetitle"]) ? ' - (' . $tplRow["sitetitle"] . ')' : '')); } if ($manyTemplatesMenu) { $theOutput .= $this->pObj->doc->section("", $manyTemplatesMenu); } // debug($tmpl->hierarchyInfo); $tmpl->clearList_const_temp = array_flip($tmpl->clearList_const); $tmpl->clearList_setup_temp = array_flip($tmpl->clearList_setup); $pointer = count($tmpl->hierarchyInfo); $tmpl->hierarchyInfoArr = $tmpl->ext_process_hierarchyInfo(array(), $pointer); $tmpl->processIncludes(); $hierarArr = array(); $head = '<tr class="t3-row-header">'; $head .= '<td>' . $GLOBALS['LANG']->getLL('title', true) . '</td>'; $head .= '<td>' . $GLOBALS['LANG']->getLL('rootlevel', true) . '</td>'; $head .= '<td>' . $GLOBALS['LANG']->getLL('clearSetup', true) . '</td>'; $head .= '<td>' . $GLOBALS['LANG']->getLL('clearConstants', true) . '</td>'; $head .= '<td>' . $GLOBALS['LANG']->getLL('pid', true) . '</td>'; $head .= '<td>' . $GLOBALS['LANG']->getLL('rootline', true) . '</td>'; $head .= '<td>' . $GLOBALS['LANG']->getLL('nextLevel', true) . '</td>'; $head .= '</tr>'; $hierar = implode(array_reverse($tmpl->ext_getTemplateHierarchyArr($tmpl->hierarchyInfoArr, "", array(), 1)), ""); $hierar = '<table id="ts-analyzer" border="0" cellpadding="0" cellspacing="1">' . $head . $hierar . '</table>'; $theOutput .= $this->pObj->doc->spacer(5); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateHierarchy', true), $hierar, 0, 1); $completeLink = '<p><a href="index.php?id=' . $GLOBALS['SOBE']->id . '&template=all">' . $GLOBALS['LANG']->getLL('viewCompleteTS', TRUE) . '</a></p>'; $theOutput .= $this->pObj->doc->spacer(5); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('completeTS', TRUE), $completeLink, 0, 1); // Output options $theOutput .= $this->pObj->doc->spacer(25); $theOutput .= $this->pObj->doc->divider(0); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('displayOptions', true), '', 1, 1); $addParams = t3lib_div::_GET('template') ? '&template=' . t3lib_div::_GET('template') : ''; $theOutput .= '<div class="tst-analyzer-options">' . t3lib_BEfunc::getFuncCheck($this->pObj->id, "SET[ts_analyzer_checkLinenum]", $this->pObj->MOD_SETTINGS["ts_analyzer_checkLinenum"], '', $addParams, 'id="checkTs_analyzer_checkLinenum"') . '<label for="checkTs_analyzer_checkLinenum">' . $GLOBALS['LANG']->getLL('lineNumbers', true) . '</label> ' . t3lib_BEfunc::getFuncCheck($this->pObj->id, "SET[ts_analyzer_checkSyntax]", $this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntax"], '', $addParams, 'id="checkTs_analyzer_checkSyntax"') . '<label for="checkTs_analyzer_checkSyntax">' . $GLOBALS['LANG']->getLL('syntaxHighlight', true) . '</label> ' . (!$this->pObj->MOD_SETTINGS["ts_analyzer_checkSyntax"] ? t3lib_BEfunc::getFuncCheck($this->pObj->id, "SET[ts_analyzer_checkComments]", $this->pObj->MOD_SETTINGS["ts_analyzer_checkComments"], '', $addParams, 'id="checkTs_analyzer_checkComments"') . '<label for="checkTs_analyzer_checkComments">' . $GLOBALS['LANG']->getLL('comments', true) . '</label> ' . t3lib_BEfunc::getFuncCheck($this->pObj->id, "SET[ts_analyzer_checkCrop]", $this->pObj->MOD_SETTINGS["ts_analyzer_checkCrop"], '', $addParams, 'id="checkTs_analyzer_checkCrop"') . '<label for="checkTs_analyzer_checkCrop">' . $GLOBALS['LANG']->getLL('cropLines', true) . '</label> ' : '') . '</div>'; // Output Constants if (t3lib_div::_GET('template')) { $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants', true), "", 0, 1); $theOutput .= $this->pObj->doc->sectionEnd(); $theOutput .= ' <table border="0" cellpadding="1" cellspacing="0"> '; $tmpl->ext_lineNumberOffset = -2; // Don't know why -2 and not 0... :-) But works. $tmpl->ext_lineNumberOffset_mode = "const"; $tmpl->ext_lineNumberOffset += count(explode(LF, t3lib_TSparser::checkIncludeLines("" . $GLOBALS["TYPO3_CONF_VARS"]["FE"]["defaultTypoScript_constants"]))) + 1; reset($tmpl->clearList_const); foreach ($tmpl->constants as $key => $val) { $cVal = current($tmpl->clearList_const); if ($cVal == t3lib_div::_GET('template') || t3lib_div::_GET('template') == 'all') { $theOutput .= ' <tr> <td><img src="clear.gif" width="3" height="1" alt="" /></td><td class="bgColor2"><strong>' . htmlspecialchars($tmpl->templateTitles[$cVal]) . '</strong></td></tr> <tr> <td><img src="clear.gif" width="3" height="1" alt="" /></td> <td class="bgColor2"><table border="0" cellpadding="0" cellspacing="0" class="bgColor0" width="100%"><tr><td nowrap="nowrap">' . $tmpl->ext_outputTS(array($val), $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0) . '</td></tr></table> </td> </tr> '; if (t3lib_div::_GET('template') != "all") { break; } } $tmpl->ext_lineNumberOffset += count(explode(LF, $val)) + 1; next($tmpl->clearList_const); } $theOutput .= ' </table> '; } // Output setup if (t3lib_div::_GET('template')) { $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup', true), "", 0, 1); $theOutput .= $this->pObj->doc->sectionEnd(); $theOutput .= ' <table border="0" cellpadding="1" cellspacing="0"> '; $tmpl->ext_lineNumberOffset = 0; $tmpl->ext_lineNumberOffset_mode = "setup"; $tmpl->ext_lineNumberOffset += count(explode(LF, t3lib_TSparser::checkIncludeLines("" . $GLOBALS["TYPO3_CONF_VARS"]["FE"]["defaultTypoScript_setup"]))) + 1; reset($tmpl->clearList_setup); foreach ($tmpl->config as $key => $val) { if (current($tmpl->clearList_setup) == t3lib_div::_GET('template') || t3lib_div::_GET('template') == 'all') { $theOutput .= ' <tr> <td><img src="clear.gif" width="3" height="1" alt="" /></td><td class="bgColor2"><strong>' . htmlspecialchars($tmpl->templateTitles[current($tmpl->clearList_setup)]) . '</strong></td></tr> <tr> <td><img src="clear.gif" width="3" height="1" alt="" /></td> <td class="bgColor2"><table border="0" cellpadding="0" cellspacing="0" class="bgColor0" width="100%"><tr><td nowrap="nowrap">' . $tmpl->ext_outputTS(array($val), $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0) . '</td></tr></table> </td> </tr> '; if (t3lib_div::_GET('template') != "all") { break; } } $tmpl->ext_lineNumberOffset += count(explode(LF, $val)) + 1; next($tmpl->clearList_setup); } $theOutput .= ' </table> '; } return $theOutput; }
/** * @param $strategy * @return array */ protected function getStrategyConfig($strategy) { if ($this->strategyConfig[$strategy['uid']] === NULL) { $parseObj = t3lib_div::makeInstance('t3lib_TSparser'); $config = t3lib_TSparser::checkIncludeLines($strategy['config']); $parseObj->parse($config); $config = $parseObj->setup; $this->strategyConfig[$strategy['uid']] = $config; } return $this->strategyConfig[$strategy['uid']]; }