From: Alexander Ebert Date: Fri, 8 Apr 2016 10:30:59 +0000 (+0200) Subject: Added method to retrieve the current page id X-Git-Tag: 3.0.0_Beta_1~1947 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d7529a2cd2665b7a90297f28d3b8bfd6e3a53228;p=GitHub%2FWoltLab%2FWCF.git Added method to retrieve the current page id --- diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index 1634c80d05..31436fd3f6 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -1,11 +1,12 @@ * @package com.woltlab.wcf * @subpackage system.request @@ -29,6 +30,12 @@ class Request { */ protected $metaData; + /** + * current page id + * @var integer + */ + protected $pageID; + /** * page name * @var string @@ -155,4 +162,28 @@ class Request { return false; } + + /** + * Returns the current page id. + * + * @return integer current page id or `0` if unknown + */ + public function getPageID() { + if ($this->pageID === null) { + if (isset($this->metaData['cms'])) { + $this->pageID = $this->metaData['cms']['pageID']; + } + else { + $page = PageCache::getInstance()->getPageByController($this->className); + if ($page !== null) { + $this->pageID = $page->pageID; + } + else { + $this->pageID = 0; + } + } + } + + return $this->pageID; + } }