*/
public static final function getInstance() {
$className = get_called_class();
- if (!isset(self::$__singletonObjects[$className])) {
+ if (!array_key_exists($className, self::$__singletonObjects)) {
+ self::$__singletonObjects[$className] = null;
self::$__singletonObjects[$className] = new $className();
}
+ else if (array_key_exists($className, self::$__singletonObjects) && is_null(self::$__singletonObjects[$className])) {
+ throw new SystemException("Infinite loop detected while trying to retrieve object for '".$className."'");
+ }
return self::$__singletonObjects[$className];
}
<?php
namespace wcf\system\breadcrumb;
+use wcf\system\menu\page\PageMenu;
use wcf\system\SingletonFactory;
+use wcf\system\WCF;
/**
* Manages breadcrumbs.
*/
protected $index = 0;
+ /**
+ * @see wcf\system\SingletonFactory::init()
+ */
+ protected function init() {
+ // set default menu item
+ $landingPage = PageMenu::getInstance()->getLandingPage();
+ if ($landingPage !== null) {
+ PageMenu::getInstance()->setActiveMenuItem($landingPage->menuItem);
+
+ // add main breadcrumbs entry
+ $this->add(new Breadcrumb(WCF::getLanguage()->get(PAGE_TITLE), $landingPage->getLink()));
+ }
+ }
+
/**
* Adds a breadcrumb (insertion order is crucial!).
*
use wcf\system\event\EventHandler;
use wcf\system\menu\ITreeMenuItem;
use wcf\system\menu\TreeMenu;
-use wcf\system\request\LinkHandler;
use wcf\system\WCF;
/**
}
}
}
-
- // set default menu item
- if ($this->landingPage !== null) {
- $this->setActiveMenuItem($this->landingPage->menuItem);
-
- // add main breadcrumbs entry
- WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get(PAGE_TITLE), LinkHandler::getInstance()->getLink()));
- }
}
/**
<?php
namespace wcf\system\request;
-use wcf\system\menu\page\PageMenu;
-
+use wcf\data\DatabaseObjectDecorator;
use wcf\system\application\ApplicationHandler;
+use wcf\system\menu\page\PageMenu;
use wcf\system\request\RouteHandler;
+use wcf\system\Regex;
use wcf\system\SingletonFactory;
/**
* Handles relative links within the wcf.
*
* @author Marcel Werk
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.request
* @category Community Framework
*/
class LinkHandler extends SingletonFactory {
+ /**
+ * regex object to filter title
+ * @var wcf\system\RegEx
+ */
+ protected $titleRegex = null;
+
+ /**
+ * @see wcf\system\SingletonFactory::init()
+ */
+ protected function init() {
+ $this->titleRegex = new Regex('[\x0-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+');
+ }
+
/**
* Returns a relative link.
*
// handle object
if (isset($parameters['object'])) {
- if (!($parameters['object'] instanceof \wcf\system\request\IRouteController) && $parameters['object'] instanceof \wcf\data\DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof \wcf\system\request\IRouteController) {
+ if (!($parameters['object'] instanceof IRouteController) && $parameters['object'] instanceof DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof IRouteController) {
$parameters['object'] = $parameters['object']->getDecoratedObject();
}
- if ($parameters['object'] instanceof \wcf\system\request\IRouteController) {
+ if ($parameters['object'] instanceof IRouteController) {
$parameters['id'] = $parameters['object']->getID();
$parameters['title'] = $parameters['object']->getTitle();
}
if (isset($parameters['title'])) {
// remove illegal characters
- $parameters['title'] = trim(preg_replace('/[\x0-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/', '-', $parameters['title']), '-');
+ $parameters['title'] = trim($this->titleRegex->replace($parameters['title'], '-'), '-');
}
$parameters['controller'] = $controller;