root/branches/99-toolbar/code/libraries/koowa/template/abstract.php
| 2522 | 2532 | ||
|---|---|---|---|
22 | * | 22 | * |
23 | * @var array | 23 | * @var array |
24 | */ | 24 | */ |
25 | protected $_path = array(); | 25 | protected $_paths = array(); |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * The set of template filters for templates | 28 | * The set of template filters for templates |
... | ... | ||
37 | * @var string|object | 37 | * @var string|object |
38 | */ | 38 | */ |
39 | protected $_view; | 39 | protected $_view; |
40 | 40 | | |
41 | /** | 41 | /** |
42 | * Constructor | 42 | * Constructor |
43 | * | 43 | * |
... | ... | ||
58 | KTemplateStream::register(); | 58 | KTemplateStream::register(); |
59 | 59 | ||
60 | //Set the paths | 60 | //Set the paths |
61 | $this->_path = $config->path; | 61 | $this->_paths = $config->paths; |
62 | 62 | ||
63 | // Mixin a command chain | 63 | // Mixin a command chain |
64 | $this->mixin(new KMixinCommandchain($config->append(array('mixer' => $this)))); | 64 | $this->mixin(new KMixinCommandchain($config->append(array('mixer' => $this)))); |
... | ... | ||
76 | { | 76 | { |
77 | $config->append(array( | 77 | $config->append(array( |
78 | 'view ' => null, | 78 | 'view ' => null, |
79 | 'path' => array(), | 79 | 'paths' => array(), |
80 | 'command_chain' => new KCommandChain(), | 80 | 'command_chain' => new KCommandChain(), |
81 | 'dispatch_events' => false, | 81 | 'dispatch_events' => false, |
82 | 'enable_callbacks' => false, | 82 | 'enable_callbacks' => false, |
... | ... | ||
149 | public function find( $path, $data) | 149 | public function find( $path, $data) |
150 | { | 150 | { |
151 | //add the default path to the end of the array | 151 | //add the default path to the end of the array |
152 | array_push( $this->_path, dirname($path)); | 152 | array_push( $this->_paths, dirname($path)); |
153 | 153 | ||
154 | // load the template script | 154 | // load the template script |
155 | $template = $this->findPath(basename($path)); | 155 | $template = $this->findPath(basename($path)); |
... | ... | ||
177 | */ | 177 | */ |
178 | public function render($path, $data) | 178 | public function render($path, $data) |
179 | { | 179 | { |
180 | extract($data, EXTR_SKIP); //extract the data in local scope | 180 | //Set the path and data in object scope |
181 | $this->path = $path; | ||
182 | $this->data = $data; | ||
181 | 183 | ||
182 | //Set the template in the template registry | 184 | //Remove the path and data from local scope |
183 | KFactory::get('lib.koowa.template.registry')->set($path, $this); | 185 | unset($data); |
186 | unset($path); | ||
187 | | ||
188 | //Set the template in the template registry | ||
189 | KFactory::get('lib.koowa.template.registry')->set($this->path, $this); | ||
190 | | ||
191 | extract($this->data, EXTR_SKIP); //extract the data in local scope | ||
184 | 192 | ||
185 | // Capturing output into a buffer | 193 | // Capturing output into a buffer |
186 | ob_start(); | 194 | ob_start(); |
187 | include 'tmpl://'.$path; | 195 | include 'tmpl://'.$this->path; |
188 | $output = ob_get_contents(); | 196 | $output = ob_get_contents(); |
189 | ob_end_clean(); | 197 | ob_end_clean(); |
190 | 198 | ||
... | ... | ||
192 | $output = $this->filter($output, KTemplateFilter::MODE_WRITE); | 200 | $output = $this->filter($output, KTemplateFilter::MODE_WRITE); |
193 | 201 | ||
194 | //Remove the template object from the template registry | 202 | //Remove the template object from the template registry |
195 | KFactory::get('lib.koowa.template.registry')->del($path); | 203 | KFactory::get('lib.koowa.template.registry')->del($this->path); |
196 | 204 | ||
197 | return $output; | 205 | return $output; |
198 | } | 206 | } |
... | ... | ||
285 | 293 | ||
286 | // add to the top of the search dirs | 294 | // add to the top of the search dirs |
287 | if(!$append) { | 295 | if(!$append) { |
288 | array_unshift( $this->_path, $dir); | 296 | array_unshift( $this->_paths, $dir); |
289 | } else { | 297 | } else { |
290 | array_push( $this->_path, $dir); | 298 | array_push( $this->_paths, $dir); |
291 | } | 299 | } |
292 | } | 300 | } |
293 | 301 | ||
... | ... | ||
306 | settype($paths, 'array'); //force to array | 314 | settype($paths, 'array'); //force to array |
307 | 315 | ||
308 | // start looping through the path set | 316 | // start looping through the path set |
309 | foreach ($this->_path as $path) | 317 | foreach ($this->_paths as $path) |
310 | { | 318 | { |
311 | // get the path to the file | 319 | // get the path to the file |
312 | $fullname = $path.'/'.$file; | 320 | $fullname = $path.'/'.$file; |
Download diff