Added auto-guessing for template environment
authorAlexander Ebert <ebert@woltlab.com>
Mon, 5 Nov 2012 22:17:59 +0000 (23:17 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 5 Nov 2012 22:17:59 +0000 (23:17 +0100)
wcfsetup/install/files/lib/page/AbstractPage.class.php

index 3cdc4ee2d483e756b4802cd8395bc3f61683d3e6..712c4ffeced21ba38055346927fad37acfddb7a4 100644 (file)
@@ -162,28 +162,28 @@ abstract class AbstractPage implements IPage, ITrackablePage {
                // read data
                $this->readData();
                
+               // assign variables
+               $this->assignVariables();
+               
+               // call show event
+               EventHandler::getInstance()->fireAction($this, 'show');
+               
                // try to guess template name
+               $classParts = explode('\\', get_class($this));
                if (empty($this->templateName)) {
-                       $classParts = explode('\\', get_class($this));
                        $className = preg_replace('~(Form|Page)$~', '', array_pop($classParts));
-                       
+                               
                        // check if this an *Edit page and use the add-template instead
                        if (substr($className, -4) == 'Edit') {
                                $className = substr($className, 0, -4) . 'Add';
                        }
-                       
+                               
                        $this->templateName = lcfirst($className);
                }
                
-               // assign variables
-               $this->assignVariables();
-               
-               // call show event
-               EventHandler::getInstance()->fireAction($this, 'show');
-               
                if ($this->useTemplate) {
                        // show template
-                       WCF::getTPL()->display($this->templateName);
+                       WCF::getTPL()->display($this->templateName, array_shift($classParts));
                }
        }