load('template', null); /** * File System Template System * * This framework merely replaces the template loading functions with * file-system based ones. * * @author Iris Studios, Inc. * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc. * @version $Revision$ * @package ISSO * */ class Template_FS extends Template { /** * The path, from the path of the application, where templates are stored * @var string * @access private */ var $templatedir = ''; /** * The extension all the template files have * @var string * @access private */ var $extension = 'tpl'; /** * Fields array that is used in this module * @var array * @access private */ var $fields = array( 'templatedir' => array(REQ_YES, 'fetch_sourcepath', false), 'extension' => array(REQ_YES, null, false), 'pre_parse_hook' => array(REQ_NO, null, false) ); // ################################################################### /** * Constructor */ function __construct(&$registry) { $this->registry =& $registry; } // ################################################################### /** * (PHP 4) Constructor */ function Template_FS(&$registry) { $this->__construct($registry); } // ################################################################### /** * Sets an ISSO field * * @access public * * @param string Field name * @param mixed Value of the field */ function set($name, $value) { $this->registry->do_set($name, $value, 'template_fs'); } // ################################################################### /** * Gets an ISSO field * * @access public * * @param string Field name * * @return mixed Value of the field */ function get($fieldname) { return $this->do_get($fieldname, 'template_fs'); } // ################################################################### /** * Takes an array of template names, loads them, and then stores a * parsed version for optimum speed. * * @access public * * @param array List of template names to be cached */ function cache($namearray) { if (sizeof($this->cache) > 0) { trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING); } else { foreach ($namearray AS $name) { $template = $this->_load($name); $template = $this->_parse($template); $this->cache["$name"] = $template; $this->usage["$name"] = 0; } } } // ################################################################### /** * Loads a template from the file system from the specified * $templatedir with the file extension $extension * * @access private * * @param string The name of the template call */ function _load($name) { $this->registry->check_isso_fields(get_class($this)); $path = $this->registry->apppath . $this->templatedir . $name . '.' . $this->extension; if (is_file($path)) { if (($template = @file_get_contents($path)) !== false) { return $template; } else { trigger_error("Could not load the template '$path'", E_USER_ERROR); exit; } } else { trigger_error("Could not load the template '$path'", E_USER_ERROR); exit; } } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>