Development

Changeset 5025

You must first sign up to be able to contribute.

Changeset 5025

Show
Ignore:
Timestamp:
09/09/07 22:29:32 (1 year ago)
Author:
fabien
Message:

refactored template and layout management between action and view

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/action/sfAction.class.php

    r4957 r5025  
    406406    } 
    407407 
    408     $this->getResponse()->setParameter($this->getModuleName().'_'.$this->getActionName().'_template', $name, 'symfony/action/view'); 
     408    sfConfig::set($this->getModuleName().'_'.$this->getActionName().'_template', $name); 
    409409  } 
    410410 
     
    421421  public function getTemplate() 
    422422  { 
    423     return $this->getResponse()->getParameter($this->getModuleName().'_'.$this->getActionName().'_template', null, 'symfony/action/view'); 
     423    return sfConfig::get($this->getModuleName().'_'.$this->getActionName().'_template'); 
    424424  } 
    425425 
     
    440440    } 
    441441 
    442     $this->getResponse()->setParameter($this->getModuleName().'_'.$this->getActionName().'_layout', $name, 'symfony/action/view'); 
     442    sfConfig::set($this->getModuleName().'_'.$this->getActionName().'_layout', $name); 
    443443  } 
    444444 
     
    453453  public function getLayout() 
    454454  { 
    455     return $this->getResponse()->getParameter($this->getModuleName().'_'.$this->getActionName().'_layout', null, 'symfony/action/view'); 
     455    return sfConfig::get($this->getModuleName().'_'.$this->getActionName().'_layout'); 
    456456  } 
    457457 
  • trunk/lib/config/sfViewConfigHandler.class.php

    r4951 r5025  
    175175    $defaultTemplateName = $templateName ? "'$templateName'" : '$this->actionName'; 
    176176 
    177     $data .= "  \$templateName = \$response->getParameter(\$this->moduleName.'_'.\$this->actionName.'_template', $defaultTemplateName, 'symfony/action/view');\n"; 
     177    $data .= "  \$templateName = sfConfig::get(\$this->moduleName.'_'.\$this->actionName.'_template', $defaultTemplateName);\n"; 
    178178    $data .= "  \$this->setTemplate(\$templateName.\$this->viewName.\$this->getExtension());\n"; 
    179179 
  • trunk/lib/view/sfPHPView.class.php

    r4951 r5025  
    100100 
    101101    // decorator configuration 
    102     $this->updateDecoratorConfiguration(); 
     102    $this->setDecoratorTemplate(sfConfig::get($this->moduleName.'_'.$this->actionName.'_layout')); 
    103103 
    104104    // set template directory 
     
    144144      $uri = $this->context->getRouting()->getCurrentInternalUri(); 
    145145 
    146       list($content, $attributeHolder) = $viewCache->getActionCache($uri); 
     146      list($content, $attributeHolder, $decoratorTemplate) = $viewCache->getActionCache($uri); 
    147147      if (!is_null($content)) 
    148148      { 
    149149        $this->attributeHolder = $attributeHolder; 
     150        $this->setDecoratorTemplate($decoratorTemplate); 
    150151      } 
    151  
    152       // FIXME: needed because the response in cache can change the layout 
    153       $this->updateDecoratorConfiguration(); 
    154152    } 
    155153 
     
    165163      if (sfConfig::get('sf_cache')) 
    166164      { 
    167         $content = $viewCache->setActionCache($uri, $content, $this->attributeHolder); 
     165        $content = $viewCache->setActionCache($uri, $content, $this->attributeHolder, $this->isDecorator() ? $this->getDecoratorDirectory().'/'.$this->getDecoratorTemplate() : false); 
    168166      } 
    169167    } 
     
    177175    return $content; 
    178176  } 
    179  
    180   protected function updateDecoratorConfiguration() 
    181   { 
    182     // decorator configuration 
    183     $layout = $this->context->getResponse()->getParameter($this->moduleName.'_'.$this->actionName.'_layout', null, 'symfony/action/view'); 
    184     if (false === $layout) 
    185     { 
    186       $this->setDecorator(false); 
    187     } 
    188     else if (!is_null($layout)) 
    189     { 
    190       $this->setDecoratorTemplate($layout.$this->getExtension()); 
    191     } 
    192   } 
    193177} 
  • trunk/lib/view/sfView.class.php

    r5018 r5025  
    360360  public function setDecoratorTemplate($template) 
    361361  { 
     362    if (false === $template) 
     363    { 
     364      $this->decorator = false; 
     365 
     366      return; 
     367    } 
     368    else if (is_null($template)) 
     369    { 
     370      return; 
     371    } 
     372 
    362373    if (sfToolkit::isPathAbsolute($template)) 
    363374    { 
  • trunk/lib/view/sfViewCacheManager.class.php

    r5016 r5025  
    563563    } 
    564564 
    565     return array($content, $cache['attributeHolder']); 
     565    return array($content, $cache['attributeHolder'], $cache['decoratorTemplate']); 
    566566  } 
    567567 
     
    575575   * @return string The cached content 
    576576   */ 
    577   public function setActionCache($uri, $content, $attributeHolder
     577  public function setActionCache($uri, $content, $attributeHolder, $decoratorTemplate
    578578  { 
    579579    if (!$this->isCacheable($uri) || $this->withLayout($uri)) 
     
    582582    } 
    583583 
    584     $saved = $this->set(serialize(array('content' => $content, 'attributeHolder' => $attributeHolder, 'response' => $this->context->getResponse())), $uri); 
     584    $saved = $this->set(serialize(array('content' => $content, 'attributeHolder' => $attributeHolder, 'decoratorTemplate' => $decoratorTemplate, 'response' => $this->context->getResponse())), $uri); 
    585585 
    586586    if ($saved && sfConfig::get('sf_web_debug'))