mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
修正模板文件
This commit is contained in:
@@ -101,13 +101,13 @@ class Build
|
|||||||
$namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path;
|
$namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path;
|
||||||
$class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : '');
|
$class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : '');
|
||||||
switch ($path) {
|
switch ($path) {
|
||||||
case CONTROLLER_LAYER: // 控制器
|
case CONTROLLER_LAYER: // 控制器
|
||||||
$content = "<?php\nnamespace {$namespace};\n\nclass {$class}\n{\n\n}";
|
$content = "<?php\nnamespace {$namespace};\n\nclass {$class}\n{\n\n}";
|
||||||
break;
|
break;
|
||||||
case MODEL_LAYER: // 模型
|
case MODEL_LAYER: // 模型
|
||||||
$content = "<?php\nnamespace {$namespace};\n\nuse think\Model;\n\nclass {$class} extends Model\n{\n\n}";
|
$content = "<?php\nnamespace {$namespace};\n\nuse think\Model;\n\nclass {$class} extends Model\n{\n\n}";
|
||||||
break;
|
break;
|
||||||
case VIEW_LAYER: // 视图
|
case VIEW_LAYER: // 视图
|
||||||
$filename = $modulePath . $path . DS . $val . '.html';
|
$filename = $modulePath . $path . DS . $val . '.html';
|
||||||
if (!is_dir(dirname($filename))) {
|
if (!is_dir(dirname($filename))) {
|
||||||
// 创建目录
|
// 创建目录
|
||||||
@@ -131,7 +131,7 @@ class Build
|
|||||||
// 创建欢迎页面
|
// 创建欢迎页面
|
||||||
protected static function buildHello($module)
|
protected static function buildHello($module)
|
||||||
{
|
{
|
||||||
$filename = APP_PATH . ($module ? $module . DS : '') . CONTROLLER_LAYER . DS . Config::get('default_controller') . (CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : '') . EXT;
|
$filename = APP_PATH . ($module ? $module . DS : '') . CONTROLLER_LAYER . DS . 'Index' . (CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : '') . EXT;
|
||||||
if (!is_file($filename)) {
|
if (!is_file($filename)) {
|
||||||
$content = file_get_contents(THINK_PATH . 'tpl' . DS . 'default_index.tpl');
|
$content = file_get_contents(THINK_PATH . 'tpl' . DS . 'default_index.tpl');
|
||||||
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [APP_NAMESPACE, $module ? $module . '\\' : '', CONTROLLER_LAYER, CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : ''], $content);
|
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [APP_NAMESPACE, $module ? $module . '\\' : '', CONTROLLER_LAYER, CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : ''], $content);
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ class View
|
|||||||
$template = str_replace('.', DS, CONTROLLER_NAME) . $depr . $template;
|
$template = str_replace('.', DS, CONTROLLER_NAME) . $depr . $template;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $path . $template . $this->config['view_suffix'];
|
return realpath($path) . DS . $template . $this->config['view_suffix'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="Generator" content="EditPlus®">
|
||||||
|
<meta name="Author" content="">
|
||||||
|
<meta name="Keywords" content="">
|
||||||
|
<meta name="Description" content="">
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -121,12 +121,14 @@ class viewTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testParseTemplate()
|
public function testParseTemplate()
|
||||||
{
|
{
|
||||||
$view_instance = \think\View::instance();
|
$view_instance = \think\View::instance();
|
||||||
$method = new \ReflectionMethod('\think\View', 'ParseTemplate');
|
$view_instance->theme(true);
|
||||||
|
$view_instance->config(['view_path' => __DIR__ . DS]);
|
||||||
|
$method = new \ReflectionMethod('\think\View', 'ParseTemplate');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
if (defined('CONTROLLER_NAME')) {
|
if (defined('CONTROLLER_NAME')) {
|
||||||
$expect_data = 'view_path' . 'theme_name' . DS . CONTROLLER_NAME . DS . 'template_name.html';
|
$expect_data = __DIR__ . DS . 'default' . DS . CONTROLLER_NAME . DS . 'template.html';
|
||||||
} else {
|
} else {
|
||||||
$expect_data = 'view_path' . 'theme_name' . DS . 'template_name.html';
|
$expect_data = __DIR__ . DS . 'default' . DS . 'template.html';
|
||||||
}
|
}
|
||||||
$this->assertEquals($expect_data, $method->invoke($view_instance, 'template_name'));
|
$this->assertEquals($expect_data, $method->invoke($view_instance, 'template_name'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user