extincting $this out of smarty_core_*-functions

This commit is contained in:
messju
2003-06-30 00:08:28 +00:00
parent 473b7d8ace
commit db4af8295e
4 changed files with 55 additions and 55 deletions

View File

@@ -14,43 +14,43 @@
* @param array Format: null * @param array Format: null
* @param Smarty * @param Smarty
*/ */
function smarty_core_display_debug_console($params, &$this) function smarty_core_display_debug_console($params, &$smarty)
{ {
// we must force compile the debug template in case the environment // we must force compile the debug template in case the environment
// changed between separate applications. // changed between separate applications.
if(empty($this->debug_tpl)) { if(empty($smarty->debug_tpl)) {
// set path to debug template from SMARTY_DIR // set path to debug template from SMARTY_DIR
$this->debug_tpl = SMARTY_DIR . 'debug.tpl'; $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
if($this->security && is_file($this->debug_tpl)) { if($smarty->security && is_file($smarty->debug_tpl)) {
$this->secure_dir[] = $this->debug_tpl; $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
} }
} }
$_ldelim_orig = $this->left_delimiter; $_ldelim_orig = $smarty->left_delimiter;
$_rdelim_orig = $this->right_delimiter; $_rdelim_orig = $smarty->right_delimiter;
$this->left_delimiter = '{'; $smarty->left_delimiter = '{';
$this->right_delimiter = '}'; $smarty->right_delimiter = '}';
$_compile_id_orig = $this->_compile_id; $_compile_id_orig = $smarty->_compile_id;
$this->_compile_id = null; $smarty->_compile_id = null;
$_compile_path = $this->_get_compile_path($this->debug_tpl); $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
if ($this->_compile_resource($this->debug_tpl, $_compile_path)) if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
{ {
ob_start(); ob_start();
include($_compile_path); $smarty->smarty_include($_compile_path);
$_results = ob_get_contents(); $_results = ob_get_contents();
ob_end_clean(); ob_end_clean();
} else { } else {
$_results = ''; $_results = '';
} }
$this->_compile_id = $_compile_id_orig; $smarty->_compile_id = $_compile_id_orig;
$this->left_delimiter = $_ldelim_orig; $smarty->left_delimiter = $_ldelim_orig;
$this->right_delimiter = $_rdelim_orig; $smarty->right_delimiter = $_rdelim_orig;
return $_results; return $_results;
} }

View File

@@ -11,26 +11,26 @@
* @param string $results * @param string $results
* @return string * @return string
*/ */
function smarty_core_process_cached_inserts($params, &$this) function smarty_core_process_cached_inserts($params, &$smarty)
{ {
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis', preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
$params['results'], $match); $params['results'], $match);
list($cached_inserts, $insert_args) = $match; list($cached_inserts, $insert_args) = $match;
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
if ($this->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$debug_start_time = smarty_core_get_microtime($_params, $this); $debug_start_time = smarty_core_get_microtime($_params, $smarty);
} }
$args = unserialize($insert_args[$i]); $args = unserialize($insert_args[$i]);
$name = $args['name']; $name = $args['name'];
if (isset($args['script'])) { if (isset($args['script'])) {
$_params = array('resource_name' => $this->_dequote($args['script'])); $_params = array('resource_name' => $smarty->_dequote($args['script']));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
if(!smarty_core_get_php_resource($_params, $this)) { if(!smarty_core_get_php_resource($_params, $smarty)) {
return false; return false;
} }
$resource_type = $_params['resource_type']; $resource_type = $_params['resource_type'];
@@ -38,23 +38,23 @@ function smarty_core_process_cached_inserts($params, &$this)
if ($resource_type == 'file') { if ($resource_type == 'file') {
include_once($php_resource); $smarty->smarty_include($php_resource, true);
} else { } else {
eval($php_resource); $smarty->smarty_eval($php_resource);
} }
} }
$function_name = $this->_plugins['insert'][$name][0]; $function_name = $smarty->_plugins['insert'][$name][0];
$replace = $function_name($args, $this); $replace = $function_name($args, $smarty);
$params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
if ($this->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$this->_smarty_debug_info[] = array('type' => 'insert', $smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$name, 'filename' => 'insert_'.$name,
'depth' => $this->_inclusion_depth, 'depth' => $smarty->_inclusion_depth,
'exec_time' => smarty_core_get_microtime($_params, $this) - $debug_start_time); 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
} }
} }

