/** * 返回模板文件 * @param string $file * @param string $tpldir * @return string */ function template($file, $tpldir = '') { global $G; $tpldir = $tpldir ? $tpldir : $G['m']; !$tpldir && ($tpldir = 'common'); $theme = defined('THEME') ? THEME : 'default'; $tplfile = TPL_PATH . $theme . '/' . $tpldir . '/' . $file . '.htm'; if (!is_file($tplfile)) { $tplfile = TPL_PATH . 'default/' . $tpldir . '/' . $file . '.htm'; if (!is_file($tplfile)) { $tpldir = 'common'; $tplfile = TPL_PATH . $theme . '/common/' . $file . '.htm'; if (!is_file($tplfile)) { $tplfile = $tplfile = TPL_PATH . 'default/common/' . $file . '.htm'; } } } $objfile = DATA_PATH . 'template/' . $tpldir . '/' . $file . '.tpl.php'; @mkdir(dirname($objfile), 0777, true); if (!is_file($objfile) || filemtime($tplfile) > filemtime($objfile)) { \Core\Template::parse_template($tplfile, $tpldir, $objfile); } return $objfile; }