diff --git a/libs/core/core.assemble_auto_filename.php b/libs/core/core.assemble_auto_filename.php index bcaa2b79..9cad8b71 100644 --- a/libs/core/core.assemble_auto_filename.php +++ b/libs/core/core.assemble_auto_filename.php @@ -15,14 +15,14 @@ * @staticvar string|null * @staticvar string|null */ -function smarty_core_assemble_auto_filename($params, &$this) +function smarty_core_assemble_auto_filename($params, &$smarty) { static $_dir_sep = null; static $_dir_sep_enc = null; if(!isset($_dir_sep)) { $_dir_sep_enc = urlencode(DIRECTORY_SEPARATOR); - if($this->use_sub_dirs) { + if($smarty->use_sub_dirs) { $_dir_sep = DIRECTORY_SEPARATOR; } else { $_dir_sep = '^'; @@ -35,7 +35,7 @@ function smarty_core_assemble_auto_filename($params, &$this) // auto_base not found, try include_path $_params = array('file_path' => $params['auto_base']); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); - smarty_core_get_include_path($_params, $this); + smarty_core_get_include_path($_params, $smarty); $_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null; } @@ -49,7 +49,7 @@ function smarty_core_assemble_auto_filename($params, &$this) if(isset($params['auto_source'])) { // make source name safe for filename - if($this->use_sub_dirs) { + if($smarty->use_sub_dirs) { $_filename = urlencode(basename($params['auto_source'])); $_crc32 = crc32($params['auto_source']) . $_dir_sep; // prepend %% to avoid name conflicts with diff --git a/libs/core/core.assemble_plugin_filepath.php b/libs/core/core.assemble_plugin_filepath.php index 26962bcb..f9fae398 100644 --- a/libs/core/core.assemble_plugin_filepath.php +++ b/libs/core/core.assemble_plugin_filepath.php @@ -12,12 +12,12 @@ * @param string $name * @return string|false */ -function smarty_core_assemble_plugin_filepath($params, &$this) +function smarty_core_assemble_plugin_filepath($params, &$smarty) { $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php'; - foreach ((array)$this->plugins_dir as $_plugin_dir) { + foreach ((array)$smarty->plugins_dir as $_plugin_dir) { $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; @@ -44,7 +44,7 @@ function smarty_core_assemble_plugin_filepath($params, &$this) $_params = array('file_path' => $_plugin_filepath); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $this)) { + if(smarty_core_get_include_path($_params, $smarty)) { return $_params['new_file_path']; } } diff --git a/libs/core/core.assign_smarty_interface.php b/libs/core/core.assign_smarty_interface.php index 49123316..be46ed27 100644 --- a/libs/core/core.assign_smarty_interface.php +++ b/libs/core/core.assign_smarty_interface.php @@ -14,9 +14,9 @@ * @param array Format: null * @param Smarty */ -function smarty_core_assign_smarty_interface($params, &$this) +function smarty_core_assign_smarty_interface($params, &$smarty) { - if (isset($this->_smarty_vars) && isset($this->_smarty_vars['request'])) { + if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) { return; } @@ -28,14 +28,14 @@ function smarty_core_assign_smarty_interface($params, &$this) $_smarty_vars_request = array(); - foreach (preg_split('!!', strtolower($this->request_vars_order)) as $_c) { + foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) { if (isset($_globals_map[$_c])) { $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); } } $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); - $this->_smarty_vars['request'] = $_smarty_vars_request; + $smarty->_smarty_vars['request'] = $_smarty_vars_request; } /* vim: set expandtab: */ diff --git a/libs/core/core.create_dir_structure.php b/libs/core/core.create_dir_structure.php index e74af32a..88b0aeab 100644 --- a/libs/core/core.create_dir_structure.php +++ b/libs/core/core.create_dir_structure.php @@ -13,7 +13,7 @@ // $dir -function smarty_core_create_dir_structure($params, &$this) +function smarty_core_create_dir_structure($params, &$smarty) { if (!file_exists($params['dir'])) { $_open_basedir_ini = ini_get('open_basedir'); @@ -65,8 +65,8 @@ function smarty_core_create_dir_structure($params, &$this) $_make_new_dir = true; } - if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $this->_dir_perms)) { - $this->trigger_error("problem creating directory '" . $_new_dir . "'"); + if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms)) { + $smarty->trigger_error("problem creating directory '" . $_new_dir . "'"); return false; } $_new_dir .= '/'; diff --git a/libs/core/core.fetch_resource_info.php b/libs/core/core.fetch_resource_info.php index 9205a3bc..c3a0a059 100644 --- a/libs/core/core.fetch_resource_info.php +++ b/libs/core/core.fetch_resource_info.php @@ -19,7 +19,7 @@ * @return boolean */ -function smarty_core_fetch_resource_info(&$params, &$this) +function smarty_core_fetch_resource_info(&$params, &$smarty) { if(!isset($params['get_source'])) { $params['get_source'] = true; } @@ -28,13 +28,13 @@ function smarty_core_fetch_resource_info(&$params, &$this) $_return = false; $_params = array('resource_name' => $params['resource_name']) ; require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.parse_resource_name.php'); - if (smarty_core_parse_resource_name($_params, $this)) { + if (smarty_core_parse_resource_name($_params, $smarty)) { $_resource_type = $_params['resource_type']; $_resource_name = $_params['resource_name']; switch ($_resource_type) { case 'file': if ($params['get_source']) { - $params['source_content'] = $this->_read_file($_resource_name); + $params['source_content'] = $smarty->_read_file($_resource_name); } $params['resource_timestamp'] = filemtime($_resource_name); $_return = true; @@ -43,16 +43,16 @@ function smarty_core_fetch_resource_info(&$params, &$this) default: // call resource functions to fetch the template source and timestamp if ($params['get_source']) { - $_source_return = isset($this->_plugins['resource'][$_resource_type]) && - call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], - array($_resource_name, &$params['source_content'], &$this)); + $_source_return = isset($smarty->_plugins['resource'][$_resource_type]) && + call_user_func_array($smarty->_plugins['resource'][$_resource_type][0][0], + array($_resource_name, &$params['source_content'], &$smarty)); } else { $_source_return = true; } - $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && - call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], - array($_resource_name, &$params['resource_timestamp'], &$this)); + $_timestamp_return = isset($smarty->_plugins['resource'][$_resource_type]) && + call_user_func_array($smarty->_plugins['resource'][$_resource_type][0][1], + array($_resource_name, &$params['resource_timestamp'], &$smarty)); $_return = $_source_return && $_timestamp_return; break; @@ -61,13 +61,13 @@ function smarty_core_fetch_resource_info(&$params, &$this) if (!$_return) { // see if we can get a template with the default template handler - if (!empty($this->default_template_handler_func)) { - if (!$this->_plugin_implementation_exists($this->default_template_handler_func)) { - $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); + if (!empty($smarty->default_template_handler_func)) { + if (!$smarty->_plugin_implementation_exists($smarty->default_template_handler_func)) { + $smarty->trigger_error("default template handler function \"$smarty->default_template_handler_func\" doesn't exist."); } else { $_return = call_user_func_array( - $this->default_template_handler_func, - array($_resource_type, $_resource_name, &$params['source_content'], &$params['resource_timestamp'], &$this)); + $smarty->default_template_handler_func, + array($_resource_type, $_resource_name, &$params['source_content'], &$params['resource_timestamp'], &$smarty)); } } } @@ -75,11 +75,11 @@ function smarty_core_fetch_resource_info(&$params, &$this) require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php'); if (!$_return) { if (!$params['quiet']) { - $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"'); + $smarty->trigger_error('unable to read resource: "' . $params['resource_name'] . '"'); } - } else if ($_return && $this->security && !smarty_core_is_secure($_params, $this)) { + } else if ($_return && $smarty->security && !smarty_core_is_secure($_params, $smarty)) { if (!$params['quiet']) - $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed'); + $smarty->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed'); $params['source_content'] = null; $params['resource_timestamp'] = null; return false; diff --git a/libs/core/core.get_include_path.php b/libs/core/core.get_include_path.php index 7807f68b..2216d13f 100644 --- a/libs/core/core.get_include_path.php +++ b/libs/core/core.get_include_path.php @@ -16,7 +16,7 @@ // $file_path, &$new_file_path -function smarty_core_get_include_path(&$params, &$this) +function smarty_core_get_include_path(&$params, &$smarty) { static $_path_array = null; diff --git a/libs/core/core.get_microtime.php b/libs/core/core.get_microtime.php index 44a2b46c..c7601c2e 100644 --- a/libs/core/core.get_microtime.php +++ b/libs/core/core.get_microtime.php @@ -9,7 +9,7 @@ * Get seconds and microseconds * @return double */ -function smarty_core_get_microtime($params, &$this) +function smarty_core_get_microtime($params, &$smarty) { $mtime = microtime(); $mtime = explode(" ", $mtime); diff --git a/libs/core/core.get_php_resource.php b/libs/core/core.get_php_resource.php index b256f555..4837644b 100644 --- a/libs/core/core.get_php_resource.php +++ b/libs/core/core.get_php_resource.php @@ -15,12 +15,12 @@ * @return boolean */ -function smarty_core_get_php_resource(&$params, &$this) +function smarty_core_get_php_resource(&$params, &$smarty) { - $params['resource_base_path'] = $this->trusted_dir; + $params['resource_base_path'] = $smarty->trusted_dir; require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.parse_resource_name.php'); - smarty_core_parse_resource_name($params, $this); + smarty_core_parse_resource_name($params, $smarty); /* * Find out if the resource exists. @@ -34,37 +34,37 @@ function smarty_core_get_php_resource(&$params, &$this) // test for file in include_path $_params = array('file_path' => $params['resource_name']); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $this)) { + if(smarty_core_get_include_path($_params, $smarty)) { $_include_path = $_params['new_file_path']; $_readable = true; } } } else if ($params['resource_type'] != 'file') { $_template_source = null; - $_readable = $this->_plugin_implementation_exists($this->_plugins['resource'][$params['resource_type']][0][0]) - && call_user_func_array($this->_plugins['resource'][$params['resource_type']][0][0], - array($params['resource_name'], &$_template_source, &$this)); + $_readable = $smarty->_plugin_implementation_exists($smarty->_plugins['resource'][$params['resource_type']][0][0]) + && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0], + array($params['resource_name'], &$_template_source, &$smarty)); } /* * Set the error function, depending on which class calls us. */ - if (method_exists($this, '_syntax_error')) { + if (method_exists($smarty, '_syntax_error')) { $_error_funcc = '_syntax_error'; } else { $_error_funcc = 'trigger_error'; } if ($_readable) { - if ($this->security) { + if ($smarty->security) { require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php'); - if (!smarty_core_is_trusted($params, $this)) { - $this->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); + if (!smarty_core_is_trusted($params, $smarty)) { + $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); return false; } } } else { - $this->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); + $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); return false; } diff --git a/libs/core/core.is_secure.php b/libs/core/core.is_secure.php index d80121af..5e8803f3 100644 --- a/libs/core/core.is_secure.php +++ b/libs/core/core.is_secure.php @@ -15,16 +15,16 @@ // $resource_type, $resource_name -function smarty_core_is_secure($params, &$this) +function smarty_core_is_secure($params, &$smarty) { - if (!$this->security || $this->security_settings['INCLUDE_ANY']) { + if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) { return true; } $_smarty_secure = false; if ($params['resource_type'] == 'file') { - if (!empty($this->secure_dir)) { - foreach ((array)$this->secure_dir as $curr_dir) { + if (!empty($smarty->secure_dir)) { + foreach ((array)$smarty->secure_dir as $curr_dir) { if ( !empty($curr_dir) && is_readable ($curr_dir)) { if (substr(realpath($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $_smarty_secure = true; @@ -36,8 +36,8 @@ function smarty_core_is_secure($params, &$this) } else { // resource is not on local file system $_smarty_secure = call_user_func_array( - $this->_plugins['resource'][$params['resource_type']][0][2], - array($params['resource_name'], &$_smarty_secure, &$this)); + $smarty->_plugins['resource'][$params['resource_type']][0][2], + array($params['resource_name'], &$_smarty_secure, &$smarty)); } return $_smarty_secure; diff --git a/libs/core/core.is_trusted.php b/libs/core/core.is_trusted.php index 0e0461a0..922619b4 100644 --- a/libs/core/core.is_trusted.php +++ b/libs/core/core.is_trusted.php @@ -18,16 +18,16 @@ // $resource_type, $resource_name -function smarty_core_is_trusted($params, &$this) +function smarty_core_is_trusted($params, &$smarty) { $_smarty_trusted = false; if ($params['resource_type'] == 'file') { - if (!empty($this->trusted_dir)) { + if (!empty($smarty->trusted_dir)) { // see if template file is within a trusted directory. If so, // disable security during the execution of the template. - if (!empty($this->trusted_dir)) { - foreach ((array)$this->trusted_dir as $curr_dir) { + if (!empty($smarty->trusted_dir)) { + foreach ((array)$smarty->trusted_dir as $curr_dir) { if (!empty($curr_dir) && is_readable ($curr_dir)) { if (substr(realpath($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $_smarty_trusted = true; @@ -39,8 +39,8 @@ function smarty_core_is_trusted($params, &$this) } } else { // resource is not on local file system - $_smarty_trusted = call_user_func_array($this->_plugins['resource'][$params['resource_type']][0][3], - array($params['resource_name'], $this)); + $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], + array($params['resource_name'], $smarty)); } return $_smarty_trusted; diff --git a/libs/core/core.load_plugins.php b/libs/core/core.load_plugins.php index c5ba61a2..6e2a8253 100644 --- a/libs/core/core.load_plugins.php +++ b/libs/core/core.load_plugins.php @@ -13,12 +13,12 @@ // $plugins -function smarty_core_load_plugins($params, &$this) +function smarty_core_load_plugins($params, &$smarty) { foreach ($params['plugins'] as $_plugin_info) { list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info; - $_plugin = &$this->_plugins[$_type][$_name]; + $_plugin = &$smarty->_plugins[$_type][$_name]; /* * We do not load plugin more than once for each instance of Smarty. @@ -32,8 +32,8 @@ function smarty_core_load_plugins($params, &$this) */ if (isset($_plugin)) { if (empty($_plugin[3])) { - if (!$this->_plugin_implementation_exists($_plugin[0])) { - $this->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__); + if (!$smarty->_plugin_implementation_exists($_plugin[0])) { + $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__); } else { $_plugin[1] = $_tpl_file; $_plugin[2] = $_tpl_line; @@ -54,7 +54,7 @@ function smarty_core_load_plugins($params, &$this) } } - $_plugin_file = $this->_get_plugin_filepath($_type, $_name); + $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name); if (! $_found = ($_plugin_file != false)) { $_message = "could not load plugin file '$_type.$_name.php'\n"; @@ -69,8 +69,8 @@ function smarty_core_load_plugins($params, &$this) include_once $_plugin_file; $_plugin_func = 'smarty_' . $_type . '_' . $_name; - if (!$this->_plugin_implementation_exists($_plugin_func)) { - $this->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); + if (!$smarty->_plugin_implementation_exists($_plugin_func)) { + $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); continue; } } @@ -93,7 +93,7 @@ function smarty_core_load_plugins($params, &$this) * directly, we only allow those specified in the security * context. */ - if ($this->security && !in_array($_name, $this->security_settings['MODIFIER_FUNCS'])) { + if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) { $_message = "(secure mode) modifier '$_name' is not allowed"; } else { if (!function_exists($_name)) { @@ -112,10 +112,10 @@ function smarty_core_load_plugins($params, &$this) } if ($_found) { - $this->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true); + $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true); } else { // output error - $this->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); + $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); } } } diff --git a/libs/core/core.load_resource_plugin.php b/libs/core/core.load_resource_plugin.php index 0b3b06e6..4f1b57f8 100644 --- a/libs/core/core.load_resource_plugin.php +++ b/libs/core/core.load_resource_plugin.php @@ -13,7 +13,7 @@ // $type -function smarty_core_load_resource_plugin($params, &$this) +function smarty_core_load_resource_plugin($params, &$smarty) { /* * Resource plugins are not quite like the other ones, so they are @@ -22,12 +22,12 @@ function smarty_core_load_resource_plugin($params, &$this) * all of them exist or not. */ - $_plugin = &$this->_plugins['resource'][$params['type']]; + $_plugin = &$smarty->_plugins['resource'][$params['type']]; if (isset($_plugin)) { if (!$_plugin[1] && count($_plugin[0])) { $_plugin[1] = true; foreach ($_plugin[0] as $_plugin_func) { - if (!$this->_plugin_implementation_exists($_plugin_func)) { + if (!$smarty->_plugin_implementation_exists($_plugin_func)) { $_plugin[1] = false; break; } @@ -35,20 +35,20 @@ function smarty_core_load_resource_plugin($params, &$this) } if (!$_plugin[1]) { - $this->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); + $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); } return; } - $_plugin_file = $this->_get_plugin_filepath('resource', $params['type']); + $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']); $_found = ($_plugin_file != false); if ($_found) { /* * If the plugin file is found, it -must- provide the properly named * plugin functions. */ - include_once $_plugin_file; + $smarty->smarty_include_once($_plugin_file); /* * Locate functions that we require the plugin to provide. @@ -58,14 +58,14 @@ function smarty_core_load_resource_plugin($params, &$this) foreach ($_resource_ops as $_op) { $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op; if (!function_exists($_plugin_func)) { - $this->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); + $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); return; } else { $_resource_funcs[] = $_plugin_func; } } - $this->_plugins['resource'][$params['type']] = array($_resource_funcs, true); + $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true); } } diff --git a/libs/core/core.parse_resource_name.php b/libs/core/core.parse_resource_name.php index 8830c897..ef09373f 100644 --- a/libs/core/core.parse_resource_name.php +++ b/libs/core/core.parse_resource_name.php @@ -17,7 +17,7 @@ // $resource_base_path, $resource_name, &$resource_type, &$resource_name -function smarty_core_parse_resource_name(&$params, &$this) +function smarty_core_parse_resource_name(&$params, &$smarty) { // split tpl_path by the first colon @@ -25,12 +25,12 @@ function smarty_core_parse_resource_name(&$params, &$this) if (count($_resource_name_parts) == 1) { // no resource type given - $params['resource_type'] = $this->default_resource_type; + $params['resource_type'] = $smarty->default_resource_type; $params['resource_name'] = $_resource_name_parts[0]; } else { if(strlen($_resource_name_parts[0]) == 1) { // 1 char is not resource type, but part of filepath - $params['resource_type'] = $this->default_resource_type; + $params['resource_type'] = $smarty->default_resource_type; $params['resource_name'] = $params['resource_name']; } else { $params['resource_type'] = $_resource_name_parts[0]; @@ -42,7 +42,7 @@ function smarty_core_parse_resource_name(&$params, &$this) if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { // relative pathname to $params['resource_base_path'] // use the first directory where the file is found - $_resource_base_path = isset($params['resource_base_path']) ? $params['resource_base_path'] : array($this->template_dir, '.'); + $_resource_base_path = isset($params['resource_base_path']) ? $params['resource_base_path'] : array($smarty->template_dir, '.'); settype($_resource_base_path, 'array'); foreach ($_resource_base_path as $_curr_path) { $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; @@ -51,10 +51,10 @@ function smarty_core_parse_resource_name(&$params, &$this) return true; } // didn't find the file, try include_path - $_params = array('resource_name' => $_fullpath); + $_params = array('file_path' => $_fullpath); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $this)) { - $params['resource_name'] = $_params['new_resource_name']; + if(smarty_core_get_include_path($_params, $smarty)) { + $params['resource_name'] = $_params['new_file_path']; return true; } } @@ -63,7 +63,7 @@ function smarty_core_parse_resource_name(&$params, &$this) } else { $_params = array('type' => $params['resource_type']); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_resource_plugin.php'); - smarty_core_load_resource_plugin($_params, $this); + smarty_core_load_resource_plugin($_params, $smarty); } return true; diff --git a/libs/core/core.read_cache_file.php b/libs/core/core.read_cache_file.php index 695e8643..0f2e46ac 100644 --- a/libs/core/core.read_cache_file.php +++ b/libs/core/core.read_cache_file.php @@ -18,29 +18,29 @@ // $tpl_file, $cache_id, $compile_id, &$results -function smarty_core_read_cache_file(&$params, &$this) +function smarty_core_read_cache_file(&$params, &$smarty) { static $content_cache = array(); - if ($this->force_compile) { + if ($smarty->force_compile) { // force compile enabled, always regenerate return false; } if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) { - list($params['results'], $this->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; + list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; return true; } - if (!empty($this->cache_handler_func)) { + if (!empty($smarty->cache_handler_func)) { // use cache_handler function - call_user_func_array($this->cache_handler_func, - array('read', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); + call_user_func_array($smarty->cache_handler_func, + array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file - $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); - $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); - $params['results'] = $this->_read_file($_cache_file); + $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); + $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); + $params['results'] = $smarty->_read_file($_cache_file); } if (empty($params['results'])) { @@ -51,39 +51,39 @@ function smarty_core_read_cache_file(&$params, &$this) $cache_split = explode("\n", $params['results'], 2); $cache_header = $cache_split[0]; - $this->_cache_info = unserialize($cache_header); + $smarty->_cache_info = unserialize($cache_header); - if ($this->caching == 2 && isset ($this->_cache_info['expires'])){ + if ($smarty->caching == 2 && isset ($smarty->_cache_info['expires'])){ // caching by expiration time - if ($this->_cache_info['expires'] > -1 && (time() > $this->_cache_info['expires'])) { + if ($smarty->_cache_info['expires'] > -1 && (time() > $smarty->_cache_info['expires'])) { // cache expired, regenerate return false; } } else { // caching by lifetime - if ($this->cache_lifetime > -1 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) { + if ($smarty->cache_lifetime > -1 && (time() - $smarty->_cache_info['timestamp'] > $smarty->cache_lifetime)) { // cache expired, regenerate return false; } } - if ($this->compile_check) { + if ($smarty->compile_check) { require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.fetch_resource_info.php'); - foreach (array_keys($this->_cache_info['template']) as $_template_dep) { + foreach (array_keys($smarty->_cache_info['template']) as $_template_dep) { $_params = array('resource_name' => $_template_dep); - smarty_core_fetch_resource_info($_params, $this); - if ($this->_cache_info['timestamp'] < $_params['resource_timestamp']) { + smarty_core_fetch_resource_info($_params, $smarty); + if ($smarty->_cache_info['timestamp'] < $_params['resource_timestamp']) { // template file has changed, regenerate cache return false; } } - if (isset($this->_cache_info['config'])) { + if (isset($smarty->_cache_info['config'])) { require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.fetch_resource_info.php'); - foreach (array_keys($this->_cache_info['config']) as $_config_dep) { + foreach (array_keys($smarty->_cache_info['config']) as $_config_dep) { $_params = array('resource_name' => $_config_dep); - smarty_core_fetch_resource_info($_params, $this); - if ($this->_cache_info['timestamp'] < $_params['resource_timestamp']) { + smarty_core_fetch_resource_info($_params, $smarty); + if ($smarty->_cache_info['timestamp'] < $_params['resource_timestamp']) { // config file has changed, regenerate cache return false; } @@ -91,11 +91,11 @@ function smarty_core_read_cache_file(&$params, &$this) } } - $this->_cache_serials = array_merge($this->_cache_serials, - $this->_cache_info['cache_serials']); + $smarty->_cache_serials = array_merge($smarty->_cache_serials, + $smarty->_cache_info['cache_serials']); $params['results'] = $cache_split[1]; - $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $this->_cache_info); + $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $smarty->_cache_info); return true; } diff --git a/libs/core/core.rm_auto.php b/libs/core/core.rm_auto.php index f4fdd6bd..61ea8734 100644 --- a/libs/core/core.rm_auto.php +++ b/libs/core/core.rm_auto.php @@ -17,7 +17,7 @@ // $auto_base, $auto_source = null, $auto_id = null, $exp_time = null -function smarty_core_rm_auto($params, &$this) +function smarty_core_rm_auto($params, &$smarty) { if (!@is_dir($params['auto_base'])) return false; @@ -29,20 +29,20 @@ function smarty_core_rm_auto($params, &$this) 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); - $_res = smarty_core_rmdir($_params, $this); + $_res = smarty_core_rmdir($_params, $smarty); } else { - $_tname = $this->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); + $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); if(isset($params['auto_source'])) { - $_res = $this->_unlink($_tname); - } elseif ($this->use_sub_dirs) { + $_res = $smarty->_unlink($_tname); + } elseif ($smarty->use_sub_dirs) { $_params = array( 'dirname' => $_tname, 'level' => 1, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); - $_res = smarty_core_rmdir($_params, $this); + $_res = smarty_core_rmdir($_params, $smarty); } else { // remove matching file names $_handle = opendir($params['auto_base']); @@ -51,7 +51,7 @@ function smarty_core_rm_auto($params, &$this) if($_filename == '.' || $_filename == '..') { continue; } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { - $_res &= (bool)$this->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); + $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); } } } diff --git a/libs/core/core.rmdir.php b/libs/core/core.rmdir.php index 468b0e69..7169a3b9 100644 --- a/libs/core/core.rmdir.php +++ b/libs/core/core.rmdir.php @@ -17,7 +17,7 @@ // $dirname, $level = 1, $exp_time = null -function smarty_core_rmdir($params, &$this) +function smarty_core_rmdir($params, &$smarty) { if(!isset($params['level'])) { $params['level'] = 1; } if(!isset($params['exp_time'])) { $params['exp_time'] = null; } @@ -33,10 +33,10 @@ function smarty_core_rmdir($params, &$this) 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); - smarty_core_rmdir($_params, $this); + smarty_core_rmdir($_params, $smarty); } else { - $this->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); + $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); } } } diff --git a/libs/core/core.write_cache_file.php b/libs/core/core.write_cache_file.php index ef7cb1d0..75d808ee 100644 --- a/libs/core/core.write_cache_file.php +++ b/libs/core/core.write_cache_file.php @@ -18,17 +18,17 @@ // $tpl_file, $cache_id, $compile_id, $results -function smarty_core_write_cache_file($params, &$this) +function smarty_core_write_cache_file($params, &$smarty) { // put timestamp in cache header - $this->_cache_info['timestamp'] = time(); - if ($this->cache_lifetime > -1){ + $smarty->_cache_info['timestamp'] = time(); + if ($smarty->cache_lifetime > -1){ // expiration set - $this->_cache_info['expires'] = $this->_cache_info['timestamp'] + $this->cache_lifetime; + $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime; } else { // cache will never expire - $this->_cache_info['expires'] = -1; + $smarty->_cache_info['expires'] = -1; } // collapse {nocache...}-tags @@ -37,33 +37,33 @@ function smarty_core_write_cache_file($params, &$this) .'{/nocache\:\\3#\\4\})!Us' ,'\\2' ,$params['results']); - $this->_cache_info['cache_serials'] = $this->_cache_serials; + $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; // prepend the cache header info into cache file - $params['results'] = serialize($this->_cache_info)."\n".$params['results']; + $params['results'] = serialize($smarty->_cache_info)."\n".$params['results']; - if (!empty($this->cache_handler_func)) { + if (!empty($smarty->cache_handler_func)) { // use cache_handler function - call_user_func_array($this->cache_handler_func, - array('write', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); + call_user_func_array($smarty->cache_handler_func, + array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file - if(!@is_writable($this->cache_dir)) { + if(!@is_writable($smarty->cache_dir)) { // cache_dir not writable, see if it exists - if(!@is_dir($this->cache_dir)) { - $this->trigger_error('the $cache_dir \'' . $this->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + if(!@is_dir($smarty->cache_dir)) { + $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } - $this->trigger_error('unable to write to $cache_dir \'' . realpath($this->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); + $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); return false; } - $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); - $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); + $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); + $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); - smarty_core_write_file($_params, $this); + smarty_core_write_file($_params, $smarty); return true; } } diff --git a/libs/core/core.write_cache_paths_file.php b/libs/core/core.write_cache_paths_file.php index d01850bb..0aa82011 100644 --- a/libs/core/core.write_cache_paths_file.php +++ b/libs/core/core.write_cache_paths_file.php @@ -12,22 +12,22 @@ * @return boolean */ -function smarty_core_write_cache_paths_file($params, &$this) +function smarty_core_write_cache_paths_file($params, &$smarty) { // see if there is an pruning to do - foreach($this->_cache_paths_max as $_max_key => $_max_val) { - if(isset($this->_cache_paths[$_max_key]) - && count($this->_cache_paths[$_max_key]) > $_max_val) { + foreach($smarty->_cache_paths_max as $_max_key => $_max_val) { + if(isset($smarty->_cache_paths[$_max_key]) + && count($smarty->_cache_paths[$_max_key]) > $_max_val) { // remove the oldest (first) value - array_unshift($this->_cache_paths[$_max_key]); + array_unshift($smarty->_cache_paths[$_max_key]); } } - $_compiled_content = function_exists('var_export') ? var_export($this->_cache_paths, true) : "unserialize('" . serialize($this->_cache_paths) . "')"; - $_compiled_content = '_cache_paths = ' . $_compiled_content . '; ?>'; - $_params = array('compile_path' => $this->_cache_paths_file, 'compiled_content' => $_compiled_content, 'resource_timestamp' => time()); + $_compiled_content = function_exists('var_export') ? var_export($smarty->_cache_paths, true) : "unserialize('" . serialize($smarty->_cache_paths) . "')"; + $_compiled_content = '_cache_paths = ' . $_compiled_content . '; ?>'; + $_params = array('compile_path' => $smarty->_cache_paths_file, 'compiled_content' => $_compiled_content, 'resource_timestamp' => time()); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php'); - smarty_core_write_compiled_resource($_params, $this); + smarty_core_write_compiled_resource($_params, $smarty); return $_return; } diff --git a/libs/core/core.write_compiled_include.php b/libs/core/core.write_compiled_include.php index a38f9699..5b8dc2ea 100644 --- a/libs/core/core.write_compiled_include.php +++ b/libs/core/core.write_compiled_include.php @@ -14,10 +14,10 @@ * @return boolean */ -function smarty_core_write_compiled_include($params, &$this) +function smarty_core_write_compiled_include($params, &$smarty) { - $_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}'; - $_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}'; + $_tag_start = 'if \(\$smarty->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}'; + $_tag_end = 'if \(\$smarty->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}'; preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', $params['compiled_content'], $_match_source, PREG_SET_ORDER); @@ -30,15 +30,15 @@ function smarty_core_write_compiled_include($params, &$this) $_compile_path = $params['include_file_path']; - $this->_cache_serials[$_compile_path] = $this->_cache_serial; - $_include_compiled .= "\$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."';\n\n?>"; + $smarty->_cache_serials[$_compile_path] = $smarty->_cache_serial; + $_include_compiled .= "\$smarty->_cache_serials['".$smarty->_cache_include."'] = '".$smarty->_cache_serial."';\n\n?>"; $_include_compiled .= $params['plugins_code']; $_include_compiled .= " $_include_compiled, 'create_dirs' => true); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); - smarty_core_write_file($_params, $this); + smarty_core_write_file($_params, $smarty); return true; } diff --git a/libs/core/core.write_compiled_resource.php b/libs/core/core.write_compiled_resource.php index d2c014b2..9867d0c2 100644 --- a/libs/core/core.write_compiled_resource.php +++ b/libs/core/core.write_compiled_resource.php @@ -13,21 +13,21 @@ * @param integer $resource_timestamp * @return true */ -function smarty_core_write_compiled_resource($params, &$this) +function smarty_core_write_compiled_resource($params, &$smarty) { - if(!@is_writable($this->compile_dir)) { + if(!@is_writable($smarty->compile_dir)) { // compile_dir not writable, see if it exists - if(!@is_dir($this->compile_dir)) { - $this->trigger_error('the $compile_dir \'' . $this->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + if(!@is_dir($smarty->compile_dir)) { + $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } - $this->trigger_error('unable to write to $compile_dir \'' . realpath($this->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); + $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); return false; } $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); - smarty_core_write_file($_params, $this); + smarty_core_write_file($_params, $smarty); touch($params['compile_path'], $params['resource_timestamp']); return true; } diff --git a/libs/core/core.write_file.php b/libs/core/core.write_file.php index 83e0e8d4..5ab3502c 100644 --- a/libs/core/core.write_file.php +++ b/libs/core/core.write_file.php @@ -13,14 +13,14 @@ * @param boolean $create_dirs * @return boolean */ -function smarty_core_write_file($params, &$this) +function smarty_core_write_file($params, &$smarty) { $_dirname = dirname($params['filename']); if ($params['create_dirs']) { $_params = array('dir' => $_dirname); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.create_dir_structure.php'); - smarty_core_create_dir_structure($_params, $this); + smarty_core_create_dir_structure($_params, $smarty); } // write to tmp file, then rename it to avoid @@ -28,7 +28,7 @@ function smarty_core_write_file($params, &$this) $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid(''); if (!($fd = @fopen($_tmp_file, 'w'))) { - $this->trigger_error("problem writing temporary file '$_tmp_file'"); + $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); return false; } @@ -38,7 +38,7 @@ function smarty_core_write_file($params, &$this) @unlink($params['filename']); } @rename($_tmp_file, $params['filename']); - chmod($params['filename'], $this->_file_perms); + chmod($params['filename'], $smarty->_file_perms); return true; } diff --git a/libs/plugins/modifier.date_format.php b/libs/plugins/modifier.date_format.php index 5fe9847d..dbe26a55 100644 --- a/libs/plugins/modifier.date_format.php +++ b/libs/plugins/modifier.date_format.php @@ -8,7 +8,7 @@ /** * Include the {@link shared.make_timestamp.php} plugin */ -require_once $this->_get_plugin_filepath('shared','make_timestamp'); +require_once $smarty->_get_plugin_filepath('shared','make_timestamp'); /** * Smarty date_format modifier plugin *