/** * generates a string for the URL * * @param array $uParts the parts of the URL * @return string the URL string */ function getUrlStr($uParts) { $baseURL = $this->getBaseURL(); if (is_array($uParts) && GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') == $uParts['host']) { $m = array(); // do we have an id? if (preg_match('/(?:^|&)id=([0-9a-z_]+)/', $uParts['query'], $m)) { $isInt = MathUtility::canBeInterpretedAsInteger($m[1]); if ($isInt) { $uid = intval($m[1]); } else { $uid = $this->sys_page->getPageIdFromAlias($m[1]); } $temp_root_line = $this->sys_page->getRootLine($uid); $temp_page = array_shift($temp_root_line); // array_shift reverses the array (rootline has numeric index in the wrong order!) $temp_root_line = array_reverse($temp_root_line); $query = preg_replace('/(?:^|&)id=([0-9a-z_]+)/', '', $uParts['query']); $urlstr = GeneralUtility::fixed_lgd_cs($temp_page['title'], 50) . GeneralUtility::fixed_lgd_cs($query ? ' / ' . $query : '', 20); } else { $urlstr = $baseURL . substr($uParts['path'], 1); $urlstr .= $uParts['query'] ? '?' . $uParts['query'] : ''; $urlstr .= $uParts['fragment'] ? '#' . $uParts['fragment'] : ''; } } else { $urlstr = ($uParts['host'] ? $uParts['scheme'] . '://' . $uParts['host'] : $baseURL) . $uParts['path']; $urlstr .= $uParts['query'] ? '?' . $uParts['query'] : ''; $urlstr .= $uParts['fragment'] ? '#' . $uParts['fragment'] : ''; } return $urlstr; }
/** * Fixes page id if it is not a direct numeric page id. */ protected function fixPageId() { if (!MathUtility::canBeInterpretedAsInteger($this->urlParameters['id'])) { // Seems to be an alias $alias = $this->urlParameters['id']; $this->urlParameters['id'] = $this->pageRepository->getPageIdFromAlias($alias); if ($this->urlParameters['id'] === 0) { throw new \Exception(sprintf('Page with alias "%s" does not exist.', $alias), 1457183797); } } }
/** * Fetches the integer page id for a page alias. * Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id * * @return void * @access private * @todo Define visibility */ public function checkAndSetAlias() { if ($this->id && !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->id)) { $aid = $this->sys_page->getPageIdFromAlias($this->id); if ($aid) { $this->id = $aid; } else { $this->pageNotFound = 4; } } }