• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getTree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: admin

		public function admin() {
// 			$category = D ( 'Category' );
// 			$data = $category->select();
			
// 			load('@.tree');
// 			$data = getTree( $data );
					
// 			$this->assign ( 'data', $data );
// 			$this->display( 'admin' );

			import ('ORG.Util.Page');
			$cate = D('Category');
			$count = $cate->count();
			$page = new Page ($count, 11);
			$page->setConfig('header', '个分类');
			$show = $page->show();
			$this->assign('show', $show);
			$data = $cate->select();
			// 加载函数文件
			load ( '@.tree' );
			// 生成树状结构
			$data = getTree ( $data );
			// 截取之后的数组
			$list = array_slice ( $data, $page->firstRow, $page->listRows );
			// 分配数组数据
			$this->assign ( 'data', $list );
			// 显示模板
			$this->display ( 'admin' );
		}
开发者ID:uhgy,项目名称:phppractice,代码行数:29,代码来源:CategoryAction.class.php


示例2: getTree

function getTree($parentid, &$array_cat, $separator = "")
{
    global $mainframe, $option;
    $order = '';
    $filter_order = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', '', 'cmd');
    $filter_order_Dir = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
    // ensure we have a valid value for filter_order
    if (!in_array($filter_order, array('ordering', 'id', 'parentid', 'name'))) {
        $filter_order = 'parentid';
    }
    if ($filter_order == 'ordering') {
        $order = ' ORDER BY parentid,ordering,name ' . $filter_order_Dir;
    } elseif ($filter_order == 'name') {
        $order = ' ORDER BY parentid,name ' . $filter_order_Dir;
    } else {
        $order = ' ORDER BY parentid, id DESC ';
    }
    $db =& JFactory::getDBO();
    $query = ' SELECT id, parentid, name, ordering, published FROM #__w_categories ' . ' WHERE parentid = ' . $parentid . ' ' . $order;
    $db->setQuery($query);
    $cats = $db->loadObjectList();
    if ($cats == NULL) {
        return NULL;
    } else {
        $i = 1;
        foreach ($cats as $cat) {
            $cat->name_display = $separator . $i . ". " . $cat->name;
            $cat->parent[$i] = $cat->name;
            $array_cat[] = $cat;
            getTree($cat->id, $array_cat, "    " . $separator . $i . ".");
            $i++;
        }
    }
}
开发者ID:geilin,项目名称:jooomlashop,代码行数:34,代码来源:functions.php


示例3: oui_prefs_cat_article_list

function oui_prefs_cat_article_list($name, $val)
{
    $rs = getTree('root', 'article', "title != 'default' ORDER BY id, title");
    if ($rs) {
        return treeSelectInput($name, $rs, $val);
    }
    return gtxt('no_categories_exist');
}
开发者ID:NicolasGraph,项目名称:oui_prefs_functions,代码行数:8,代码来源:cat_article_list.php


示例4: oui_prefs_category_list

function oui_prefs_category_list($name, $val)
{
    $rs = getTree('root', '');
    if ($rs) {
        return treeSelectInput($name, $rs, $val);
    }
    return gtxt('no_categories_exist');
}
开发者ID:NicolasGraph,项目名称:oui_prefs_functions,代码行数:8,代码来源:category_list.php


示例5: edit

 /**
  * edit data page
  * @param int id
  * @return view
  */
 public function edit($id)
 {
     $categoryData = Category::get();
     $ids = getChild($categoryData, $id);
     $ids[] = $id;
     $category = getTree($categoryData);
     $info = Category::findOrFail($id);
     return view('admin.category.edit', compact('ids', 'category', 'info'));
 }
开发者ID:Jokeramc,项目名称:amc,代码行数:14,代码来源:CategoryController.php


示例6: linkcategory_popup

function linkcategory_popup($cat = "")
{
    $arr = array('');
    $rs = getTree("root", "link");
    if ($rs) {
        return treeSelectInput("category", $rs, $cat);
    }
    return false;
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:9,代码来源:txp_link.php


示例7: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     //获取商品类型
     $type_list = Type::all();
     //获取商品分类
     $categoryData = Category::get();
     $cate_list = getTree($categoryData);
     return view('admin.goods.create', compact('type_list', 'cate_list'));
 }
开发者ID:Jokeramc,项目名称:amc,代码行数:14,代码来源:GoodController.php


示例8: getTree

 function getTree($parent = NULL)
 {
     $section = new Section();
     $section->where('parent_section', $parent)->get();
     $line = array();
     foreach ($section as $item) {
         $children = getTree($item->id);
         $line[] = count($children) > 0 ? array('id' => $item->id, 'description' => $item->name, 'line' => $children) : array('id' => $item->id, 'description' => $item->name);
     }
     return $line;
 }
开发者ID:kabircse,项目名称:Codeigniter-Egypt,代码行数:11,代码来源:section_editor.php


示例9: getTree

