<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
include_once(LAB_PATH_KERNEL."/classes/Smarty/Smarty.class.php");

class Tpl extends Smarty
{
	protected static $instance;
	public function __construct()
	{
		parent::__construct();
	
		$this->setCompileCheck(config::get('core.debug_mode'));
		
		if ((config::get('core.debug_mode')
			|| LabVars::$allow_debug)
			&& isset($_GET["debug"])
		) {
			$this->debugging=true;
			$this->setCompileCheck(true);
			$this->force_cache=true;
		}
		$this->setPluginsDir(
			array(
				LAB_PATH_KERNEL.'/custom_files/smarty_plugins',
				LAB_PATH_KERNEL.'/classes/Smarty/lc_plugins',
				LAB_PATH_KERNEL.'/classes/Smarty/plugins'
			)
		);

		$this->setTemplateDir(null);
		
		$this->compile_dir  = LAB_PATH_DATA.'/template_c/';
		$this->cache_dir    = LAB_PATH_DATA.'/cache/smarty/';
		
		$this->cache_locking    = true;
		$this->cache_modified_check    = true;
		//$this->error_reporting = E_ALL & ~E_NOTICE;
		$this->error_reporting    = (error_reporting() & ~E_NOTICE);
		$this->setCacheLifetime(60*60*24);
		
		if (config::get('core.cache')
			&& config::get('core.use_memcached_tpl')
		) {
			$this->caching_type='memcache';
			$this->cache_modified_check=false;
		}
	}

	public static function i()
	{
		return self::instance();
	}
	
	public static function instance()
	{
		if (self::$instance === null) {
			self::$instance = new self;
		}
		return self::$instance;
	}
	
}