3 * Smarty Internal Plugin Resource String
6 * @subpackage TemplateResources
12 * Smarty Internal Plugin Resource String
13 * Implements the strings as resource for Smarty template
14 * {@internal unlike eval-resources the compiled state of string-resources is saved for subsequent access}}
17 * @subpackage TemplateResources
19 class Smarty_Internal_Resource_String extends Smarty_Resource
22 * populate Source Object with meta data from Resource
24 * @param Smarty_Template_Source $source source object
25 * @param Smarty_Internal_Template $_template template object
29 public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
31 $source->uid = $source->filepath = sha1($source->name . $source->smarty->_joined_template_dir);
32 $source->timestamp = $source->exists = true;
36 * Load template's source from $resource_name into current template object
38 * @uses decode() to decode base64 and urlencoded template_resources
40 * @param Smarty_Template_Source $source source object
42 * @return string template source
44 public function getContent(Smarty_Template_Source $source)
46 return $this->decode($source->name);
50 * decode base64 and urlencode
52 * @param string $string template_resource to decode
54 * @return string decoded template_resource
56 protected function decode($string)
58 // decode if specified
59 if (($pos = strpos($string, ':')) !== false) {
60 if (!strncmp($string, 'base64', 6)) {
61 return base64_decode(substr($string, 7));
62 } elseif (!strncmp($string, 'urlencode', 9)) {
63 return urldecode(substr($string, 10));
71 * modify resource_name according to resource handlers specifications
73 * @param Smarty $smarty Smarty instance
74 * @param string $resource_name resource_name to make unique
75 * @param boolean $isConfig flag for config resource
77 * @return string unique resource name
79 public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false)
81 return get_class($this) . '#' . $this->decode($resource_name);
85 * Determine basename for compiled filename
86 * Always returns an empty string.
88 * @param Smarty_Template_Source $source source object
90 * @return string resource's basename
92 public function getBasename(Smarty_Template_Source $source)
98 * Disable timestamp checks for string resource.
102 public function checkTimestamps()