/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // remove default breadcrumb entry if (PageMenu::getInstance()->getLandingPage()->menuItem == 'wcf.user.dashboard') { WCF::getBreadcrumbs()->remove(0); } }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // remove default breadcrumb entry and set current page as 'website' if (PageMenu::getInstance()->getLandingPage()->menuItem == 'ict.header.menu.tracker') { WCF::getBreadcrumbs()->remove(0); MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('ProjectList', array('application' => 'ict')), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'website', true); MetaTagHandler::getInstance()->addTag('og:title', 'og:title', WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:description', 'og:description', WCF::getLanguage()->get(PAGE_DESCRIPTION), true); } }
/** * Sets breadcrumbs for the given page. * * @param \cms\data\page\Page $page */ public static function setBreadcrumbs(Page $page) { if (PageMenu::getInstance()->getLandingPage()->getProcessor() instanceof CMSPageMenuItemProvider) { $pageID = PageMenu::getInstance()->getLandingPage()->getProcessor()->getPage()->pageID; } if (isset($pageID) && $pageID == $page->pageID) { WCF::getBreadcrumbs()->remove(0); } // add breadcrumbs foreach ($page->getParentPages() as $child) { WCF::getBreadcrumbs()->add($child->getBreadcrumb()); } }
public function readData() { parent::readData(); $categoryTree = new NewsCategoryNodeTree('de.codequake.cms.category.news'); $this->categoryList = $categoryTree->getIterator(); $this->categoryList->setMaxDepth(0); if (PageMenu::getInstance()->getLandingPage()->menuItem == 'cms.page.news') { WCF::getBreadcrumbs()->remove(0); MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('NewsList', array('application' => 'cms')), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'website', true); MetaTagHandler::getInstance()->addTag('og:title', 'og:title', WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:description', 'og:description', WCF::getLanguage()->get(PAGE_DESCRIPTION), true); MetaTagHandler::getInstance()->addTag('generator', 'generator', 'Fireball CMS'); } }
/** * Builds a new request. * * @param string $application */ protected function buildRequest($application) { try { $routeData = RouteHandler::getInstance()->getRouteData(); // handle landing page for frontend requests if (!$this->isACPRequest()) { $landingPage = PageMenu::getInstance()->getLandingPage(); if ($landingPage !== null && RouteHandler::getInstance()->isDefaultController()) { // check if redirect URL matches current URL $redirectURL = $landingPage->getLink(); if (StringUtil::replace(RouteHandler::getHost(), '', $redirectURL) == $_SERVER['REQUEST_URI']) { $routeData['controller'] = $landingPage->getController(); } else { // redirect to landing page HeaderUtil::redirect($landingPage->getLink(), true); exit; } } } $controller = $routeData['controller']; // validate class name if (!preg_match('~^[a-z0-9_]+$~i', $controller)) { throw new SystemException("Illegal class name '".$controller."'"); } // find class $classData = $this->getClassData($controller, 'page', $application); if ($classData === null) $classData = $this->getClassData($controller, 'form', $application); if ($classData === null) $classData = $this->getClassData($controller, 'action', $application); if ($classData === null) { throw new SystemException("unable to find class for controller '".$controller."'"); } else if (!class_exists($classData['className'])) { throw new SystemException("unable to find class '".$classData['className']."'"); } $this->activeRequest = new Request($classData['className'], $classData['controller'], $classData['pageType']); } catch (SystemException $e) { throw new IllegalLinkException(); } }
/** * Sets the breadcrumbs. * * @param \news\data\category\NewsCategory $category * @param \news\data\news\News $news */ public function setBreadcrumbs(array $parentCategories = array(), NewsCategory $category = null, News $news = null) { if (PageMenu::getInstance()->getLandingPage()->menuItem != 'news.header.menu.news') { WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('news.header.menu.news'), LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'news')))); } foreach ($parentCategories as $parentCategory) { WCF::getBreadcrumbs()->add($parentCategory->getBreadcrumb()); } if ($category !== null) { WCF::getBreadcrumbs()->add($category->getBreadcrumb()); } if ($news !== null) { if ($news->isArchived) { WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('news.header.menu.news.archive'), LinkHandler::getInstance()->getLink('NewsArchive', array('application' => 'news')))); } WCF::getBreadcrumbs()->add($news->getBreadcrumb()); } }
/** * Sets the active menu item of the page. */ protected function setActiveMenuItem() { if (!empty($this->activeMenuItem)) { if (RequestHandler::getInstance()->isACPRequest()) { ACPMenu::getInstance()->setActiveMenuItem($this->activeMenuItem); } else { PageMenu::getInstance()->setActiveMenuItem($this->activeMenuItem); } } }
/** * @see wcf\system\SingletonFactory::init() */ protected function init() { // add main breadcrumbs entry $this->add(new Breadcrumb(WCF::getLanguage()->get(PAGE_TITLE), PageMenu::getInstance()->getLandingPage()->getLink())); }
/** * Returns a relative link. * * @param string $controller * @param array $parameters * @param string $url * @return string */ public function getLink($controller = null, array $parameters = array(), $url = '') { $abbreviation = 'wcf'; $anchor = ''; $isACP = $originIsACP = RequestHandler::getInstance()->isACPRequest(); $forceWCF = $isRaw = false; $appendSession = $encodeTitle = true; // enforce a certain level of sanitation and protection for links embedded in emails if (isset($parameters['isEmail']) && (bool) $parameters['isEmail']) { $parameters['forceFrontend'] = true; $parameters['appendSession'] = false; unset($parameters['isEmail']); } if (isset($parameters['application'])) { $abbreviation = $parameters['application']; } if (isset($parameters['isRaw'])) { $isRaw = $parameters['isRaw']; unset($parameters['isRaw']); } if (isset($parameters['appendSession'])) { $appendSession = $parameters['appendSession']; unset($parameters['appendSession']); } if (isset($parameters['isACP'])) { $isACP = (bool) $parameters['isACP']; unset($parameters['isACP']); // drop session id if link leads to ACP from frontend or vice versa if ($originIsACP != $isACP) { $appendSession = false; } } if (isset($parameters['forceFrontend'])) { if ($parameters['forceFrontend'] && $isACP) { $isACP = false; $appendSession = false; } unset($parameters['forceFrontend']); } if (isset($parameters['forceWCF'])) { if ($parameters['forceWCF'] && $isACP) { $forceWCF = true; } unset($parameters['forceWCF']); } if (isset($parameters['encodeTitle'])) { $encodeTitle = $parameters['encodeTitle']; unset($parameters['encodeTitle']); } // remove anchor before parsing if (($pos = strpos($url, '#')) !== false) { $anchor = substr($url, $pos); $url = substr($url, 0, $pos); } // build route if ($controller === null) { if ($isACP) { $controller = 'Index'; } else { return PageMenu::getInstance()->getLandingPage()->getProcessor()->getLink(); } } // handle object if (isset($parameters['object'])) { if (!$parameters['object'] instanceof IRouteController && $parameters['object'] instanceof DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof IRouteController) { $parameters['object'] = $parameters['object']->getDecoratedObject(); } if ($parameters['object'] instanceof IRouteController) { $parameters['id'] = $parameters['object']->getObjectID(); $parameters['title'] = $parameters['object']->getTitle(); } } unset($parameters['object']); if (isset($parameters['title'])) { // component replacement if (!empty($this->titleSearch)) { $parameters['title'] = str_replace($this->titleSearch, $this->titleReplace, $parameters['title']); } // remove illegal characters $parameters['title'] = trim($this->titleRegex->replace($parameters['title'], '-'), '-'); // trim to 80 characters $parameters['title'] = rtrim(mb_substr($parameters['title'], 0, 80), '-'); if (!URL_LEGACY_MODE) { $parameters['title'] = mb_strtolower($parameters['title']); } // encode title if ($encodeTitle) { $parameters['title'] = rawurlencode($parameters['title']); } } $parameters['controller'] = $controller; $routeURL = RouteHandler::getInstance()->buildRoute($parameters, $isACP); if (!$isRaw && !empty($url)) { $routeURL .= strpos($routeURL, '?') === false ? '?' : '&'; } // encode certain characters if (!empty($url)) { $url = str_replace(array('[', ']'), array('%5B', '%5D'), $url); } $url = $routeURL . $url; // append session id if ($appendSession) { $url .= strpos($url, '?') === false ? SID_ARG_1ST : SID_ARG_2ND_NOT_ENCODED; } // handle applications if (!PACKAGE_ID) { $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url; } else { if (RequestHandler::getInstance()->inRescueMode()) { $pageURL = RouteHandler::getHost() . str_replace('//', '/', RouteHandler::getPath(array('acp'))); } else { // try to resolve abbreviation $application = null; if ($abbreviation != 'wcf') { $application = ApplicationHandler::getInstance()->getApplication($abbreviation); } // fallback to primary application if abbreviation is 'wcf' or unknown if ($forceWCF) { $application = ApplicationHandler::getInstance()->getWCF(); } else { if ($application === null) { $application = ApplicationHandler::getInstance()->getPrimaryApplication(); } } $pageURL = $application->getPageURL(); } $url = $pageURL . ($isACP ? 'acp/' : '') . $url; } // append previously removed anchor $url .= $anchor; return $url; }
/** * Checks page access for possible mandatory redirects. * * @param string $application * @param array $routeData */ protected function handleDefaultController($application, array &$routeData) { if (!RouteHandler::getInstance()->isDefaultController()) { return; } $landingPage = PageMenu::getInstance()->getLandingPage(); if ($landingPage === null) { return; } if (empty($routeData['controller'])) { $routeData['isImplicitController'] = true; } // resolve implicit application abbreviation for landing page controller $landingPageApplication = $landingPage->getApplication(); $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication(); $primaryApplicationAbbr = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID); if ($landingPageApplication == 'wcf') { $landingPageApplication = $primaryApplicationAbbr; } // check if currently invoked application matches the landing page if ($landingPageApplication == $application) { $routeData['controller'] = $landingPage->getController(); if (!URL_LEGACY_MODE) { $routeData['controller'] = self::getTokenizedController($routeData['controller']); } // use alias if defined to prevent incorrect recognition $alias = $this->getAliasByController($routeData['controller']); if ($alias !== null) { $routeData['controller'] = $alias; } return; } // redirect if this is the primary application if ($application === $primaryApplicationAbbr) { HeaderUtil::redirect($landingPage->getLink()); exit; } // set default controller $applicationObj = WCF::getApplicationObject(ApplicationHandler::getInstance()->getApplication($application)); $routeData['controller'] = preg_replace('~^.*?\\\\([^\\\\]+)(?:Action|Form|Page)$~', '\\1', $applicationObj->getPrimaryController()); if (!URL_LEGACY_MODE) { $routeData['controller'] = self::getTokenizedController($routeData['controller']); } }
/** * Builds a link upon route components. * * @param array $components * @return string */ public function buildLink(array $components) { $link = ''; // handle default values for controller $buildRoute = true; if (count($components) == 1 && isset($components['controller'])) { $ignoreController = false; if (isset($this->parameterOptions['controller']) && strcasecmp($this->parameterOptions['controller']['default'], $components['controller']) == 0) { // only the controller was given and matches default, omit routing $ignoreController = true; } else if (!RequestHandler::getInstance()->isACPRequest()) { $landingPage = PageMenu::getInstance()->getLandingPage(); if ($landingPage !== null && ($landingPage->getController() == $components['controller'])) { $ignoreController = true; } } // drops controller from route if ($ignoreController) { $buildRoute = false; // unset the controller, since it would otherwise added with http_build_query() unset($components['controller']); } } if ($buildRoute) { foreach ($this->routeSchema as $component) { if (!isset($components[$component])) { continue; } // handle built-in SEO if ($component === 'id' && isset($components['title'])) { $link .= $components[$component] . '-' . $components['title'] . '/'; unset($components['title']); } else { $link .= $components[$component] . '/'; } unset($components[$component]); } } if (!empty($link)) { $link = 'index.php/' . $link; } if (!empty($components)) { $link .= '?' . http_build_query($components, '', '&'); } return $link; }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // cache message data $this->cacheMessageData(); // get messages $this->readMessages(); // set active menu item if (isset($this->searchData['selectedObjectTypes']) && count($this->searchData['selectedObjectTypes']) == 1) { $objectType = SearchEngine::getInstance()->getObjectType(reset($this->searchData['selectedObjectTypes'])); if ($activeMenuItem = $objectType->getActiveMenuItem()) { PageMenu::getInstance()->setActiveMenuItem($activeMenuItem); } } // add breadcrumbs WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.search.title'), LinkHandler::getInstance()->getLink('Search'))); }
/** * Returns a relative link. * * @param string $controller * @param array $parameters * @param string $url * @return string */ public function getLink($controller = null, array $parameters = array(), $url = '') { $abbreviation = 'wcf'; $anchor = ''; $isACP = $originIsACP = RequestHandler::getInstance()->isACPRequest(); $isRaw = false; $appendSession = true; if (isset($parameters['application'])) { $abbreviation = $parameters['application']; unset($parameters['application']); } if (isset($parameters['isRaw'])) { $isRaw = $parameters['isRaw']; unset($parameters['isRaw']); } if (isset($parameters['appendSession'])) { $appendSession = $parameters['appendSession']; unset($parameters['appendSession']); } if (isset($parameters['isACP'])) { $isACP = (bool) $parameters['isACP']; unset($parameters['isACP']); // drop session id if link leads to ACP from frontend or vice versa if ($originIsACP != $isACP) { $appendSession = false; } } // remove anchor before parsing if (($pos = strpos($url, '#')) !== false) { $anchor = substr($url, $pos); $url = substr($url, 0, $pos); } // build route if ($controller === null) { // build link to landing page $landingPage = PageMenu::getInstance()->getLandingPage(); $controller = $landingPage->getController(); $abbreviation = $landingPage->getApplication(); $url = $landingPage->menuItemLink; } // handle object if (isset($parameters['object'])) { if (!($parameters['object'] instanceof IRouteController) && $parameters['object'] instanceof DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof IRouteController) { $parameters['object'] = $parameters['object']->getDecoratedObject(); } if ($parameters['object'] instanceof IRouteController) { $parameters['id'] = $parameters['object']->getObjectID(); $parameters['title'] = $parameters['object']->getTitle(); } unset($parameters['object']); } if (isset($parameters['title'])) { // remove illegal characters $parameters['title'] = trim($this->titleRegex->replace($parameters['title'], '-'), '-'); } $parameters['controller'] = $controller; $routeURL = RouteHandler::getInstance()->buildRoute($parameters); if (!$isRaw && !empty($url)) { $routeURL .= (strpos($routeURL, '?') === false) ? '?' : '&'; } $url = $routeURL . $url; // append session id if ($appendSession) { $url .= (strpos($url, '?') === false) ? SID_ARG_1ST : SID_ARG_2ND_NOT_ENCODED; } // handle applications if (!PACKAGE_ID) { $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url; } else { // try to resolve abbreviation $application = null; if ($abbreviation != 'wcf') { $application = ApplicationHandler::getInstance()->getApplication($abbreviation); } // fallback to primary application if abbreviation is 'wcf' or unknown if ($application === null) { $application = ApplicationHandler::getInstance()->getPrimaryApplication(); } $url = $application->getPageURL() . ($isACP ? 'acp/' : '') . $url; } // append previously removed anchor $url .= $anchor; return $url; }
/** * @see \wcf\system\request\IRoute::buildLink() */ public function buildLink(array $components) { $application = isset($components['application']) ? $components['application'] : null; self::loadDefaultControllers(); // drop application component to avoid being appended as query string unset($components['application']); $link = ''; // handle default values for controller $buildRoute = true; if (count($components) == 1 && isset($components['controller'])) { $ignoreController = false; if (isset($this->parameterOptions['controller']) && strcasecmp($this->parameterOptions['controller']['default'], $components['controller']) == 0) { // only the controller was given and matches default, omit routing $ignoreController = true; } else { if (!RequestHandler::getInstance()->isACPRequest()) { $landingPage = PageMenu::getInstance()->getLandingPage(); if ($landingPage !== null && strcasecmp($landingPage->getController(), $components['controller']) == 0) { $ignoreController = true; } // check if this is the default controller of the requested application if (!URL_LEGACY_MODE && !$ignoreController && $application !== null) { if (isset(self::$defaultControllers[$application]) && self::$defaultControllers[$application] == $components['controller']) { // check if this is the primary application and the landing page originates to the same application $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication(); $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID); if ($abbreviation != $application || $landingPage === null) { $ignoreController = true; } } } } } // drops controller from route if ($ignoreController) { $buildRoute = false; // unset the controller, since it would otherwise be added with http_build_query() unset($components['controller']); } } if ($buildRoute) { foreach ($this->routeSchema as $component) { if (!isset($components[$component])) { continue; } // handle controller names if (!URL_LEGACY_MODE && $component === 'controller') { $components[$component] = $this->getControllerName($application, $components[$component]); } // handle built-in SEO if ($component === 'id' && isset($components['title'])) { $link .= $components[$component] . '-' . $components['title'] . '/'; unset($components['title']); } else { $link .= $components[$component] . '/'; } unset($components[$component]); } } // enforce non-legacy URLs for ACP and disregard rewrite settings if ($this->isACP()) { if (!empty($link)) { $link = '?' . $link; } } else { if (!URL_OMIT_INDEX_PHP && !empty($link)) { $link = (URL_LEGACY_MODE ? 'index.php/' : '?') . $link; } } if (!empty($components)) { if (strpos($link, '?') === false) { $link .= '?'; } else { $link .= '&'; } $link .= http_build_query($components, '', '&'); } return $link; }
/** * @see \wcf\system\request\IRoute::buildLink() */ public function buildLink(array $components) { $application = isset($components['application']) ? $components['application'] : null; // drop application component to avoid being appended as query string unset($components['application']); // handle default values for controller $useBuildSchema = true; if (count($components) == 1 && isset($components['controller'])) { $ignoreController = false; if (!RequestHandler::getInstance()->isACPRequest()) { $landingPage = PageMenu::getInstance()->getLandingPage(); if ($this->primaryApplication === '') { $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication(); $this->primaryApplication = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID); } // check if this is the default controller if (strcasecmp(RouteHandler::getInstance()->getDefaultController($application), $components['controller']) === 0) { // check if this matches the primary application if ($this->primaryApplication === $application) { if (strcasecmp($landingPage->getController(), $components['controller']) === 0) { // skip controller if it matches the default controller $ignoreController = true; } } else { // skip default controller $ignoreController = true; } } else { if (strcasecmp($landingPage->getController(), $components['controller']) === 0) { // landing page $ignoreController = true; } } } // drops controller from route if ($ignoreController) { $useBuildSchema = false; // unset the controller, since it would otherwise be added with http_build_query() unset($components['controller']); } } return $this->buildRoute($components, $application, $useBuildSchema); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // news stats $this->stats = NewsStatsCacheBuilder::getInstance()->getData(); $this->stats['categories'] = count(CategoryHandler::getInstance()->getCategories('de.voolia.news.category')); // categories $categoryTree = new NewsCategoryNodeTree('de.voolia.news.category'); $this->categoryList = $categoryTree->getIterator(); $this->categoryList->setMaxDepth(0); // users online list if (MODULE_USERS_ONLINE && NEWS_INDEX_ENABLE_USERS_ONLINE_LIST) { $this->usersOnlineList = new UsersOnlineList(); $this->usersOnlineList->readStats(); $this->usersOnlineList->getConditionBuilder()->add('session.userID IS NOT NULL'); $this->usersOnlineList->readObjects(); } // add breadcrumbs if ($this->category !== null) { NEWSCore::getInstance()->setBreadcrumbs($this->category->getParentCategories()); } else { if (PageMenu::getInstance()->getLandingPage()->menuItem == 'news.header.menu.news') { // remove default breadcrumb entry and set current page as 'website' WCF::getBreadcrumbs()->remove(0); // meta tags MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'news')), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'website', true); MetaTagHandler::getInstance()->addTag('og:title', 'og:title', WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:description', 'og:description', WCF::getLanguage()->get(PAGE_DESCRIPTION), true); MetaTagHandler::getInstance()->addTag('generator', 'generator', 'voolia News-System'); } } }