コード例 #1
0
ファイル: Database.php プロジェクト: reoring/sabel
 private static function initTable()
 {
     if (extension_loaded("mysql")) {
         $params = array("package" => "sabel.db.mysql", "host" => "127.0.0.1", "user" => "root", "password" => "", "database" => "sdb_test");
     } elseif (extension_loaded("pgsql")) {
         $params = array("package" => "sabel.db.pgsql", "host" => "127.0.0.1", "user" => "root", "password" => "", "database" => "sdb_test");
     } elseif (extension_loaded("pdo_sqlite")) {
         $params = array("package" => "sabel.db.pdo.sqlite", "database" => SABEL_BASE . "/Test/data/sdb_test.sq3");
     } else {
         Sabel_Console::message("skipped 'Test_Session_Database'.");
         return false;
     }
     Sabel_Db_Config::add("default", $params);
     Sabel_Db::createDriver("default")->execute("DELETE FROM session");
     return true;
 }
コード例 #2
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);
             }
         }
     }
 }
コード例 #3
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));
 }
コード例 #4
0
ファイル: TemplateDb.php プロジェクト: reoring/sabel
 private static function initTable()
 {
     if (extension_loaded("mysql")) {
         $params = array("package" => "sabel.db.mysql", "host" => "127.0.0.1", "user" => "root", "password" => "", "database" => "sdb_test");
     } elseif (extension_loaded("pgsql")) {
         $params = array("package" => "sabel.db.pgsql", "host" => "127.0.0.1", "user" => "root", "password" => "", "database" => "sdb_test");
     } elseif (extension_loaded("pdo_sqlite")) {
         $params = array("package" => "sabel.db.pdo.sqlite", "database" => SABEL_BASE . "/Test/data/sdb_test.sq3");
     } else {
         Sabel_Console::message("skipped 'TemplateDb'.");
         return false;
     }
     Sabel_Db_Config::add("default", $params);
     $stmt = Sabel_Db::createStatement();
     $tblName = $stmt->quoteIdentifier("sbl_template");
     $nCol = $stmt->quoteIdentifier("name");
     $nsCol = $stmt->quoteIdentifier("namespace");
     $cCol = $stmt->quoteIdentifier("contents");
     $stmt->setQuery("DELETE FROM {$tblName}")->execute();
     $data = array();
     $data[0]["path"] = "views" . DS . "serverError" . TPL_SUFFIX;
     $data[0]["cont"] = "";
     $data[1]["path"] = "index" . DS . "views" . DS . "error" . TPL_SUFFIX;
     $data[1]["cont"] = "";
     $data[2]["path"] = "index" . DS . "views" . DS . "hoge" . DS . "index" . TPL_SUFFIX;
     $data[2]["cont"] = "hoge/index.tpl";
     $data[3]["path"] = "index" . DS . "views" . DS . "hoge" . DS . "hoge" . TPL_SUFFIX;
     $data[3]["cont"] = "hoge/hoge.tpl";
     $data[4]["path"] = "index" . DS . "views" . DS . "fuga" . DS . "index" . TPL_SUFFIX;
     $data[4]["cont"] = "fuga/index.tpl";
     $data[5]["path"] = "index" . DS . "views" . DS . "fuga" . DS . "fuga" . TPL_SUFFIX;
     $data[5]["cont"] = "fuga/fuga.tpl";
     foreach ($data as $d) {
         $query = "INSERT INTO {$tblName}({$nCol}, {$nsCol}, {$cCol}) VALUES('{$d["path"]}', '', '{$d["cont"]}')";
         $stmt->setQuery($query)->execute();
     }
     return true;
 }
コード例 #5
0
ファイル: Task.php プロジェクト: hamaco/phwittr-on-xoops
 public function message($msg)
 {
     echo Sabel_Console::message($msg);
 }