From: Alexander Ebert Date: Fri, 4 Dec 2015 14:11:45 +0000 (+0100) Subject: CMS page data is now available in the Request object X-Git-Tag: 3.0.0_Beta_1~2030^2~212^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=df4aca531adac41ed7a6167d2f9349ed775a9fd0;p=GitHub%2FWoltLab%2FWCF.git CMS page data is now available in the Request object --- diff --git a/wcfsetup/install/files/lib/page/CmsPage.class.php b/wcfsetup/install/files/lib/page/CmsPage.class.php index df64878fdc..8e5456e9d3 100644 --- a/wcfsetup/install/files/lib/page/CmsPage.class.php +++ b/wcfsetup/install/files/lib/page/CmsPage.class.php @@ -3,6 +3,7 @@ namespace wcf\page; use wcf\data\page\Page; use wcf\system\exception\IllegalLinkException; use wcf\system\request\LinkHandler; +use wcf\system\request\RequestHandler; use wcf\system\WCF; /** @@ -43,8 +44,12 @@ class CmsPage extends AbstractPage { public function readParameters() { parent::readParameters(); - if (isset($_GET['languageID'])) $this->languageID = intval($_GET['languageID']); - if (isset($_GET['pageID'])) $this->pageID = intval($_GET['pageID']); + $metaData = RequestHandler::getInstance()->getActiveRequest()->getMetaData(); + if (isset($metaData['cms'], $metaData['cms']['pageID'])) { + $this->pageID = $metaData['cms']['pageID']; + + if (isset($metaData['cms']['languageID'])) $this->languageID = $metaData['cms']['languageID']; + } if ($this->pageID) { $this->page = new Page($this->pageID); diff --git a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php index 3dcb0149bd..1bf707e48d 100644 --- a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php +++ b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php @@ -106,8 +106,10 @@ class ControllerMap extends SingletonFactory { 'className' => CmsPage::class, 'controller' => 'cms', 'pageType' => 'page', - 'languageID' => $matches['languageID'], - 'pageID' => $matches['pageID'] + + // CMS page meta data + 'cmsPageID' => $matches['pageID'], + 'cmsPageLanguageID' => $matches['languageID'] ]; } else { diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index 943110863d..35fb4d4f54 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -18,6 +18,12 @@ class Request { */ protected $className = ''; + /** + * request meta data + * @var string[] + */ + protected $metaData; + /** * page name * @var string @@ -34,17 +40,19 @@ class Request { * request object * @var object */ - protected $requestObject = null; + protected $requestObject; /** * Creates a new request object. * - * @param string $className - * @param string $pageName - * @param string $pageType + * @param string $className fully qualified name + * @param string $pageName class name + * @param string $pageType can be 'action', 'form' or 'page' + * @param string[] $metaData additional meta data */ - public function __construct($className, $pageName, $pageType) { + public function __construct($className, $pageName, $pageType, array $metaData) { $this->className = $className; + $this->metaData = $metaData; $this->pageName = $pageName; $this->pageType = $pageType; } @@ -77,6 +85,15 @@ class Request { return $this->className; } + /** + * Returns request meta data. + * + * @return string[] + */ + public function getMetaData() { + return $this->metaData; + } + /** * Returns the page name of this request. * diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index e1cfe6af6f..9ef31df7fb 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -177,10 +177,21 @@ class RequestHandler extends SingletonFactory { } } - $this->activeRequest = new Request($classData['className'], $classData['controller'], $classData['pageType']); + // handle CMS page meta data + $metaData = []; + if (isset($routeData['cmsPageID'])) { + $metaData['cms'] = [ + 'pageID' => $routeData['cmsPageID'], + 'languageID' => $routeData['cmsPageLanguageID'] + ]; + + unset($routeData['cmsPageID']); + unset($routeData['cmsPageLanguageID']); + } + + $this->activeRequest = new Request($classData['className'], $classData['controller'], $classData['pageType'], $metaData); } catch (SystemException $e) { - die("
".$e->getMessage());
 			throw new IllegalLinkException();
 		}
 	}
@@ -188,9 +199,9 @@ class RequestHandler extends SingletonFactory {
 	/**
 	 * Redirects to the actual URL, e.g. controller has been aliased or mistyped (boardlist instead of board-list).
 	 * 
-	 * @param	array		$routeData
-	 * @param	string			$application
-	 * @param	string			$controller
+	 * @param	string[]	$routeData
+	 * @param	string		$application
+	 * @param	string		$controller
 	 */
 	protected function redirect(array $routeData, $application, $controller = null) {
 		$routeData['application'] = $application;