| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Modifier | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |  * Compiles code for modifier execution | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @author Uwe Tews | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Modifier Class | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |      * Compiles code for modifier execution | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param array  $args      array with attributes from parser | 
					
						
							|  |  |  |      * @param object $compiler  compiler object | 
					
						
							|  |  |  |      * @param array  $parameter array with compilation parameter | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |      * @return string compiled code | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |     public function compile($args, $compiler, $parameter) | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         // check and get attributes
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $_attr = $this->getAttributes($compiler, $args); | 
					
						
							|  |  |  |         $output = $parameter['value']; | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |         // loop over list of modifiers
 | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |         foreach ($parameter['modifierlist'] as $single_modifier) { | 
					
						
							| 
									
										
										
										
											2010-10-25 18:53:43 +00:00
										 |  |  |             $modifier = $single_modifier[0]; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             $single_modifier[0] = $output; | 
					
						
							|  |  |  |             $params = implode(',', $single_modifier); | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |             // check for registered modifier
 | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |             if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) { | 
					
						
							|  |  |  |                 $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0]; | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |                 if (!is_array($function)) { | 
					
						
							|  |  |  |                     $output = "{$function}({$params})"; | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |                     if (is_object($function[0])) { | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |                         $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')'; | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |                     } else { | 
					
						
							|  |  |  |                         $output = $function[0] . '::' . $function[1] . '(' . $params . ')'; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } else if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) { | 
					
						
							|  |  |  |                 $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty); | 
					
						
							| 
									
										
										
										
											2010-08-05 17:50:16 +00:00
										 |  |  |                 // check for plugin modifiercompiler
 | 
					
						
							| 
									
										
										
										
											2010-11-13 04:10:52 +00:00
										 |  |  |             } else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 // check if modifier allowed
 | 
					
						
							|  |  |  |                 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) { | 
					
						
							|  |  |  |                     $plugin = 'smarty_modifiercompiler_' . $modifier; | 
					
						
							|  |  |  |                     $output = $plugin($single_modifier, $compiler); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |                 // check for plugin modifier
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } else if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) { | 
					
						
							|  |  |  |                 // check if modifier allowed
 | 
					
						
							|  |  |  |                 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) { | 
					
						
							|  |  |  |                     $output = "{$function}({$params})"; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |                 // check if trusted PHP function
 | 
					
						
							|  |  |  |             } else if (is_callable($modifier)) { | 
					
						
							|  |  |  |                 // check if modifier allowed
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) { | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |                     $output = "{$modifier}({$params})"; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2010-07-23 12:53:04 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |         return $output; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-01 19:57:56 +00:00
										 |  |  | ?>
 |