22 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
26 define('
SMARTY_DIR', XOOPS_ROOT_PATH . '/class/smarty/');
27 require_once SMARTY_DIR . '
Smarty.class.php';
43 $this->left_delimiter =
'<{';
44 $this->right_delimiter =
'}>';
46 $this->cache_dir = XOOPS_VAR_PATH .
'/caches/smarty_cache';
47 $this->compile_dir = XOOPS_VAR_PATH .
'/caches/smarty_compile';
48 $this->compile_check = ($xoopsConfig[
'theme_fromfile'] == 1);
49 $this->plugins_dir = array(
50 XOOPS_ROOT_PATH .
'/class/smarty/xoops_plugins' ,
51 XOOPS_ROOT_PATH .
'/class/smarty/plugins');
52 if ($xoopsConfig[
'debug_mode']) {
53 $this->debugging_ctrl =
'URL';
54 if ($xoopsConfig[
'debug_mode'] == 3) {
55 $this->debugging =
true;
59 $this->setCompileId();
61 'xoops_url' => XOOPS_URL ,
62 'xoops_rootpath' => XOOPS_ROOT_PATH ,
76 function fetchFromData($tplSource, $display =
false,
$vars = null)
78 if (!function_exists(
'smarty_function_eval')) {
79 require_once SMARTY_DIR .
'/plugins/function.eval.php';
82 $oldVars = $this->_tpl_vars;
85 'var' => $tplSource), $this);
86 $this->_tpl_vars = $oldVars;
90 'var' => $tplSource), $this);
99 function touch($resourceName)
101 $isForced = $this->force_compile;
102 $this->force_compile =
true;
103 $this->clear_cache($resourceName);
104 $result = $this->_compile_resource($resourceName, $this->_get_compile_path($resourceName));
105 $this->force_compile = $isForced;
116 function _get_auto_id($cache_id = null, $compile_id = null)
118 if (isset($cache_id)) {
119 return (isset($compile_id)) ? $compile_id .
'-' . $cache_id : $cache_id;
120 }
else if (isset($compile_id)) {
135 function setCompileId($module_dirname = null, $theme_set = null, $template_set = null)
139 $template_set = empty($template_set) ? $xoopsConfig[
'template_set'] : $template_set;
140 $theme_set = empty($theme_set) ? $xoopsConfig[
'theme_set'] : $theme_set;
141 $module_dirname = empty($module_dirname) ? (empty(
$GLOBALS[
'xoopsModule']) ?
'system' :
$GLOBALS[
'xoopsModule']->getVar(
'dirname',
'n')) : $module_dirname;
142 $this->compile_id = substr(md5(XOOPS_URL), 0, 8) .
'-' . $module_dirname .
'-' . $theme_set .
'-' . $template_set;
143 $this->_compile_id = $this->compile_id;
154 function clearCache($module_dirname = null, $theme_set = null, $template_set = null)
156 $compile_id = $this->compile_id;
157 $this->setCompileId($module_dirname, $template_set, $theme_set);
159 'auto_base' => $this->cache_dir ,
160 'auto_source' => null ,
161 'auto_id' => $this->compile_id,
164 $this->_compile_id = $this->compile_id = $compile_id;
165 require_once SMARTY_CORE_DIR .
'core.rm_auto.php';
175 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_setTemplateDir($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->template_dir=$value;\' instead.');
179 function xoops_getTemplateDir()
181 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_getTemplateDir()\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->template_dir;\' instead.');
183 return $this->template_dir;
185 function xoops_setDebugging($flag =
false)
187 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_setDebugging($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->debugging=$value;\' instead.');
189 $this->debugging = is_bool($flag) ? $flag :
false;
191 function xoops_setCaching(
$num = 0)
193 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_setCaching($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->caching=$value;\' instead.');
199 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_setCompileDir($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->compile_dir=$value;\' instead.');
205 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_setCacheDir($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->cache_dir=$value;\' instead.');
209 function xoops_canUpdateFromFile()
211 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_canUpdateFromFile()\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->compile_check;\' instead.');
213 return $this->compile_check;
215 function xoops_fetchFromData($data)
217 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_fetchFromData($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->fetchFromData($value);\' instead.');
219 return $this->fetchFromData($data);
221 function xoops_setCacheTime(
$num = 0)
223 $GLOBALS[
'xoopsLogger']->addDeprecated(
'\'$xoopsTpl->xoops_setCacheTime($value)\
' is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->cache_lifetime=$value;\' instead.');
243 $tplfile =& $tplfile_handler->get($tpl_id);
245 if (is_object($tplfile)) {
246 $file = $tplfile->getVar(
'tpl_file',
'n');
262 $count = count($block_arr);
266 for (
$i = 0;
$i < $count;
$i++) {
267 if ($block_arr[
$i]->getVar(
'template') !=
'') {
268 $xoopsTpl->clear_cache(
'db:' . $block_arr[
$i]->getVar(
'template'),
'blk_' . $block_arr[
$i]->getVar(
'bid'));