Exemple #1
0
function tree__getajax()
{
    $tree = aikiReadTree($_GET["from"]);
    if (!isset($_GET["item"])) {
        $tree = $tree["tree"];
    } else {
        $tree = tagTree_find($tree["tree"], $_GET["item"]);
    }
    return json_encode($tree);
}
Exemple #2
0
 function tagTreeUl($Item = array())
 {
     $this->contentSetAttributes($Item);
     $name = $this->attr("from");
     $item = $this->attr("item");
     $nobranch = $this->attr("branch");
     $parent = $this->attr("parent");
     if ($parent == "true" or $parent == "1" or $parent == "") {
         $parent = true;
     } else {
         $parent = false;
     }
     $that = $this->clone();
     $tree = aikiReadTree($name);
     $html = $this->html();
     $this->html("");
     $id = "";
     if ($item > "") {
         $branch = tagTree_find($tree["tree"], $item);
         if ($branch !== false) {
             $tree["tree"] = $branch["children"];
         } else {
             $id = $item;
         }
     }
     if (!isset($branch) or $branch !== $Item) {
         $_SESSION["tree_idx"] = 0;
         $_SESSION["tmp_srcTree"] = $Item;
         $this->tagTreeUl_step($tree["tree"], $html, $id, $nobranch, $Item, $that);
         if ($_SESSION["tmp_tagTree"] == false) {
             $tpl = aikiFromString($html);
             $tpl->contentSetData($branch);
             $this->append($tpl);
         }
         unset($_SESSION["tmp_tagTree"], $_SESSION["tmp_srcTree"]);
     }
     unset($_SESSION["tree_idx"], $p, $html);
 }
Exemple #3
0
function aikiFindTreeData($branch, $field, $value, $parent = null)
{
    if (is_string($branch)) {
        $branch = aikiReadTree($branch)["tree"];
    }
    $res = false;
    foreach ($branch as $key => $val) {
        $val["parent"] = $parent;
        $val["idx"] = $key;
        if ($val[$field] == $value) {
            if (isset($val["children"])) {
                $val["children"] = $val["children"][0];
            }
            $res = $val;
            return $res;
        } else {
            if (isset($val["children"]) && $res == false) {
                $res = aikiFindTreeData($val["children"][0], $field, $value, $val["id"]);
            }
        }
    }
    return $res;
}