public function makeLayoutTemplateFile($filePath, $selectTableName)
 {
     $fileContent = file_get_contents($filePath);
     //$fileContent = mb_convert_encoding($fileContent, 'UTF-8');
     $menu = "";
     $selectTableNameArray = $selectTableName;
     for ($i = 0; $i < count($selectTableNameArray); $i++) {
         $menu .= '<li class="has_sub"><a href="#"><i class="icon-list-alt"></i> ' . tableNameToModelName($selectTableNameArray[$i]) . '<span class="pull-right"><i class="icon-chevron-right"></i></span></a>';
         $menu .= "\r\n<ul>\r\n";
         $menu .= '<li><a href="__MODULE__/' . tableNameToModelName($selectTableNameArray[$i]) . "/all\">管理</a></li>\r\n";
         $menu .= '<li><a href="__MODULE__/' . tableNameToModelName($selectTableNameArray[$i]) . "/add\">新建</a></li>\r\n</ul>\r\n</li>\r\n";
     }
     $fileContent = str_replace('@menu', $menu, $fileContent);
     return $fileContent;
 }
 public function createViewModelFile()
 {
     $modelName = I('modelName');
     $moduleName = I('moduleName');
     $modelPath = APP_PATH . $moduleName . '/Model/';
     $code = htmlspecialchars_decode(I('code'));
     file_put_contents($modelPath . tableNameToModelName($modelName) . "ViewModel.class.php", $code);
     echo '生成成功,生成路径为:' . $modelPath;
 }
 public function creatAllFiles()
 {
     $tableName = I('selectTableName');
     $moduleName = I('moduleName');
     $controllerPath = APP_PATH . tableNameToModelName($moduleName) . "/Controller/";
     for ($i = 0; $i < count($tableName); $i++) {
         $_POST['table'] = $tableName[$i];
         $viewPath = APP_PATH . tableNameToModelName($moduleName) . "/View/" . tableNameToModelName($tableName[$i]) . "/";
         $controllerStr = "<?php\r\n";
         $controllerStr .= "//由ThinkphpHelper自动生成,请根据需要修改\r\n";
         $controllerStr .= "namespace " . tableNameToModelName($moduleName) . "\\Controller;\r\n";
         $controllerStr .= "use Think\\Controller;\r\n\r\n";
         $controllerStr .= "class " . tableNameToModelName($tableName[$i]) . "Controller extends Controller {\r\n";
         $controllerStr .= $this->generateAllCode() . "\r\n\r\n";
         $controllerStr .= $this->generateAddCode() . "\r\n\r\n";
         $controllerStr .= $this->generateEditCode() . "\r\n\r\n";
         $controllerStr .= $this->generateDeleteCode() . "\r\n\r\n}";
         $originalAllViewStr = $this->generateAllPageCode();
         $allViewStr = $this->makeViewTemplate("all.html", "管理" . $tableName[$i], $originalAllViewStr);
         $originalAddViewStr = $this->generateAddPage();
         $addViewStr = $this->makeViewTemplate("add.html", "新建" . $tableName[$i], $originalAddViewStr);
         $originalEditViewStr = $this->generateEditPage();
         $editViewStr = $this->makeViewTemplate("edit.html", "编辑" . $tableName[$i], $originalEditViewStr);
         file_put_contents($controllerPath . tableNameToModelName($tableName[$i]) . "Controller.class.php", $controllerStr);
         //生成Controller文件
         FileUtil::createDir($viewPath);
         file_put_contents($viewPath . "all.html", $allViewStr);
         file_put_contents($viewPath . "add.html", $addViewStr);
         file_put_contents($viewPath . "edit.html", $editViewStr);
     }
     echo "生成完成。";
 }