Пример #1
0
 public function main()
 {
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     $_->usage = $_->getUsage();
     $params = $_->getParams();
     if ($params['rootDir']) {
         $parentPath = $params['rootDir'];
     } else {
         $parentPath = CmdLibs::getParentPath($_->APP_ROOT);
     }
     echo "parentPath={$parentPath}\n";
     $newAppRoot = $parentPath . '/' . $params['appName'];
     if (!file_exists($newAppRoot)) {
         mkdir($newAppRoot, 0755, true);
         $filename = 'composer.json';
         copy($_->APP_ROOT . '/' . $filename, "{$newAppRoot}/{$filename}");
         $subdirs = array("behavior" => 0755, "bin" => 0755, "controller" => 0755, "controller/cmn" => 0755, "etc" => 0755, "etc/template" => 0755, "htdocs" => 0755, "htdocs/cmn" => 0755, "htdocs/cmn/img" => 0755, "lib" => 0755, "lib/Datatype" => 0755, "lib/DbOperator" => 0755, "lib/share" => 0755, "lib/Util" => 0755, "model" => 0755, "model/_def" => 0755, "model/_def/api" => 0755, "model/_def/db" => 0755, "model/amazon" => 0755, "model/excel" => 0755, "test" => 0755, "test/controller" => 0755, "test/model" => 0755, "test/model/amazon" => 0755, "test/model/excel" => 0755, "var" => 0755, "var/compiled" => 0777, "var/files" => 0777, "var/images" => 0777, "var/images/uploaded" => 0777, "var/log" => 0777, "view" => 0755, "view/cmn" => 0755, "view/cmn/css" => 0755, "view/cmn/includes" => 0755, "view/cmn/js" => 0755, "view/cmn/js/jarty" => 0755, "view/cmn/js/validationEngine" => 0755, "view/cmn/js/validationEngine/languages" => 0755, "view/cmn/js/validationEngine/contrib" => 0755, "view/cmn/lang" => 0755, "view/cmn/layout" => 0755);
         $oldMask = umask(0);
         foreach ($subdirs as $subdir => $permission) {
             mkdir("{$newAppRoot}/{$subdir}", $permission, true);
             if ($subdir == 'var/compiled') {
                 continue;
             }
             $files = glob($_->APP_ROOT . "/{$subdir}/*");
             if (!empty($files)) {
                 foreach ($files as $filepath) {
                     if (!is_dir($filepath)) {
                         $filename = basename($filepath);
                         copy($filepath, "{$newAppRoot}/{$subdir}/{$filename}");
                     }
                 }
             }
         }
         $_->copySubdirs("etc/template", $newAppRoot);
         $_->view->assign('APP_NAME', $params['appName']);
         $_->view->assign('APP_ROOT', $newAppRoot);
         $localVh = $_->view->fetch($_->APP_ROOT . '/etc/local_vh.conf');
         $vhFilePath = "{$newAppRoot}/etc/local_vh.conf";
         file_put_contents($vhFilePath, $localVh);
         chmod("{$newAppRoot}/bin/makeNewApp.php", 0755);
         chmod("{$newAppRoot}/bin/makeDbClassFile.php", 0755);
         chmod("{$newAppRoot}/bin/makeTableClassFiles.php", 0755);
         chmod("{$newAppRoot}/bin/makeModelClassFiles.php", 0755);
         chmod("{$newAppRoot}/bin/makeCtlAndView.php", 0755);
         chmod("{$newAppRoot}/bin/test.sh", 0755);
         chmod("{$newAppRoot}/bin/genTest.sh", 0755);
         chmod("{$newAppRoot}/bin/backSyncToMin.sh", 0755);
         chmod("{$newAppRoot}/bin/syncFromMin.sh", 0755);
         chmod("{$newAppRoot}/bin/setup.sh", 0755);
         chmod("{$newAppRoot}/etc/template/bin/setSample.sh", 0755);
         umask($oldMask);
     }
     if (!empty($params['dbName'])) {
         $_->saveDbClassFile($params);
     }
     echo "\n\nPlease run 'composer install' at new app root.\n";
     exit;
 }
Пример #2
0
 public function __construct()
 {
     parent::__construct();
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     echo "\nmake table Class file from database;.\n\n";
 }
Пример #3
0
 public function main()
 {
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     $_->usage = $_->getUsage();
     $params = $_->getDbParams();
     if (!empty($params['dbName'])) {
         $_->saveDbClassFile($params);
     } else {
         echo "Plaese set database name.\n";
         die($_->usage);
     }
     exit;
 }
