1:<?php 2: 3:include_once("Smarty-2.6.2/libs/Smarty.class.php"); 4:/** 5: * clase Theme, permite usar algunas de las funciones de smarty de manera 6: * más amistosa :P 7: * @date: 20-mar-2004 8: * @author Isaías Enrique González Romero <gonzalez.i@interplanet.com.mx> 9: */ 10: 11:class Theme{ 12: var $_smarty; 13: var $_template; 14: 15: /** 16: * @param string directorio que contiene al tema 17: * @param bool cachear 18: * @param int tiempo de vida del cache 19: */ 20: function Theme($dir, $cache = true, $cacheLife = 43200){ 21: $this->_smarty = new Smarty(); 22: $this->_smarty ->caching = $cache; 23: $this->_smarty ->cache_lifetime = $cacheLife; 24: $this->_smarty->use_sub_dirs = true; 25: $this->_smarty ->compile_check = true; 26: $this->_smarty ->template_dir = "templates/".$dir."/"; 27: $this->_smarty ->compile_dir = "templates_c/"; 28: $this->_smarty ->config_dir = "language/".LANG."/"; 29: $this->_smarty ->cache_dir = "cache/"; 30: 31: $this->_smarty ->register_block('dynamic', array($this, 'smarty_block_dynamic'), false); 32: } 33: 34: /** 35: * establece el template 36: * @param string nombre del template sin extensión 37: */ 38: function setTemplate($template){ 39: $this->_template = $template.".html"; 40: if($this->_smarty ->template_exists($this->_template)!=true){ 41: die('no existe el template: <b>'. $this->_template.'</b> del idioma: <b>'.LANG.'</b>'); 42: } 43: } 44: 45: /** 46: * obtiene el contenido de un template 47: * @param int id de lo que se cacheará 48: * @return string 49: */ 50: function fetch($id = 'void'){ 51: return $this->_smarty ->fetch($this->_template,$id.THEME.LANG, THEME); 52: } 53: 54: /** 55: * obtiene y despliega en pantalla el contenido de un template 56: * @param int id de lo que se cacheará 57: */ 58: function display($id = 'void'){ 59: $this->_smarty ->display($this->_template,$id.THEME.LANG, THEME); 60: } 61: 62: /** 63: * verifica si lo que tiene el id está chacheado 64: * @param int id de lo que se verifica que este en cache 65: */ 66: function isCached($id){ 67: return $this->_smarty->is_cached($this->_template, $id.LANG, THEME); 68: } 69: 70: /** 71: * registra un plugin de smarty 72: */ 73: function smarty_block_dynamic($param, $content, &$smarty) { 74: return $content; 75: } 76:} 77: 78:?>