12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace KIF\Core;
- use Smarty;
- include KIF_PATH . "/smarty/Smarty.class.php";
- use KIF\Core\Config;
- class View extends Smarty
- {
-
- static private $auto_registers = array();
- private $tpl_type ;
-
- private $directory;
-
- public function __construct($directory = '')
- {
- $this->left_delimiter = "<{";
- $this->right_delimiter = "}>";
- $this->directory = $directory;
- foreach (self::$auto_registers as $tmpV) {
- $this->register_function($tmpV['smarty_func'], $tmpV['php_func'], $tmpV['cacheable'], $tmpV['cache_attrs']);
- }
- }
-
- static function auto_register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) {
- self::$auto_registers[] = array(
- 'smarty_func' => $function,
- 'php_func' => $function_impl,
- 'cacheable' => $cacheable,
- 'cache_attrs' => $cache_attrs,
- );
- }
-
- public function d($tpl, $cache_id = null, $compile_id = null)
- {
- $this->r($tpl, $cache_id , $compile_id ,true);
- }
-
-
- public function r($tpl, $cache_id = null, $compile_id = null, $display = false)
- {
- $smarty_config = Config::getInstance()->get('smarty');
-
- $this->template_dir = $smarty_config['template_dir'];
- $this->compile_dir = $smarty_config['compile_dir'];
- $this->tpl_type = $smarty_config['tpl_type'] ? $smarty_config['tpl_type'] : 'html';
- $content = $this->fetch($tpl . "." . $this->tpl_type, $cache_id , $compile_id , $display);
- return $content;
- }
- }
|