Ejemplo n.º 1
0
     if (!$ret) {
         header('HTTP/1.1: 404 Not Found');
         exit;
     }
     echo json_encode($ret);
     break;
 case "children":
     if (is_null(arg('id'))) {
         header('HTTP/1.1: 400 Bad Request');
         exit;
     }
     // Here we implemented the children method to return indexes for performance, keeping the backward compatibility
     if (arg("int") === '1') {
         echo json_encode(model::children(arg('id')));
     } else {
         echo json_encode(model_json::multi(model::children(arg('id'))));
     }
     break;
 case "move":
     if (is_null(arg('id')) || is_null(arg('target'))) {
         header("HTTP/1.1: 400 Bad Request");
         echo "Bad command";
         exit;
     }
     if (!model::move(arg("id"), arg("target"))) {
         header("HTTP/1.1: 409 Conflict");
         echo "move Error, please change your values";
         exit;
     }
     break;
 default:
Ejemplo n.º 2
0
 /**
  * Replace all substring occurences by another one in every keys on node and sub nodes.
  * @param {Integer} $id node index
  * @param {String} $old old substring value to replace
  * @param {String} $new new substring value
  */
 static function setKeys($id, $old, $new)
 {
     $keys = model::keys($id);
     foreach ($keys as $key => $value) {
         model::setKey($id, $key, str_replace($old, $new, $value));
     }
     $children = model::children($id);
     for ($i = 0; $i < sizeof($children); $i++) {
         model::setKeys($children[$i], $old, $new);
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }