/**
     * Parses the ExtDirect configuration array "$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']"
     * and feeds the given typo3ajax instance with the resulting information. The get parameter
     * "namespace" will be used to filter the configuration.
     *
     * This method makes usage of the reflection mechanism to fetch the methods inside the
     * defined classes together with their amount of parameters. This information are building
     * the API and are required by ExtDirect. The result is cached to improve the overall
     * performance.
     *
     * @param array $ajaxParams ajax parameters
     * @param TYPO3AJAX $ajaxObj typo3ajax instance
     * @return void
     */
    public function getAPI($ajaxParams, TYPO3AJAX $ajaxObj)
    {
        $filterNamespace = t3lib_div::_GET('namespace');
        // Check GET-parameter no_cache and extCache setting
        $extCache = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && ($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === 0 || $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0');
        $noCache = t3lib_div::_GET('no_cache') ? TRUE : $extCache;
        // look up into the cache
        $cacheIdentifier = 'ExtDirectApi';
        $cacheHash = md5($cacheIdentifier . $filterNamespace . serialize($this->settings));
        // with no_cache always generate the javascript content
        $cacheContent = $noCache ? '' : t3lib_pageSelect::getHash($cacheHash);
        // generate the javascript content if it wasn't found inside the cache and cache it!
        if (!$cacheContent) {
            $javascriptNamespaces = $this->generateAPI($filterNamespace);
            if (!empty($javascriptNamespaces)) {
                t3lib_pageSelect::storeHash($cacheHash, serialize($javascriptNamespaces), $cacheIdentifier);
            }
        } else {
            $javascriptNamespaces = unserialize($cacheContent);
        }
        // return the generated javascript API configuration
        if (count($javascriptNamespaces)) {
            $setup = '
				if (typeof Ext.app.ExtDirectAPI !== "object") {
					Ext.app.ExtDirectAPI = {};
				}

				if (typeof Object.extend !== "function") {
					Object.extend = function(destination, source) {
						for (var property in source) {
							destination[property] = source[property];
						}
						return destination;
					};
				}
			';
            $ajaxObj->setContent($javascriptNamespaces);
            $ajaxObj->setContentFormat('javascript');
            $ajaxObj->setJavascriptCallbackWrap($setup . 'Ext.app.ExtDirectAPI = Object.extend(Ext.app.ExtDirectAPI, |);');
        } else {
            if ($filterNamespace) {
                // namespace error
                $errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.namespaceError'), __CLASS__, $filterNamespace);
            } else {
                // no namespace given
                $errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.noNamespace'), __CLASS__);
            }
            // make js multiline message
            $msg = t3lib_div::trimExplode(LF, str_replace('"', '\\"', $errorMessage), TRUE);
            $errorMessage = '';
            foreach ($msg as $line) {
                $errorMessage .= '"' . $line . '" + ' . LF;
            }
            $errorMessage = substr(trim($errorMessage), 0, -1);
            //generate the javascript
            $ajaxObj->setContentFormat('javascript');
            $ajaxObj->setJavascriptCallbackWrap('
				errorMessage = ' . $errorMessage . ';
				if (typeof console === "object") {
					console.log(errorMessage);
				} else {
					alert(errorMessage);
				}
			');
        }
    }
 /**
  * Converts an XML string to a PHP array.
  * This is the reverse function of array2xml()
  * This is a wrapper for xml2arrayProcess that adds a two-level cache
  *
  * @param string $string XML content to convert into an array
  * @param string $NSprefix The tag-prefix resolve, eg. a namespace like "T3:"
  * @param boolean $reportDocTag If set, the document tag will be set in the key "_DOCUMENT_TAG" of the output array
  * @return mixed If the parsing had errors, a string with the error message is returned. Otherwise an array with the content.
  * @see array2xml(),xml2arrayProcess()
  */
 public static function xml2array($string, $NSprefix = '', $reportDocTag = FALSE)
 {
     static $firstLevelCache = array();
     $identifier = md5($string . $NSprefix . ($reportDocTag ? '1' : '0'));
     // look up in first level cache
     if (!empty($firstLevelCache[$identifier])) {
         $array = $firstLevelCache[$identifier];
     } else {
         // look up in second level cache
         $cacheContent = t3lib_pageSelect::getHash($identifier, 0);
         $array = unserialize($cacheContent);
         if ($array === FALSE) {
             $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
             t3lib_pageSelect::storeHash($identifier, serialize($array), 'ident_xml2array');
         }
         // store content in first level cache
         $firstLevelCache[$identifier] = $array;
     }
     return $array;
 }
 /**
  * This is all about fetching the right TypoScript template structure. If it's not cached then it must be generated and cached!
  * The method traverses the rootline structure from out to in, fetches the hierarchy of template records and based on this either finds the cached TypoScript template structure or parses the template and caches it for next time.
  * Sets $this->setup to the parsed TypoScript template array
  *
  * @param	array		The rootline of the current page (going ALL the way to tree root)
  * @return	void
  * @see tslib_fe::getConfigArray()
  */
 function start($theRootLine)
 {
     if (is_array($theRootLine)) {
         $setupData = '';
         $hash = '';
         // Flag that indicates that the existing data in cache_pagesection
         // could be used (this is the case if $TSFE->all is set, and the
         // rowSum still matches). Based on this we decide if cache_pagesection
         // needs to be updated...
         $isCached = false;
         $this->runThroughTemplates($theRootLine);
         if ($GLOBALS['TSFE']->all) {
             $cc = $GLOBALS['TSFE']->all;
             // The two rowSums must NOT be different from each other - which they will be if start/endtime or hidden has changed!
             if (strcmp(serialize($this->rowSum), serialize($cc['rowSum']))) {
                 unset($cc);
                 // If the two rowSums differ, we need to re-make the current page data and therefore clear the existing values.
             } else {
                 // If $TSFE->all contains valid data, we don't need to update cache_pagesection (because this data was fetched from there already)
                 if (!strcmp(serialize($this->rootLine), serialize($cc['rootLine']))) {
                     $isCached = true;
                 }
                 // When the data is serialized below (ROWSUM hash), it must not contain the rootline by concept. So this must be removed (and added again later)...
                 unset($cc['rootLine']);
             }
         }
         // This is about getting the hash string which is used to fetch the cached TypoScript template.
         // If there was some cached currentPageData ($cc) then that's good (it gives us the hash).
         if (is_array($cc)) {
             // If currentPageData was actually there, we match the result (if this wasn't done already in $TSFE->getFromCache()...)
             if (!$cc['match']) {
                 // TODO: check if this can ever be the case - otherwise remove
                 $cc = $this->matching($cc);
                 ksort($cc);
             }
             $hash = md5(serialize($cc));
         } else {
             // If currentPageData was not there, we first find $rowSum (freshly generated). After that we try to see, if it is stored with a list of all conditions. If so we match the result.
             $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
             $result = t3lib_pageSelect::getHash($rowSumHash);
             if ($result) {
                 $cc = array();
                 $cc['all'] = unserialize($result);
                 $cc['rowSum'] = $this->rowSum;
                 $cc = $this->matching($cc);
                 ksort($cc);
                 $hash = md5(serialize($cc));
             }
         }
         if ($hash) {
             // Get TypoScript setup array
             $setupData = t3lib_pageSelect::getHash($hash);
         }
         if ($setupData && !$this->forceTemplateParsing) {
             // If TypoScript setup structure was cached we unserialize it here:
             $this->setup = unserialize($setupData);
         } else {
             // Make configuration
             $this->generateConfig();
             // This stores the template hash thing
             $cc = array();
             $cc['all'] = $this->sections;
             // All sections in the template at this point is found
             $cc['rowSum'] = $this->rowSum;
             // The line of templates is collected
             $cc = $this->matching($cc);
             ksort($cc);
             $hash = md5(serialize($cc));
             // This stores the data.
             t3lib_pageSelect::storeHash($hash, serialize($this->setup), 'TS_TEMPLATE');
             if ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('TS template size, serialized: ' . strlen(serialize($this->setup)) . ' bytes');
             }
             $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
             t3lib_pageSelect::storeHash($rowSumHash, serialize($cc['all']), 'TMPL_CONDITIONS_ALL');
         }
         // Add rootLine
         $cc['rootLine'] = $this->rootLine;
         ksort($cc);
         // Make global and save
         $GLOBALS['TSFE']->all = $cc;
         // Matching must be executed for every request, so this must never be part of the pagesection cache!
         unset($cc['match']);
         if (!$isCached && !$this->simulationHiddenOrTime && !$GLOBALS['TSFE']->no_cache) {
             // Only save the data if we're not simulating by hidden/starttime/endtime
             $mpvarHash = t3lib_div::md5int($GLOBALS['TSFE']->MP);
             if (TYPO3_UseCachingFramework) {
                 $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
                 /* @var $pageSectionCache t3lib_cache_AbstractCache */
                 $pageSectionCache->set(intval($GLOBALS['TSFE']->id) . '_' . $mpvarHash, serialize($cc), array('pageId_' . intval($GLOBALS['TSFE']->id), 'mpvarHash_' . $mpvarHash));
             } else {
                 $dbFields = array('content' => serialize($cc), 'tstamp' => $GLOBALS['EXEC_TIME']);
                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvarHash, $dbFields);
                 if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
                     $dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
                     $dbFields['mpvar_hash'] = $mpvarHash;
                     $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
                 }
             }
         }
         // If everything OK.
         if ($this->rootId && $this->rootLine && $this->setup) {
             $this->loaded = 1;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Init function, setting the input vars in the global space.
  *
  * @return	void
  */
 function init()
 {
     // Loading internal vars with the GET/POST parameters from outside:
     $this->file = t3lib_div::_GP('file');
     $this->width = t3lib_div::_GP('width');
     $this->height = t3lib_div::_GP('height');
     $this->sample = t3lib_div::_GP('sample');
     $this->alternativeTempPath = t3lib_div::_GP('alternativeTempPath');
     $this->effects = t3lib_div::_GP('effects');
     $this->frame = t3lib_div::_GP('frame');
     $this->bodyTag = t3lib_div::_GP('bodyTag');
     $this->title = t3lib_div::_GP('title');
     $this->wrap = t3lib_div::_GP('wrap');
     $this->md5 = t3lib_div::_GP('md5');
     $this->contentHash = t3lib_div::_GP('contentHash');
     // ***********************
     // Check parameters
     // ***********************
     // If no file-param is given, we must exit
     if (!$this->file) {
         die('Parameter Error: No file given.');
     }
     // Chech md5-checksum: If this md5-value does not match the one submitted, then we fail... (this is a kind of security that somebody don't just hit the script with a lot of different parameters
     $md5_value = md5($this->file . '|' . $this->width . '|' . $this->height . '|' . $this->effects . '|' . $this->bodyTag . '|' . $this->title . '|' . $this->wrap . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . '|');
     if ($md5_value != $this->md5) {
         die('Parameter Error: Wrong parameters sent.');
     }
     // Need to connect to database, because this is used (typo3temp_db_tracking, cached image dimensions).
     $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password);
     $GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db);
     if (TYPO3_UseCachingFramework) {
         $GLOBALS['typo3CacheManager'] = t3lib_div::makeInstance('t3lib_cache_Manager');
         $GLOBALS['typo3CacheFactory'] = t3lib_div::makeInstance('t3lib_cache_Factory');
         $GLOBALS['typo3CacheFactory']->setCacheManager($GLOBALS['typo3CacheManager']);
         t3lib_cache::initPageCache();
         t3lib_cache::initPageSectionCache();
         t3lib_cache::initContentHashCache();
     }
     // Check for the new content cache hash
     if (strlen(t3lib_div::_GP('contentHash')) > 0) {
         $this->content = t3lib_pageSelect::getHash($this->contentHash);
         if (is_null($this->content)) {
             die('Parameter Error: Content not available.');
         }
     }
     // ***********************
     // Check the file. If must be in a directory beneath the dir of this script...
     // $this->file remains unchanged, because of the code in stdgraphic, but we do check if the file exists within the current path
     // ***********************
     $test_file = PATH_site . $this->file;
     if (!t3lib_div::validPathStr($test_file)) {
         die('Parameter Error: No valid filepath');
     }
     if (!@is_file($test_file)) {
         die('The given file was not found');
     }
 }
 /**
  * Generates the API or reads it from cache
  *
  * @param  array $filterNamespaces
  * @param bool $checkGetParam
  * @return string $javascriptNamespaces
  */
 protected function getExtDirectApi(array $filterNamespaces)
 {
     // Check GET-parameter no_cache and extCache setting
     $noCache = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && ($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === 0 || $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0');
     $noCache = t3lib_div::_GET('no_cache') ? TRUE : $noCache;
     // look up into the cache
     $cacheIdentifier = 'ExtDirectApi';
     $cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . t3lib_div::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . t3lib_div::getIndpEnv('HTTP_HOST'));
     // with no_cache always generate the javascript content
     $cacheContent = $noCache ? '' : t3lib_pageSelect::getHash($cacheHash);
     // generate the javascript content if it wasn't found inside the cache and cache it!
     if (!$cacheContent) {
         $javascriptNamespaces = $this->generateAPI($filterNamespaces);
         if (count($javascriptNamespaces)) {
             t3lib_pageSelect::storeHash($cacheHash, serialize($javascriptNamespaces), $cacheIdentifier);
         }
     } else {
         $javascriptNamespaces = unserialize($cacheContent);
     }
     return $javascriptNamespaces;
 }
 /**
  * Creates the menu in the internal variables, ready for output.
  * Basically this will read the page records needed and fill in the internal $this->menuArr
  * Based on a hash of this array and some other variables the $this->result variable will be loaded either from cache OR by calling the generate() method of the class to create the menu for real.
  *
  * @return	void
  */
 function makeMenu()
 {
     if ($this->id) {
         // Initializing showAccessRestrictedPages
         if ($this->mconf['showAccessRestrictedPages']) {
             // SAVING where_groupAccess
             $SAVED_where_groupAccess = $this->sys_page->where_groupAccess;
             $this->sys_page->where_groupAccess = '';
             // Temporarily removing fe_group checking!
         }
         // Begin production of menu:
         $temp = array();
         $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
         $altSortField = $altSortFieldValue ? $altSortFieldValue : 'sorting';
         if ($this->menuNumber == 1 && $this->conf['special']) {
             // ... only for the FIRST level of a HMENU
             $value = $this->parent_cObj->stdWrap($this->conf['special.']['value'], $this->conf['special.']['value.']);
             switch ($this->conf['special']) {
                 case 'userdefined':
                     $temp = $this->includeMakeMenu($this->conf['special.'], $altSortField);
                     break;
                 case 'userfunction':
                     $temp = $this->parent_cObj->callUserFunction($this->conf['special.']['userFunc'], array_merge($this->conf['special.'], array('_altSortField' => $altSortField)), '');
                     if (!is_array($temp)) {
                         $temp = array();
                     }
                     break;
                 case 'language':
                     $temp = array();
                     // Getting current page record NOT overlaid by any translation:
                     $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $GLOBALS['TSFE']->page['uid']);
                     // Traverse languages set up:
                     $languageItems = t3lib_div::intExplode(',', $value);
                     foreach ($languageItems as $sUid) {
                         // Find overlay record:
                         if ($sUid) {
                             $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'], $sUid);
                         } else {
                             $lRecs = array();
                         }
                         // Checking if the "disabled" state should be set.
                         if (t3lib_div::hideIfNotTranslated($GLOBALS['TSFE']->page['l18n_cfg']) && $sUid && !count($lRecs) || $GLOBALS['TSFE']->page['l18n_cfg'] & 1 && (!$sUid || !count($lRecs)) || !$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs)) {
                             $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'USERDEF2' : 'USERDEF1';
                         } else {
                             $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'ACT' : 'NO';
                         }
                         if ($this->conf['addQueryString']) {
                             $getVars = $this->parent_cObj->getQueryArguments($this->conf['addQueryString.'], array('L' => $sUid), true);
                         } else {
                             $getVars = '&L=' . $sUid;
                         }
                         // Adding menu item:
                         $temp[] = array_merge(array_merge($currentPageWithNoOverlay, $lRecs), array('ITEM_STATE' => $iState, '_ADD_GETVARS' => $getVars, '_SAFE' => TRUE));
                     }
                     break;
                 case 'directory':
                     if ($value == '') {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     $items = t3lib_div::intExplode(',', $value);
                     foreach ($items as $id) {
                         $MP = $this->tmpl->getFromMPmap($id);
                         // Checking if a page is a mount page and if so, change the ID and set the MP var properly.
                         $mount_info = $this->sys_page->getMountPointInfo($id);
                         if (is_array($mount_info)) {
                             if ($mount_info['overlay']) {
                                 // Overlays should already have their full MPvars calculated:
                                 $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
                                 $MP = $MP ? $MP : $mount_info['MPvar'];
                             } else {
                                 $MP = ($MP ? $MP . ',' : '') . $mount_info['MPvar'];
                             }
                             $id = $mount_info['mount_pid'];
                         }
                         // Get sub-pages:
                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages', array('pidInList' => $id, 'orderBy' => $altSortField));
                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             $GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
                             if (is_array($row)) {
                                 // Keep mount point?
                                 $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
                                 if (is_array($mount_info) && $mount_info['overlay']) {
                                     // There is a valid mount point.
                                     $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
                                     // Using "getPage" is OK since we need the check for enableFields AND for type 2 of mount pids we DO require a doktype < 200!
                                     if (count($mp_row)) {
                                         $row = $mp_row;
                                         $row['_MP_PARAM'] = $mount_info['MPvar'];
                                     } else {
                                         unset($row);
                                     }
                                     // If the mount point could not be fetched with respect to enableFields, unset the row so it does not become a part of the menu!
                                 }
                                 // Add external MP params, then the row:
                                 if (is_array($row)) {
                                     if ($MP) {
                                         $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
                                     }
                                     $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
                                 }
                             }
                         }
                     }
                     break;
                 case 'list':
                     if ($value == '') {
                         $value = $this->id;
                     }
                     $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
                     $loadDB->start($value, 'pages');
                     $loadDB->additionalWhere['pages'] = tslib_cObj::enableFields('pages');
                     $loadDB->getFromDB();
                     foreach ($loadDB->itemArray as $val) {
                         $MP = $this->tmpl->getFromMPmap($val['id']);
                         // Keep mount point?
                         $mount_info = $this->sys_page->getMountPointInfo($val['id']);
                         if (is_array($mount_info) && $mount_info['overlay']) {
                             // There is a valid mount point.
                             $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
                             // Using "getPage" is OK since we need the check for enableFields AND for type 2 of mount pids we DO require a doktype < 200!
                             if (count($mp_row)) {
                                 $row = $mp_row;
                                 $row['_MP_PARAM'] = $mount_info['MPvar'];
                                 if ($mount_info['overlay']) {
                                     // Overlays should already have their full MPvars calculated:
                                     $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
                                     if ($MP) {
                                         unset($row['_MP_PARAM']);
                                     }
                                 }
                             } else {
                                 unset($row);
                             }
                             // If the mount point could not be fetched with respect to enableFields, unset the row so it does not become a part of the menu!
                         } else {
                             $row = $loadDB->results['pages'][$val['id']];
                         }
                         //Add versioning overlay for current page (to respect workspaces)
                         if (is_array($row)) {
                             $this->sys_page->versionOL('pages', $row, true);
                         }
                         // Add external MP params, then the row:
                         if (is_array($row)) {
                             if ($MP) {
                                 $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
                             }
                             $temp[] = $this->sys_page->getPageOverlay($row);
                         }
                     }
                     break;
                 case 'updated':
                     if ($value == '') {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     $items = t3lib_div::intExplode(',', $value);
                     if (t3lib_div::testInt($this->conf['special.']['depth'])) {
                         $depth = t3lib_div::intInRange($this->conf['special.']['depth'], 1, 20);
                         // Tree depth
                     } else {
                         $depth = 20;
                     }
                     $limit = t3lib_div::intInRange($this->conf['special.']['limit'], 0, 100);
                     // max number of items
                     $maxAge = intval(tslib_cObj::calc($this->conf['special.']['maxAge']));
                     if (!$limit) {
                         $limit = 10;
                     }
                     $mode = $this->conf['special.']['mode'];
                     // *'auto', 'manual', 'tstamp'
                     // Get id's
                     $id_list_arr = array();
                     foreach ($items as $id) {
                         $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'], 0, 100);
                         $id_list_arr[] = tslib_cObj::getTreeList(-1 * $id, $depth - 1 + $bA, $bA - 1);
                     }
                     $id_list = implode(',', $id_list_arr);
                     // Get sortField (mode)
                     switch ($mode) {
                         case 'starttime':
                             $sortField = 'starttime';
                             break;
                         case 'lastUpdated':
                         case 'manual':
                             $sortField = 'lastUpdated';
                             break;
                         case 'tstamp':
                             $sortField = 'tstamp';
                             break;
                         case 'crdate':
                             $sortField = 'crdate';
                             break;
                         default:
                             $sortField = 'SYS_LASTCHANGED';
                             break;
                     }
                     // Get
                     $extraWhere = ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
                     if ($this->conf['special.']['excludeNoSearchPages']) {
                         $extraWhere .= ' AND pages.no_search=0';
                     }
                     if ($maxAge > 0) {
                         $extraWhere .= ' AND ' . $sortField . '>' . ($GLOBALS['SIM_ACCESS_TIME'] - $maxAge);
                     }
                     $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages', array('pidInList' => '0', 'uidInList' => $id_list, 'where' => $sortField . '>=0' . $extraWhere, 'orderBy' => $altSortFieldValue ? $altSortFieldValue : $sortField . ' desc', 'max' => $limit));
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                         $GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
                         if (is_array($row)) {
                             $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
                         }
                     }
                     break;
                 case 'keywords':
                     list($value) = t3lib_div::intExplode(',', $value);
                     if (!$value) {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
                         $kw = $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']);
                     } else {
                         $value_rec = $this->sys_page->getPage($value);
                         // The page record of the 'value'.
                         $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
                         $kw = trim(tslib_cObj::keywords($value_rec[$kfieldSrc]));
                         // keywords.
                     }
                     $mode = $this->conf['special.']['mode'];
                     // *'auto', 'manual', 'tstamp'
                     switch ($mode) {
                         case 'starttime':
                             $sortField = 'starttime';
                             break;
                         case 'lastUpdated':
                         case 'manual':
                             $sortField = 'lastUpdated';
                             break;
                         case 'tstamp':
                             $sortField = 'tstamp';
                             break;
                         case 'crdate':
                             $sortField = 'crdate';
                             break;
                         default:
                             $sortField = 'SYS_LASTCHANGED';
                             break;
                     }
                     // depth, limit, extra where
                     if (t3lib_div::testInt($this->conf['special.']['depth'])) {
                         $depth = t3lib_div::intInRange($this->conf['special.']['depth'], 0, 20);
                         // Tree depth
                     } else {
                         $depth = 20;
                     }
                     $limit = t3lib_div::intInRange($this->conf['special.']['limit'], 0, 100);
                     // max number of items
                     $extraWhere = ' AND pages.uid!=' . $value . ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
                     if ($this->conf['special.']['excludeNoSearchPages']) {
                         $extraWhere .= ' AND pages.no_search=0';
                     }
                     // start point
                     $eLevel = tslib_cObj::getKey($this->parent_cObj->stdWrap($this->conf['special.']['entryLevel'], $this->conf['special.']['entryLevel.']), $this->tmpl->rootLine);
                     $startUid = intval($this->tmpl->rootLine[$eLevel]['uid']);
                     // which field is for keywords
                     $kfield = 'keywords';
                     if ($this->conf['special.']['keywordsField']) {
                         list($kfield) = explode(' ', trim($this->conf['special.']['keywordsField']));
                     }
                     // If there are keywords and the startuid is present.
                     if ($kw && $startUid) {
                         $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'], 0, 100);
                         $id_list = tslib_cObj::getTreeList(-1 * $startUid, $depth - 1 + $bA, $bA - 1);
                         $kwArr = explode(',', $kw);
                         foreach ($kwArr as $word) {
                             $word = trim($word);
                             if ($word) {
                                 $keyWordsWhereArr[] = $kfield . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($word, 'pages') . '%\'';
                             }
                         }
                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages', array('pidInList' => '0', 'uidInList' => $id_list, 'where' => '(' . implode(' OR ', $keyWordsWhereArr) . ')' . $extraWhere, 'orderBy' => $altSortFieldValue ? $altSortFieldValue : $sortField . ' desc', 'max' => $limit));
                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             $GLOBALS['TSFE']->sys_page->versionOL('pages', $row);
                             if (is_array($row)) {
                                 $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
                             }
                         }
                     }
                     break;
                 case 'rootline':
                     $begin_end = explode('|', $this->parent_cObj->stdWrap($this->conf['special.']['range'], $this->conf['special.']['range.']));
                     $begin_end[0] = intval($begin_end[0]);
                     if (!t3lib_div::testInt($begin_end[1])) {
                         $begin_end[1] = -1;
                     }
                     $beginKey = tslib_cObj::getKey($begin_end[0], $this->tmpl->rootLine);
                     $endKey = tslib_cObj::getKey($begin_end[1], $this->tmpl->rootLine);
                     if ($endKey < $beginKey) {
                         $endKey = $beginKey;
                     }
                     $rl_MParray = array();
                     foreach ($this->tmpl->rootLine as $k_rl => $v_rl) {
                         // For overlaid mount points, set the variable right now:
                         if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL']) {
                             $rl_MParray[] = $v_rl['_MP_PARAM'];
                         }
                         // Traverse rootline:
                         if ($k_rl >= $beginKey && $k_rl <= $endKey) {
                             $temp_key = $k_rl;
                             $temp[$temp_key] = $this->sys_page->getPage($v_rl['uid']);
                             if (count($temp[$temp_key])) {
                                 if (!$temp[$temp_key]['target']) {
                                     // If there are no specific target for the page, put the level specific target on.
                                     $temp[$temp_key]['target'] = $this->conf['special.']['targets.'][$k_rl];
                                     $temp[$temp_key]['_MP_PARAM'] = implode(',', $rl_MParray);
                                 }
                             } else {
                                 unset($temp[$temp_key]);
                             }
                         }
                         // For normal mount points, set the variable for next level.
                         if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL']) {
                             $rl_MParray[] = $v_rl['_MP_PARAM'];
                         }
                     }
                     // Reverse order of elements (e.g. "1,2,3,4" gets "4,3,2,1"):
                     if (isset($this->conf['special.']['reverseOrder']) && $this->conf['special.']['reverseOrder']) {
                         $temp = array_reverse($temp);
                         $rl_MParray = array_reverse($rl_MParray);
                     }
                     break;
                 case 'browse':
                     list($value) = t3lib_div::intExplode(',', $value);
                     if (!$value) {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     if ($value != $this->tmpl->rootLine[0]['uid']) {
                         // Will not work out of rootline
                         $recArr = array();
                         $value_rec = $this->sys_page->getPage($value);
                         // The page record of the 'value'.
                         if ($value_rec['pid']) {
                             // 'up' page cannot be outside rootline
                             $recArr['up'] = $this->sys_page->getPage($value_rec['pid']);
                             // The page record of 'up'.
                         }
                         if ($recArr['up']['pid'] && $value_rec['pid'] != $this->tmpl->rootLine[0]['uid']) {
                             // If the 'up' item was NOT level 0 in rootline...
                             $recArr['index'] = $this->sys_page->getPage($recArr['up']['pid']);
                             // The page record of "index".
                         }
                         // prev / next is found
                         $prevnext_menu = $this->sys_page->getMenu($value_rec['pid'], '*', $altSortField);
                         $lastKey = 0;
                         $nextActive = 0;
                         foreach ($prevnext_menu as $k_b => $v_b) {
                             if ($nextActive) {
                                 $recArr['next'] = $v_b;
                                 $nextActive = 0;
                             }
                             if ($v_b['uid'] == $value) {
                                 if ($lastKey) {
                                     $recArr['prev'] = $prevnext_menu[$lastKey];
                                 }
                                 $nextActive = 1;
                             }
                             $lastKey = $k_b;
                         }
                         reset($prevnext_menu);
                         $recArr['first'] = pos($prevnext_menu);
                         end($prevnext_menu);
                         $recArr['last'] = pos($prevnext_menu);
                         // prevsection / nextsection is found
                         if (is_array($recArr['index'])) {
                             // You can only do this, if there is a valid page two levels up!
                             $prevnextsection_menu = $this->sys_page->getMenu($recArr['index']['uid'], '*', $altSortField);
                             $lastKey = 0;
                             $nextActive = 0;
                             foreach ($prevnextsection_menu as $k_b => $v_b) {
                                 if ($nextActive) {
                                     $sectionRec_temp = $this->sys_page->getMenu($v_b['uid'], '*', $altSortField);
                                     if (count($sectionRec_temp)) {
                                         reset($sectionRec_temp);
                                         $recArr['nextsection'] = pos($sectionRec_temp);
                                         end($sectionRec_temp);
                                         $recArr['nextsection_last'] = pos($sectionRec_temp);
                                         $nextActive = 0;
                                     }
                                 }
                                 if ($v_b['uid'] == $value_rec['pid']) {
                                     if ($lastKey) {
                                         $sectionRec_temp = $this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'], '*', $altSortField);
                                         if (count($sectionRec_temp)) {
                                             reset($sectionRec_temp);
                                             $recArr['prevsection'] = pos($sectionRec_temp);
                                             end($sectionRec_temp);
                                             $recArr['prevsection_last'] = pos($sectionRec_temp);
                                         }
                                     }
                                     $nextActive = 1;
                                 }
                                 $lastKey = $k_b;
                             }
                         }
                         if ($this->conf['special.']['items.']['prevnextToSection']) {
                             if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last'])) {
                                 $recArr['prev'] = $recArr['prevsection_last'];
                             }
                             if (!is_array($recArr['next']) && is_array($recArr['nextsection'])) {
                                 $recArr['next'] = $recArr['nextsection'];
                             }
                         }
                         $items = explode('|', $this->conf['special.']['items']);
                         $c = 0;
                         foreach ($items as $k_b => $v_b) {
                             $v_b = strtolower(trim($v_b));
                             if (intval($this->conf['special.'][$v_b . '.']['uid'])) {
                                 $recArr[$v_b] = $this->sys_page->getPage(intval($this->conf['special.'][$v_b . '.']['uid']));
                                 // fetches the page in case of a hardcoded pid in template
                             }
                             if (is_array($recArr[$v_b])) {
                                 $temp[$c] = $recArr[$v_b];
                                 if ($this->conf['special.'][$v_b . '.']['target']) {
                                     $temp[$c]['target'] = $this->conf['special.'][$v_b . '.']['target'];
                                 }
                                 $tmpSpecialFields = $this->conf['special.'][$v_b . '.']['fields.'];
                                 if (is_array($tmpSpecialFields)) {
                                     foreach ($tmpSpecialFields as $fk => $val) {
                                         $temp[$c][$fk] = $val;
                                     }
                                 }
                                 $c++;
                             }
                         }
                     }
                     break;
             }
         } elseif (is_array($this->alternativeMenuTempArray)) {
             // Setting $temp array if not level 1.
             $temp = $this->alternativeMenuTempArray;
         } elseif ($this->mconf['sectionIndex']) {
             if ($GLOBALS['TSFE']->sys_language_uid && count($this->sys_page->getPageOverlay($this->id))) {
                 $sys_language_uid = intval($GLOBALS['TSFE']->sys_language_uid);
             } else {
                 $sys_language_uid = 0;
             }
             $selectSetup = array('pidInList' => $this->id, 'orderBy' => $altSortField, 'where' => 'colPos=0 AND sys_language_uid=' . $sys_language_uid, 'andWhere' => 'sectionIndex!=0');
             switch ($this->mconf['sectionIndex.']['type']) {
                 case 'all':
                     unset($selectSetup['andWhere']);
                     break;
                 case 'header':
                     $selectSetup['andWhere'] .= ' AND header_layout!=100 AND header!=""';
                     break;
             }
             $basePageRow = $this->sys_page->getPage($this->id);
             if (is_array($basePageRow)) {
                 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('tt_content', $selectSetup);
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                     $GLOBALS['TSFE']->sys_page->versionOL('tt_content', $row);
                     if (is_array($row)) {
                         $temp[$row['uid']] = $basePageRow;
                         $temp[$row['uid']]['title'] = $row['header'];
                         $temp[$row['uid']]['nav_title'] = $row['header'];
                         $temp[$row['uid']]['subtitle'] = $row['subheader'];
                         $temp[$row['uid']]['starttime'] = $row['starttime'];
                         $temp[$row['uid']]['endtime'] = $row['endtime'];
                         $temp[$row['uid']]['fe_group'] = $row['fe_group'];
                         $temp[$row['uid']]['media'] = $row['media'];
                         $temp[$row['uid']]['header_layout'] = $row['header_layout'];
                         $temp[$row['uid']]['bodytext'] = $row['bodytext'];
                         $temp[$row['uid']]['image'] = $row['image'];
                         $temp[$row['uid']]['sectionIndex_uid'] = $row['uid'];
                     }
                 }
             }
         } else {
             // Default:
             $temp = $this->sys_page->getMenu($this->id, '*', $altSortField);
             // gets the menu
         }
         $c = 0;
         $c_b = 0;
         $minItems = intval($this->mconf['minItems'] ? $this->mconf['minItems'] : $this->conf['minItems']);
         $maxItems = intval($this->mconf['maxItems'] ? $this->mconf['maxItems'] : $this->conf['maxItems']);
         $begin = tslib_cObj::calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
         $banUidArray = $this->getBannedUids();
         // Fill in the menuArr with elements that should go into the menu:
         $this->menuArr = array();
         foreach ($temp as $data) {
             $spacer = t3lib_div::inList($this->spacerIDList, $data['doktype']) || !strcmp($data['ITEM_STATE'], 'SPC') ? 1 : 0;
             // if item is a spacer, $spacer is set
             if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
                 $c_b++;
                 if ($begin <= $c_b) {
                     // If the beginning item has been reached.
                     $this->menuArr[$c] = $data;
                     $this->menuArr[$c]['isSpacer'] = $spacer;
                     $c++;
                     if ($maxItems && $c >= $maxItems) {
                         break;
                     }
                 }
             }
         }
         // Fill in fake items, if min-items is set.
         if ($minItems) {
             while ($c < $minItems) {
                 $this->menuArr[$c] = array('title' => '...', 'uid' => $GLOBALS['TSFE']->id);
                 $c++;
             }
         }
         // Setting number of menu items
         $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
         //	Passing the menuArr through a user defined function:
         if ($this->mconf['itemArrayProcFunc']) {
             if (!is_array($this->parentMenuArr)) {
                 $this->parentMenuArr = array();
             }
             $this->menuArr = $this->userProcess('itemArrayProcFunc', $this->menuArr);
         }
         $this->hash = md5(serialize($this->menuArr) . serialize($this->mconf) . serialize($this->tmpl->rootLine) . serialize($this->MP_array));
         // Get the cache timeout:
         if ($this->conf['cache_period']) {
             $cacheTimeout = $this->conf['cache_period'];
         } else {
             $cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout();
         }
         $serData = $this->sys_page->getHash($this->hash);
         if (!$serData) {
             $this->generate();
             $this->sys_page->storeHash($this->hash, serialize($this->result), 'MENUDATA', $cacheTimeout);
         } else {
             $this->result = unserialize($serData);
         }
         // End showAccessRestrictedPages
         if ($this->mconf['showAccessRestrictedPages']) {
             // RESTORING where_groupAccess
             $this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
         }
     }
 }
 /**
  * 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;
 }