| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |  * Smarty Internal Plugin Compile Special Smarty Variable | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |  * Compiles the special $smarty variables | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @author Uwe Tews | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |  * Smarty Internal Plugin Compile special Smarty Variable Class | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage Compiler | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |      * Compiles code for the speical $smarty variables | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param array  $args     array with attributes from parser | 
					
						
							| 
									
										
										
										
											2010-08-17 15:39:51 +00:00
										 |  |  |      * @param object $compiler compiler object | 
					
						
							|  |  |  |      * @return string compiled code | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |     public function compile($args, $compiler, $parameter) | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |         $_index = preg_split("/\]\[/",substr($parameter, 1, strlen($parameter)-2)); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         $compiled_ref = ' '; | 
					
						
							| 
									
										
										
										
											2009-12-04 15:44:47 +00:00
										 |  |  |         $variable = trim($_index[0], "'"); | 
					
						
							|  |  |  |         switch ($variable) { | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             case 'foreach': | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |                 return "\$_smarty_tpl->getVariable('smarty')->value$parameter"; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             case 'section': | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |                 return "\$_smarty_tpl->getVariable('smarty')->value$parameter"; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             case 'capture': | 
					
						
							| 
									
										
										
										
											2010-11-15 22:54:59 +00:00
										 |  |  |                 return "Smarty::\$_smarty_vars$parameter"; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |             case 'now': | 
					
						
							| 
									
										
										
										
											2010-11-18 18:58:53 +00:00
										 |  |  |                 return 'time()'; | 
					
						
							| 
									
										
										
										
											2010-01-14 19:12:14 +00:00
										 |  |  |             case 'cookies': | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |                 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) { | 
					
						
							| 
									
										
										
										
											2010-01-14 19:12:14 +00:00
										 |  |  |                     $compiler->trigger_template_error("(secure mode) super globals not permitted"); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2010-01-14 19:12:14 +00:00
										 |  |  |                 $compiled_ref = '$_COOKIE'; | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             case 'get': | 
					
						
							|  |  |  |             case 'post': | 
					
						
							|  |  |  |             case 'env': | 
					
						
							|  |  |  |             case 'server': | 
					
						
							|  |  |  |             case 'session': | 
					
						
							|  |  |  |             case 'request': | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |                 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) { | 
					
						
							| 
									
										
										
										
											2009-12-04 15:44:47 +00:00
										 |  |  |                     $compiler->trigger_template_error("(secure mode) super globals not permitted"); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2010-01-14 19:12:14 +00:00
										 |  |  |                 $compiled_ref = '$_'.strtoupper($variable); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'template': | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 return 'basename($_smarty_tpl->source->filepath)'; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             case 'current_dir': | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 return 'dirname($_smarty_tpl->source->filepath)'; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             case 'version': | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 $_version = Smarty::SMARTY_VERSION; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |                 return "'$_version'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'const': | 
					
						
							| 
									
										
										
										
											2010-11-11 21:34:36 +00:00
										 |  |  |                 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) { | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |                     $compiler->trigger_template_error("(secure mode) constants not permitted"); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |                 return '@' . trim($_index[1], "'"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'config': | 
					
						
							|  |  |  |                 return "\$_smarty_tpl->getConfigVariable($_index[1])"; | 
					
						
							|  |  |  |             case 'ldelim': | 
					
						
							|  |  |  |                 $_ldelim = $compiler->smarty->left_delimiter; | 
					
						
							|  |  |  |                 return "'$_ldelim'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'rdelim': | 
					
						
							|  |  |  |                 $_rdelim = $compiler->smarty->right_delimiter; | 
					
						
							|  |  |  |                 return "'$_rdelim'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             default: | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid'); | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-11-06 14:35:00 +00:00
										 |  |  |         if (isset($_index[1])) { | 
					
						
							|  |  |  |             array_shift($_index); | 
					
						
							|  |  |  |             foreach ($_index as $_ind) { | 
					
						
							|  |  |  |                 $compiled_ref = $compiled_ref . "[$_ind]"; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2010-11-15 19:17:18 +00:00
										 |  |  |         return $compiled_ref; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-04 15:44:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-15 14:08:56 +00:00
										 |  |  | ?>
 |