| 
									
										
										
										
											2003-05-08 20:21:16 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty plugin | 
					
						
							|  |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage plugins | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Replace cached inserts with the actual results | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @param string $results | 
					
						
							|  |  |  |  * @return string | 
					
						
							|  |  |  |  */     | 
					
						
							|  |  |  | function smarty_core_process_cached_inserts($params, &$this) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis', | 
					
						
							|  |  |  |                    $params['results'], $match); | 
					
						
							|  |  |  |     list($cached_inserts, $insert_args) = $match; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { | 
					
						
							|  |  |  |         if ($this->debugging) { | 
					
						
							|  |  |  | 			$_params = array(); | 
					
						
							| 
									
										
										
										
											2003-06-21 17:35:15 +00:00
										 |  |  | 			require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); | 
					
						
							| 
									
										
										
										
											2003-06-16 15:18:38 +00:00
										 |  |  |             $debug_start_time = smarty_core_get_microtime($_params, $this); | 
					
						
							| 
									
										
										
										
											2003-05-08 20:21:16 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $args = unserialize($insert_args[$i]); | 
					
						
							|  |  |  |         $name = $args['name']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (isset($args['script'])) { | 
					
						
							| 
									
										
										
										
											2003-06-20 20:01:10 +00:00
										 |  |  | 			$_params = array('resource_name' => $this->_dequote($args['script'])); | 
					
						
							| 
									
										
										
										
											2003-06-21 17:35:15 +00:00
										 |  |  | 			require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); | 
					
						
							| 
									
										
										
										
											2003-06-16 15:18:38 +00:00
										 |  |  | 			if(!smarty_core_get_php_resource($_params, $this)) { | 
					
						
							| 
									
										
										
										
											2003-05-08 20:21:16 +00:00
										 |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			$resource_type = $_params['resource_type']; | 
					
						
							|  |  |  | 			$php_resource = $_params['php_resource']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ($resource_type == 'file') { | 
					
						
							|  |  |  |                 include_once($php_resource); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 eval($php_resource); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $function_name = $this->_plugins['insert'][$name][0]; | 
					
						
							|  |  |  |         $replace = $function_name($args, $this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); | 
					
						
							|  |  |  |         if ($this->debugging) { | 
					
						
							|  |  |  | 			$_params = array(); | 
					
						
							| 
									
										
										
										
											2003-06-21 17:35:15 +00:00
										 |  |  | 			require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); | 
					
						
							| 
									
										
										
										
											2003-05-08 20:21:16 +00:00
										 |  |  |             $this->_smarty_debug_info[] = array('type'      => 'insert', | 
					
						
							|  |  |  |                                                 'filename'  => 'insert_'.$name, | 
					
						
							|  |  |  |                                                 'depth'     => $this->_inclusion_depth, | 
					
						
							| 
									
										
										
										
											2003-06-16 15:18:38 +00:00
										 |  |  |                                                 'exec_time' => smarty_core_get_microtime($_params, $this) - $debug_start_time); | 
					
						
							| 
									
										
										
										
											2003-05-08 20:21:16 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return $params['results']; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* vim: set expandtab: */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |