当前位置: 首页>>代码示例>>PHP>>正文


PHP build_tree函数代码示例

本文整理汇总了PHP中build_tree函数的典型用法代码示例。如果您正苦于以下问题:PHP build_tree函数的具体用法?PHP build_tree怎么用?PHP build_tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了build_tree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_delete

function do_delete()
{
    global $delete, $conn, $modul;
    if ($delete) {
        preg_match("/(.*)_(.*)/i", $modul, $alter_modul);
        if (isset($alter_modul[2])) {
            if ($alter_modul[2] == 'fields') {
                $sql = "SELECT title, c_default FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE id='" . $delete . "' ";
                $result = db_mysql_query($sql, $conn);
                $arr = db_mysql_fetch_array($result);
                if ($arr['c_default'] == '1') {
                    unset($delete);
                } else {
                    $sql = "ALTER TABLE " . $_SESSION['TABLE_PREFIX'] . $alter_modul[1] . " \n\t\t\t\t\t\t\t\t\tDROP COLUMN " . $arr['title'] . " ";
                    db_mysql_query($sql, $conn);
                }
            }
            if ($alter_modul[2] == 'tree') {
                $data = array();
                $sql = "SELECT id, title, id_parent, sort_order FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE c_active = '1' ORDER BY sort_order ASC ";
                $result = db_mysql_query($sql, $conn);
                while ($arr = db_mysql_fetch_array($result)) {
                    $data[$arr['id']] = $arr;
                }
                delete_tree($alter_modul[1], build_tree($data, $delete), $delete);
                $sql = "DELETE FROM " . $_SESSION['TABLE_PREFIX'] . $alter_modul[1] . " WHERE id_tree = '" . $delete . "' ";
                db_mysql_query($sql, $conn);
            }
        }
        if (isset($delete)) {
            $sql = "DELETE FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE id = '" . $delete . "' ";
            db_mysql_query($sql, $conn);
        }
    }
}
开发者ID:entire-media,项目名称:comator,代码行数:35,代码来源:edit.inc.php

示例2: test_compareTree

 /**
  * @dataProvider mydataProvider
  */
 public function test_compareTree($expr1, $expr2, $result)
 {
     global $typeOfVars;
     $tree1 = build_tree($expr1, $typeOfVars);
     $tree2 = build_tree($expr2, $typeOfVars);
     $this->assertEquals($result, is_tree_equal($tree1, $tree2, FALSE));
 }
开发者ID:anhptvolga,项目名称:normalandcomp,代码行数:10,代码来源:test_is_tree_equal.php

示例3: generate_static

function generate_static($out_dir)
{
    global $tree, $base, $docs_path, $output_path, $options, $mode, $multilanguage, $output_language;
    $mode = 'Static';
    if ($out_dir === '') {
        $output_path = $base . '/static';
    } else {
        if (substr($out_dir, 0, 1) !== '/') {
            $output_path = $base . '/' . $out_dir;
        } else {
            $output_path = $out_dir;
        }
    }
    clean_copy_assets($output_path);
    build_tree();
    if (!$multilanguage) {
        generate_static_branch($tree, '');
    } else {
        foreach ($options['languages'] as $languageKey => $language) {
            $output_language = $languageKey;
            generate_static_branch($tree[$languageKey], $languageKey);
        }
    }
    $index = $docs_path . '/index.md';
    if (is_file($index)) {
        $index = generate_page($index);
        file_put_contents($output_path . '/index.html', $index);
    }
}
开发者ID:cdlabal,项目名称:doc,代码行数:29,代码来源:static.php

示例4: process_each_expression

function process_each_expression($filename, $filegv)
{
    try {
        $exp = readExp($filename);
        $tree = build_tree($exp);
        // преобразовать
        $tree->ptonewchild = null;
        $tree->convert($tree);
        while ($tree->ptonewchild != null) {
            $tree = $tree->ptonewchild;
            $tree->ptonewchild = null;
            $tree->convert($tree);
        }
        // печать DOT файл
        $file = fopen($filegv, "w");
        fwrite($file, "digraph {\n");
        print_tree_to_dot($file, $tree);
        fwrite($file, '}');
        fclose($file);
        return $tree;
    } catch (Exception $e) {
        echo "In file {$filename}: " . $e->getMessage() . " \n";
        return null;
    }
}
开发者ID:anhptvolga,项目名称:normalandcomp,代码行数:25,代码来源:main.php

