Changeset 847 in ExiteCMS for trunk/includes/theme_functions.php
- Timestamp:
- 09/28/07 21:08:59 (5 years ago)
- File:
-
- 1 edited
-
trunk/includes/theme_functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/theme_functions.php
r843 r847 15 15 if (eregi("theme_functions.php", $_SERVER['PHP_SELF']) || !defined('ExiteCMS_INIT')) die(); 16 16 17 // load the Smarty template engine 18 require_once PATH_INCLUDES."Smarty-2.6.18/Smarty.class.php"; 19 20 // extend Smarty with the ExiteCMS custom bits 21 class ExiteCMS_Smarty extends Smarty { 22 23 /**#@+ 24 * ExiteCMS Smarty Configuration Section 25 */ 26 27 /** 28 * Array with names of directories where templates can be located. 29 * 30 * @var string 31 */ 32 var $template_dir = array('templates'); 33 34 /**#@-*/ 35 /** 36 * The class constructor. 37 */ 38 function ExiteCMS_Smarty() { 39 global $settings; 40 41 $this->Smarty(); 42 43 // debugging needed? 44 $this->debugging = false; 45 46 // on-the-fly compilation needed? 47 $this->compile_check = true; 48 49 // set the compile ID for this website/theme (themes can have different templates!) 50 $this->compile_id = $_SERVER['SERVER_NAME'].".".$settings['theme']; 51 52 // caching required? 53 $this->caching = 0; 54 55 // path definitions 56 $this->config_dir = PATH_THEME.'templates/configs'; 57 $this->compile_dir = PATH_ROOT.'files/tplcache'; 58 $this->cache_dir = PATH_ROOT.'files/cache'; 59 60 // PHP in Templates? Don't think so! 61 $this->php_handling = SMARTY_PHP_REMOVE; 62 63 // Template security settings: allow PHP functions 64 $this->security = false; 65 } 66 67 /** 68 * get a concrete filename for automagically created content 69 * 70 * @param string $auto_base 71 * @param string $auto_source 72 * @param string $auto_id 73 * @return string 74 * @staticvar string|null 75 * @staticvar string|null 76 */ 77 function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) 78 { 79 $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; 80 $_return = $auto_base . DIRECTORY_SEPARATOR; 81 82 if(isset($auto_id)) { 83 // make auto_id safe for directory names 84 $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id))); 85 } 86 87 if(isset($auto_source)) { 88 // make source name safe for filename 89 $auto_source = urlencode(basename($auto_source)); 90 if (preg_match("%[\\\/:;*?\"\[\]\%]%", $auto_source)) { 91 $auto_source = md5($auto_source); 92 } 93 $_crc32 = sprintf('%08X', crc32($auto_source)); 94 // prepend %% to avoid name conflicts with 95 // with $params['auto_id'] names 96 $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . 97 substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32; 98 } 99 return $_return.(isset($auto_source)?($auto_source."."):"").(isset($auto_id)?($auto_id."."):"").(isset($_crc32)?$_crc32:""); 100 } 101 102 /** 103 * Returns the last modified timestamp of a template, or false if not found. 104 * 105 * @param string $tpl_file 106 * @return mixed 107 */ 108 function template_timestamp($tpl_file) 109 { 110 $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false); 111 if ($this->_fetch_resource_info($_params)) { 112 return $_params['resource_timestamp']; 113 } else { 114 return false; 115 } 116 } 117 } 118 17 119 // Smarty template engine definitions and initialisation 18 require_once PATH_INCLUDES."Smarty-2.6.18/Smarty.class.php"; 19 20 // initialize the class 21 $template = & new Smarty(); 22 23 // debugging needed? 24 $template->debugging = false; 25 26 // on-the-fly compilation needed? 27 $template->compile_check = true; 28 29 // set the compile ID for this website 30 $template->compile_id = $_SERVER['SERVER_NAME']; 31 32 // caching required? 33 $template->caching = 0; 34 35 // path definitions 36 $template->template_dir = PATH_THEME.'templates/source'; 37 $template->compile_dir = PATH_THEME.'templates/templates'; 38 $template->config_dir = PATH_THEME.'templates/configs'; 39 $template->cache_dir = PATH_THEME.'cache'; 120 121 // initialize the template engine 122 $template = & new ExiteCMS_Smarty(); 40 123 41 124 // plugin's, where to find them? … … 43 126 // first check if there's one defined in the current theme 44 127 if (is_dir(PATH_THEME."template/plugins")) $plugins_dir[] = PATH_THEME."template/plugins"; 45 // next, check the CMS custom plugins46 $plugins_dir[] = 'custom-plugins';128 // next, check the ExiteCMS custom plugins 129 $plugins_dir[] = PATH_INCLUDES.'template-plugins'; 47 130 // and finaly, use the default Smarty plugins 48 131 $plugins_dir[] = 'smarty-plugins'; … … 53 136 $template_dir = array(); 54 137 // first check if there's one defined in the current theme 55 if (is_dir(PATH_THEME."templates/ source")) $template_dir[] = PATH_THEME."templates/source";138 if (is_dir(PATH_THEME."templates/templates")) $template_dir[] = PATH_THEME."templates/templates"; 56 139 // next, check the CMS template directory 57 140 $template_dir[] = PATH_INCLUDES.'templates'; 58 141 59 142 $template->template_dir = $template_dir; 60 61 // PHP in Templates? Don't think so!62 $template->php_handling = SMARTY_PHP_REMOVE;63 64 // Template security settings: allow PHP functions65 $template->security = false;66 143 67 144 // Register the panel template resource … … 83 160 global $settings, $userdata, $db_prefix, $aidlink, 84 161 $template, $template_panels, $template_variables, 85 $_loadstats, $_headparms, $_bodyparms ;162 $_loadstats, $_headparms, $_bodyparms, $_last_updated; 86 163 87 164 // reset all assigned template variables … … 181 258 } 182 259 183 // if a template is defined, load the template, 184 if (isset($panel['template'])) $template->display($panel['template']); 260 // if a template is defined, get the last modified date, and load the template 261 if (isset($panel['template'])) { 262 // get the timestamp of the template, and update the last update timestamp if newer 263 $ts = $template->template_timestamp($panel['template']); 264 $_last_updated = isset($_last_updated) ? ($ts > $_last_updated ? $ts : $_last_updated ) : $ts; 265 $template->assign("_last_updated", $_last_updated); 266 // and load the template 267 $template->display($panel['template']); 268 } 185 269 186 270 // restore the template direcory if needed
Note: See TracChangeset
for help on using the changeset viewer.