Пример #4
0
 public function makeBlankModel($pageName)
 {
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     $dirPath = $_->APP_ROOT . "/model/{$pageName}";
     if (!file_exists($dirPath)) {
         mkdir($dirPath, 0777, true);
     }
     $className = ucfirst($pageName) . 'Model';
     $_->view->assign('pageName', $pageName);
     $_->view->assign('className', $className);
     $filePath = $dirPath . '/' . $className . ".php";
     // model file
     if (file_exists($filePath)) {
         echo "error: {$filePath} is exists. can not save file.\n\n";
     } else {
         $templateFile = $_->APP_ROOT . '/etc/template/model/blankModel.php';
         $classCode = $_->view->fetch($templateFile);
         file_put_contents($filePath, $classCode);
         echo "------------------------------\n";
         echo "save class file {$className}.php\n";
         echo "\n";
         //echo $classCode;
         //echo "\n";
     }
     // Blank Model Test
     $testDirPath = $_->APP_ROOT . "/test/model/{$pageName}";
     if (!file_exists($testDirPath)) {
         mkdir($testDirPath, 0777, true);
     }
     $filePath = $testDirPath . '/' . $className . "Test.php";
     if (file_exists($filePath)) {
         echo "error: {$filePath} is exists. can not save file.\n\n";
     } else {
         $templateFile = $_->APP_ROOT . '/etc/template/test/model/blankModelTest.php';
         $classCode = $_->view->fetch($templateFile);
         file_put_contents($filePath, $classCode);
         echo "------------------------------\n";
         echo "save class file {$className}" . "Test.php\n";
         echo "\n";
         //echo $classCode;
         //echo "\n";
     }
 }
Пример #5
0
 public function main()
 {
     $_ = $this;
     $_->APP_ROOT = CmdLibs::getAppRoot(1);
     $_->initView();
     $_->view->assign('localTestServer', $this->C['LOCAL_TEST_SERVER']);
     // パラメータからモデル名とページ名を決定。
     $modelName = cmdLibs::getParam('-m');
     $pageName = cmdLibs::getParam('-p');
     $overWrite = cmdLibs::getParam('-o');
     if (empty($modelName) && empty($pageName)) {
         die("usage: " . cmdLibs::scriptName() . " -m modelName -p pageName [-o yes]\n At least you should spec one parameter -m or -p.\n");
     }
     if ($modelName) {
         echo "use model name  {$modelName}.\n";
         // テーブル名を取得
         //$MODEL = $_->getModel($modelName);
         $MODEL = new $modelName();
         $tableName = $MODEL->TABLE->TABLE;
         if (empty($tableName)) {
             die("\nmodel {$modelName} is not correct.\n\n");
         }
         echo "table name is '{$tableName}'.\n";
         // テーブルのカラム一覧を取得
         $DB = $MODEL->DB;
         $DbOperator = new DbOperatorContext($DB::$SYSTEM);
         $DbOperator->setDb($DB);
         $columns = $DbOperator->getColumns($tableName);
         // モデル関連テンプレート変数の設定
         $_->view->assign('modelName', $modelName);
         $_->view->assign('tableName', $tableName);
         $_->view->assign('columns', $columns);
     }
     // ページ名を決定
     if (!$pageName) {
         if (preg_match("/(.*)List/", $modelName, $m)) {
             $pageName = lcfirst($m[1]);
         } elseif (preg_match("/(.*)Record/", $modelName, $m)) {
             $pageName = lcfirst($m[1]) . '/record';
         } else {
             $pageName = $tableName;
         }
     }
     echo "page name is '{$pageName}'.\n";
     // 上書きモードを設定
     if ($overWrite == 'yes') {
         $_->overWrite = true;
     } else {
         $_->overWrite = false;
     }
     // ページ名からクラス名を生成
     if (strpos($pageName, '/') !== false) {
         $pageNameAry = explode('/', $pageName);
         $pageNameAry = array_map("ucfirst", $pageNameAry);
         $className = implode('', $pageNameAry);
     } else {
         $className = ucfirst($pageName);
     }
     echo "class name is '{$className}'.\n\n";
     // ページ関係テンプレート変数の設定
     $_->view->assign('pageName', $pageName);
     $_->view->assign('className', $className);
     // 各ファイルの保存
     if (isset($MODEL)) {
         switch ($MODEL::MODEL_TYPE) {
             case 'List':
                 $_->genListCtl($pageName, $className);
                 $_->genListHtml($pageName);
                 $_->genAutoList($pageName);
                 $_->genScrollAndSearch($pageName, $className);
                 $_->genLangResource($pageName);
                 $_->genListTest($pageName, $className);
                 break;
             case 'Record':
                 $_->genRecordCtl($pageName, $className);
                 $_->genRecordHtml($pageName);
                 $_->genAddHtml($pageName);
                 $_->genEditHtml($pageName);
                 $_->genAutoRecord($pageName);
                 $_->genAutoAddForm($pageName);
                 $_->genAutoEditForm($pageName);
                 $_->genPost($pageName, $className);
                 $_->genLangResource($pageName);
                 $_->genRecordTest($pageName, $className);
                 break;
         }
     } else {
         $_->genBlankCtl($pageName, $className);
         $_->genBlankHtml($pageName);
         $_->genLangResource($pageName);
         $_->genBlankTest($pageName, $className);
     }
 }