改进template类parseTemplateFile方法支持跨模块调用模板

route类method路由参数支持使用 GET|POST 选择多种请求
This commit is contained in:
thinkphp
2015-12-31 20:46:13 +08:00
parent ab467b3b7e
commit a807dbce81
2 changed files with 9 additions and 7 deletions

View File

@@ -249,7 +249,7 @@ class Route
$option = $val['option']; $option = $val['option'];
$pattern = $val['pattern']; $pattern = $val['pattern'];
// 请求类型检测 // 请求类型检测
if (isset($option['method']) && REQUEST_METHOD != strtoupper($option['method'])) { if (isset($option['method']) && false === stripos($option['method'], REQUEST_METHOD)) {
continue; continue;
} }
// 伪静态后缀检测 // 伪静态后缀检测
@@ -289,7 +289,7 @@ class Route
if (is_array($route)) { if (is_array($route)) {
$option1 = $route[1]; $option1 = $route[1];
// 请求类型检测 // 请求类型检测
if (isset($option1['method']) && REQUEST_METHOD != strtoupper($option1['method'])) { if (isset($option1['method']) && false === stripos($option1['method'], REQUEST_METHOD)) {
continue; continue;
} }
// 伪静态后缀检测 // 伪静态后缀检测

View File

@@ -727,10 +727,10 @@ class Template
case 'array': // 识别为数组 case 'array': // 识别为数组
$parseStr = $first . '[\'' . implode('\'][\'', $vars) . '\']'; $parseStr = $first . '[\'' . implode('\'][\'', $vars) . '\']';
break; break;
case 'obj': // 识别为对象 case 'obj': // 识别为对象
$parseStr = $first . '->' . implode('->', $vars); $parseStr = $first . '->' . implode('->', $vars);
break; break;
default: // 自动判断数组或对象 只支持二维 default: // 自动判断数组或对象 只支持二维
$parseStr = 'is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars); $parseStr = 'is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars);
} }
} }
@@ -917,10 +917,12 @@ class Template
private function parseTemplateFile($template) private function parseTemplateFile($template)
{ {
if (false === strpos($template, '.')) { if (false === strpos($template, '.')) {
return (defined('THEME_PATH') && substr_count($template, '/') < 2 ? THEME_PATH : $this->config['tpl_path']) . $template . $this->config['tpl_suffix']; // 跨模块支持
} else { $template = strpos($template, '@') ?
return $template; APP_PATH . str_replace('@', '/' . basename($this->config['tpl_path']) . '/', $template) . $this->config['tpl_suffix'] :
(defined('THEME_PATH') && substr_count($template, '/') < 2 ? THEME_PATH : $this->config['tpl_path']) . $template . $this->config['tpl_suffix'];
} }
return $template;
} }
/** /**