改进create类

This commit is contained in:
thinkphp
2015-03-05 15:36:14 +08:00
parent 4e9d824993
commit f1ca12de41

View File

@@ -45,23 +45,23 @@ class Create {
mkdir(APP_PATH.$module.'/'.$path);
}
foreach($file as $val){
$filename = strtolower($val);
$filename = APP_PATH.$module.'/'.$path.'/'.strtolower($val).EXT;
switch($path) {
case 'controller':// 控制器
if(!is_file(APP_PATH.$module.'/'.$path.'/'.$filename.'.php')) {
file_put_contents(APP_PATH.$module.'/'.$path.'/'.$filename.'.php',"<?php\nnamespace {$module}\\{$path};\nclass {$filename} {\n}");
if(!is_file($filename)) {
file_put_contents($filename,"<?php\nnamespace {$module}\\{$path};\nclass {$filename} {\n}");
}
break;
case 'model': // 模型
if(!is_file(APP_PATH.$module.'/'.$path.'/'.$filename.'.php')) {
file_put_contents(APP_PATH.$module.'/'.$path.'/'.$filename.'.php',"<?php\nnamespace {$module}\\{$path};\nclass {$filename} extends \Think\Model{\n}");
if(!is_file($filename)) {
file_put_contents($filename,"<?php\nnamespace {$module}\\{$path};\nclass {$filename} extends \Think\Model{\n}");
}
break;
case 'view': // 视图
break;
default:
if(!is_file(APP_PATH.$module.'/'.$path.'/'.$filename.'.php')) {
file_put_contents(APP_PATH.$module.'/'.$path.'/'.$filename.'.php',"<?php\nnamespace {$module}\\{$path};\nclass {$filename} {\n}");
if(!is_file($filename)) {
file_put_contents($filename,"<?php\nnamespace {$module}\\{$path};\nclass {$filename} {\n}");
}
}
@@ -75,13 +75,14 @@ class Create {
// 创建欢迎页面
static public function buildHelloController($module) {
if(!is_file(APP_PATH.$module.'/controller/index.php')) {
$filename = APP_PATH.$module.'/controller/index'.EXT;
if(!is_file($filename)) {
$content = file_get_contents(THINK_PATH.'tpl/default_index.tpl');
$content = str_replace('{$module}',$module,$content);
if(!is_dir(APP_PATH.$module.'/controller')) {
mkdir(APP_PATH.$module.'/controller');
}
file_put_contents(APP_PATH.$module.'/controller/index.php',$content);
file_put_contents($filename,$content);
}
}