/** show dbs in left frame **/
 public function doDbs()
 {
     $dbs = $this->_server->listDbs();
     $this->dbs = array_values(rock_array_sort($dbs["databases"], "name"));
     $this->baseUrl = $this->path("admin.dbs");
     $this->tableUrl = $this->path("collection.index");
     $this->showDbSelector = false;
     //add collection count
     foreach ($this->dbs as $index => $db) {
         $collectionCount = count(MDb::listCollections($this->_mongo->selectDB($db["name"])));
         $db["collectionCount"] = $collectionCount;
         if (isset($db["sizeOnDisk"])) {
             $db["size"] = round($db["sizeOnDisk"] / 1024 / 1024, 2);
             //M
         }
         $this->dbs[$index] = $db;
     }
     //current db
     $db = x("db");
     $this->tables = array();
     if ($db) {
         $mongodb = $this->_mongo->selectDB($db);
         $tables = MDb::listCollections($mongodb);
         foreach ($tables as $table) {
             $this->tables[$table->getName()] = $table->count();
         }
     }
     $this->display();
 }
Beispiel #2
0
 /**
  * Call onAfter() method in plugin
  *
  */
 public static function callAfter()
 {
     $plugins = rock_array_sort(self::$_plugins, "priority", false);
     foreach ($plugins as $plugin) {
         $plugin["obj"]->onAfter();
     }
 }
 /**
  * Dispatch event
  * 
  * @param string $event Event name
  * @param array $params
  */
 public static function dispatch($event, array $params = array())
 {
     if (empty(self::$_listeners[$event])) {
         return;
     }
     if (isset(self::$_events[$event]["enabled"]) && !self::$_events[$event]["enabled"]) {
         return;
     }
     foreach (rock_array_sort(self::$_listeners[$event], "priority") as $index => $listener) {
         call_user_func_array($listener["callback"], array($params));
         if (isset(self::$_events[$event]["enabled"]) && !self::$_events[$event]["enabled"]) {
             return;
         }
     }
 }
 /**
  * Apply filters to data
  *
  * @param string $dataType Data Type
  * @param mixed $data Data to be filtered
  * @param array $params parameters will be passed to "filter callback function"
  */
 public static function apply($dataType, &$data, array $params = array())
 {
     if (empty(self::$_filters[$dataType])) {
         return;
     }
     if (isset(self::$_dataTypes[$dataType]["enabled"]) && !self::$_dataTypes[$dataType]["enabled"]) {
         return;
     }
     $newParams = array(&$data);
     foreach ($params as $param) {
         $newParams[] = $param;
     }
     foreach (rock_array_sort(self::$_filters[$dataType], "priority") as $index => $filter) {
         call_user_func_array($filter["callback"], $newParams);
         if (isset(self::$_dataTypes[$dataType]["enabled"]) && !self::$_dataTypes[$dataType]["enabled"]) {
             return;
         }
     }
 }
Beispiel #5
0
 /** show databases **/
 public function doDatabases()
 {
     $ret = $this->_server->listDbs();
     $this->dbs = $ret["databases"];
     foreach ($this->dbs as $index => $db) {
         $mongodb = $this->_mongo->selectDB($db["name"]);
         $ret = $mongodb->command(array("dbstats" => 1));
         $ret["collections"] = count(MDb::listCollections($mongodb));
         if (isset($db["sizeOnDisk"])) {
             $ret["diskSize"] = $this->_formatBytes($db["sizeOnDisk"]);
             $ret["dataSize"] = $this->_formatBytes($ret["dataSize"]);
         } else {
             $ret["diskSize"] = "-";
             $ret["dataSize"] = "-";
         }
         $ret["storageSize"] = $this->_formatBytes($ret["storageSize"]);
         $ret["indexSize"] = $this->_formatBytes($ret["indexSize"]);
         $this->dbs[$index] = array_merge($this->dbs[$index], $ret);
     }
     $this->dbs = rock_array_sort($this->dbs, "name");
     $this->display();
 }
Beispiel #6
0
/**
 * Load all lanugages
 *
 * @return array
 */
function rock_load_languages()
{
    $dir = __ROOT__ . DS . "langs";
    $handler = opendir($dir);
    $languages = array();
    while (($file = readdir($handler)) !== false) {
        $langDir = $dir . DS . $file;
        if (is_dir($langDir) && preg_match("/^\\w+_\\w+\$/", $file)) {
            require $langDir . DS . "message.php";
            $languages[$file] = array("code" => $file, "name" => $message["TRANSLATION_NAME"], "id" => $message["TRANSLATION_ID"]);
        }
    }
    closedir($handler);
    $languages = rock_array_sort($languages, "id");
    return rock_array_combine($languages, "code", "name");
}