From 2c8e27c9eaccdb6c1b90f1625cd739ecffec92c0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 11 Oct 2011 19:08:17 +0200 Subject: [PATCH] AbstractPage now tries to guess the template name --- .../files/lib/page/AbstractPage.class.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/page/AbstractPage.class.php b/wcfsetup/install/files/lib/page/AbstractPage.class.php index 045528da43..dbaf1341d7 100644 --- a/wcfsetup/install/files/lib/page/AbstractPage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractPage.class.php @@ -21,6 +21,12 @@ abstract class AbstractPage implements IPage { */ public $templateName = ''; + /** + * enables template usage + * @var string + */ + public $useTemplate = true; + /** * value of the given action parameter * @var string @@ -131,8 +137,15 @@ abstract class AbstractPage implements IPage { // call show event EventHandler::getInstance()->fireAction($this, 'show'); - // show template - if (!empty($this->templateName)) { + if ($this->useTemplate) { + // try to guess template name + if (empty($this->templateName)) { + $classParts = explode('\\', get_class($this)); + $className = preg_replace('~(Form|Page)$~', '', array_pop($classParts)); + $this->templateName = lcfirst($className); + } + + // show template WCF::getTPL()->display($this->templateName); } } -- 2.20.1