1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * interface that represents a dwoo template |
---|
5 | * |
---|
6 | * This software is provided 'as-is', without any express or implied warranty. |
---|
7 | * In no event will the authors be held liable for any damages arising from the use of this software. |
---|
8 | * |
---|
9 | * @author Jordi Boggiano <j.boggiano@seld.be> |
---|
10 | * @copyright Copyright (c) 2008, Jordi Boggiano |
---|
11 | * @license http://dwoo.org/LICENSE Modified BSD License |
---|
12 | * @link http://dwoo.org/ |
---|
13 | * @version 1.1.0 |
---|
14 | * @date 2009-07-18 |
---|
15 | * @package Dwoo |
---|
16 | */ |
---|
17 | interface Dwoo_ITemplate |
---|
18 | { |
---|
19 | /** |
---|
20 | * returns the cache duration for this template |
---|
21 | * |
---|
22 | * defaults to null if it was not provided |
---|
23 | * |
---|
24 | * @return int|null |
---|
25 | */ |
---|
26 | public function getCacheTime(); |
---|
27 | |
---|
28 | /** |
---|
29 | * sets the cache duration for this template |
---|
30 | * |
---|
31 | * can be used to set it after the object is created if you did not provide |
---|
32 | * it in the constructor |
---|
33 | * |
---|
34 | * @param int $seconds duration of the cache validity for this template, if |
---|
35 | * null it defaults to the Dwoo instance's cache time. 0 = disable and |
---|
36 | * -1 = infinite cache |
---|
37 | */ |
---|
38 | public function setCacheTime($seconds = null); |
---|
39 | |
---|
40 | /** |
---|
41 | * returns the cached template output file name, true if it's cache-able but not cached |
---|
42 | * or false if it's not cached |
---|
43 | * |
---|
44 | * @param Dwoo_Core $dwoo the dwoo instance that requests it |
---|
45 | * @return string|bool |
---|
46 | */ |
---|
47 | public function getCachedTemplate(Dwoo_Core $dwoo); |
---|
48 | |
---|
49 | /** |
---|
50 | * caches the provided output into the cache file |
---|
51 | * |
---|
52 | * @param Dwoo_Core $dwoo the dwoo instance that requests it |
---|
53 | * @param string $output the template output |
---|
54 | * @return mixed full path of the cached file or false upon failure |
---|
55 | */ |
---|
56 | public function cache(Dwoo_Core $dwoo, $output); |
---|
57 | |
---|
58 | /** |
---|
59 | * clears the cached template if it's older than the given time |
---|
60 | * |
---|
61 | * @param Dwoo_Core $dwoo the dwoo instance that was used to cache that template |
---|
62 | * @param int $olderThan minimum time (in seconds) required for the cache to be cleared |
---|
63 | * @return bool true if the cache was not present or if it was deleted, false if it remains there |
---|
64 | */ |
---|
65 | public function clearCache(Dwoo_Core $dwoo, $olderThan = -1); |
---|
66 | |
---|
67 | /** |
---|
68 | * returns the compiled template file name |
---|
69 | * |
---|
70 | * @param Dwoo_Core $dwoo the dwoo instance that requests it |
---|
71 | * @param Dwoo_ICompiler $compiler the compiler that must be used |
---|
72 | * @return string |
---|
73 | */ |
---|
74 | public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null); |
---|
75 | |
---|
76 | /** |
---|
77 | * returns the template name |
---|
78 | * |
---|
79 | * @return string |
---|
80 | */ |
---|
81 | public function getName(); |
---|
82 | |
---|
83 | /** |
---|
84 | * returns the resource name for this template class |
---|
85 | * |
---|
86 | * @return string |
---|
87 | */ |
---|
88 | public function getResourceName(); |
---|
89 | |
---|
90 | /** |
---|
91 | * returns the resource identifier for this template or false if it has no identifier |
---|
92 | * |
---|
93 | * @return string|false |
---|
94 | */ |
---|
95 | public function getResourceIdentifier(); |
---|
96 | |
---|
97 | /** |
---|
98 | * returns the template source of this template |
---|
99 | * |
---|
100 | * @return string |
---|
101 | */ |
---|
102 | public function getSource(); |
---|
103 | |
---|
104 | /** |
---|
105 | * returns an unique string identifying the current version of this template, |
---|
106 | * for example a timestamp of the last modified date or a hash of the template source |
---|
107 | * |
---|
108 | * @return string |
---|
109 | */ |
---|
110 | public function getUid(); |
---|
111 | |
---|
112 | /** |
---|
113 | * returns the compiler used by this template, if it was just compiled, or null |
---|
114 | * |
---|
115 | * @return Dwoo_ICompiler |
---|
116 | */ |
---|
117 | public function getCompiler(); |
---|
118 | |
---|
119 | /** |
---|
120 | * returns some php code that will check if this template has been modified or not |
---|
121 | * |
---|
122 | * if the function returns null, the template will be instanciated and then the Uid checked |
---|
123 | * |
---|
124 | * @return string |
---|
125 | */ |
---|
126 | public function getIsModifiedCode(); |
---|
127 | |
---|
128 | /** |
---|
129 | * returns a new template object from the given resource identifier, null if no include is |
---|
130 | * possible (resource not found), or false if include is not permitted by this resource type |
---|
131 | * |
---|
132 | * this method should also check if $dwoo->getSecurityPolicy() is null or not and do the |
---|
133 | * necessary permission checks if required, if the security policy prevents the template |
---|
134 | * generation it should throw a new Dwoo_Security_Exception with a relevant message |
---|
135 | * |
---|
136 | * @param mixed $resourceId the resource identifier |
---|
137 | * @param int $cacheTime duration of the cache validity for this template, |
---|
138 | * if null it defaults to the Dwoo instance that will |
---|
139 | * render this template |
---|
140 | * @param string $cacheId the unique cache identifier of this page or anything else that |
---|
141 | * makes this template's content unique, if null it defaults |
---|
142 | * to the current url |
---|
143 | * @param string $compileId the unique compiled identifier, which is used to distinguish this |
---|
144 | * template from others, if null it defaults to the filename+bits of the path |
---|
145 | * @param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through |
---|
146 | * an include, extends or any other plugin) |
---|
147 | * @return Dwoo_ITemplate|null|false |
---|
148 | */ |
---|
149 | public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null); |
---|
150 | } |
---|