38 $components = explode(
'|', $source->name);
40 foreach ($components as $component) {
42 if ($s->type ==
'php') {
43 throw new SmartyException(
"Resource type {$s->type} cannot be used with the extends resource type");
47 if ($_template && $_template->smarty->compile_check) {
48 $exists = $exists && $s->exists;
52 $source->filepath = $s->filepath;
53 $source->uid = sha1($uid);
54 if ($_template && $_template->smarty->compile_check) {
55 $source->timestamp = $s->timestamp;
56 $source->exists = $exists;
59 $source->template = $_template;
69 $source->exists =
true;
70 foreach ($source->components as $s) {
71 $source->exists = $source->exists && $s->exists;
73 $source->timestamp = $s->timestamp;
85 if (!$source->exists) {
86 throw new SmartyException(
"Unable to read template {$source->type} '{$source->name}'");
89 $this->mbstring_overload = ini_get(
'mbstring.func_overload') & 2;
90 $_rdl = preg_quote($source->smarty->right_delimiter);
91 $_ldl = preg_quote($source->smarty->left_delimiter);
92 if (!$source->smarty->auto_literal) {
97 $_components = array_reverse($source->components);
98 $_first = reset($_components);
99 $_last = end($_components);
101 foreach ($_components as $_component) {
103 if ($_component != $_first) {
104 $source->template->properties[
'file_dependency'][$_component->uid] = array($_component->filepath, $_component->timestamp, $_component->type);
108 $source->filepath = $_component->filepath;
109 $_content = $_component->content;
112 if ($_component != $_last) {
113 if (preg_match_all(
"!({$_ldl}{$al}block\s(.+?)\s*{$_rdl})!", $_content, $_open) !=
114 preg_match_all(
"!({$_ldl}{$al}/block\s*{$_rdl})!", $_content, $_close)) {
115 throw new SmartyException(
"unmatched {block} {/block} pairs in template {$_component->type} '{$_component->name}'");
117 preg_match_all(
"!{$_ldl}{$al}block\s(.+?)\s*{$_rdl}|{$_ldl}{$al}/block\s*{$_rdl}|{$_ldl}\*([\S\s]*?)\*{$_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
118 $_result_count = count($_result[0]);
120 while ($_start+1 < $_result_count) {
123 if (($this->mbstring_overload ? mb_substr($_result[0][$_start][0],0,mb_strlen($source->smarty->left_delimiter,
'latin1')+1,
'latin1') : substr($_result[0][$_start][0],0,strlen($source->smarty->left_delimiter)+1)) == $source->smarty->left_delimiter.
'*') {
127 while ($_level != 0) {
129 if (($this->mbstring_overload ? mb_substr($_result[0][$_start + $_end][0],0,mb_strlen($source->smarty->left_delimiter,
'latin1')+1,
'latin1') : substr($_result[0][$_start + $_end][0],0,strlen($source->smarty->left_delimiter)+1)) == $source->smarty->left_delimiter.
'*') {
132 if (!strpos($_result[0][$_start + $_end][0],
'/')) {
138 $_block_content = str_replace($source->smarty->left_delimiter .
'$smarty.block.parent' . $source->smarty->right_delimiter,
'%%%%SMARTY_PARENT%%%%',
139 ($this->mbstring_overload ? mb_substr($_content, $_result[0][$_start][1] + mb_strlen($_result[0][$_start][0],
'latin1'), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + mb_strlen($_result[0][$_start][0],
'latin1'),
'latin1') : substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))));
141 $_start = $_start + $_end + 1;
157 return str_replace(
':',
'.', basename($source->filepath));
static saveBlockData($block_content, $block_tag, $template, $filepath)
Save or replace child block source by block name during parsing.
static source(Smarty_Internal_Template $_template=null, Smarty $smarty=null, $template_resource=null)
initialize Source Object for given resource
populateTimestamp(Smarty_Template_Source $source)
populate Source Object with timestamp and exists from Resource
getContent(Smarty_Template_Source $source)
Load template's source from files into current template object.
getBasename(Smarty_Template_Source $source)
Determine basename for compiled filename.
populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
populate Source Object with meta data from Resource