function getTree($data, $cid = 0) {
	static $tree = array();
	foreach ( $data as $key => $value ) {
		if ($value ['cid'] == $cid) {
			$tree [] = $value;
			unset ($data [$key] );
			getTree( $data, $value['id'] );
		}
	}
	return $tree;
}
开发者ID:uhgy,项目名称:phppractice,代码行数:11,代码来源:tree.php


示例10: getTree

function getTree($list, $parent_id = 0, $lev = 0)
{
    static $tree = [];
    foreach ($list as $key => $value) {
        if ($value['parent_id'] == $parent_id) {
            $value['lev'] = $lev;
            $tree[] = $value;
            getTree($list, $value['id'], $lev + 1);
        }
    }
    return $tree;
}
开发者ID:Jokeramc,项目名称:amc,代码行数:12,代码来源:helpers.php


示例11: getTree

function getTree($arr, $pid = 0, $deep)
{
    static $tree = array();
    foreach ($arr as $row) {
        if ($row['parent_id'] == $pid) {
            $row['deep'] = $deep;
            $tree[] = $row;
            getTree($arr, $row['cat_id'], $deep + 1);
        }
    }
    return $tree;
}
开发者ID:holyCoco,项目名称:phpdemo,代码行数:12,代码来源:tree_view.php


示例12: sidebar

 public function sidebar()
 {
     header("Content-type:text/html;charset=utf-8");
     if (!access(C('FM_content'))) {
         $this->error(C('access_error'));
         return;
     }
     $Column = M('Column');
     $columns = $Column->field('id,name,parentid,class,sort')->select();
     //         var_dump($columns);
     $this->assign('columns', getTree($columns));
     $this->display();
 }
开发者ID:breaktian,项目名称:smartcms,代码行数:13,代码来源:ContentController.class.php


示例13: getTree

function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0)
{
    global $link;
    $children = array();
    if (isset($resultParents[$id_category]) and sizeof($resultParents[$id_category]) and ($maxDepth == 0 or $currentDepth < $maxDepth)) {
        foreach ($resultParents[$id_category] as $subcat) {
            $children[] = getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1);
        }
    }
    if (!isset($resultIds[$id_category])) {
        return false;
    }
    return array('id' => $id_category, 'name' => $resultIds[$id_category]['name'], 'children' => $children);
}
开发者ID:yiuked,项目名称:tmcart,代码行数:14,代码来源:product_to_category.php


示例14: image_edit

