From 12a2ff01b58973bd880331433a715d475c171cf4 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 19 May 2016 23:12:54 +0200 Subject: [PATCH] Added getter function to retrieve active page object --- .../install/files/lib/system/WCF.class.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index a265241116..f0a637df0f 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -5,6 +5,8 @@ use wcf\data\option\OptionEditor; use wcf\data\package\Package; use wcf\data\package\PackageCache; use wcf\data\package\PackageEditor; +use wcf\data\page\Page; +use wcf\data\page\PageCache; use wcf\system\application\ApplicationHandler; use wcf\system\application\IApplication; use wcf\system\box\BoxHandler; @@ -20,6 +22,7 @@ use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\SystemException; use wcf\system\language\LanguageFactory; use wcf\system\package\PackageInstallationDispatcher; +use wcf\system\request\Request; use wcf\system\request\RequestHandler; use wcf\system\request\RouteHandler; use wcf\system\session\SessionFactory; @@ -796,6 +799,24 @@ class WCF { return self::getRequestURI() . '#' . $fragment; } + /** + * Returns the currently active page or null if unknown. + * + * @return Page|null + */ + public static function getActivePage() { + return PageCache::getInstance()->getPageByController(self::getActiveRequest()->getClassName()); + } + + /** + * Returns the currently active request. + * + * @return Request + */ + public static function getActiveRequest() { + return RequestHandler::getInstance()->getActiveRequest(); + } + /** * Returns the URI of the current page. * -- 2.20.1