1 <?php
3 /**
4 * Smarty Internal Plugin Resource Stream
5 *
6 * Implements the streams as resource for Smarty template
7 *
8 * @package Smarty
9 * @subpackage TemplateResources
10 * @author Uwe Tews
11 */
12 /**
13 * Smarty Internal Plugin Resource Stream
14 */
16 class Smarty_Internal_Resource_Stream {
17 public function __construct($smarty)
18 {
19 $this->smarty = $smarty;
20 }
21 // classes used for compiling Smarty templates from file resource
22 public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
23 public $template_lexer_class = 'Smarty_Internal_Templatelexer';
24 public $template_parser_class = 'Smarty_Internal_Templateparser';
25 // properties
26 public $usesCompiler = true;
27 public $isEvaluated = true;
29 /**
30 * Return flag if template source is existing
31 *
32 * @return boolean true
33 */
34 public function isExisting($template)
35 {
36 if ($template->getTemplateSource() == '') {
37 return false;
38 } else {
39 return true;
40 }
41 }
42 /**
43 * Get filepath to template source
44 *
45 * @param object $_template template object
46 * @return string return 'string' as template source is not a file
47 */
48 public function getTemplateFilepath($_template)
49 {
50 // no filepath for strings
51 // return resource name for compiler error messages
52 return str_replace(':', '://', $_template->template_resource);
53 }
55 /**
56 * Get timestamp to template source
57 *
58 * @param object $_template template object
59 * @return boolean false as string resources have no timestamp
60 */
61 public function getTemplateTimestamp($_template)
62 {
63 // strings must always be compiled and have no timestamp
64 return false;
65 }
67 /**
68 * Retuen template source from resource name
69 *
70 * @param object $_template template object
71 * @return string content of template source
72 */
73 public function getTemplateSource($_template)
74 {
75 // return template string
76 $_template->template_source = '';
77 $fp = fopen(str_replace(':', '://', $_template->template_resource),'r+');
78 while (!feof($fp)) {
79 $_template->template_source .= fgets($fp);
80 }
81 fclose($fp);
83 return true;
84 }
86 /**
87 * Get filepath to compiled template
88 *
89 * @param object $_template template object
90 * @return boolean return false as compiled template is not stored
91 */
92 public function getCompiledFilepath($_template)
93 {
94 // no filepath for strings
95 return false;
96 }
97 }
99 ?>