From 257a31551f2331fa2b6b444ca44461454881e66c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 8 Dec 2015 22:46:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=9C=BA=E5=88=B6=20=E5=A2=9E=E5=8A=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=A6=81=E6=AD=A2=E8=AE=BF=E9=97=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 6 +- library/think/app.php | 10 +-- library/think/create.php | 160 +++++++++++++++++++++++++-------------- start.php | 5 ++ 4 files changed, 117 insertions(+), 64 deletions(-) diff --git a/convention.php b/convention.php index ee1fce46..421ab39c 100644 --- a/convention.php +++ b/convention.php @@ -13,6 +13,8 @@ return [ 'pathinfo_depr' => '/', // 默认模块名 'default_module' => 'index', + // 禁止访问模块 + 'deny_module_list' => [COMMON_MODULE, 'runtime'], // 默认控制器名 'default_controller' => 'index', // 默认操作名 @@ -21,8 +23,6 @@ return [ 'empty_controller' => 'error', // 操作方法后缀 'action_suffix' => '', - // URL模式 - 'url_model' => 1, // 获取当前页面地址的系统变量 默认为REQUEST_URI 'url_request_uri' => 'REQUEST_URI', // 基础URL路径 @@ -59,7 +59,7 @@ return [ //默认输出类型 'default_return_type' => 'html', //默认语言 - 'default_lang' => 'zh-cn', + 'default_lang' => 'zh-cn', //是否使用session 'use_session' => true, //url地址的后缀 diff --git a/library/think/app.php b/library/think/app.php index b0bd4c3e..e7c0451e 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -278,10 +278,10 @@ class App $depr = $config['pathinfo_depr']; // 还原劫持后真实pathinfo $path_info = - (defined('BIND_MODULE') ? BIND_MODULE . $depr : '') . - (defined('BIND_CONTROLLER') ? BIND_CONTROLLER . $depr : '') . - (defined('BIND_ACTION') ? BIND_ACTION . $depr : '') . - __INFO__; + (defined('BIND_MODULE') ? BIND_MODULE . $depr : '') . + (defined('BIND_CONTROLLER') ? BIND_CONTROLLER . $depr : '') . + (defined('BIND_ACTION') ? BIND_ACTION . $depr : '') . + __INFO__; // 路由检测 if (!empty($config['url_route_on'])) { @@ -322,7 +322,7 @@ class App define('MODULE_NAME', defined('BIND_MODULE') ? BIND_MODULE : strip_tags($module)); // 模块初始化 - if (MODULE_NAME && MODULE_NAME != COMMON_MODULE && is_dir(APP_PATH . MODULE_NAME)) { + if (MODULE_NAME && !in_array(MODULE_NAME, $config['deny_module_list']) && is_dir(APP_PATH . MODULE_NAME)) { Hook::listen('app_begin'); define('MODULE_PATH', APP_PATH . MODULE_NAME . '/'); define('VIEW_PATH', MODULE_PATH . VIEW_LAYER . '/'); diff --git a/library/think/create.php b/library/think/create.php index 8185666f..03c3ea00 100644 --- a/library/think/create.php +++ b/library/think/create.php @@ -25,85 +25,133 @@ class Create } } foreach ($build as $module => $list) { - if (!is_dir(APP_PATH . $module)) { - // 创建模块目录 - mkdir(APP_PATH . $module); - } - // 创建配置文件和公共文件 - self::buildCommonFile($module); - // 创建欢迎页面 - self::buildHelloController($module); - - // 创建子目录和文件 - foreach ($list as $path => $file) { - if (is_int($path)) { - // 生成文件 - if (!is_file(APP_PATH . $module . '/' . $file)) { - file_put_contents(APP_PATH . $module . '/' . $file, " $file) { + $modulePath = APP_PATH . $module . '/'; + if ('__dir__' == $path) { + // 生成子目录 + foreach ($file as $dir) { + if (!is_dir($modulePath . $dir)) { + // 创建目录 + mkdir($modulePath . $dir, 0777, true); + } + } + } elseif ('__file__' == $path) { + // 生成(空白)文件 + foreach ($file as $name) { + if (!is_file($modulePath . $name)) { + file_put_contents($modulePath . $name, ''); + } + } + } else { + // 生成相关MVC文件 + foreach ($file as $val) { + $filename = $modulePath . $path . '/' . Loader::parseName($val) . EXT; + switch ($path) { + case CONTROLLER_LAYER: // 控制器 + $content = "