예제 #1
0
 /** called before any actions **/
 public function onBefore()
 {
     global $MONGO;
     //exception handler
     set_exception_handler(array($this, "exceptionHandler"));
     $this->_admin = MUser::userInSession();
     if (!$this->_admin) {
         //if user is loged in?
         $server = MServer::serverWithIndex(xi("host"));
         //filter server plugins
         if (class_exists("RFilter")) {
             RFilter::apply("SERVER_FILTER", $server);
         }
         //if auth is disabled
         if ($server && !$server->mongoAuth() && !$server->controlAuth()) {
             MUser::login("rockmongo_memo", "rockmongo_memo", xi("host"), "admin", 10800);
             $this->_admin = MUser::userInSession();
         } else {
             $this->redirect("login.index", array("host" => xi("host")));
         }
     }
     if (!$this->_admin->validate()) {
         $this->redirect("login.index", array("host" => $this->_admin->hostIndex()));
     }
     $this->_server = MServer::serverWithIndex($this->_admin->hostIndex());
     $this->_mongo = $this->_server->mongo();
     //log query
     if (isset($MONGO["features"]["log_query"]) && $MONGO["features"]["log_query"] == "on") {
         $this->_logQuery = true;
     }
     //render header
     if (!$this->isAjax()) {
         render_view("header");
     }
 }
예제 #2
0
/**
 * Render document operations
 * 
 * @param string $dbName database name
 * @param string $collectionName collection name
 * @param mixed $docId document id 
 * @param integer $docIndex document index
 * @since 1.1.0
 */
function render_doc_menu($dbName, $collectionName, $docId, $docIndex)
{
    $menuItems = array(array("action" => "collection.none", "name" => rock_lang("text"), "attr.onclick" => "changeText('{$docIndex}');return false;"), array("action" => "collection.none", "name" => "Expand", "attr.id" => "expand_{$docIndex}", "attr.onclick" => "expandText('{$docIndex}');return false;"));
    //plugin
    if (class_exists("RFilter")) {
        RFilter::apply("DOC_MENU_FILTER", $menuItems, array("dbName" => $dbName, "collectionName" => $collectionName, "docId" => $docId, "docIndex" => $docIndex));
    }
    $displayCount = 2;
    $hasMore = false;
    $string = "";
    $count = count($menuItems);
    foreach ($menuItems as $index => $op) {
        if ($index >= $displayCount && !$hasMore) {
            $hasMore = true;
            $string .= "<a href=\"#\" onclick=\"showMoreDocMenus(this, {$docIndex});return false;\">" . rock_lang("more") . " &raquo;</a>";
            $string .= "<div class=\"doc_menu doc_menu_{$docIndex}\">";
        }
        if (!empty($op["action"])) {
            $string .= '<a href="' . url($op["action"], isset($op["params"]) ? $op["params"] : array()) . '"';
            if (__CONTROLLER__ . "." . __ACTION__ == $op["action"]) {
                $string .= ' class="current"';
            }
            foreach ($op as $attrName => $attrValue) {
                if (preg_match("/^attr\\.(\\w+)/", $attrName, $match)) {
                    $string .= " " . $match[1] . "=\"" . $attrValue . "\"";
                }
            }
            $string .= ">" . $op["name"] . "</a>";
        } else {
            if (!empty($op["url"])) {
                $string .= "<a href=\"" . $op["url"] . "\" target=\"_blank\">";
            }
            $string .= $op["name"];
            if (!empty($op["url"])) {
                $string .= "</a>";
            }
        }
        if ($hasMore) {
            $string .= "<br/>";
        } else {
            if ($index < $count - 1) {
                $string .= " | ";
            }
        }
    }
    if ($hasMore) {
        $string .= "</div>";
    }
    echo $string;
}