<?php
/**
 *      [XCECP] (C) COLNET Inc.
 *      This is NOT a freeware, use is subject to license terms
 */
if(!defined("IN_QKWEB")){exit("Access Denied");}
if(!file_exists(ROOT_PATH."plugins/Smarty/Smarty.class.php")){Msg::show('模板引擎载入失败');}
require_once(ROOT_PATH."plugins/Smarty/Smarty.class.php");
class LoadSmarty extends Smarty{
	function LoadSmarty()
	{
		parent::__construct();
		$this->template_dir=ROOT_PATH.'/templates/'.(((isset($GLOBALS['cfg_tmpl']) && $GLOBALS['cfg_tmpl']))?$GLOBALS['cfg_tmpl']:'default').'/';
		$this->compile_dir=ROOT_PATH.'/data/compile/';
		if(!is_writeable($this->compile_dir) && !@chmod($this->compile_dir,0777)){ Msg::show('缓存目录不可写入'); }
		$this->config_dir=ROOT_PATH.'/configs/';
		$this->cache_dir=ROOT_PATH.'/data/cache/';
		$this->addPluginsDir(ROOT_PATH.'/includes/tags/');
		$this->caching = (isset($GLOBALS['caching']) && ($GLOBALS['caching']===false||$GLOBALS['caching']===true))?$GLOBALS['caching']:true;
	}

   	function display($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL)
   {
        $this->fetch($template, $cache_id, $compile_id, null,true);
   }

   function fetch($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
   {
		$html = parent::fetch($template, $cache_id , $compile_id ,null, false);
        if($display) echo $html;
		else return $html;
   }
}
?>