function image_edit($message = '', $id = '')
{
    if (!$id) {
        $id = gps('id');
    }
    global $txpcfg, $img_dir;
    pagetop('image', $message);
    $categories = getTree("root", "image");
    $rs = safe_row("*", "txp_image", "id='{$id}'");
    if ($rs) {
        extract($rs);
        echo startTable('list'), tr(td('<img src="' . hu . $img_dir . '/' . $id . $ext . '" height="' . $h . '" width="' . $w . '" alt="" />' . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'image_replace', 'image', $id))), tr(td(join('', array($thumbnail ? '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . '" alt="" />' . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', 'image', $id))))), function_exists("imagecreatefromjpeg") ? thumb_ui($id) : '', tr(td(form(graf(gTxt('image_name') . br . fInput('text', 'name', $name, 'edit')) . graf(gTxt('image_category') . br . treeSelectInput('category', $categories, $category)) . graf(gTxt('alt_text') . br . fInput('text', 'alt', $alt, 'edit', '', '', 50)) . graf(gTxt('caption') . br . text_area('caption', '100', '400', $caption)) . graf(fInput('submit', '', gTxt('save'), 'publish')) . hInput('id', $id) . eInput('image') . sInput('image_save')))), endTable();
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:14,代码来源:txp_image.php


示例15: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //获取当前角色的信息
     $role = Models\Role::find($id);
     //获取当前角色所拥有的权限的ID
     $nowAuths = array();
     foreach ($role->auths as $auth) {
         $nowAuths[] = $auth->id;
     }
     //获取所有权限的信息
     $auths = Models\Auth::getAuth();
     $auths = getTree($auths);
     return view('admin.role.edit', compact('role', 'auths', 'nowAuths'));
 }
开发者ID:honxin,项目名称:studentclub,代码行数:20,代码来源:RoleController.php


示例16: getTree

function getTree(&$data, $pid = 0, $count = 1)
{
    if (!isset($data['odl'])) {
        $data = array('new' => array(), 'odl' => $data);
    }
    foreach ($data['odl'] as $k => $v) {
        if ($v['pid'] == $pid) {
            $v['level'] = $count;
            $data['new'][] = $v;
            unset($data['odl'][$k]);
            getTree($data, $v['id'], $count + 1);
        }
    }
    return $data['new'];
}
开发者ID:Ajh100,项目名称:manage,代码行数:15,代码来源:function.php


示例17: getTree

 function getTree($kat_id, $pic_id)
 {
     include '../../share/global_config.php';
     include $sr . '/bin/share/db_connect1.php';
     $result2 = mysql_query("SELECT kat_id, kategorie FROM {$table4} WHERE parent='" . $kat_id . "' ORDER BY kategorie");
     while ($einzeln = @mysql_fetch_assoc($result2)) {
         if (hasChildKats($einzeln['kat_id'], $pic_id)) {
             $KA = $einzeln['kat_id'];
             $result3 = mysql_query("DELETE FROM {$table10} WHERE pic_id = '{$pic_id}' AND kat_id = '{$KA}'");
             $KAE = getTree($einzeln['kat_id'], $pic_id);
         } else {
             $KA = $einzeln['kat_id'];
             $result4 = mysql_query("DELETE FROM {$table10} WHERE pic_id = '{$pic_id}' AND kat_id = '{$KA}'");
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:pic2base-svn,代码行数:16,代码来源:update_kat_remove.php


示例18: getTree

function getTree($nodes)
{
    $nodeHtml = '<ul>';
    foreach ($nodes as $node) {
        $id = $node['id'];
        $icon = $node['type'] === 'field' ? 'jstree-file' : 'jstree-folder';
        $nodeHtml .= '<li id="' . $id . '" data-jstree=\'{"icon":"' . $icon . '"}\'>';
        $nodeHtml .= $node['label'];
        if (count($node['field_definitions']) > 0) {
            $nodeHtml .= getTree($node['field_definitions']);
        }
        $nodeHtml .= '</li>';
    }
    $nodeHtml .= '</ul>';
    return $nodeHtml;
}
开发者ID:jackblackCH,项目名称:polylang-supertext,代码行数:16,代码来源:settings-custom-fields.php


示例19: getTree

function getTree($parentID, $level)
{
    global $config;
    $childCount = 0;
    $cCounter = 1;
    if ($children = findChildren($parentID)) {
        $childCount = count($children);
        $cCounter = 1;
        foreach ($children as $value) {
            for ($x = 0; $x < $level; $x++) {
                //echo "&nbsp;";
            }
            $galleryNameText = $_SESSION['galleriesData'][$value]['name'];
            //$galleryNameText = str_replace("'",'\'',$galleryNameText);
            //$galleryNameText = str_replace('"','&quot;',$galleryNameText);
            $galleryNameText = str_replace('\\', '', $galleryNameText);
            $galleryNameText = htmlspecialchars($galleryNameText);
            // New in 4.4.7
            /*
            $galleryNameText = str_replace('(','',$galleryNameText);
            $galleryNameText = str_replace(')','',$galleryNameText);
            $galleryNameText = str_replace('/','',$galleryNameText);
            $galleryNameText = str_replace(')','',$galleryNameText);
            */
            //$galleryNameText = cleanString($galleryNameText);
            if ($config['settings']['gallery_count'] and $_SESSION['galleriesData'][$value]['gallery_count']) {
                $galleryNameText .= " (" . $_SESSION['galleriesData'][$value]['gallery_count'] . ")";
            }
            if ($_SESSION['galleriesData'][$value]['password']) {
                $galleryNameText .= " <span class='treeLock'>&nbsp;&nbsp;&nbsp;</span>";
            }
            $linkto = $_SESSION['galleriesData'][$value]['linkto'];
            echo "{ \r\n\t\t\t\t\t\"attr\" : { \"id\" : \"galleryTree{$value}\" }, \r\n\t\t\t\t\t\"data\" : { \r\n\t\t\t\t\t\t\"title\" : \"{$galleryNameText}\", \r\n\t\t\t\t\t\t\"level\" : \"{$level}\", \r\n\t\t\t\t\t\t\"attr\" : { \"href\" : \"{$linkto}\" }, \r\n\t\t\t\t\t\t\"icon\" : \"\" \r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"children\" : [ ";
            if ($value) {
                getTree($value, $level + 1);
            }
            echo " ]";
            // ,\"state\" : \"closed\"
            echo "}";
            //echo "<br /><br />"; // For testing
            if ($cCounter < $childCount) {
                echo ",";
            }
            $cCounter++;
        }
    }
}
开发者ID:spencerlambert,项目名称:willie-php,代码行数:47,代码来源:tree.data.php


示例20: wet_article_partial_category_1

/**
 * Fiddle with the article's category selects
 */
function wet_article_partial_category_1($rs)
{
    static $cats = null;
    if ($cats == null) {
        $cats = getTree('root', 'article');
    }
    // Make radio buttons, not drop-downs
    $out = array();
    if ($cats) {
        foreach ($cats as $c) {
            $c = doSpecial($c);
            $id = 'wet_cat-' . $c['name'];
            $out[] = radio('Category1', $c['name'], $rs['Category1'] == $c['name'] ? '1' : '', 'cat-' . $c['name']) . "<label for='{$id}'>{$c['title']}</label>";
        }
    }
    return '<ul class="plain-list"><li>' . join('</li><li>', $out) . '</li></ul>';
}
开发者ID:rwetzlmayr,项目名称:wet_sample_partials_meta,代码行数:20,代码来源:wet_sample_partials_meta.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getTweets函数代码示例发布时间:2022-05-15
下一篇:
PHP getTranslation函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap