--- /dev/null
+<?php
+namespace wcf\data;
+
+/**
+ * Common interface to require both title and link.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data
+ * @category Community Framework
+ * @since 2.2
+ */
+interface ITitledLinkObject extends ILinkableObject, ITitledObject {}
* @subpackage data
* @category Community Framework
*/
-interface IUserContent extends ILinkableObject, ITitledObject {
+interface IUserContent extends ITitledLinkObject {
/**
* Returns message creation timestamp.
*
<?php
namespace wcf\data\page;
use wcf\data\DatabaseObject;
+use wcf\data\ILinkableObject;
+use wcf\data\ITitledObject;
use wcf\data\TDatabaseObjectOptions;
use wcf\data\TDatabaseObjectPermissions;
use wcf\system\application\ApplicationHandler;
* Represents a page.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data.page
* @property-read string $permissions
* @property-read string $options
*/
-class Page extends DatabaseObject {
+class Page extends DatabaseObject implements ILinkableObject, ITitledObject {
use TDatabaseObjectOptions;
use TDatabaseObjectPermissions;
}
/**
- * Returns the page URL.
- *
- * @return string
+ * @inheritDoc
*/
public function getLink() {
if ($this->controller) {
}
}
+ /**
+ * @inheritDoc
+ */
+ public function getTitle() {
+ $title = PageCache::getInstance()->getPageTitle($this->pageID);
+ if (empty($title)) {
+ $title = $this->getGenericTitle();
+ }
+
+ return $title;
+ }
+
/**
* Returns shortened link for acp page list.
*
return '';
}
+ /**
+ * Returns the value of a generic phrase based upon a page's identifier.
+ *
+ * @return string generic title
+ */
+ protected function getGenericTitle() {
+ return WCF::getLanguage()->get('wcf.page.' . $this->identifier);
+ }
+
/**
* Returns the page with the given identifier.
*
namespace wcf\data\page;
use wcf\system\cache\builder\PageCacheBuilder;
use wcf\system\SingletonFactory;
+use wcf\system\WCF;
/**
* Provides access to the page cache.
* @package com.woltlab.wcf
* @subpackage data.page
* @category Community Framework
+ * @since 2.2
*/
class PageCache extends SingletonFactory {
/**
return null;
}
+
+ /**
+ * Returns the localized page title by page id, optionally retrieving the title
+ * for given language id if it is a multilingual page.
+ *
+ * @param integer $pageID page id
+ * @param integer $languageID specific value by language id
+ * @return string localized page title
+ */
+ public function getPageTitle($pageID, $languageID = null) {
+ if (isset($this->cache['pageTitles'][$pageID])) {
+ $page = $this->getPage($pageID);
+ if ($page->isMultilingual) {
+ if ($languageID !== null && isset($this->cache['pageTitles'][$pageID][$languageID])) {
+ return $this->cache['pageTitles'][$pageID][$languageID];
+ }
+
+ return $this->cache['pageTitles'][$pageID][WCF::getUser()->getLanguage()->languageID];
+ }
+ else {
+ return $this->cache['pageTitles'][$pageID][0];
+ }
+ }
+
+ return '';
+ }
+
+ /**
+ * Returns the global landing page.
+ *
+ * @return Page
+ */
+ public function getLandingPage() {
+ return $this->cache['landingPage'];
+ }
}
<?php
namespace wcf\data\user;
+use wcf\data\ITitledLinkObject;
use wcf\data\user\avatar\DefaultAvatar;
use wcf\data\user\avatar\Gravatar;
use wcf\data\user\avatar\IUserAvatar;
use wcf\data\user\option\ViewableUserOption;
use wcf\data\user\rank\UserRank;
use wcf\data\DatabaseObjectDecorator;
-use wcf\system\breadcrumb\Breadcrumb;
-use wcf\system\breadcrumb\IBreadcrumbProvider;
use wcf\system\cache\builder\UserGroupPermissionCacheBuilder;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
* @property-read integer $likesReceived
* @property-read string $socialNetworkPrivacySettings
*/
-class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider {
+class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
/**
* @inheritDoc
*/
return ($this->activationCode ? false : true);
}
- /**
- * @inheritDoc
- */
- public function getBreadcrumb() {
- return new Breadcrumb($this->username, LinkHandler::getInstance()->getLink('User', [
- 'object' => $this
- ]));
- }
-
/**
* Returns the encoded email address.
*
return '<a href="'.$link.'" class="userLink" data-user-id="'.$this->userID.'">'.StringUtil::encodeHTML($this->username).'</a>';
}
+ /**
+ * @inheritDoc
+ */
+ public function getLink() {
+ return $this->getDecoratedObject()->getLink();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTitle() {
+ return $this->getDecoratedObject()->getTitle();
+ }
+
/**
* Returns an "empty" user profile object for a guest with the given username.
*
use wcf\data\comment\StructuredCommentList;
use wcf\data\moderation\queue\ModerationQueueAction;
use wcf\data\moderation\queue\ViewableModerationQueue;
-use wcf\system\breadcrumb\Breadcrumb;
use wcf\system\comment\manager\ICommentManager;
use wcf\system\comment\CommentHandler;
use wcf\system\event\EventHandler;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
-use wcf\system\request\LinkHandler;
+use wcf\system\page\PageLocationManager;
use wcf\system\WCF;
/**
$this->assignedUserID = $this->queue->assignedUserID;
}
- WCF::getBreadcrumbs()->add(new Breadcrumb(
- WCF::getLanguage()->get('wcf.moderation.moderation'),
- LinkHandler::getInstance()->getLink('ModerationList')
- ));
+ PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.ModerationList');
$this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue');
$this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor();
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\mail\Mail;
+use wcf\system\page\PageLocationManager;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
* Shows the user mail form.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage form
*/
class MailForm extends AbstractCaptchaForm {
/**
- * @see \wcf\form\AbstractCaptchaForm::$useCaptcha
+ * @inheritDoc
*/
public $useCaptcha = PROFILE_MAIL_USE_CAPTCHA;
public $email = '';
/**
- * @see \wcf\page\IPage::readParameters()
+ * @inheritDoc
+ */
+ public $neededPermissions = ['user.profile.canMail'];
+
+ /**
+ * @inheritDoc
*/
public function readParameters() {
parent::readParameters();
throw new PermissionDeniedException();
}
- $this->canonicalURL = LinkHandler::getInstance()->getLink('Mail', array('object' => $this->user->getDecoratedObject()));
+ $this->canonicalURL = LinkHandler::getInstance()->getLink('Mail', ['object' => $this->user->getDecoratedObject()]);
}
/**
- * @see \wcf\form\IForm::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
parent::readFormParameters();
}
/**
- * @see \wcf\form\IForm::validate()
+ * @inheritDoc
*/
public function validate() {
if (!WCF::getUser()->userID) {
}
/**
- * @see \wcf\form\IForm::save()
+ * @inheritDoc
*/
public function save() {
parent::save();
$userLanguage = $this->user->getLanguage();
// build message data
- $subjectData = array(
+ $subjectData = [
'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email,
'subject' => $this->subject
- );
- $messageData = array(
+ ];
+ $messageData = [
'message' => $this->message,
'recipient' => $this->user,
'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email,
- );
+ ];
// build mail
- $mail = new Mail(array($this->user->username => $this->user->email), $userLanguage->getDynamicVariable('wcf.user.mail.mail.subject', $subjectData), $userLanguage->getDynamicVariable('wcf.user.mail.mail', $messageData));
+ $mail = new Mail([$this->user->username => $this->user->email], $userLanguage->getDynamicVariable('wcf.user.mail.mail.subject', $subjectData), $userLanguage->getDynamicVariable('wcf.user.mail.mail', $messageData));
$mail->setLanguage($userLanguage);
// add reply-to tag
$this->saved();
// forward to profile page
- HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('User', array('object' => $this->user)), WCF::getLanguage()->getDynamicVariable('wcf.user.mail.sent', array('user' => $this->user)));
+ HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('User', ['object' => $this->user]), WCF::getLanguage()->getDynamicVariable('wcf.user.mail.sent', ['user' => $this->user]));
exit;
}
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
parent::readData();
- WCF::getBreadcrumbs()->add($this->user->getBreadcrumb());
+ PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.User', $this->user->userID, $this->user);
+ if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'user' => $this->user,
'showAddress' => $this->showAddress,
'message' => $this->message,
'subject' => $this->subject,
'email' => $this->email
- ));
+ ]);
}
/**
- * @see \wcf\page\IPage::show()
+ * @inheritDoc
*/
public function show() {
- WCF::getSession()->checkPermissions(array('user.profile.canMail'));
-
if (!$this->user->isAccessible('canMail')) {
throw new PermissionDeniedException();
}
namespace wcf\form;
use wcf\acp\form\UserOptionListForm;
use wcf\data\search\SearchEditor;
-use wcf\system\breadcrumb\Breadcrumb;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\UserInputException;
+use wcf\system\page\PageLocationManager;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
$this->readOptionTree();
// add breadcrumbs
- WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
+ if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
}
/**
<?php
namespace wcf\page;
use wcf\data\user\activity\event\ViewableUserActivityEventList;
-use wcf\system\breadcrumb\Breadcrumb;
-use wcf\system\request\LinkHandler;
+use wcf\system\page\PageLocationManager;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\WCF;
* Shows the global recent activity list page.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage page
class RecentActivityListPage extends AbstractPage {
/**
* viewable user activity event list
- * @var \wcf\data\user\activity\event\ViewableUserActivityEventList
+ * @var ViewableUserActivityEventList
*/
public $eventList = null;
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
parent::readData();
$this->eventList->readObjects();
// add breadcrumbs
- if (MODULE_MEMBERS_LIST) WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
+ if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
// removes orphaned and non-accessable events
UserActivityEventHandler::validateEvents($this->eventList);
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'eventList' => $this->eventList,
'lastEventTime' => $lastEventTime,
'allowSpidersToIndexThisPage' => true
- ));
+ ]);
}
}
use wcf\data\search\ISearchResultObject;
use wcf\data\search\Search;
use wcf\system\application\ApplicationHandler;
-use wcf\system\breadcrumb\Breadcrumb;
use wcf\system\event\EventHandler;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\SystemException;
-use wcf\system\request\LinkHandler;
+use wcf\system\page\PageLocationManager;
use wcf\system\search\SearchEngine;
use wcf\system\WCF;
}
// add breadcrumbs
- WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.search.title'), LinkHandler::getInstance()->getLink('Search')));
+ PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.Search');
}
/**
<?php
namespace wcf\page;
-use wcf\system\breadcrumb\Breadcrumb;
-use wcf\system\request\LinkHandler;
+use wcf\data\user\TeamList;
+use wcf\system\page\PageLocationManager;
use wcf\system\WCF;
/**
* Shows the team members list.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage page
*/
class TeamPage extends MultipleLinkPage {
/**
- * @see \wcf\page\AbstractPage::$neededPermissions
+ * @inheritDoc
*/
- public $neededPermissions = array('user.profile.canViewMembersList');
+ public $neededPermissions = ['user.profile.canViewMembersList'];
/**
- * @see \wcf\page\AbstractPage::$neededModules
+ * @inheritDoc
*/
- public $neededModules = array('MODULE_TEAM_PAGE');
+ public $neededModules = ['MODULE_TEAM_PAGE'];
/**
- * @see \wcf\page\AbstractPage::$enableTracking
+ * @inheritDoc
*/
public $enableTracking = true;
/**
- * @see \wcf\page\MultipleLinkPage::$itemsPerPage
+ * @inheritDoc
*/
public $itemsPerPage = 1000;
/**
- * @see \wcf\page\MultipleLinkPage::$sortField
+ * @inheritDoc
*/
public $sortField = MEMBERS_LIST_DEFAULT_SORT_FIELD;
/**
- * @see \wcf\page\MultipleLinkPage::$sortOrder
+ * @inheritDoc
*/
public $sortOrder = MEMBERS_LIST_DEFAULT_SORT_ORDER;
/**
- * @see \wcf\page\MultipleLinkPage::$objectListClassName
+ * @inheritDoc
*/
- public $objectListClassName = 'wcf\data\user\TeamList';
+ public $objectListClassName = TeamList::class;
/**
- * @see \wcf\page\IPage::readData()
+ * @inheritDoc
*/
public function readData() {
parent::readData();
// add breadcrumbs
- if (MODULE_MEMBERS_LIST) WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
+ if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
}
/**
- * @see \wcf\page\IPage::assignVariables()
+ * @inheritDoc
*/
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'allowSpidersToIndexThisPage' => true
- ));
+ ]);
}
}
use wcf\data\user\profile\visitor\UserProfileVisitorList;
use wcf\data\user\UserEditor;
use wcf\data\user\UserProfile;
-use wcf\system\breadcrumb\Breadcrumb;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\menu\user\profile\UserProfileMenu;
+use wcf\system\page\PageLocationManager;
use wcf\system\request\LinkHandler;
use wcf\system\MetaTagHandler;
use wcf\system\WCF;
parent::readData();
// add breadcrumbs
- if (MODULE_MEMBERS_LIST) WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
+ if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
// get profile content
if ($this->editOnInit) {
use wcf\data\page\PageCache;
use wcf\data\user\online\UserOnline;
use wcf\data\user\online\UsersOnlineList;
-use wcf\system\breadcrumb\Breadcrumb;
use wcf\system\page\handler\IOnlineLocationPageHandler;
+use wcf\system\page\PageLocationManager;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
parent::readData();
// add breadcrumbs
- if (MODULE_MEMBERS_LIST) {
- WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
- }
+ if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
// cache all necessary data for showing locations
foreach ($this->objectList as $userOnline) {
<?php
namespace wcf\system\breadcrumb;
+use wcf\data\page\PageCache;
+use wcf\system\page\PageLocationManager;
use wcf\system\SingletonFactory;
/**
* list of breadcrumbs
* @var Breadcrumb[]
*/
- protected $items = [];
+ protected $items = null;
/**
* Current iterator-index
* Adds a breadcrumb (insertion order is crucial!).
*
* @param Breadcrumb $item
+ * @deprecated 2.2
*/
public function add(Breadcrumb $item) {
- $this->items[] = $item;
+ throw new \BadMethodCallException("Breadcrumbs::add() is no longer supported, please use " . PageLocationManager::class . " instead.");
}
/**
* @return Breadcrumb[]
*/
public function get() {
+ if ($this->items === null) {
+ $this->loadBreadcrumbs();
+ }
+
return $this->items;
}
* @param Breadcrumb $item
* @param integer $index
* @return boolean
+ * @deprecated 2.2
*/
public function replace(Breadcrumb $item, $index) {
- if (isset($this->items[$index])) {
- $this->items[$index] = $item;
-
- return true;
- }
-
- return false;
+ throw new \BadMethodCallException("Breadcrumbs::replace() is no longer supported, please use " . PageLocationManager::class . " instead.");
}
/**
*
* @param integer $index
* @return boolean
+ * @deprecated 2.2
*/
public function remove($index) {
- if (isset($this->items[$index])) {
- unset($this->items[$index]);
-
- return true;
+ throw new \BadMethodCallException("Breadcrumbs::remove() is no longer supported, please use " . PageLocationManager::class . " instead.");
+ }
+
+ protected function loadBreadcrumbs() {
+ $this->items = [];
+ $locations = PageLocationManager::getInstance()->getLocations();
+
+ // locations are provided starting with the current location followed
+ // by all relevant ancestors, but breadcrumbs appear in the reverse order
+ $locations = array_reverse($locations);
+
+ // add the landing page as first location, unless it is already included
+ $landingPage = PageCache::getInstance()->getLandingPage();
+ $addLandingPage = true;
+ for ($i = 0, $length = count($locations); $i < $length; $i++) {
+ if ($locations[$i]['pageID'] == $landingPage->pageID) {
+ $addLandingPage = false;
+ break;
+ }
+ }
+
+ if ($addLandingPage) {
+ array_unshift($locations, [
+ 'link' => $landingPage->getLink(),
+ 'title' => $landingPage->getTitle()
+ ]);
}
- return false;
+ // ignore the last location as it represents the current page
+ array_pop($locations);
+
+ for ($i = 0, $length = count($locations); $i < $length; $i++) {
+ $this->items[] = new Breadcrumb($locations[$i]['title'], $locations[$i]['link']);
+ }
}
/**
* @inheritDoc
*/
public function count() {
+ if ($this->items === null) {
+ $this->loadBreadcrumbs();
+ }
+
return count($this->items);
}
namespace wcf\system\cache\builder;
use wcf\data\page\Page;
use wcf\data\page\PageList;
+use wcf\system\WCF;
/**
* Caches the page data.
* @package com.woltlab.wcf
* @subpackage system.cache.builder
* @category Community Framework
+ * @since 2.2
*/
class PageCacheBuilder extends AbstractCacheBuilder {
/**
'identifier' => [],
'controller' => [],
'pages' => [],
+ 'pageTitles' => [],
'landingPage' => null
];
$pageList->readObjects();
$data['pages'] = $pageList->getObjects();
+ // get page titles
+ $sql = "SELECT pageID, languageID, title
+ FROM wcf".WCF_N."_page_content";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+ while ($row = $statement->fetchArray()) {
+ $pageID = $row['pageID'];
+
+ if (!isset($data['pageTitles'])) {
+ $data['pageTitles'][$pageID] = [];
+ }
+
+ $data['pageTitles'][$pageID][$row['languageID'] ?: 0] = $row['title'];
+ }
+
// build lookup table
/** @var Page $page */
foreach ($pageList as $page) {
<?php
namespace wcf\system\page;
+use wcf\data\ITitledLinkObject;
use wcf\data\page\PageCache;
use wcf\system\exception\SystemException;
use wcf\system\request\RequestHandler;
* @package com.woltlab.wcf
* @subpackage system.page
* @category Community Framework
+ * @since 2.2
*/
class PageLocationManager extends SingletonFactory {
/**
}
$metaData = $activeRequest->getMetaData();
+ $link = $title = '';
+ $page = null;
if (isset($metaData['cms'])) {
$pageID = $metaData['cms']['pageID'];
+
+ $page = PageCache::getInstance()->getPage($pageID);
}
else {
$page = PageCache::getInstance()->getPageByController($activeRequest->getClassName());
if ($pageID !== null) {
$this->stack[] = [
+ 'identifier' => $page->identifier,
+ 'link' => $page->getLink(),
'pageID' => $pageID,
- 'pageObjectID' => $pageObjectID
+ 'pageObjectID' => $pageObjectID,
+ 'title' => $page->getTitle()
];
}
}
* Appends a parent location to the stack, the later it is added the lower
* is its assumed priority when matching suitable menu items.
*
- * @param string $identifier internal page identifier
- * @param integer $pageObjectID page object id
+ * @param string $identifier internal page identifier
+ * @param integer $pageObjectID page object id
+ * @param ITitledLinkObject $locationObject optional label for breadcrumbs usage
* @throws SystemException
*/
- public function addParentLocation($identifier, $pageObjectID = 0) {
+ public function addParentLocation($identifier, $pageObjectID = 0, ITitledLinkObject $locationObject = null) {
$page = PageCache::getInstance()->getPageByIdentifier($identifier);
if ($page === null) {
throw new SystemException("Unknown page identifier '".$identifier."'.");
}
+ // check if the provided location is already part of the stack
+ for ($i = 0, $length = count($this->stack); $i < $length; $i++) {
+ if ($this->stack[$i]['identifier'] == $identifier && $this->stack[$i]['pageObjectID'] == $pageObjectID) {
+ return;
+ }
+ }
+
+ if ($locationObject !== null) {
+ $link = $locationObject->getLink();
+ $title = $locationObject->getTitle();
+ }
+ else {
+ $link = $page->getLink();
+ $title = $page->getTitle();
+ }
+
$this->stack[] = [
+ 'identifier' => $identifier,
+ 'link' => $link,
'pageID' => $page->pageID,
- 'pageObjectID' => $pageObjectID
+ 'pageObjectID' => $pageObjectID,
+ 'title' => $title
];
}
* Resolves incoming requests and performs lookups for controller to url mappings.
*
* @author Alexander Ebert
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.request
* @param string $application application identifier
* @param string $controller url controller
* @param boolean $isAcpRequest true if this is an ACP request
- * @return mixed array containing className, controller and pageType or a string containing the controller name for aliased controllers
+ * @return mixed array containing className, controller and pageType or a string containing the controller name for aliased controllers
* @throws SystemException
*/
public function resolve($application, $controller, $isAcpRequest) {