Code

Readded smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_config_source.php
1 <?php
2 /**
3  * Smarty Internal Plugin
4  *
5  * @package Smarty
6  * @subpackage TemplateResources
7  */
9 /**
10  * Smarty Resource Data Object
11  *
12  * Meta Data Container for Config Files
13  *
14  * @package Smarty
15  * @subpackage TemplateResources
16  * @author Rodney Rehm
17  *
18  * @property string $content
19  * @property int    $timestamp
20  * @property bool   $exists
21  */
22 class Smarty_Config_Source extends Smarty_Template_Source {
24     /**
25      * create Config Object container
26      *
27      * @param Smarty_Resource $handler          Resource Handler this source object communicates with
28      * @param Smarty          $smarty           Smarty instance this source object belongs to
29      * @param string          $resource         full config_resource
30      * @param string          $type             type of resource
31      * @param string          $name             resource name
32      * @param string          $unique_resource  unqiue resource name
33      */
34     public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource)
35     {
36         $this->handler = $handler; // Note: prone to circular references
38         // Note: these may be ->config_compiler_class etc in the future
39         //$this->config_compiler_class = $handler->config_compiler_class;
40         //$this->config_lexer_class = $handler->config_lexer_class;
41         //$this->config_parser_class = $handler->config_parser_class;
43         $this->smarty = $smarty;
44         $this->resource = $resource;
45         $this->type = $type;
46         $this->name = $name;
47         $this->unique_resource = $unique_resource;
48     }
50     /**
51      * <<magic>> Generic setter.
52      *
53      * @param string $property_name valid: content, timestamp, exists
54      * @param mixed  $value         newly assigned value (not check for correct type)
55      * @throws SmartyException when the given property name is not valid
56      */
57     public function __set($property_name, $value)
58     {
59         switch ($property_name) {
60             case 'content':
61             case 'timestamp':
62             case 'exists':
63                 $this->$property_name = $value;
64                 break;
66             default:
67                 throw new SmartyException("invalid config property '$property_name'.");
68         }
69     }
71     /**
72      * <<magic>> Generic getter.
73      *
74      * @param string $property_name valid: content, timestamp, exists
75      * @throws SmartyException when the given property name is not valid
76      */
77     public function __get($property_name)
78     {
79         switch ($property_name) {
80             case 'timestamp':
81             case 'exists':
82                 $this->handler->populateTimestamp($this);
83                 return $this->$property_name;
85             case 'content':
86                 return $this->content = $this->handler->getContent($this);
88             default:
89                 throw new SmartyException("config property '$property_name' does not exist.");
90         }
91     }
93 }
95 ?>