本文整理汇总了PHP中getTree函数的典型用法代码示例。如果您正苦于以下问题:PHP getTree函数的具体用法?PHP getTree怎么用?PHP getTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getTree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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' );
}
示例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++;
}
}
}
示例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');
}
示例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');
}
示例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'));
}
示例6: linkcategory_popup
function linkcategory_popup($cat = "")
{
$arr = array('');
$rs = getTree("root", "link");
if ($rs) {
return treeSelectInput("category", $rs, $cat);
}
return false;
}
示例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'));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
}
示例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'));
}