* // accessing templates in /usr/share and compile them in /var/cache * $conf->templatePath = "/usr/share/eztemplate"; * $conf->compilePath = "/var/cache/eztemplate"; * * * Accessing templates from the applications directory is done with a single dot * (.), these are also the default values. * * // uses current directory for accessing templates and compiling them * $conf->templatePath = "."; * $conf->compilePath = "."; * * * The $context property is by default assigned to an ezcTemplateXhtmlContext object. * * @package Template * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License * @version 1.0beta1 * @access private */ class ezcTemplateConfiguration { /** * List of global instances, looked up using the identifier string. */ static private $instanceList = array(); /** * An array containing the properties of this object. * * templatePath: The base path for all the source templates. e.g. 'design' or 'templates'. * compilepath : The base path for all the compiled templates. e.g. 'var/template/compiled'. * * @var array(string=>mixed) */ private $properties = array( 'context' => false, 'templatePath' => ".", 'compilePath' => ".", 'checkModifiedTemplates' => true, ); /** * Returns the value of the property $name. * * The properties that can be retrieved are: * * - ezcTemplateOutputCollection context : Contains the template context. * - string templatePath : Base path where the source templates are stored. * - string compilePath : Base path where the compiled templates are stored. * - bool checkModifiedTemplates : Set to true, to recompile outdated compiled templates. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @return mixed */ public function __get( $name ) { switch( $name ) { case 'context': case 'templatePath': case 'compilePath': case 'checkModifiedTemplates': return $this->properties[$name]; default: throw new ezcBasePropertyNotFoundException( $name ); } } /** * Sets the property $name to the value $value * * The properties that can be set are: * * - ezcTemplateOutputCollection context : Contains the template context. * - string templatePath : Base path where the source templates are stored. * - string compilePath : Base path where the compiled templates are stored. * - bool checkModifiedTemplates : Set to true, to recompile outdated compiled templates. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @return mixed */ public function __set( $name, $value ) { switch( $name ) { case 'context': if( !$value instanceof ezcTemplateOutputContext ) { throw new ezcBaseValueException( $name, $value, 'ezcTemplateContext' ); } $this->properties[$name] = $value; break; case 'templatePath': case 'compilePath': case 'checkModifiedTemplates': $this->properties[$name] = $value; break; default: throw new ezcBasePropertyNotFoundException( $name ); } } /** * Returns true if the property $name is set, otherwise false. * * @return bool */ public function __isset( $name ) { switch( $name ) { case 'context': return true; case 'templatePath': case 'compilePath': case 'checkModifiedTemplates': return isset( $this->properties[$name] ); default: return false; } } /** * Initialises the configuration with default template, compiled path, and context. * * All requested templates are search from the defined $templatePath. * Use an empty string to fetch templates from the root of the filesystem. * * All compiled templates are placed in subfulders under the compiled templates. * Use an empty string to compile templates at the root of the filesystem. */ public function __construct( $templatePath = ".", $compilePath = ".", $context = null ) { $this->properties["templatePath"] = $templatePath; $this->properties["compilePath"] = $compilePath; $this->properties['context'] = ( $context == null ? new ezcTemplateXhtmlContext() : $context ); } /** * Returns the unique configuration instance named $name. * * @return ezcTemplateConfiguration */ public static function getInstance( $name = "default" ) { if ( !isset( self::$instanceList[$name] ) ) { self::$instanceList[$name] = new ezcTemplateConfiguration(); } return self::$instanceList[$name]; } } ?>