示例#1
0
文件: tree.php 项目: aikianapa/aiki
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);
}
示例#2
0
文件: kiDom.php 项目: aikianapa/aiki
 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);
 }
示例#3
0
function tagTree_find($branch = array(), $id = "", $parent = null)
{
    $res = false;
    if ($id > "") {
        foreach ($branch as $key => $val) {
            if ($val["id"] == $id) {
                $val["parent"] = $parent;
                $val["idx"] = $key;
                if (isset($val["children"])) {
                    $val["children"] = $val["children"][0];
                }
                $res = $val;
                return $res;
            } else {
                if (isset($val["children"]) && $res == false) {
                    $parent = $val["id"];
                    $res = tagTree_find($val["children"][0], $id, $parent);
                }
            }
        }
    }
    return $res;
}