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-2018 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 * Returns the textual description if a user is currently online viewing this page.
32 * @param Page $page visited page
33 * @param UserOnline $user user online object with request data
35 * @see IOnlineLocationPageHandler::getOnlineLocation()
37 public function getOnlineLocation(Page $page, UserOnline $user) {
38 if ($user->pageObjectID === null) {
42 $className = $this->getDecoratedCategoryClass();
43 if (!is_subclass_of($className, AbstractDecoratedCategory::class)) {
44 throw new ParentClassException($className, AbstractDecoratedCategory::class);
47 /** @var AbstractDecoratedCategory $category */
48 /** @noinspection PhpUndefinedMethodInspection */
49 $category = $className::getCategory($user->pageObjectID);
50 if ($category === null) {
54 if ($category instanceof IAccessibleObject && !$category->isAccessible()) {
58 return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier, ['category' => $category]);