| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Function
 | 
					
						
							|  |  |  |  * Compiles the {function} {/function} tags | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @author     Uwe Tews | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Function Class | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |     public $required_attributes = array('name'); | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |     public $shorttag_order = array('name'); | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $optional_attributes = array('_any'); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |      * Compiles code for the {function} tag | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  array  $args      array with attributes from parser | 
					
						
							|  |  |  |      * @param  object $compiler  compiler object | 
					
						
							|  |  |  |      * @param  array  $parameter array with compilation parameter | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @return boolean true | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |     public function compile($args, $compiler, $parameter) | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if ($_attr['nocache'] === true) { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         unset($_attr['nocache']); | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $_name = trim($_attr['name'], "'\""); | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  |         $compiler->parent_compiler->templateProperties['tpl_function'][$_name] = array(); | 
					
						
							|  |  |  |         $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->has_nocache_code, $compiler->template->required_plugins, $compiler->template->caching); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $this->openTag($compiler, 'function', $save); | 
					
						
							| 
									
										
										
										
											2011-09-28 15:56:01 +00:00
										 |  |  |         // set flag that we are compiling a template function
 | 
					
						
							|  |  |  |         $compiler->compiles_template_function = true; | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |         // Init temporary context
 | 
					
						
							| 
									
										
										
										
											2010-03-25 20:43:56 +00:00
										 |  |  |         $compiler->template->required_plugins = array('compiled' => array(), 'nocache' => array()); | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |         $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template($compiler->parser); | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         $compiler->template->has_nocache_code = false; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $compiler->template->caching = true; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Functionclose Class | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Compiler object | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var object | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private $compiler = null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |      * Compiles code for the {/function} tag | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  |      * @param  array                                       $args      array with attributes from parser | 
					
						
							|  |  |  |      * @param object|\Smarty_Internal_TemplateCompilerBase $compiler  compiler object | 
					
						
							|  |  |  |      * @param  array                                       $parameter array with compilation parameter | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-05-14 15:11:38 +02:00
										 |  |  |      * @return bool true | 
					
						
							| 
									
										
										
										
											2010-05-25 19:33:55 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |     public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $this->compiler = $compiler; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $saved_data = $this->closeTag($compiler, array('function')); | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $_attr = $saved_data[0]; | 
					
						
							|  |  |  |         $_name = trim($_attr['name'], "'\""); | 
					
						
							|  |  |  |         // reset flag that we are compiling a template function
 | 
					
						
							|  |  |  |         $compiler->compiles_template_function = false; | 
					
						
							| 
									
										
										
										
											2015-03-17 04:53:57 +01:00
										 |  |  |         $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['called_functions'] = $compiler->called_functions; | 
					
						
							|  |  |  |         $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['compiled_filepath'] = $compiler->parent_compiler->template->compiled->filepath; | 
					
						
							|  |  |  |         $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['uid'] = $compiler->template->source->uid; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $compiler->called_functions = array(); | 
					
						
							|  |  |  |         $_parameter = $_attr; | 
					
						
							|  |  |  |         unset($_parameter['name']); | 
					
						
							|  |  |  |         // default parameter
 | 
					
						
							|  |  |  |         $_paramsArray = array(); | 
					
						
							|  |  |  |         foreach ($_parameter as $_key => $_value) { | 
					
						
							|  |  |  |             if (is_int($_key)) { | 
					
						
							|  |  |  |                 $_paramsArray[] = "$_key=>$_value"; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 $_paramsArray[] = "'$_key'=>$_value"; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!empty($_paramsArray)) { | 
					
						
							|  |  |  |             $_params = 'array(' . implode(",", $_paramsArray) . ')'; | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $_paramsCode = "\$params = array_merge($_params, \$params);\n"; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             $_paramsCode = ''; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |         $_functionCode = $compiler->parser->current_buffer; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         // setup buffer for template function code
 | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |         $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template($compiler->parser); | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $_funcName = "smarty_template_function_{$_name}_{$compiler->template->properties['nocache_hash']}"; | 
					
						
							|  |  |  |         $_funcNameCaching = $_funcName . '_nocache'; | 
					
						
							|  |  |  |         if ($compiler->template->has_nocache_code) { | 
					
						
							| 
									
										
										
										
											2015-03-17 04:53:57 +01:00
										 |  |  |             $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['call_name_caching'] = $_funcNameCaching; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |             $output = "<?php\n"; | 
					
						
							|  |  |  |             $output .= "/* {$_funcNameCaching} */\n"; | 
					
						
							|  |  |  |             $output .= "if (!function_exists('{$_funcNameCaching}')) {\n"; | 
					
						
							|  |  |  |             $output .= "function {$_funcNameCaching} (\$_smarty_tpl,\$params) {\n"; | 
					
						
							|  |  |  |             // build plugin include code
 | 
					
						
							|  |  |  |             if (!empty($compiler->template->required_plugins['compiled'])) { | 
					
						
							|  |  |  |                 foreach ($compiler->template->required_plugins['compiled'] as $tmp) { | 
					
						
							|  |  |  |                     foreach ($tmp as $data) { | 
					
						
							| 
									
										
										
										
											2015-01-07 16:45:33 +01:00
										 |  |  |                         $output .= "if (!is_callable('{$data['function']}')) require_once '{$data['file']}';\n"; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |             if (!empty($compiler->template->required_plugins['nocache'])) { | 
					
						
							|  |  |  |                 $output .= "echo '/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php "; | 
					
						
							|  |  |  |                 foreach ($compiler->template->required_plugins['nocache'] as $tmp) { | 
					
						
							|  |  |  |                     foreach ($tmp as $data) { | 
					
						
							| 
									
										
										
										
											2015-01-07 16:45:33 +01:00
										 |  |  |                         $output .= "if (!is_callable(\'{$data['function']}\')) require_once \'{$data['file']}\';\n"; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $output .= "?>/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/';\n"; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $output .= "ob_start();\n"; | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |             $output .= $_paramsCode; | 
					
						
							| 
									
										
										
										
											2015-04-20 22:59:45 +02:00
										 |  |  |             $output .= "\$_smarty_tpl->properties['saved_tpl_vars'][] = \$_smarty_tpl->tpl_vars;\n"; | 
					
						
							| 
									
										
										
										
											2015-01-06 01:18:58 +01:00
										 |  |  |             $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}"; | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $output .= "\$params = var_export(\$params, true);\n"; | 
					
						
							|  |  |  |             $output .= "echo \"/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php "; | 
					
						
							| 
									
										
										
										
											2015-01-06 01:18:58 +01:00
										 |  |  |             $output .= "\\\$saved_tpl_vars = \\\$_smarty_tpl->tpl_vars;\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value);\n}\n?>"; | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $output .= "/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/\n\";?>"; | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |             $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output)); | 
					
						
							|  |  |  |             $compiler->parser->current_buffer->append_subtree($_functionCode); | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php "; | 
					
						
							| 
									
										
										
										
											2015-03-20 18:25:59 +01:00
										 |  |  |             $output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value){\n"; | 
					
						
							|  |  |  |             $output .= "if (\\\$_smarty_tpl->tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n"; | 
					
						
							|  |  |  |             $output .= "\\\$_smarty_tpl->tpl_vars = \\\$saved_tpl_vars;?>\n"; | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $output .= "/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/\";\n?>"; | 
					
						
							| 
									
										
										
										
											2015-04-20 22:59:45 +02:00
										 |  |  |             $output .= "<?php echo str_replace('{$compiler->template->properties['nocache_hash']}', \$_smarty_tpl->properties['nocache_hash'], ob_get_clean());\n"; | 
					
						
							|  |  |  |             $output .= "\$_smarty_tpl->tpl_vars = array_pop(\$_smarty_tpl->properties['saved_tpl_vars']);\n}\n}\n"; | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |             $output .= "/*/ {$_funcName}_nocache */\n\n"; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |             $output .= "?>\n"; | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |             $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output)); | 
					
						
							|  |  |  |             $_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%\*\/';(\?>\n)?)/", array($this, 'removeNocache'), $_functionCode->to_smarty_php())); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-03-17 04:53:57 +01:00
										 |  |  |         $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['call_name'] = $_funcName; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $output = "<?php\n"; | 
					
						
							|  |  |  |         $output .= "/* {$_funcName} */\n"; | 
					
						
							|  |  |  |         $output .= "if (!function_exists('{$_funcName}')) {\n"; | 
					
						
							|  |  |  |         $output .= "function {$_funcName}(\$_smarty_tpl,\$params) {\n"; | 
					
						
							|  |  |  |         // build plugin include code
 | 
					
						
							| 
									
										
										
										
											2010-03-25 20:43:56 +00:00
										 |  |  |         if (!empty($compiler->template->required_plugins['nocache'])) { | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |             $compiler->template->required_plugins['compiled'] = array_merge($compiler->template->required_plugins['compiled'], $compiler->template->required_plugins['nocache']); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!empty($compiler->template->required_plugins['compiled'])) { | 
					
						
							|  |  |  |             foreach ($compiler->template->required_plugins['compiled'] as $tmp) { | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |                 foreach ($tmp as $data) { | 
					
						
							| 
									
										
										
										
											2015-01-07 16:45:33 +01:00
										 |  |  |                     $output .= "if (!is_callable('{$data['function']}')) require_once '{$data['file']}';\n"; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $output .= "\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;\n"; | 
					
						
							|  |  |  |         $output .= $_paramsCode; | 
					
						
							| 
									
										
										
										
											2015-01-06 01:18:58 +01:00
										 |  |  |         $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}?>"; | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |         $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output)); | 
					
						
							| 
									
										
										
										
											2014-11-11 01:01:01 +01:00
										 |  |  |         $compiler->parser->current_buffer->append_subtree($_functionCode); | 
					
						
							| 
									
										
										
										
											2015-03-20 18:25:59 +01:00
										 |  |  |         $output = "<?php foreach (Smarty::\$global_tpl_vars as \$key => \$value){\n"; | 
					
						
							|  |  |  |         $output .= "if (\$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n"; | 
					
						
							|  |  |  |         $output .= "\$_smarty_tpl->tpl_vars = \$saved_tpl_vars;\n}\n}\n"; | 
					
						
							| 
									
										
										
										
											2014-11-10 23:57:30 +01:00
										 |  |  |         $output .= "/*/ {$_funcName} */\n\n"; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $output .= "?>\n"; | 
					
						
							| 
									
										
										
										
											2014-12-30 16:16:54 +01:00
										 |  |  |         $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output)); | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $compiler->parent_compiler->templateFunctionCode .= $compiler->parser->current_buffer->to_smarty_php(); | 
					
						
							|  |  |  |         // restore old buffer
 | 
					
						
							| 
									
										
										
										
											2010-07-14 22:47:37 +00:00
										 |  |  |         $compiler->parser->current_buffer = $saved_data[1]; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         // restore old status
 | 
					
						
							|  |  |  |         $compiler->template->has_nocache_code = $saved_data[2]; | 
					
						
							| 
									
										
										
										
											2010-07-14 22:47:37 +00:00
										 |  |  |         $compiler->template->required_plugins = $saved_data[3]; | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |         $compiler->template->caching = $saved_data[4]; | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-01 22:42:34 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param $match | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return mixed | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     function removeNocache($match) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $code = preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->properties['nocache_hash']}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->properties['nocache_hash']}%%\*\/';(\?>\n)?)/", '', $match[0]); | 
					
						
							|  |  |  |         $code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code); | 
					
						
							|  |  |  |         return $code; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } |