[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/view/src/wact/ -> lmbWactTemplateLocator.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  require_once('limb/wact/src/locator/WactTemplateLocator.interface.php');
  10  
  11  /**

  12   * class lmbWactTemplateLocator.

  13   *

  14   * @package view

  15   * @version $Id$

  16   */
  17  class lmbWactTemplateLocator implements WactTemplateLocator
  18  {
  19    protected $locator;
  20    protected $cache_dir;
  21  
  22    function __construct($locator, $cache_dir)
  23    {
  24      $this->locator = $locator;
  25      $this->cache_dir = $cache_dir;
  26    }
  27  
  28    function setFileLocator($file_locator)
  29    {
  30      $this->locator = $file_locator;
  31    }
  32  
  33    function getFileLocator()
  34    {
  35      return $this->locator;
  36    }
  37  
  38    function locateSourceTemplate($file)
  39    {
  40      $params = $this->_collectParams();
  41      try
  42      {
  43        return $this->locator->locate($file, $params);
  44      }
  45      catch(lmbFileNotFoundException $e){}
  46    }
  47  
  48    function locateCompiledTemplate($file)
  49    {
  50      $params = $this->_collectParams();
  51      $full_path = $this->locateSourceTemplate($file);
  52      return $this->cache_dir . '/' . md5($full_path . serialize($params)) . '.php';
  53    }
  54  
  55    protected function _collectParams()
  56    {
  57      return array();
  58    }
  59  
  60    function readTemplateFile($fileName)
  61    {
  62      if(file_exists($fileName))
  63        return file_get_contents($fileName);
  64    }
  65  }
  66  ?>


Generated: Fri Aug 29 04:49:26 2008 Cross-referenced by PHPXref 0.7