| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Print Expression | 
					
						
							|  |  |  |  * Compiles any tag which will output an expression or variable | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  * @author     Uwe Tews | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Print Expression Class | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     public $optional_attributes = array('assign'); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:19:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * Attribute definition: Overwrites base class. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      * @see Smarty_Internal_CompileBase | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     public $option_flags = array('nocache', 'nofilter'); | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * Compiles code for generating output from any expression | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-08-06 01:19:11 +02:00
										 |  |  |      * @param array                                 $args      array with attributes from parser | 
					
						
							|  |  |  |      * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object | 
					
						
							|  |  |  |      * @param array                                 $parameter array with compilation parameter | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-08-06 01:19:11 +02:00
										 |  |  |      * @return string | 
					
						
							|  |  |  |      * @throws \SmartyException | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-08-06 01:19:11 +02:00
										 |  |  |     public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							| 
									
										
										
										
											2016-07-18 17:57:50 +02:00
										 |  |  |         $output = $parameter[ 'value' ]; | 
					
						
							|  |  |  |         // tag modifier
 | 
					
						
							|  |  |  |         if (!empty($parameter[ 'modifierlist' ])) { | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |             $output = $compiler->compileTag( | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                 'private_modifier', | 
					
						
							|  |  |  |                 array(), | 
					
						
							|  |  |  |                 array( | 
					
						
							|  |  |  |                     'modifierlist' => $parameter[ 'modifierlist' ], | 
					
						
							|  |  |  |                     'value'        => $output | 
					
						
							|  |  |  |                 ) | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |             ); | 
					
						
							| 
									
										
										
										
											2016-07-18 17:57:50 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |         if (isset($_attr[ 'assign' ])) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             // assign output to variable
 | 
					
						
							| 
									
										
										
										
											2016-07-18 17:57:50 +02:00
										 |  |  |             return "<?php \$_smarty_tpl->assign({$_attr['assign']},{$output});?>"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             // display value
 | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |             if (!$_attr[ 'nofilter' ]) { | 
					
						
							| 
									
										
										
										
											2011-10-05 18:17:40 +00:00
										 |  |  |                 // default modifier
 | 
					
						
							|  |  |  |                 if (!empty($compiler->smarty->default_modifiers)) { | 
					
						
							|  |  |  |                     if (empty($compiler->default_modifier_list)) { | 
					
						
							|  |  |  |                         $modifierlist = array(); | 
					
						
							|  |  |  |                         foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) { | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                             preg_match_all( | 
					
						
							|  |  |  |                                 '/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                                 $single_default_modifier, | 
					
						
							|  |  |  |                                 $mod_array | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                             ); | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                             for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i++) { | 
					
						
							| 
									
										
										
										
											2017-11-06 01:02:56 +01:00
										 |  |  |                                 if ($mod_array[ 0 ][ $i ] !== ':') { | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |                                     $modifierlist[ $key ][] = $mod_array[ 0 ][ $i ]; | 
					
						
							| 
									
										
										
										
											2011-10-05 18:17:40 +00:00
										 |  |  |                                 } | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                             } | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |                         $compiler->default_modifier_list = $modifierlist; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                     $output = $compiler->compileTag( | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                         'private_modifier', | 
					
						
							|  |  |  |                         array(), | 
					
						
							|  |  |  |                         array( | 
					
						
							|  |  |  |                             'modifierlist' => $compiler->default_modifier_list, | 
					
						
							|  |  |  |                             'value'        => $output | 
					
						
							|  |  |  |                         ) | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                     ); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |                 // autoescape html
 | 
					
						
							|  |  |  |                 if ($compiler->template->smarty->escape_html) { | 
					
						
							| 
									
										
										
										
											2011-12-18 18:20:09 +00:00
										 |  |  |                     $output = "htmlspecialchars({$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')"; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |                 // loop over registered filters
 | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |                 if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) { | 
					
						
							|  |  |  |                     foreach ($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ] as $key => | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                         $function) { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                         if (!is_array($function)) { | 
					
						
							|  |  |  |                             $output = "{$function}({$output},\$_smarty_tpl)"; | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |                         } elseif (is_object($function[ 0 ])) { | 
					
						
							|  |  |  |                             $output = | 
					
						
							|  |  |  |                                 "\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)"; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                         } else { | 
					
						
							|  |  |  |                             $output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)"; | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 // auto loaded filters
 | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |                 if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                     foreach ((array)$compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name) { | 
					
						
							| 
									
										
										
										
											2017-11-20 11:11:46 +01:00
										 |  |  |                         $result = $this->compile_variable_filter($compiler, $name, $output); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                         if ($result !== false) { | 
					
						
							|  |  |  |                             $output = $result; | 
					
						
							|  |  |  |                         } else { | 
					
						
							|  |  |  |                             // not found, throw exception
 | 
					
						
							| 
									
										
										
										
											2017-11-20 11:11:46 +01:00
										 |  |  |                             throw new SmartyException("Unable to load variable filter '{$name}'"); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2015-08-23 13:24:24 +02:00
										 |  |  |                 foreach ($compiler->variable_filters as $filter) { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                     if (count($filter) === 1 | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                         && ($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false | 
					
						
							| 
									
										
										
										
											2015-08-23 13:24:24 +02:00
										 |  |  |                     ) { | 
					
						
							|  |  |  |                         $output = $result; | 
					
						
							|  |  |  |                     } else { | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                         $output = $compiler->compileTag( | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |                             'private_modifier', | 
					
						
							|  |  |  |                             array(), | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |                             array('modifierlist' => array($filter), 'value' => $output) | 
					
						
							|  |  |  |                         ); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-11-20 04:07:51 +01:00
										 |  |  |             $output = "<?php echo {$output};?>\n"; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return $output; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2015-08-06 01:19:11 +02:00
										 |  |  |      * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object | 
					
						
							|  |  |  |      * @param string                                $name     name of variable filter | 
					
						
							|  |  |  |      * @param string                                $output   embedded output | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return string | 
					
						
							| 
									
										
										
										
											2017-10-26 10:25:41 +02:00
										 |  |  |      * @throws \SmartyException | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2017-11-20 11:11:46 +01:00
										 |  |  |     private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |         $function = $compiler->getPlugin($name, 'variablefilter'); | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |         if ($function) { | 
					
						
							| 
									
										
										
										
											2017-11-20 11:11:46 +01:00
										 |  |  |             return "{$function}({$output},\$_smarty_tpl)"; | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             // not found
 | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } |