Changeset 5992


Ignore:
Timestamp:
02/02/12 19:39:34 (4 months ago)
Author:
vain
Message:
  • modified display() method to use the view/template mapping
Location:
trunk/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/modulecontroller.core.php

    r5991 r5992  
    9393 
    9494    /** 
    95      * Returns the Doctrine Entity Manager  
     95     * Returns the Doctrine Entity Manager 
    9696     * 
    9797     * @return \Doctrine\ORM\EntityManager 
     
    200200 
    201201           $repos = $module_models_path . 'repositories' . DS . ucfirst($modulename) . 'Repository.php'; 
    202             
     202 
    203203           if(is_file($repos) === true and class_exists('Entities\\' . ucfirst($modulename), false) === false) 
    204204           { 
     
    372372 
    373373    /** 
    374      * Set the template name 
    375      * 
    376      * @param string $template Name of the Template with full Path 
    377      */ 
    378     public function setTemplate($template) 
    379     { 
    380         #self::checkTemplateExtension($template); 
    381         $this->template = $template; 
    382     } 
    383  
    384     /** 
    385374     * Sets the Render Mode 
    386375     * 
     
    422411    public function display($templates = null) 
    423412    { 
     413        include ROOT_CORE . 'renderer/templatemapper.php'; 
     414        $view_mapper = new Clansuite_View_Mapper; 
     415 
    424416        # set layout and content template by parameter array 
    425417        if(is_array($templates) === true) 
     
    427419            if(isset($templates['layout_template']) === true) 
    428420            { 
    429                 $this->setLayoutTemplate($templates['layout_template']); 
     421                $view_mapper->setLayoutTemplate($templates['layout_template']); 
    430422            } 
    431423 
    432424            if(isset($templates['content_template']) === true) 
    433425            { 
    434                 $this->setTemplate($templates['content_template']); 
     426                $view_mapper->setTemplate($templates['content_template']); 
    435427            } 
    436428        } 
    437429 
    438430        # only the content template is set 
    439         if(is_string($templates)) { $this->setTemplate($templates); } 
     431        if(is_string($templates)) { $view_mapper->setTemplate($templates); } 
    440432 
    441433        # get the templatename 
    442         $templatename = $this->getTemplateName(); 
     434        $templatename = $view_mapper->getTemplateName(); 
    443435 
    444436        # get the view 
     
    521513            $route = Clansuite_HttpRequest::getRoute(); 
    522514 
    523             # we use internal rewrite style here: /module/action             
     515            # we use internal rewrite style here: /module/action 
    524516            $redirect_to = '/' . $route->getModuleName(); 
    525517            $submodule = $route->getSubModuleName(); 
  • trunk/core/renderer/templatemapper.php

    r5991 r5992  
    4343 * Clansuite_View_Mapper is a "class action" to "template" mapper. 
    4444 * This has nothing to do with rendering, but with template selection for the view. 
    45  * If no template was set manually in the action of a module (class),  
    46  * this class will help determining the template,  
     45 * If no template was set manually in the action of a module (class), 
     46 * this class will help determining the template, 
    4747 * by mapping the requested class and action to a template. 
    4848 */ 
    4949class Clansuite_View_Mapper 
    5050{ 
     51    /** 
     52     * Template name. 
     53     * 
     54     * @var string 
     55     */ 
     56    public $template; 
     57 
    5158    /** 
    5259     * Ensures the template extension is correct. 
     
    8289            # construct template name 
    8390            $template = Clansuite_TargetRoute::getActionName() . '.tpl'; 
    84               
     91 
    8592            $this->setTemplate($template); 
    8693        } 
     
    8895        return $this->template; 
    8996    } 
     97 
     98    /** 
     99     * Set the template name 
     100     * 
     101     * @param string $template Name of the Template with full Path 
     102     */ 
     103    public function setTemplate($template) 
     104    { 
     105        #self::checkTemplateExtension($template); 
     106        $this->template = (string) $template; 
     107    } 
    90108} 
    91109?> 
Note: See TracChangeset for help on using the changeset viewer.