1 <?php |
|
2 /** |
|
3 * Smarty Resource Plugin |
|
4 * |
|
5 * @package Smarty |
|
6 * @subpackage TemplateResources |
|
7 * @author Rodney Rehm |
|
8 */ |
|
9 |
|
10 /** |
|
11 * Smarty Resource Plugin |
|
12 * Base implementation for resource plugins that don't use the compiler |
|
13 * |
|
14 * @package Smarty |
|
15 * @subpackage TemplateResources |
|
16 */ |
|
17 abstract class Smarty_Resource_Uncompiled extends Smarty_Resource { |
|
18 /** |
|
19 * Flag that it's an uncompiled resource |
|
20 * |
|
21 * @var bool |
|
22 */ |
|
23 public $uncompiled = true; |
|
24 |
|
25 /** |
|
26 * Render and output the template (without using the compiler) |
|
27 * |
|
28 * @param Smarty_Template_Source $source source object |
|
29 * @param Smarty_Internal_Template $_template template object |
|
30 * |
|
31 * @throws SmartyException on failure |
|
32 */ |
|
33 abstract public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template); |
|
34 |
|
35 /** |
|
36 * populate compiled object with compiled filepath |
|
37 * |
|
38 * @param Smarty_Template_Compiled $compiled compiled object |
|
39 * @param Smarty_Internal_Template $_template template object (is ignored) |
|
40 */ |
|
41 public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template) { |
|
42 $compiled->filepath = false; |
|
43 $compiled->timestamp = false; |
|
44 $compiled->exists = false; |
|
45 } |
|
46 |
|
47 /** |
|
48 * render compiled template code |
|
49 * |
|
50 * @param Smarty_Internal_Template $_template |
|
51 * |
|
52 * @return string |
|
53 * @throws Exception |
|
54 */ |
|
55 public function render($_template) { |
|
56 $level = ob_get_level(); |
|
57 ob_start(); |
|
58 try { |
|
59 $this->renderUncompiled($_template->source, $_template); |
|
60 return ob_get_clean(); |
|
61 } catch (Exception $e) { |
|
62 while (ob_get_level() > $level) { |
|
63 ob_end_clean(); |
|
64 } |
|
65 throw $e; |
|
66 } |
|
67 } |
|
68 } |
|