From 2f2a7efbc37a11593186de91e671a7693d3ad26f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 7 Apr 2013 14:30:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Think\Create=E7=B1=BB=20?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=A1=86=E6=9E=B6=E7=9A=84=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Think/Create.php | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Think/Create.php diff --git a/Think/Create.php b/Think/Create.php new file mode 100644 index 00000000..0065fe80 --- /dev/null +++ b/Think/Create.php @@ -0,0 +1,73 @@ + +// +---------------------------------------------------------------------- +// $Id$ + +namespace Think; +class Create { + static public function build($install) { + // 锁定 + $lockfile = APP_PATH.'install.lock'; + if(is_writable($lockfile)) { + return ; + } else { + touch($lockfile); + } + foreach ($install as $module=>$list){ + if(!is_dir(APP_PATH.$module)) {// 创建模块目录 + mkdir(APP_PATH.$module); + } + foreach($list as $path=>$file){ + if(is_int($path)) { + // 生成文件 + if(!is_file(APP_PATH.$module.'/'.$file)) { + file_put_contents(APP_PATH.$module.'/'.$file,""); + } + }else{ + if(!is_dir(APP_PATH.$module.'/'.$path)){ + mkdir(APP_PATH.$module.'/'.$path); + } + foreach($file as $val){ + switch($path) { + case 'Controller': + $filename = ucwords($val).$path; + if(!is_file(APP_PATH.$module.'/'.$path.'/'.$filename.'.php')) { + file_put_contents(APP_PATH.$module.'/'.$path.'/'.$filename.'.php',"