2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**  
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Smarty  Internal  Plugin  Compile  Insert 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Compiles  the  { insert }  tag 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  @ package  Smarty 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  @ subpackage  Compiler 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  @ author  Uwe  Tews  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/**  
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Smarty  Internal  Plugin  Compile  Insert  Class 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								class  Smarty_Internal_Compile_Insert  extends  Smarty_Internal_CompileBase  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    /** 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  Compiles  code  for  the  { insert }  tag 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @ param  array  $args  array  with  attributes  from  parser 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @ param  object  $compiler  compiler  object 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @ return  string  compiled  code 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    public  function  compile ( $args ,  $compiler ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-12 17:20:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $this -> compiler  =  $compiler ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $this -> required_attributes  =  array ( 'name' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> optional_attributes  =  array ( '_any' );  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // check and get attributes
 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-12 17:20:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $_attr  =  $this -> _get_attributes ( $args );  
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // never compile as nocache code
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> compiler -> suppressNocacheProcessing  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $this -> compiler -> tag_nocache  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $_smarty_tpl  =  $compiler -> template ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $_output  =  '<?php ' ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // save posible attributes
 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        eval ( '$_name = '  .  $_attr [ 'name' ]  .  ';' ); 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        if  ( isset ( $_attr [ 'assign' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // output will be stored in a smarty variable instead of beind displayed
 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-12 17:20:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_assign  =  $_attr [ 'assign' ];  
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            // create variable to make shure that the compiler knows about its nocache status
 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-12 17:20:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $this -> compiler -> template -> tpl_vars [ trim ( $_attr [ 'assign' ],  " ' " )]  =  new  Smarty_Variable ( null ,  true ); 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( isset ( $_attr [ 'script' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // script which must be included
 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_function  =  " smarty_insert_ { $_name } " ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-12 17:20:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_smarty_tpl  =  $compiler -> template ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_filepath  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-12 17:20:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            eval ( '$_script = '  .  $_attr [ 'script' ]  .  ';' ); 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! $this -> compiler -> smarty -> security  &&  file_exists ( $_script ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $_filepath  =  $_script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( $this -> compiler -> smarty -> security )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $_dir  =  $this -> compiler -> smarty -> security_policy -> trusted_dir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $_dir  =  $this -> compiler -> smarty -> trusted_dir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! empty ( $_dir ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    foreach (( array ) $_dir  as  $_script_dir )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( strpos ( '/\\' ,  substr ( $_script_dir ,  - 1 ))  ===  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            $_script_dir  .=  DS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( file_exists ( $_script_dir  .  $_script ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            $_filepath  =  $_script_dir  .  $_script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $_filepath  ==  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $this -> compiler -> trigger_template_error ( " { insert} missing script file ' { $_script } ' " ,  $this -> compiler -> lex -> taglineno ); 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // code for script file loading
 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_output  .=  " require_once ' { $_filepath } ' ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            require_once  $_filepath ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! is_callable ( $_function ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $this -> compiler -> trigger_template_error ( "   { insert} function ' { $_function } ' is not callable in script file ' { $_script } ' " ,  $this -> compiler -> lex -> taglineno ); 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_filepath  =  'null' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $_function  =  " insert_ { $_name } " ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // function in PHP script ?
 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! is_callable ( $_function ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // try plugin
 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( ! $_function  =  $this -> compiler -> getPlugin ( $_name ,  'insert' ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $this -> compiler -> trigger_template_error ( " { insert} no function or plugin found for ' { $_name } ' " ,  $this -> compiler -> lex -> taglineno ); 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                }  
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // delete {insert} standard attributes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        unset ( $_attr [ 'name' ],  $_attr [ 'assign' ],  $_attr [ 'script' ]);  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // convert attributes into parameter array string
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $_paramsArray  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach  ( $_attr  as  $_key  =>  $_value )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $_paramsArray []  =  " ' $_key ' =>  $_value " ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  
							 
						 
					
						
							
								
									
										
										
										
											2010-01-11 20:22:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $_params  =  'array('  .  implode ( " ,  " ,  $_paramsArray )  .  ')' ;  
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        // call insert
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( isset ( $_assign ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $_smarty_tpl -> caching )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $_output  .=  " echo Smarty_Internal_Nocache_Insert::compile (' { $_function } ', { $_params } ,  \$ _smarty_tpl, ' { $_filepath } ', { $_assign } );?> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $_output  .=  " \$ _smarty_tpl->assign( { $_assign }  ,  { $_function }  ( { $_params } , \$ _smarty_tpl->smarty, \$ _smarty_tpl), true);?> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $this -> compiler -> has_output  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $_smarty_tpl -> caching )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-07 22:08:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $_output  .=  " echo Smarty_Internal_Nocache_Insert::compile (' { $_function } ', { $_params } ,  \$ _smarty_tpl, ' { $_filepath } ');?> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $_output  .=  " echo  { $_function } ( { $_params } , \$ _smarty_tpl->smarty, \$ _smarty_tpl);?> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  
							 
						 
					
						
							
								
									
										
										
										
											2009-03-22 16:09:05 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $_output ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-05-05 19:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?>