2 namespace wcf\system\page\handler;
3 use wcf\data\category\AbstractDecoratedCategory;
4 use wcf\data\page\Page;
5 use wcf\data\user\online\UserOnline;
6 use wcf\data\IAccessibleObject;
7 use wcf\system\exception\ParentClassException;
11 * Implementation of the `IOnlineLocationPageHandler` interface for decorated category-bound pages.
13 * @author Matthias Schmidt
14 * @copyright 2001-2016 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\Page\Handler
19 trait TDecoratedCategoryOnlineLocationPageHandler {
20 use TOnlineLocationPageHandler;
23 * Returns the name of the decorated class name.
27 abstract protected function getDecoratedCategoryClass();
30 * @see IOnlineLocationPageHandler::getOnlineLocation()
32 public function getOnlineLocation(Page $page, UserOnline $user) {
33 if ($user->pageObjectID === null) {
37 $className = $this->getDecoratedCategoryClass();
38 if (!is_subclass_of($className, AbstractDecoratedCategory::class)) {
39 throw new ParentClassException($className, AbstractDecoratedCategory::class);
42 /** @var AbstractDecoratedCategory $category */
43 $category = $className::getCategory($user->pageObjectID);
44 if ($category === null) {
48 if ($category instanceof IAccessibleObject && !$category->isAccessible()) {
52 return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier, ['category' => $category]);