AbstractPage now tries to guess the template name
authorAlexander Ebert <ebert@woltlab.com>
Tue, 11 Oct 2011 17:08:17 +0000 (19:08 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 11 Oct 2011 17:08:17 +0000 (19:08 +0200)
wcfsetup/install/files/lib/page/AbstractPage.class.php

index 045528da43c40b12867b7094401922826cdb4030..dbaf1341d791576f424e8f4bb66b2c6697ca11d5 100644 (file)
@@ -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);
                }
        }