示例5: build_tree

 /**
  * Build tree
  *
  * Creates adjacency list based on group id or slug
  *
  * @param mixed $group      Group id or slug
  * @param array $attributes Any attributes
  * @param array &$tree      Tree array
  *
  * @return string
  */
 function build_tree($group, $attributes = array(), &$tree = array())
 {
     if (empty($tree)) {
         $CI =& get_instance();
         $CI->load->library('adjacency_list');
         $tree = $CI->adjacency_list->get_all($group);
         $tree = parse_children($tree);
     }
     foreach (array('start_tag' => '<li>', 'end_tag' => '</li>', 'sub_start_tag' => '<ul>', 'sub_end_tag' => '</ul>') as $key => $val) {
         $atts[$key] = !isset($attributes[$key]) ? $val : $attributes[$key];
         unset($attributes[$key]);
     }
     $output = '';
     if (!empty($tree)) {
         foreach ($tree as &$leaf) {
             $leaf['name'] = htmlspecialchars($leaf['name'], ENT_QUOTES, 'UTF-8');
             if (isset($leaf['children']) && !empty($leaf['children'])) {
                 $output .= $atts['start_tag'] . '<a href="' . $leaf['url'] . '">' . $leaf['name'] . '</a>';
                 $output .= $atts['sub_start_tag'] . build_tree($group, $attributes, $leaf['children']) . $atts['sub_end_tag'];
                 $output .= $atts['end_tag'];
             } else {
                 $output .= $atts['start_tag'] . '<a href="' . $leaf['url'] . '">' . $leaf['name'] . '</a>' . $atts['end_tag'];
             }
         }
     }
     return $output;
 }
开发者ID:eboominathan,项目名称:CodeIgniter-Adjacency-List,代码行数:38,代码来源:adjacency_list_helper.php

示例6: build_tree

function build_tree($person, $henry, $level, $total)
{
    // Recursive routine that does the major work.
    global $coparents, $descendants;
    $maxlevel = 15;
    $count = 0;
    $family = find_family($person);
    while (isset($family[$count][0])) {
        $coparent = $family[$count][1];
        $coparents++;
        printf("<li>~ %s\n<ul class=\"descendants\">\n", get_name_and_dates('', $coparent));
        while (isset($family[$count][1]) && $family[$count][1] == $coparent) {
            $henry[$level] = $count + 1;
            $descendants++;
            printf("<li>%s %s", get_henry($henry, $level), get_name_and_dates('', $family[$count][0]));
            if ($level == $maxlevel && has_descendants($family[$count][0])) {
                print " <strong>+</strong>";
            }
            print "</li>\n";
            if ($level < $maxlevel) {
                // point of recursion
                build_tree($family[$count][0], $henry, $level + 1, $total);
            }
            $count++;
        }
        echo "</ul></li>\n";
    }
    return;
}
开发者ID:AlexSnet,项目名称:yggdrasil-genealogy,代码行数:29,代码来源:descendants.php

示例7: test_convert

 /**
  * @dataProvider mydataProvider
  */
 public function test_convert($expr1, $expr2)
 {
     global $typeOfVars;
     $tree1 = build_tree($expr1, $typeOfVars);
     $tree2 = build_tree($expr2, $typeOfVars);
     $tree1->ptonewchild = null;
     $tree1->convert($tree1);
     while ($tree1->ptonewchild != null) {
         $tree1 = $tree1->ptonewchild;
         $tree1->ptonewchild = null;
         $tree1->convert($tree1);
     }
     $file = fopen("tree2.gv", "w");
     fwrite($file, "digraph {\n");
     print_tree_to_dot($file, $tree2);
     fwrite($file, '}');
     fclose($file);
     $tree2->ptonewchild = null;
     $tree2->convert($tree2);
     while ($tree2->ptonewchild != null) {
         $tree2 = $tree2->ptonewchild;
         $tree2->ptonewchild = null;
         $tree2->convert($tree2);
     }
     $file = fopen("tree1.gv", "w");
     fwrite($file, "digraph {\n");
     print_tree_to_dot($file, $tree1);
     fwrite($file, '}');
     fclose($file);
     $this->assertTrue(is_tree_equal($tree1, $tree2, TRUE));
     $tree1->delete_childrens();
     $tree2->delete_childrens();
     unset($tree1);
     unset($tree2);
 }
开发者ID:anhptvolga,项目名称:normalandcomp,代码行数:38,代码来源:test_convert.php

示例8: test_openbracket

 /**
  * @dataProvider mydataProvider
  */
 public function test_openbracket($expr1, $expr2)
 {
     global $typeOfVars;
     $tree1 = build_tree($expr1, $typeOfVars);
     $tree2 = build_tree($expr2, $typeOfVars);
     $opened = $tree1->open_bracket();
     $this->assertTrue(is_tree_equal($opened, $tree2, TRUE));
 }
开发者ID:anhptvolga,项目名称:normalandcomp,代码行数:11,代码来源:test_open_bracket.php

示例9: test_sortchild

 /**
  * @dataProvider mydataProvider
  */
 public function test_sortchild($expr1, $expr2)
 {
     global $typeOfVars;
     $tree1 = build_tree($expr1, $typeOfVars);
     $tree2 = build_tree($expr2, $typeOfVars);
     $tree1->sort_childrens();
     $tree2->sort_childrens();
     $this->assertTrue(is_tree_equal($tree1, $tree2, FALSE));
 }
开发者ID:anhptvolga,项目名称:normalandcomp,代码行数:12,代码来源:test_sort_childrens.php

