<?php
/**
 * ****************************************************************
 * Project:      *
 * Copyright:    Copyright (c) 2007
 * Company:      Thomas Niemann
 * ****************************************************************
 * Workfile:     SmartyHelper.php
 * ****************************************************************
 * Description:  
 *                
 * ***************************************************************/
class SmartyHelper extends Smarty implements SingletonInterface {
	private static $instance;

	/***************************************************************
	 * create instance of smarty class
	 ***************************************************************/
	public static function getInstance() {
		if (!isset(self::$instance)) {
			self::$instance = new SmartyHelper();			
			self::$instance->template_dir 	= ConfigLoader :: getInstance()->getConfigPath('smarty_template_dir');
			self::$instance->compile_dir  	= ConfigLoader :: getInstance()->getConfigPath('smarty_compile_dir');
		}

		return self::$instance;
	}

	/***************************************************************
	 * assigns all templatesvars in the delivered array
	 * and optionally displays the delivered template file
	 ***************************************************************/
	public function assignArray($_templates, $_templateFile = null) {
		foreach ($_templates as $key => $val)
			if(!$smarty->is_cached($_templateFile)) {echo "222";die;
			   // not cached, so you might do some database queries here,
			   // then assign the returned content. We just use static
			   $this->assign($key, $val);
			}			

		if (isset($_templateFile))
			$this->display($_templateFile);
	}
}
?>