コード例 #1
0
ファイル: model.json.php プロジェクト: remyla/damas-core
 case "roots":
     echo json_encode(model::roots());
     break;
 case "links2":
     if (is_null(arg('id'))) {
         header('HTTP/1.1: 400 Bad Request');
         exit;
     }
     echo json_encode(model::links2(arg("id")));
     break;
 case "links":
     if (is_null(arg('id'))) {
         header('HTTP/1.1: 400 Bad Request');
         exit;
     }
     echo json_encode(model_json::links(arg("id")));
     break;
 case "list":
     if (is_null(arg('key'))) {
         $result = mysql_query("SELECT DISTINCT name FROM `key` ORDER BY name;");
         $res = array();
         while ($row = mysql_fetch_array($result)) {
             $res[] = $row['name'];
         }
         echo json_encode($res);
     } else {
         $result = mysql_query("SELECT DISTINCT value FROM `key` WHERE name='" . arg('key') . "' ORDER BY value;");
         $res = array();
         while ($row = mysql_fetch_array($result)) {
             $res[] = $row['value'];
         }
コード例 #2
0
ファイル: model_json.php プロジェクト: remyla/damas-core
 /**
  * Gets a node and subnodes in array format
  * @param {Integer} $id node index
  * @param {Integer} $depth integer depth of recursion (0 means no limit, 1 for single node)
  * @param {Integer} $flags integer of needed informations for the nodes
  * @return {Array} array of nodes or empty array if no node found
  */
 static function node($id, $depth = 0, $flags = 15)
 {
     if ($id === false) {
         return false;
     }
     if ($id === null) {
         return false;
     }
     if ($id === "") {
         return false;
     }
     $contents = array();
     $tags = model::tags($id);
     if ($tags) {
         $contents["tags"] = $tags;
     }
     $keys = model::keys($id);
     if ($keys) {
         $contents["keys"] = $keys;
     }
     if ($flags & 8) {
         $contents["links"] = model_json::links($id);
         $contents["rlinks"] = model_json::rlink($id);
     }
     if ($depth != 1) {
         $children = model::children($id);
         for ($i = 0; $i < sizeof($children); $i++) {
             $contents["children"][] = model_json::node($children[$i], max($depth - 1, 0));
         }
     }
     return model_json::node_jsontag($id, $contents);
 }