示例10: single

 public function single($id)
 {
     $categorylist = M('article_category')->where(array("lang" => LANG_SET))->select();
     $tree = build_tree(0, $categorylist);
     $this->assign('categorylist', $tree);
     // 赋值数据集
     $article = M('article')->where("id='{$id}'")->select();
     $article[0]["category"] = M('article_category')->where(array("id" => $article[0]['category_id']))->select();
     $this->article = $article;
     $this->assign('currcategory', $article[0]["category"][0]);
     // 赋值数据集
     $this->theme("default")->display('Article/single');
 }
开发者ID:songkang1,项目名称:tp_yining,代码行数:13,代码来源:IndexController.class.php

示例11: test_sortchild

 /**
  * @dataProvider mydataProvider
  */
 public function test_sortchild($expr1, $expr2)
 {
     global $typeOfVars;
     $tree1 = build_tree($expr1, $typeOfVars);
     $tree2 = build_tree($expr2, $typeOfVars);
     $tree1->convert_quine_mc_cluskey();
     $tmp;
     if (get_class($tree2) != 'qtype_correctwriting_or_logic_operator') {
         $tmp = new qtype_correctwriting_or_logic_operator();
         array_push($tmp->childrens, $tree2);
         $tree2 = $tmp;
     }
     $this->assertTrue(is_tree_equal($tree1, $tree2, TRUE));
 }
开发者ID:anhptvolga,项目名称:normalandcomp,代码行数:17,代码来源:test_convert_quine_mc_cluskey.php

示例12: build_tree

function build_tree(array &$elements, $id_parent = 0)
{
    $branch = array();
    foreach ($elements as &$element) {
        if ($element['id_parent'] == $id_parent) {
            $children = build_tree($elements, $element['id']);
            if ($children) {
                $element['children'] = $children;
            }
            $branch[$element['id']] = $element;
            unset($element);
        }
    }
    return $branch;
}
开发者ID:entire-media,项目名称:comator,代码行数:15,代码来源:tree.inc.php

示例13: single

 public function single($id)
 {
     $categorylist = M('product_category')->where(array("lang" => LANG_SET))->order(array("order" => "asc", "created" => "desc"))->select();
     $tree = build_tree(0, $categorylist);
     $this->assign('categorylist', $tree);
     // 赋值数据集
     $product = M('product')->where("id='{$id}'")->select();
     $arr = explode("||", $product[0]['img']);
     $product[0]["img"] = $arr;
     $this->product = $product;
     $currcategory = M('product_category')->where(array("id" => $product[0]['category_id']))->select();
     $after = M("product")->where("id>" . $id)->order('id asc')->limit('1')->find();
     $this->assign('after', $after);
     // 赋值数据集
     $this->assign('currcategory', $currcategory[0]);
     // 赋值数据集
     $this->theme("default")->display('Product/single');
 }
开发者ID:songkang1,项目名称:tp_yining,代码行数:18,代码来源:IndexController.class.php

示例14: build_tree

 function build_tree($comments)
 {
     if ($comments) {
         $result = "<ul>\n";
         foreach ($comments as $comment) {
             $result .= "<li>";
             $result .= $comment->id;
             $result .= "</li>\n";
             //                    $count = Comment::findorFail(2)->childrens;
             $children = Comment::findorFail($comment->id)->childrens;
             if (isset($children)) {
                 $result .= build_tree($children);
             }
             $result .= "</li>\n";
         }
         $result .= "</ul>";
         return $result;
     }
 }
开发者ID:RapidRocket,项目名称:comments.app,代码行数:19,代码来源:CommentsController.php

示例15: build_tree

function build_tree($category_id, $lang, $addon)
{
    $CI =& get_instance();
    $rtrn = '<ul id="cat_' . $category_id . '" style="display:none;">';
    $CI->db->order_by('name', 'asc');
    // Сортируем названию
    $CI->db->order_by('pos', 'asc');
    // Сортируем по позиции
    $CI->db->where('lang', $lang);
    // Берем только русские
    $CI->db->where('cat_id', $category_id);
    $data = $CI->db->get('categories')->result_array();
    foreach ($data as $item) {
        $rtrn .= '<li ' . $addon . '><a href="' . base_url() . 'ru/catalog/' . $item['url'] . '"  title="' . $item['meta_title'] . '"> <i class="fa fa-angle-right" style="margin-right: 17px; color: c8c8c8; display: inline;"></i> ' . $item['name'] . '</a>';
        if (count($CI->db->where('cat_id', $item['id'])->get('categories')->result()) > 0) {
            $rtrn .= '<span style="position:absolute; right:0px; top:7px; display:block; float:right; clear:none; z-index:1; width:27px; height:27px; cursor:pointer; font-weight:bold; color:#bcbcbc; font-size:12px;"><i class="fa fa-plus-circle"></i></span>';
        }
        $rtrn .= '' . build_tree($item['id'], $lang, "style=\"padding-left:10px;\"") . '
				</li>';
    }
    return $rtrn . '</ul>';
}
开发者ID:xdevteam,项目名称:renovation,代码行数:22,代码来源:dev_helper.php


注:本文中的build_tree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。