/**
  * Resolves the TypoScript reference for $pluginConfiguration[$setting].
  * In case the setting is a string and starts with "<", we know that this is a TypoScript reference which
  * needs to be resolved separately.
  *
  * @param array $pluginConfiguration The whole plugin configuration
  * @param string $setting The key inside the $pluginConfiguration to check
  * @return array The modified plugin configuration
  */
 protected function resolveTyposcriptReference($pluginConfiguration, $setting)
 {
     if (is_string($pluginConfiguration[$setting]) && substr($pluginConfiguration[$setting], 0, 1) === '<') {
         $key = trim(substr($pluginConfiguration[$setting], 1));
         $setup = $this->loadTypoScriptSetup();
         list(, $newValue) = $this->typoScriptParser->getVal($key, $setup);
         unset($pluginConfiguration[$setting]);
         $pluginConfiguration[$setting . '.'] = $newValue;
     }
     return $pluginConfiguration;
 }
 /**
  * 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;
 }
 /**
  * Loads Page TSconfig until the outermost template record and parses the configuration - if TSFE.constants object path is found it is merged with the default data in here!
  *
  * @param	array		Constants array, default input.
  * @return	array		Constants array, modified
  * @todo	Apply caching to the parsed Page TSconfig. This is done in the other similar functions for both frontend and backend. However, since this functions works for BOTH frontend and backend we will have to either write our own local caching function or (more likely) detect if we are in FE or BE and use caching functions accordingly. Not having caching affects mostly the backend modules inside the "Template" module since the overhead in the frontend is only seen when TypoScript templates are parsed anyways (after which point they are cached anyways...)
  */
 function mergeConstantsFromPageTSconfig($constArray)
 {
     $TSdataArray = array();
     $TSdataArray[] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
     // Setting default configuration:
     for ($a = 0; $a <= $this->outermostRootlineIndexWithTemplate; $a++) {
         $TSdataArray[] = $this->absoluteRootLine[$a]['TSconfig'];
     }
     // Parsing the user TS (or getting from cache)
     $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
     $userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
     $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
     $parseObj->parse($userTS);
     if (is_array($parseObj->setup['TSFE.']['constants.'])) {
         $constArray = t3lib_div::array_merge_recursive_overrule($constArray, $parseObj->setup['TSFE.']['constants.']);
     }
     return $constArray;
 }
 /**
  * Processes the string in each value of the input array with extractIncludes
  *
  * @param	array		Array with TypoScript in each value
  * @return	array		Same array but where the values has been processed with extractIncludes
  * @author	 Fabrizio Branca <*****@*****.**>
  */
 function extractIncludes_array($array)
 {
     foreach ($array as $k => $v) {
         $array[$k] = t3lib_TSparser::extractIncludes($array[$k]);
     }
     return $array;
 }
 /**
  * Returns the parsed TSconfig for the fe_user
  * First time this function is called it will parse the TSconfig and store it in $this->userTS. Subsequent requests will not re-parse the TSconfig but simply return what is already in $this->userTS
  *
  * @return	array		TSconfig array for the fe_user
  */
 function getUserTSconf()
 {
     if (!$this->userTSUpdated) {
         // Parsing the user TS (or getting from cache)
         $this->TSdataArray = t3lib_TSparser::checkIncludeLines_array($this->TSdataArray);
         $userTS = implode(LF . '[GLOBAL]' . LF, $this->TSdataArray);
         $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
         $parseObj->parse($userTS);
         $this->userTS = $parseObj->setup;
         $this->userTSUpdated = 1;
     }
     return $this->userTS;
 }
 /**
  * Returns the pages TSconfig array based on the currect ->rootLine
  *
  * @return	array
  */
 function getPagesTSconfig()
 {
     if (!is_array($this->pagesTSconfig)) {
         $TSdataArray = array();
         $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];
         // Setting default configuration:
         foreach ($this->rootLine as $k => $v) {
             $TSdataArray[] = $v['TSconfig'];
         }
         // Parsing the user TS (or getting from cache)
         $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
         $userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
         $hash = md5('pageTS:' . $userTS);
         $cachedContent = $this->sys_page->getHash($hash);
         if (isset($cachedContent)) {
             $this->pagesTSconfig = unserialize($cachedContent);
         } else {
             $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
             $parseObj->parse($userTS);
             $this->pagesTSconfig = $parseObj->setup;
             $this->sys_page->storeHash($hash, serialize($this->pagesTSconfig), 'PAGES_TSconfig');
         }
     }
     return $this->pagesTSconfig;
 }
 /**
  * Returns the Page TSconfig for page with id, $id
  * Requires class "t3lib_TSparser"
  * Usage: 26 (spec. in ext info_pagetsconfig)
  *
  * @param	integer		Page uid for which to create Page TSconfig
  * @param	array		If $rootLine is an array, that is used as rootline, otherwise rootline is just calculated
  * @param	boolean		If $returnPartArray is set, then the array with accumulated Page TSconfig is returned non-parsed. Otherwise the output will be parsed by the TypoScript parser.
  * @return	array		Page TSconfig
  * @see t3lib_TSparser
  */
 public static function getPagesTSconfig($id, $rootLine = '', $returnPartArray = 0)
 {
     $id = intval($id);
     if (!is_array($rootLine)) {
         $rootLine = self::BEgetRootLine($id, '', TRUE);
     }
     ksort($rootLine);
     // Order correctly
     $TSdataArray = array();
     $TSdataArray['defaultPageTSconfig'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
     // Setting default configuration:
     foreach ($rootLine as $k => $v) {
         $TSdataArray['uid_' . $v['uid']] = $v['TSconfig'];
     }
     $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
     if ($returnPartArray) {
         return $TSdataArray;
     }
     // Parsing the page TS-Config (or getting from cache)
     $pageTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
     if ($GLOBALS['TYPO3_CONF_VARS']['BE']['TSconfigConditions']) {
         /* @var $parseObj t3lib_TSparser_TSconfig */
         $parseObj = t3lib_div::makeInstance('t3lib_TSparser_TSconfig');
         $res = $parseObj->parseTSconfig($pageTS, 'PAGES', $id, $rootLine);
         if ($res) {
             $TSconfig = $res['TSconfig'];
         }
     } else {
         $hash = md5('pageTS:' . $pageTS);
         $cachedContent = self::getHash($hash);
         $TSconfig = array();
         if (isset($cachedContent)) {
             $TSconfig = unserialize($cachedContent);
         } else {
             $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
             $parseObj->parse($pageTS);
             $TSconfig = $parseObj->setup;
             self::storeHash($hash, serialize($TSconfig), 'PAGES_TSconfig');
         }
     }
     // get User TSconfig overlay
     $userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
     if (is_array($userTSconfig)) {
         $TSconfig = t3lib_div::array_merge_recursive_overrule($TSconfig, $userTSconfig);
     }
     return $TSconfig;
 }
    /**
     * Initializes a lot of stuff like the access-lists, database-mountpoints and filemountpoints
     * This method is called by ->backendCheckLogin() (from extending class t3lib_beuserauth) if the backend user login has verified OK.
     * Generally this is required initialization of a backend user.
     *
     * @return	void
     * @access private
     * @see t3lib_TSparser
     */
    function fetchGroupData()
    {
        if ($this->user['uid']) {
            // Get lists for the be_user record and set them as default/primary values.
            $this->dataLists['modList'] = $this->user['userMods'];
            // Enabled Backend Modules
            $this->dataLists['allowed_languages'] = $this->user['allowed_languages'];
            // Add Allowed Languages
            $this->dataLists['workspace_perms'] = $this->user['workspace_perms'];
            // Set user value for workspace permissions.
            $this->dataLists['webmount_list'] = $this->user['db_mountpoints'];
            // Database mountpoints
            $this->dataLists['filemount_list'] = $this->user['file_mountpoints'];
            // File mountpoints
            $this->dataLists['fileoper_perms'] = (int) $this->user['fileoper_perms'];
            // Fileoperation permissions
            // Setting default User TSconfig:
            $this->TSdataArray[] = $this->addTScomment('From $GLOBALS["TYPO3_CONF_VARS"]["BE"]["defaultUserTSconfig"]:') . $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'];
            // Default TSconfig for admin-users
            if ($this->isAdmin()) {
                $this->TSdataArray[] = $this->addTScomment('"admin" user presets:') . '
					admPanel.enable.all = 1
				';
                if (t3lib_extMgm::isLoaded('sys_note')) {
                    $this->TSdataArray[] = '
						// Setting defaults for sys_note author / email...
						TCAdefaults.sys_note.author = ' . $this->user['realName'] . '
						TCAdefaults.sys_note.email = ' . $this->user['email'] . '
					';
                }
            }
            // FILE MOUNTS:
            // Admin users has the base fileadmin dir mounted
            if ($this->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) {
                $this->addFileMount($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '', PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], 0, '');
            }
            // If userHomePath is set, we attempt to mount it
            if ($GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath']) {
                // First try and mount with [uid]_[username]
                $didMount = $this->addFileMount($this->user['username'], '', $GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'] . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'], 0, 'user');
                if (!$didMount) {
                    // If that failed, try and mount with only [uid]
                    $this->addFileMount($this->user['username'], '', $GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'] . $this->user['uid'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'], 0, 'user');
                }
            }
            // BE_GROUPS:
            // Get the groups...
            #			$grList = t3lib_BEfunc::getSQLselectableList($this->user[$this->usergroup_column],$this->usergroup_table,$this->usergroup_table);
            $grList = $GLOBALS['TYPO3_DB']->cleanIntList($this->user[$this->usergroup_column]);
            // 240203: Since the group-field never contains any references to groups with a prepended table name we think it's safe to just intExplode and re-implode - which should be much faster than the other function call.
            if ($grList) {
                // Fetch groups will add a lot of information to the internal arrays: modules, accesslists, TSconfig etc. Refer to fetchGroups() function.
                $this->fetchGroups($grList);
            }
            // Add the TSconfig for this specific user:
            $this->TSdataArray[] = $this->addTScomment('USER TSconfig field') . $this->user['TSconfig'];
            // Check include lines.
            $this->TSdataArray = t3lib_TSparser::checkIncludeLines_array($this->TSdataArray);
            $this->userTS_text = implode(LF . '[GLOBAL]' . LF, $this->TSdataArray);
            // Imploding with "[global]" will make sure that non-ended confinements with braces are ignored.
            if ($GLOBALS['TYPO3_CONF_VARS']['BE']['TSconfigConditions'] && !$this->userTS_dontGetCached) {
                // Perform TS-Config parsing with condition matching
                $parseObj = t3lib_div::makeInstance('t3lib_TSparser_TSconfig');
                $res = $parseObj->parseTSconfig($this->userTS_text, 'userTS');
                if ($res) {
                    $this->userTS = $res['TSconfig'];
                    $this->userTSUpdated = $res['cached'] ? 0 : 1;
                }
            } else {
                // Parsing the user TSconfig (or getting from cache)
                $hash = md5('userTS:' . $this->userTS_text);
                $cachedContent = t3lib_BEfunc::getHash($hash);
                if (isset($cachedContent) && !$this->userTS_dontGetCached) {
                    $this->userTS = unserialize($cachedContent);
                } else {
                    $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
                    $parseObj->parse($this->userTS_text);
                    $this->userTS = $parseObj->setup;
                    t3lib_BEfunc::storeHash($hash, serialize($this->userTS), 'BE_USER_TSconfig');
                    // Update UC:
                    $this->userTSUpdated = 1;
                }
            }
            // Processing webmounts
            if ($this->isAdmin() && !$this->getTSConfigVal('options.dontMountAdminMounts')) {
                // Admin's always have the root mounted
                $this->dataLists['webmount_list'] = '0,' . $this->dataLists['webmount_list'];
            }
            // Processing filemounts
            t3lib_div::loadTCA('sys_filemounts');
            $orderBy = $GLOBALS['TCA']['sys_filemounts']['ctrl']['default_sortby'] ? $GLOBALS['TYPO3_DB']->stripOrderBy($GLOBALS['TCA']['sys_filemounts']['ctrl']['default_sortby']) : 'sorting';
            $this->dataLists['filemount_list'] = t3lib_div::uniqueList($this->dataLists['filemount_list']);
            if ($this->dataLists['filemount_list']) {
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $this->dataLists['filemount_list'] . ')', '', $orderBy);
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                    $this->addFileMount($row['title'], $row['path'], $row['path'], $row['base'] ? 1 : 0, '');
                }
            }
            // The lists are cleaned for duplicates
            $this->groupData['webmounts'] = t3lib_div::uniqueList($this->dataLists['webmount_list']);
            $this->groupData['pagetypes_select'] = t3lib_div::uniqueList($this->dataLists['pagetypes_select']);
            $this->groupData['tables_select'] = t3lib_div::uniqueList($this->dataLists['tables_modify'] . ',' . $this->dataLists['tables_select']);
            $this->groupData['tables_modify'] = t3lib_div::uniqueList($this->dataLists['tables_modify']);
            $this->groupData['non_exclude_fields'] = t3lib_div::uniqueList($this->dataLists['non_exclude_fields']);
            $this->groupData['explicit_allowdeny'] = t3lib_div::uniqueList($this->dataLists['explicit_allowdeny']);
            $this->groupData['allowed_languages'] = t3lib_div::uniqueList($this->dataLists['allowed_languages']);
            $this->groupData['custom_options'] = t3lib_div::uniqueList($this->dataLists['custom_options']);
            $this->groupData['modules'] = t3lib_div::uniqueList($this->dataLists['modList']);
            $this->groupData['fileoper_perms'] = $this->dataLists['fileoper_perms'];
            $this->groupData['workspace_perms'] = $this->dataLists['workspace_perms'];
            // populating the $this->userGroupsUID -array with the groups in the order in which they were LAST included.!!
            $this->userGroupsUID = array_reverse(array_unique(array_reverse($this->includeGroupArray)));
            // Finally this is the list of group_uid's in the order they are parsed (including subgroups!) and without duplicates (duplicates are presented with their last entrance in the list, which thus reflects the order of the TypoScript in TSconfig)
            $this->groupList = implode(',', $this->userGroupsUID);
            $this->setCachedList($this->groupList);
            // Checking read access to webmounts:
            if (trim($this->groupData['webmounts']) !== '') {
                $webmounts = explode(',', $this->groupData['webmounts']);
                // Explode mounts
                $MProws = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'deleted=0 AND uid IN (' . $this->groupData['webmounts'] . ') AND ' . $this->getPagePermsClause(1), '', '', '', 'uid');
                // Selecting all webmounts with permission clause for reading
                foreach ($webmounts as $idx => $mountPointUid) {
                    if ($mountPointUid > 0 && !isset($MProws[$mountPointUid])) {
                        // If the mount ID is NOT found among selected pages, unset it:
                        unset($webmounts[$idx]);
                    }
                }
                $this->groupData['webmounts'] = implode(',', $webmounts);
                // Implode mounts in the end.
            }
            // Setting up workspace situation (after webmounts are processed!):
            $this->workspaceInit();
        }
    }
 /**
  * Process template row before saving
  * 
  * @param 	array 	$tplRow: template row
  * @return 	array	preprocessed template row
  * @author	Fabrizio Branca <*****@*****.**>
  */
 function processTemplateRowBeforeSaving(array $tplRow)
 {
     if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
         $tplRow = t3lib_TSparser::extractIncludes_array($tplRow);
     }
     return $tplRow;
 }
 /**
  * Call back method for preg_replace_callback in substituteConstants
  *
  * @param $matches
  * @return	string		Replacement
  * @see substituteConstants()
  */
 public function substituteConstantsCallBack($matches)
 {
     $s = $this->_constParser->getVal($matches[1], $this->_constParser->setup);
     return isset($s[0]) ? $s[0] : $matches[0];
 }
 /**
  * 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 . '&amp;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']];
 }