예제 #1
0
파일: generator.php 프로젝트: reoring/sabel
 public function create($dir = null)
 {
     if ($dir === null) {
         $dir = $this->skeletonDir . DS . self::DEFAULT_LANGUAGE;
     }
     foreach (scandir($dir) as $item) {
         if ($item[0] === "." && $item !== ".htaccess") {
             continue;
         }
         $fullPath = $dir . DS . $item;
         $targetItem = substr($fullPath, $this->basedirNameLength + 1);
         $targetPath = $this->targetDir . DS . $targetItem;
         if (is_dir($fullPath)) {
             if (isset($this->ignore[$targetItem])) {
                 Sabel_Console::message("ignore '{$targetItem}'.");
             } else {
                 if (is_dir($targetPath)) {
                     Sabel_Console::warning("'{$targetItem}' already exists.");
                 } else {
                     Sabel_Console::success("create {$targetItem}");
                     mkdir($targetPath);
                 }
                 $this->create($fullPath);
             }
         } else {
             if ($this->lang !== self::DEFAULT_LANGUAGE) {
                 $_target = substr($fullPath, strlen($this->skeletonDir) + 4);
                 // DS(1) + lang(2) + DS(1)
                 $_target = $this->skeletonDir . DS . $this->lang . DS . $_target;
                 if (is_dir($_target) || is_file($_target)) {
                     $fullPath = $_target;
                 }
             }
             if (isset($this->ignore[$targetItem])) {
                 Sabel_Console::message("ignore '{$targetItem}'.");
             } elseif (is_file($targetPath)) {
                 Sabel_Console::warning("'{$targetItem}' already exists.");
             } else {
                 Sabel_Console::success("create {$targetItem}");
                 copy($fullPath, $targetPath);
             }
         }
     }
 }
예제 #2
0
파일: Console.php 프로젝트: reoring/sabel
 public function testMessage()
 {
     $_SERVER["IS_WINDOWS"] = true;
     ob_start();
     Sabel_Console::success("success");
     $result = ob_get_clean();
     $this->assertEquals("[SUCCESS] success", rtrim($result));
     ob_start();
     Sabel_Console::warning("warning");
     $result = ob_get_clean();
     $this->assertEquals("[WARNING] warning", rtrim($result));
     ob_start();
     Sabel_Console::error("failure");
     $result = ob_get_clean();
     $this->assertEquals("[FAILURE] failure", rtrim($result));
     ob_start();
     Sabel_Console::message("message");
     $result = ob_get_clean();
     $this->assertEquals("[MESSAGE] message", rtrim($result));
 }
예제 #3
0
 public function success($msg)
 {
     echo Sabel_Console::success($msg);
 }
예제 #4
0
파일: Schema.php 프로젝트: reoring/sabel
 public function write($connectionName)
 {
     $cn = $connectionName;
     $fileName = ucfirst($cn) . "TableList";
     $className = "Schema_" . $fileName;
     Sabel_Console::success("output table list of '{$cn}' database.");
     $contents = array();
     $contents[] = "<?php" . PHP_EOL;
     $contents[] = "class {$className}";
     $contents[] = "{";
     $contents[] = "  public function get()";
     $contents[] = "  {";
     $tables = array_map(create_function('$v', 'return \'"\' . $v . \'"\';'), $this->tables[$cn]);
     $contents[] = "    return array(" . implode(", ", $tables) . ");";
     $contents[] = "  }";
     $contents[] = "}";
     $fp = fopen($this->outputDir . DS . $fileName . ".php", "w");
     fwrite($fp, implode(PHP_EOL, $contents));
     fclose($fp);
 }