($this->compile_dir));
}
function clear_cached($file = null, $cache_id = null) {
if (!$this->cache)
return;
$this->_destroy_dir($file, $cache_id, $this->_get_dir($this->cache_dir));
}
function is_cached($file, $cache_id = null) {
if (!$this->force_compile && $this->cache && $this->_is_cached($file, $cache_id)) {
return true;
} else {
return false;
}
}
function register_modifier($modifier, $implementation) {
$this->_plugins["modifier"][$modifier] = $implementation;
}
function unregister_modifier($modifier) {
if (isset($this->_plugins["modifier"][$modifier]))
unset($this->_plugins["modifier"][$modifier]);
}
function register_function($function, $implementation) {
$this->_plugins["function"][$function] = $implementation;
}
function unregister_function($function) {
if (isset($this->_plugins["function"][$function]))
unset($this->_plugins["function"][$function]);
}
function register_block($function, $implementation) {
$this->_plugins["block"][$function] = $implementation;
}
function unregister_block($function) {
if (isset($this->_plugins["block"][$function]))
unset($this->_plugins["block"][$function]);
}
function template_exists($file) {
if (file_exists($this->_get_dir($this->template_dir).$file))
return true;
else
return false;
}
function display($file, $cache_id = null) {
$this->fetch($file, $cache_id, true);
}
function fetch($file, $cache_id = null, $display = false) {
$this->_cache_id = $cache_id;
$this->template_dir = $this->_get_dir($this->template_dir);
$this->compile_dir = $this->_get_dir($this->compile_dir);
if ($this->cache)
$this->_cache_dir = $this->_build_dir($this->cache_dir, $this->_cache_id);
$name = md5($this->template_dir.$file).'.php';
// don't display any errors
$this->_error_level = error_reporting(error_reporting() & ~E_NOTICE);
if (!$this->force_compile && $this->cache && $this->_is_cached($file, $cache_id)) {
ob_start();
include($this->_cache_dir.$name);
$output = ob_get_contents();
ob_end_clean();
$output = substr($output, strpos($output, "\n") + 1);
} else {
$output = $this->_fetch_compile($file, $cache_id);
if ($this->cache) {
$f = fopen($this->_cache_dir.$name, "w");
fwrite($f, serialize($this->_cache_info) . "\n$output");
fclose($f);
}
}
if (strpos($output, $this->_sl_md5) !== false) {
preg_match_all('!' . $this->_sl_md5 . '{_run_insert (.*)}' . $this->_sl_md5 . '!U',$output,$_match);
foreach($_match[1] as $value) {
$arguments = unserialize($value);
$output = str_replace($this->_sl_md5 . '{_run_insert ' . $value . '}' . $this->_sl_md5, call_user_func_array('insert_' . $arguments['name'], array((array)$arguments, $this)), $output);
}
}
error_reporting($this->_error_level);
if ($display)
echo $output;
else
return $output;
}
function config_load($file, $section_name = null, $var_name = null) {
$this->template_dir = $this->_get_dir($this->template_dir);
$this->config_dir = $this->_get_dir($this->config_dir);
$this->compile_dir = $this->_get_dir($this->compile_dir);
$name = md5($this->template_dir.$file.$section_name.$var_name).'.php';
if ($this->cache) {
array_push($this->_cache_info['config'], $file);
}
if (!$this->force_compile && file_exists($this->compile_dir.'c_'.$name) && (filemtime($this->compile_dir.'c_'.$name) > filemtime($this->config_dir.$file))) {
include($this->compile_dir.'c_'.$name);
return true;
}
if (!is_object($this->_config_obj)) {
requir