function tpl_parse_ext($template, $config = array()) { require_once dirname(__FILE__) . "/tpl_ext.php"; $template = template_ext($template, $config); return $template; }
function tpl_parse_ext($template) { return template_ext($template); }
<?php if (!function_exists('tpl_parse_ext')) { template_ext($template, $config); } //自定义模板标签解析函数 function template_ext($template, $config = array()) { if ($config['LANG_OPEN']) { $lang_tpl = __LANG__ . '/'; } if (MOBILE) { $mobile_tpl = 'mobile' . '/'; } //替换文件路径 $template = preg_replace("/<(.*?)(src=|href=|value=|background=)[\"|\\'](images\\/|img\\/|css\\/|js\\/|style\\/)(.*?)[\"|\\'](.*?)>/i", "<\$1\$2\"" . __ROOT__ . "/<?php echo \$config['TPL_TEMPLATE_PATH']; ?>" . $lang_tpl . $mobile_tpl . "\$3\$4\"\$5>", $template); //替换载入模板 $template = preg_replace('/<!--#include\\s*file=[\\"|\'](.*)[\\"|\']-->/iU', "<?php \$file=explode('.', \"\$1\"); ?>{include file=\"" . $lang_tpl . $mobile_tpl . "\$file[0]\"}", $template); //替换菜单与内容的反向超链接 $template = preg_replace("/\\{\\\$curl\\.([a-z0-9_]+)\\}/iU", "<?php echo module('label')->get_curl(\$1); ?>", $template); $template = preg_replace("/\\{\\\$aurl\\.([a-z0-9_]+)\\}/iU", "<?php echo module('label')->get_aurl(\$1); ?>", $template); //替换菜单超链接 $template = preg_replace("/\\{(\\\$[a-z0-9_]+)\\.curl\\}/iU", "<?php if(!empty(\$1['url'])){ echo module('common')->return_tpl(html_out(\$1['url'])); }else{ echo module('label')->get_curl(\$1['cid']); } ?>", $template); //替换内容超链接 $template = preg_replace("/\\{(\\\$[a-z0-9_]+)\\.aurl\\}/iU", "<?php if(!empty(\$1['url'])){ echo module('common')->return_tpl(html_out(\$1['url'])); }else{ echo module('label')->get_aurl(\$1['aid']); } ?>", $template); //生成表单访问地址 $template = preg_replace("/\\{\\\$([a-z0-9_]+)\\.form\\}/iU", "<?php echo module('label')->get_furl(\$1); ?>", $template); //碎片替换 $template = preg_replace("/\\{\\\$my\\.([a-z0-9_]+)\\}/iU", "<?php echo model('fragment')->out('\$1'); ?>", $template); //PHP语句 /*{$php(xxx)}替换成 <?php xxx ?>*/
function tpl_parse_ext($template) { require_once dirname(__FILE__) . "/Template_ext.php"; $template = template_ext($template); return $template; }