View File

@@ -14,13 +14,13 @@
* @return string * @return string
*/ */
function smarty_core_process_compiled_include($params, &$this) function smarty_core_process_compiled_include($params, &$smarty)
{ {
$_return = $params['results']; $_return = $params['results'];
foreach ($this->_cache_serials as $_include_file_path=>$_cache_serial) { foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) {
include_once($_include_file_path); $smarty->smarty_include($_include_file_path, true);
$_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
array(&$this, '_process_compiled_include_callback'), array(&$smarty, '_process_compiled_include_callback'),
$_return); $_return);
} }
return $_return; return $_return;

View File

@@ -11,55 +11,55 @@
* @param array $args * @param array $args
* @return string * @return string
*/ */
function smarty_core_run_insert_handler($params, &$this) function smarty_core_run_insert_handler($params, &$smarty)
{ {
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
if ($this->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
$_debug_start_time = smarty_core_get_microtime($_params, $this); $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
} }
if ($this->caching) { if ($smarty->caching) {
$_arg_string = serialize($params['args']); $_arg_string = serialize($params['args']);
$_name = $params['args']['name']; $_name = $params['args']['name'];
if (!isset($this->_cache_info['insert_tags'][$_name])) { if (!isset($smarty->_cache_info['insert_tags'][$_name])) {
$this->_cache_info['insert_tags'][$_name] = array('insert', $smarty->_cache_info['insert_tags'][$_name] = array('insert',
$_name, $_name,
$this->_plugins['insert'][$_name][1], $smarty->_plugins['insert'][$_name][1],
$this->_plugins['insert'][$_name][2], $smarty->_plugins['insert'][$_name][2],
!empty($params['args']['script']) ? true : false); !empty($params['args']['script']) ? true : false);
} }
return $this->_smarty_md5."{insert_cache $_arg_string}".$this->_smarty_md5; return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
} else { } else {
if (isset($params['args']['script'])) { if (isset($params['args']['script'])) {
$_params = array('resource_name' => $this->_dequote($params['args']['script'])); $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
if(!smarty_core_get_php_resource($_params, $this)) { if(!smarty_core_get_php_resource($_params, $smarty)) {
return false; return false;
} }
if ($_params['resource_type'] == 'file') { if ($_params['resource_type'] == 'file') {
include_once($_params['php_resource']); $smarty->smarty_include_once($_params['php_resource']);
} else { } else {
eval($_params['php_resource']); $smarty->smarty_eval($_params['php_resource']);
} }
unset($params['args']['script']); unset($params['args']['script']);
} }
$_funcname = $this->_plugins['insert'][$params['args']['name']][0]; $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
$_content = $_funcname($params['args'], $this); $_content = $_funcname($params['args'], $smarty);
if ($this->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$this->_smarty_debug_info[] = array('type' => 'insert', $smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$params['args']['name'], 'filename' => 'insert_'.$params['args']['name'],
'depth' => $this->_inclusion_depth, 'depth' => $smarty->_inclusion_depth,
'exec_time' => smarty_core_get_microtime($_params, $this) - $_debug_start_time); 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
} }
if (!empty($params['args']["assign"])) { if (!empty($params['args']["assign"])) {
$this->assign($params['args']["assign"], $_content); $smarty->assign($params['args']["assign"], $_content);
} else { } else {
return $_content; return $_content;
} }