diff --git a/includes/cls_template.php b/includes/cls_template.php index 6b56ae9..349b910 100644 --- a/includes/cls_template.php +++ b/includes/cls_template.php @@ -323,7 +323,10 @@ class cls_template $source= str_replace('%%%SMARTYSP'.$curr_sp.'%%%', ''."\n", $source); } }*/ - return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source); + //return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source); + return preg_replace_callback("/{([^\}\{]*)}/", function($r) { return $this->select($r[1]); }, $source); + + } /** @@ -521,7 +524,9 @@ class cls_template case 'insert' : $t = $this->get_para(substr($tag, 7), false); - $out = "_echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>"; return $out; @@ -580,7 +585,9 @@ class cls_template { if (strrpos($val, '[') !== false) { - $val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val); + //$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val); + $val = preg_replace_callback('/\[([^\[\]]*)\]/is',function ($matches) {return '.'.str_replace('$','\$',$matches[1]);},$val); + } if (strrpos($val, '|') !== false) @@ -1097,9 +1104,12 @@ class cls_template if ($file_type == '.dwt') { /* 将模板中所有library替换为链接 */ - $pattern = '/.*?/se'; - $replacement = "'{include file='.strtolower('\\1'). '}'"; - $source = preg_replace($pattern, $replacement, $source); +// $pattern = '/.*?/se'; +// $replacement = "'{include file='.strtolower('\\1'). '}'"; +// $source = preg_replace($pattern, $replacement, $source); + $pattern = '/.*?/s'; + $replacement = function($r){return '{include file='.strtolower($r[1]). '}';}; + $source = preg_replace_callback($pattern, $replacement, $source); /* 检查有无动态库文件,如果有为其赋值 */ $dyna_libs = get_dyna_libs($GLOBALS['_CFG']['template'], $this->_current_file);