| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile Smarty | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * Compiles the special $smarty variables | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * @package Smarty | 
					
						
							|  |  |  | * @subpackage Compiler | 
					
						
							|  |  |  | * @author Uwe Tews  | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Smarty Internal Plugin Compile Smarty Class | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-04-28 15:37:13 +00:00
										 |  |  | class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_CompileBase { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Compiles code for the speical $smarty variables | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param array $args array with attributes from parser | 
					
						
							|  |  |  |     * @param object $compiler compiler object | 
					
						
							|  |  |  |     * @return string compiled code | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     public function compile($args, $compiler) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $_index = explode(',', str_replace(array('][', '[', ']'), array(',', '', ''), $args)); | 
					
						
							|  |  |  |         $compiled_ref = ' '; | 
					
						
							|  |  |  |         switch (trim($_index[0], "'")) { | 
					
						
							|  |  |  |             case 'foreach': | 
					
						
							|  |  |  |                 return "\$_smarty_tpl->getVariable('smarty')->value$args"; | 
					
						
							|  |  |  |             case 'section': | 
					
						
							|  |  |  |                 return "\$_smarty_tpl->getVariable('smarty')->value$args"; | 
					
						
							|  |  |  |             case 'capture': | 
					
						
							|  |  |  |                 return "\$_smarty_tpl->smarty->_smarty_vars$args"; | 
					
						
							|  |  |  |             case 'now': | 
					
						
							|  |  |  |                 return 'time()'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'get': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_GET"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'post': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_POST"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'cookies': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_COOKIE"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'env': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_ENV"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'server': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_SERVER"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'session': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_SESSION"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'request': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $compiled_ref = "\$_REQUEST"; | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             case 'template': | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 $_template_name = basename($compiler->template->getTemplateFilepath()); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 return "'$_template_name'"; | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 18:51:21 +00:00
										 |  |  |             case 'current_dir': | 
					
						
							|  |  |  |                 $_template_dir_name = dirname($compiler->template->getTemplateFilepath()); | 
					
						
							|  |  |  |                 return "'$_template_dir_name'"; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             case 'version': | 
					
						
							|  |  |  |                 $_version = Smarty::$_version; | 
					
						
							|  |  |  |                 return "'$_version'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'const': | 
					
						
							| 
									
										
										
										
											2009-06-14 11:07:26 +00:00
										 |  |  |                 if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     $compiler->trigger_template_error("(secure mode) constants not permitted"); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |                 return '@' . trim($_index[1], "'"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'config': | 
					
						
							|  |  |  |                 return "\$_smarty_tpl->getConfigVariable($_index[1])"; | 
					
						
							|  |  |  |             case 'block': | 
					
						
							| 
									
										
										
										
											2009-04-10 02:29:46 +00:00
										 |  |  |                 if ($_index[1] == '\'parent\'') { | 
					
						
							|  |  |  |                     return "'" . addcslashes($compiler->template->block_data[trim($_index[2], "'")]['source'], "'") . "'"; | 
					
						
							| 
									
										
										
										
											2009-03-26 21:06:02 +00:00
										 |  |  |                 } else { | 
					
						
							|  |  |  |                     return "''"; | 
					
						
							|  |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             case 'ldelim': | 
					
						
							| 
									
										
										
										
											2009-06-14 11:07:26 +00:00
										 |  |  |                 $_ldelim = $compiler->smarty->left_delimiter; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 return "'$_ldelim'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'rdelim': | 
					
						
							| 
									
										
										
										
											2009-06-14 11:07:26 +00:00
										 |  |  |                 $_rdelim = $compiler->smarty->right_delimiter; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 return "'$_rdelim'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference'); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (isset($_index[1])) { | 
					
						
							| 
									
										
										
										
											2009-06-14 11:07:26 +00:00
										 |  |  |             array_shift($_index); | 
					
						
							|  |  |  |             foreach ($_index as $_ind) { | 
					
						
							|  |  |  |                 $compiled_ref = $compiled_ref . "[$_ind]"; | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-26 21:06:02 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return $compiled_ref; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | ?>
 |