<?php
namespace boru\boruai\Tools;

if(!class_exists("Smarty")) {
    require_once(__DIR__."/../../lib/smarty-3.1.48/libs/Smarty.class.php");
}

class Smarty extends \Smarty
{
    private static $instance = null;
    public function __construct($templateDir=null)
    {
        parent::__construct();
        $this->setTemplateDir($templateDir ? $templateDir : __DIR__ . "/../../tmp/smarty/templates/");
        $this->setCompileDir(__DIR__ . "/../../tmp/smarty/compiled/");
        $this->setCacheDir(__DIR__ . "/../../tmp/smarty/cache/");
        $this->setConfigDir(__DIR__ . "/../../tmp/smarty/config/");
        //$this->caching = false;
        //$this->force_compile = true;
    }

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