【phpcms-v9】phpcms-v9中模板载入函数template详解
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-24 09:48:48 浏览: 评论:
-
-
-
-
-
-
-
-
- function template($module = 'content', $template = 'index', $style = '') {
-
-
- if(strpos($module, 'plugin/')!== false) {
- $plugin = str_replace('plugin/', '', $module);
- return p_template($plugin, $template,$style);
- }
- $module = str_replace('/', DIRECTORY_SEPARATOR, $module);
-
-
- if(!emptyempty($style) && preg_match('/([a-z0-9\-_]+)/is',$style)) {
-
-
-
- } elseif (emptyempty($style) && !defined('STYLE')) {
-
- if(defined('SITEID')) {
-
- $siteid = SITEID;
-
- } else {
- $siteid = param::get_cookie('siteid');
-
- }
- if (!$siteid) $siteid = 1;
-
- $sitelist = getcache('sitelist','commons');
-
- if(!emptyempty($siteid)) {
-
- $style = $sitelist[$siteid]['default_style'];
- }
-
- } elseif (emptyempty($style) && defined('STYLE')) {
-
- $style = STYLE;
-
-
- } else {
- $style = 'default';
-
- }
- if(!$style) $style = 'default';
- $template_cache = pc_base::load_sys_class('template_cache');
-
- $compiledtplfile = PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.php';
-
- if(file_exists(PC_PATH.'templates'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html')) {
-
- if(!file_exists($compiledtplfile) || (@filemtime(PC_PATH.'templates'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html') > @filemtime($compiledtplfile))) {
- $template_cache->template_compile($module, $template, $style);
- }
- } else {
-
- $compiledtplfile = PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.php';
-
- if(!file_exists($compiledtplfile) || (file_exists(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html') && filemtime(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html') > filemtime($compiledtplfile))) {
-
- $template_cache->template_compile($module, $template, 'default');
- } elseif (!file_exists(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html')) {
-
- showmessage('Template does not exist.'.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.'.html');
- }
- }
-
- return $compiledtplfile;
- }
分享到: