/** * Get The Page ID * This gets the id of the page, checks if the page is in the domain and if the page is accessible * Sets variables such as $this->sys_page, $this->loginUser, $this->gr_list, $this->id, $this->type, $this->domainStartPage, $this->idParts * * @return void * @access private * @todo Define visibility */ public function fetch_the_id() { $GLOBALS['TT']->push('fetch_the_id initialize/', ''); // Initialize the page-select functions. $this->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $this->sys_page->versioningPreview = $this->fePreview === 2 || intval($this->workspacePreview) || \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_view') ? TRUE : FALSE; $this->sys_page->versioningWorkspaceId = $this->whichWorkspace(); $this->sys_page->init($this->showHiddenPage); // Set the valid usergroups for FE $this->initUserGroups(); // Sets sys_page where-clause $this->setSysPageWhereClause(); // Splitting $this->id by a period (.). // First part is 'id' and second part (if exists) will overrule the &type param $idParts = explode('.', $this->id, 2); $this->id = $idParts[0]; if (isset($idParts[1])) { $this->type = $idParts[1]; } // Splitting $this->id by a comma (,). // First part is 'id' and other parts are just stored for use in scripts. // Still used in the old wapversion.lib files. $this->idParts = explode(',', $this->id); $this->id = $this->idParts[0]; // Hook for further id manipulation if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'])) { $_params = array('id' => $this->id); $newId = FALSE; foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'] as $_funcRef) { $deprecationMessage = 'Hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_fe.php][modifyPageId] is ' . 'deprecated since 6.0 and will be removed two versions later'; if (!is_object($_funcRef) || !is_a($_funcRef, 'Closure')) { $deprecationMessage .= '- used by ' . $_funcRef; } \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog($deprecationMessage); $newIdFromFunc = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this); if ($newIdFromFunc !== FALSE) { $newId = $newIdFromFunc; } } if ($newId !== FALSE) { $this->id = $newId; } } // If $this->id is a string, it's an alias $this->checkAndSetAlias(); // The id and type is set to the integer-value - just to be sure... $this->id = intval($this->id); $this->type = intval($this->type); $GLOBALS['TT']->pull(); // We find the first page belonging to the current domain $GLOBALS['TT']->push('fetch_the_id domain/', ''); // The page_id of the current domain $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']); if (!$this->id) { if ($this->domainStartPage) { // If the id was not previously set, set it to the id of the domain. $this->id = $this->domainStartPage; } else { // Find the first 'visible' page in that domain $theFirstPage = $this->sys_page->getFirstWebPage($this->id); if ($theFirstPage) { $this->id = $theFirstPage['uid']; } else { $message = 'No pages are found on the rootlevel!'; if ($this->checkPageUnavailableHandler()) { $this->pageUnavailableAndExit($message); } else { \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR); throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1301648975); } } } } $GLOBALS['TT']->pull(); $GLOBALS['TT']->push('fetch_the_id rootLine/', ''); // We store the originally requested id $requestedId = $this->id; $this->getPageAndRootlineWithDomain($this->domainStartPage); $GLOBALS['TT']->pull(); if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { $pNotFoundMsg = array(1 => 'ID was not an accessible page', 2 => 'Subsection was found and not accessible', 3 => 'ID was outside the domain', 4 => 'The requested page alias does not exist'); $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]); } if ($this->page['url_scheme'] > 0) { $newUrl = ''; $requestUrlScheme = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME); if ((int) $this->page['url_scheme'] === \t3lib_utility_http::SCHEME_HTTP && $requestUrlScheme == 'https') { $newUrl = 'http://' . substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 8); } elseif ((int) $this->page['url_scheme'] === \t3lib_utility_http::SCHEME_HTTPS && $requestUrlScheme == 'http') { $newUrl = 'https://' . substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 7); } if ($newUrl !== '') { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $headerCode = \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303; } else { $headerCode = \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_301; } \t3lib_utility_http::redirect($newUrl, $headerCode); } } // Set no_cache if set if ($this->page['no_cache']) { $this->set_no_cache(); } // Init SYS_LASTCHANGED $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']); if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED'])) { $this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']); } if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'])) { foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'] as $functionReference) { $parameters = array('parentObject' => $this); \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($functionReference, $parameters, $this); } } }
/** * Get The Page ID * This gets the id of the page, checks if the page is in the domain and if the page is accessible * Sets variables such as $this->sys_page, $this->loginUser, $this->gr_list, $this->id, $this->type, $this->domainStartPage * * @throws ServiceUnavailableException * @return void * @access private */ public function fetch_the_id() { $timeTracker = $this->getTimeTracker(); $timeTracker->push('fetch_the_id initialize/', ''); // Initialize the page-select functions. $this->sys_page = GeneralUtility::makeInstance(PageRepository::class); $this->sys_page->versioningPreview = $this->fePreview === 2 || (int) $this->workspacePreview || (bool) GeneralUtility::_GP('ADMCMD_view'); $this->sys_page->versioningWorkspaceId = $this->whichWorkspace(); $this->sys_page->init($this->showHiddenPage); // Set the valid usergroups for FE $this->initUserGroups(); // Sets sys_page where-clause $this->setSysPageWhereClause(); // Splitting $this->id by a period (.). // First part is 'id' and second part (if exists) will overrule the &type param $idParts = explode('.', $this->id, 2); $this->id = $idParts[0]; if (isset($idParts[1])) { $this->type = $idParts[1]; } // If $this->id is a string, it's an alias $this->checkAndSetAlias(); // The id and type is set to the integer-value - just to be sure... $this->id = (int) $this->id; $this->type = (int) $this->type; $timeTracker->pull(); // We find the first page belonging to the current domain $timeTracker->push('fetch_the_id domain/', ''); // The page_id of the current domain $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']); if (!$this->id) { if ($this->domainStartPage) { // If the id was not previously set, set it to the id of the domain. $this->id = $this->domainStartPage; } else { // Find the first 'visible' page in that domain $theFirstPage = $this->sys_page->getFirstWebPage($this->id); if ($theFirstPage) { $this->id = $theFirstPage['uid']; } else { $message = 'No pages are found on the rootlevel!'; if ($this->checkPageUnavailableHandler()) { $this->pageUnavailableAndExit($message); } else { GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR); throw new ServiceUnavailableException($message, 1301648975); } } } } $timeTracker->pull(); $timeTracker->push('fetch_the_id rootLine/', ''); // We store the originally requested id $this->requestedId = $this->id; $this->getPageAndRootlineWithDomain($this->domainStartPage); $timeTracker->pull(); if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { $pNotFoundMsg = array(1 => 'ID was not an accessible page', 2 => 'Subsection was found and not accessible', 3 => 'ID was outside the domain', 4 => 'The requested page alias does not exist'); $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]); } if ($this->page['url_scheme'] > 0) { $newUrl = ''; $requestUrlScheme = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME); if ((int) $this->page['url_scheme'] === HttpUtility::SCHEME_HTTP && $requestUrlScheme == 'https') { $newUrl = 'http://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 8); } elseif ((int) $this->page['url_scheme'] === HttpUtility::SCHEME_HTTPS && $requestUrlScheme == 'http') { $newUrl = 'https://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 7); } if ($newUrl !== '') { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $headerCode = HttpUtility::HTTP_STATUS_303; } else { $headerCode = HttpUtility::HTTP_STATUS_301; } HttpUtility::redirect($newUrl, $headerCode); } } // Set no_cache if set if ($this->page['no_cache']) { $this->set_no_cache('no_cache is set in page properties'); } // Init SYS_LASTCHANGED $this->register['SYS_LASTCHANGED'] = (int) $this->page['tstamp']; if ($this->register['SYS_LASTCHANGED'] < (int) $this->page['SYS_LASTCHANGED']) { $this->register['SYS_LASTCHANGED'] = (int) $this->page['SYS_LASTCHANGED']; } if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'])) { foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'] as $functionReference) { $parameters = array('parentObject' => $this); GeneralUtility::callUserFunction($functionReference, $parameters, $this); } } }