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

PHP tree_to_list函数代码示例

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

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



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

示例1: fetchList

 public function fetchList()
 {
     $menuList = $this->order('sort')->select();
     $tree = list_to_tree($menuList);
     $list = tree_to_list($tree);
     return $list;
 }
开发者ID:yunzhiclub,项目名称:wemall,代码行数:7,代码来源:CustomMenuModel.class.php


示例2: node

 public function node()
 {
     $node_model = M("Node");
     if (!empty($_POST['eq_pid'])) {
         $eq_pid = $_POST['eq_pid'];
     } else {
         $eq_pid = $node_model->where('pid=0')->order('sort asc')->getField('id');
     }
     //dump($node_model -> select());
     $node_list = $node_model->order('sort asc')->select();
     $node_list = tree_to_list(list_to_tree($node_list, $eq_pid));
     $node_list = rotate($node_list);
     //dump($node_list);
     $node_list = implode(",", $node_list['id']) . ",{$eq_pid}";
     $where['id'] = array('in', $node_list);
     $menu = $node_model->field('id,pid,name,url')->where($where)->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('eq_pid', $eq_pid);
     $list = tree_to_list($tree);
     $this->assign('node_list', $list);
     //$this->assign('menu',sub_tree_menu($list));
     $role = M("Role")->order('sort asc')->select();
     $this->assign('list', $role);
     $list = $node_model->where('pid=0')->order('sort asc')->getField('id,name');
     $this->assign('groupList', $list);
     $this->display();
 }
开发者ID:2ger,项目名称:trunk,代码行数:27,代码来源:RoleAction.class.php


示例3: index

 public function index()
 {
     $widget['date'] = true;
     $this->assign("widget", $widget);
     $this->assign('user_id', get_user_id());
     $auth = $this->config['auth'];
     $this->assign('auth', $auth);
     if ($auth['admin']) {
         $node = D("Dept");
         $dept_id = get_dept_id();
         $dept_name = get_dept_name();
         $menu = array();
         $dept_menu = $node->field('id,pid,name')->where("is_del=0")->order('sort asc')->select();
         $dept_tree = list_to_tree($dept_menu, $dept_id);
         $count = count($dept_tree);
         if (empty($count)) {
             /*获取部门列表*/
             $html = '';
             $html = $html . "<option value='{$dept_id}'>{$dept_name}</option>";
             $this->assign('dept_list', $html);
             /*获取人员列表*/
             $where['dept_id'] = array('eq', $dept_id);
             $emp_list = D("User")->where($where)->getField('id,name');
             $this->assign('emp_list', $emp_list);
         } else {
             /*获取部门列表*/
             $this->assign('dept_list', select_tree_menu($dept_tree));
             $dept_list = tree_to_list($dept_tree);
             $dept_list = rotate($dept_list);
             $dept_list = $dept_list['id'];
             /*获取人员列表*/
             $where['dept_id'] = array('in', $dept_list);
             $emp_list = D("User")->where($where)->getField('id,name');
             $this->assign('emp_list', $emp_list);
         }
     }
     $map = $this->_search();
     if ($auth['admin']) {
         if (empty($map['dept_id'])) {
             if (!empty($dept_list)) {
                 $map['dept_id'] = array('in', array_merge($dept_list, array($dept_id)));
             } else {
                 $map['dept_id'] = array('eq', $dept_id);
             }
         }
     } else {
         $map['user_id'] = get_user_id();
     }
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $model = D("WorkLog");
     if (!empty($model)) {
         $this->_list($model, $map);
     }
     $this->display();
 }
开发者ID:hongweipeng,项目名称:oa,代码行数:57,代码来源:WorkLogAction.class.php


示例4: getMenuList

 public function getMenuList()
 {
     $menuTree = $this->getMenuTree(null, $where, 0, 3);
     $menuList = tree_to_list($menuTree, 0, '_son', '_level', 'order');
     //设置总条数
     $this->totalCount = count($menuList);
     //截取该页的信息
     $menuList = array_slice($menuList, ($this->p - 1) * $this->pageSize, $this->pageSize);
     return $menuList;
 }
开发者ID:HebutJipeng,项目名称:Ethan-Wechat,代码行数:10,代码来源:MenuModel.class.php


示例5: del_tag

 function del_tag($tag_id)
 {
     $model = M("UserTag");
     $tag_list = tree_to_list(list_to_tree($this->get_tag_list("id,pid,name"), $tag_id));
     $tag_list = rotate($tag_list);
     $tag_list = implode(",", $tag_list['id']) . ",{$tag_id}";
     $where['id'] = array('in', $tag_list);
     $this->where($where)->delete();
     $this->_del_data_by_tag($tag_list);
 }
开发者ID:hongweipeng,项目名称:oa,代码行数:10,代码来源:UserTagModel.class.php


示例6: get_emp_list_by_dept_id

 private function get_emp_list_by_dept_id($id)
 {
     $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
     $dept = rotate($dept);
     $dept = implode(",", $dept['id']) . ",{$id}";
     $model = M("User");
     $where['dept_id'] = array('in', $dept);
     $data = $model->where($where)->select();
     return $data;
 }
开发者ID:TipTimesPHP,项目名称:tyj_oa_cp,代码行数:10,代码来源:SystemFolderModel.class.php


示例7: read

 function read()
 {
     $id = $_REQUEST['id'];
     $model = M("Dept");
     $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
     $dept = rotate($dept);
     $dept = implode(",", $dept['id']) . ",{$id}";
     $model = D("UserView");
     $where['is_del'] = array('eq', '0');
     $where['dept_id'] = array('in', $dept);
     $data = $model->where($where)->select();
     $this->ajaxReturn($data, "", 1);
 }
开发者ID:hongweipeng,项目名称:oa,代码行数:13,代码来源:StaffAction.class.php


示例8: _assign_badge_count

 protected function _assign_badge_count()
 {
     $node_list = D("Node")->access_list();
     $system_folder_menu = D("SystemFolder")->get_folder_menu();
     $user_folder_menu = D("UserFolder")->get_folder_menu();
     $node_list = array_merge($node_list, $system_folder_menu, $user_folder_menu);
     foreach ($node_list as $val) {
         $badge_function = $val['badge_function'];
         if (!empty($badge_function) and function_exists($badge_function) and $badge_function != 'badge_sum') {
             if ($badge_function == 'badge_count_system_folder' or $badge_function == 'badge_count_user_folder') {
                 $badge_count[$val['id']] = $badge_function($val['fid']);
             } else {
                 $badge_count[$val['id']] = $badge_function();
             }
         }
     }
     //$node_tree = list_to_tree($node_list);
     foreach ($node_list as $key => $val) {
         if ($val['badge_function'] == 'badge_sum') {
             $child_menu = list_to_tree($node_list, $val['id']);
             $child_menu = tree_to_list($child_menu);
             //dump($child_menu);
             $child_menu_id = rotate($child_menu);
             $count = 0;
             if (isset($child_menu_id['id'])) {
                 $child_menu_id = $child_menu_id['id'];
                 $count = 0;
                 foreach ($child_menu_id as $k1 => $v1) {
                     if (!empty($badge_count[$v1])) {
                         $count += $badge_count[$v1];
                     }
                 }
             }
             $badge_sum[$val['id']] = $count;
         }
     }
     if (!empty($badge_count)) {
         if (!empty($badge_sum)) {
             $total = $badge_count + $badge_sum;
         } else {
             $total = $badge_count;
         }
         $this->assign('badge_count', $total);
     }
 }
开发者ID:HappyCodingTogether,项目名称:CompanyEmailSystem,代码行数:45,代码来源:HomeController.class.php


示例9: node

 public function node()
 {
     $node = M("Node");
     if (!empty($_POST['s_pid'])) {
         $pid = $_POST['s_pid'];
     } else {
         $pid = $node->where('pid=0')->order('sort asc')->getField('id');
     }
     $menu = array();
     $menu = $node->field('id,pid,name,check_auth,"#" as url')->order('sort asc')->select();
     $tree = list_to_tree($menu, $pid);
     $this->assign('pid', $pid);
     $list = tree_to_list($tree);
     $this->assign('node_list', $list);
     //$this->assign('menu',sub_tree_menu($list));
     $role = M("Role")->select();
     $this->assign('list', $role);
     $list = $node->where('pid=0')->order('sort asc')->getField('id,name');
     $this->assign('groupList', $list);
     $this->display();
 }
开发者ID:yunsite,项目名称:smeoa,代码行数:21,代码来源:RoleAction.class.php


示例10: fetchSubMenu

 public function fetchSubMenu()
 {
     $menuInfo = $this->_fetchCurrentMenuInfo();
     //如果无此菜单,则证明为ajax方法.直接退出
     if ($menuInfo == false) {
         return;
     }
     $id = $menuInfo['id'];
     $pid = $menuInfo['pid'];
     /*
      * 有记录,查找出目录结构
      */
     $adminM = D('Admin/AdminMenu');
     $adminM->setCurrentMenuId($id);
     $menus = $adminM->fetchParetnsMenus();
     $subMenu = $adminM->fetchSubMenu($menus, 1, 2);
     $subMenu = tree_to_list($subMenu);
     //添加CURRENT,parent信息
     $subMenu = $this->_addCurrent($subMenu, $menus);
     $tree = list_to_tree($subMenu, $pk = 'id', $pid = 'pid', $child = '_child', $menus[1]);
     return '<ul class="nav nav-list">' . $this->_treeAddHtml($tree) . "</ul>";
 }
开发者ID:yunzhiclub,项目名称:wemall,代码行数:22,代码来源:MenuListController.class.php


示例11: ajaxRead

 function ajaxRead()
 {
     $type = $_REQUEST['type'];
     $id = $_REQUEST['id'];
     switch ($type) {
         case "company":
             $model = M("Dept");
             $dept = tree_to_list(list_to_tree(M("Dept")->select(), $id));
             $dept = rotate($dept);
             $dept = implode(",", $dept['id']) . ",{$id}";
             $model = M("User");
             $where['dept_id'] = array('in', $dept);
             $data = $model->where($where)->field('id,emp_name,dept_id,email')->select();
             break;
         case "rank":
             $model = M("User");
             $where['rank_id'] = array('eq', $id);
             $data = $model->where($where)->field('id,emp_name,email')->select();
             break;
         case "position":
             $model = M("User");
             $where['position_id'] = array('eq', $id);
             $data = $model->where($where)->field('id,emp_name,email')->select();
             break;
         case "personal":
             $model = M("FlowType");
             if ($id == "#") {
                 $id = "";
             }
             $where['group'] = array('eq', $id);
             $where['email'] = array('neq', '');
             $where['user_id'] = array('eq', get_user_id());
             $data = $model->where($where)->field('id,name as emp_name,email')->select();
             break;
         default:
     }
     if (true) {
         // 读取成功
         $this->ajaxReturn($data, "", 1);
     }
 }
开发者ID:uwitec,项目名称:semoa,代码行数:41,代码来源:FlowtypeAction.class.php


示例12: tree_to_list

/**
 * 将list_to_tree的树还原成列表
 * @param  array  $tree 原来的树
 * @param  string $child 孩子节点的键
 * @param  string $order 排序显示的键,一般是主键 升序排列
 * @param  array  $list 过渡用的中间数组,
 * @return array        返回排过序的列表数组
 * @author yangweijie <[email protected]>
 */
function tree_to_list($tree, $child = '_child', $order = 'id', &$list = array())
{
    if (is_array($tree)) {
        $refer = array();
        foreach ($tree as $key => $value) {
            $reffer = $value;
            if (isset($reffer[$child])) {
                unset($reffer[$child]);
                tree_to_list($value[$child], $child, $order, $list);
            }
            $list[] = $reffer;
        }
        $list = list_sort_by($list, $order, $sortby = 'asc');
    }
    return $list;
}
开发者ID:suhanyujie,项目名称:digitalOceanVps,代码行数:25,代码来源:function.php


示例13: _fetchMenuList

 /**
  * 取系统菜单列表,用于显示在上级菜单的OPTION
  * @return ARRAY 包括有所有菜单信息的二级数组
  * author:panjie [email protected]
  */
 private function _fetchMenuList()
 {
     $menuModel = new MenuModel();
     $data = $menuModel->getMenuTree(null, null, 0, 2);
     return tree_to_list($data, 0, '_son');
 }
开发者ID:HebutJipeng,项目名称:Ethan-Wechat,代码行数:11,代码来源:MenuController.class.php


示例14: select_tree_menu

function select_tree_menu($tree)
{
    $html = "";
    if (is_array($tree)) {
        $list = tree_to_list($tree);
        foreach ($list as $val) {
            $html = $html . "<option value='{$val['id']}'>" . str_pad("", $val['level'] * 3, "│") . "├─" . "{$val['name']}</option>";
        }
    }
    return $html;
}
开发者ID:TipTimesPHP,项目名称:tyj_oa,代码行数:11,代码来源:common.php


示例15: read

 function read()
 {
     $type = $_REQUEST['type'];
     $id = $_REQUEST['id'];
     switch ($type) {
         case "company":
             $model = M("Dept");
             $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
             $dept = rotate($dept);
             $dept = implode(",", $dept['id']) . ",{$id}";
         case "emp":
             $model = M("Dept");
             $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
             $dept = rotate($dept);
             $dept = implode(",", $dept['id']) . ",{$id}";
             $sql = D("UserView")->buildSql();
             $model = new Model();
             $where['dept_id'] = array('in', $dept);
             $where['is_del'] = array('eq', 0);
             $data = $model->table($sql . "a")->where($where)->select();
             break;
         case "rank":
             $sql = D("UserView")->buildSql();
             $model = new Model();
             $where['rank_id'] = array('eq', $id);
             $where['is_del'] = array('eq', 0);
             $data = $model->table($sql . "a")->where($where)->select();
             break;
         case "position":
             $sql = D("UserView")->buildSql();
             $model = new Model();
             $where['position_id'] = array('eq', $id);
             $where['is_del'] = array('eq', 0);
             $data = $model->table($sql . "a")->where($where)->select();
             break;
         case "personal":
             $model = D("UserTag");
             if ($id == "#") {
                 $data = $model->get_data_list("Contact");
                 $data = rotate($data);
                 $data = $data['row_id'];
                 $where['id'] = array('not in', implode(",", $data));
             } else {
                 $test = $model;
                 $data = $model->get_data_list("Contact", $id);
                 $data = rotate($data);
                 $data = $data['row_id'];
                 $where['id'] = array('in', implode(",", $data));
             }
             $model = M("Contact");
             $where['is_del'] = array('eq', 0);
             $data = $model->where($where)->field('id,name,position as position_name,email')->select();
             //echo $model->getLastSql();
             break;
         default:
     }
     $new = array();
     if (true) {
         // 读取成功
         $this->ajaxReturn($data, dump($test, false), 1);
     }
 }
开发者ID:hongweipeng,项目名称:oa,代码行数:62,代码来源:PopupAction.class.php


示例16: _assign_mail_folder_list

 public function _assign_mail_folder_list()
 {
     $model = D("Folder");
     $list = $model->get_list("mail/mail_list", 2);
     $system_folder = array(array("id" => 1, "name" => "收件箱"), array("id" => 2, "name" => "已发送"));
     $list = array_merge($system_folder, $list);
     $tree = list_to_tree($list);
     $this->assign('folder_list', dropdown_menu($tree));
     $temp = tree_to_list($tree);
     return $temp;
 }
开发者ID:yunsite,项目名称:smeoa,代码行数:11,代码来源:MailAction.class.php


示例17: operate

 /**
  * 操作分类初始化
  * @param string $type
  * @author huajie <[email protected]>
  */
 public function operate($type = 'move')
 {
     //检查操作参数
     if (strcmp($type, 'move') == 0) {
         $operate = '移动';
     } elseif (strcmp($type, 'merge') == 0) {
         $operate = '合并';
     } else {
         $this->error('参数错误!');
     }
     $from = intval(I('get.from'));
     empty($from) && $this->error('参数错误!');
     //获取分类
     $map = array('status' => 1, 'id' => array('neq', $from));
     $list = M('Category')->where($map)->field('id,pid,title')->select();
     //移动分类时增加移至根分类
     if (strcmp($type, 'move') == 0) {
         //不允许移动至其子孙分类
         $list = tree_to_list(list_to_tree($list));
         $pid = M('Category')->getFieldById($from, 'pid');
         $pid && array_unshift($list, array('id' => 0, 'title' => '根分类'));
     }
     $this->assign('type', $type);
     $this->assign('operate', $operate);
     $this->assign('from', $from);
     $this->assign('list', $list);
     $this->meta_title = $operate . '分类';
     $this->display();
 }
开发者ID:WineShop,项目名称:wine,代码行数:34,代码来源:CatearticleController.class.php


示例18: tree_to_list

function tree_to_list($tree, $i = 0)
{
    $list = array();
    foreach ($tree as $key => $value) {
        $value['level'] = $i;
        if (is_array($value['_child'])) {
            $i++;
            $list = array_merge($list, tree_to_list($value['_child'], $i));
            $i--;
        }
        unset($value['_child']);
        $list[] = $value;
    }
    return $list;
}
开发者ID:yunzhiclub,项目名称:wemall,代码行数:15,代码来源:function.php


示例19: mine

 public function mine()
 {
     $widget['date-range'] = true;
     $this->assign("widget", $widget);
     $this->assign('user_id', get_user_id());
     $this->assign("title", '日志查询');
     $auth = $this->config['auth'];
     $this->assign('auth', $auth);
     if ($_GET['id']) {
         $id = $_GET['id'];
         $this->assign("XIN", 0);
     } else {
         $id = get_user_id();
         $this->assign("XIN", 1);
     }
     if ($auth['admin']) {
         $rolein = false;
         $role = D('role_user')->where('user_id = ' . get_user_id())->field('role_id')->select();
         for ($i = 0; $i < count($role); $i++) {
             if ($role[$i]['role_id'] == 1 || $role[$i]['role_id'] == 12) {
                 $rolein = true;
                 continue;
             }
         }
         $node = D("Dept");
         $dept_id = get_dept_id();
         $dept_name = get_dept_name();
         $menu = array();
         $dept_menu = $node->field('id,pid,name')->where("is_del=0")->order('sort asc')->select();
         if ($rolein) {
             $dept_tree = list_to_tree($dept_menu);
         } else {
             $dept_tree = list_to_tree($dept_menu, $dept_id);
         }
         $count = count($dept_tree);
         //            dump(get_user_id());
         //            exit;
         if (empty($count)) {
             /*获取部门列表*/
             $html = '';
             $html = $html . "<option value='{$dept_id}'>{$dept_name}</option>";
             $this->assign('dept_list', $html);
             /*获取人员列表*/
             $where['dept_id'] = array('eq', $dept_id);
             $emp_list = D("User")->where($where)->getField('id,emp_name');
             //				$this->assign('emp_list',$emp_list);
         } else {
             /*获取部门列表*/
             $this->assign('dept_list', select_tree_menu($dept_tree));
             $dept_list = tree_to_list($dept_tree);
             $dept_list = rotate($dept_list);
             $dept_list = $dept_list['id'];
             /*获取人员列表*/
             $where['dept_id'] = array('in', $dept_list);
             $emp_list = D("User")->where($where)->getField('id,emp_name');
             //				$this->assign('emp_list',$emp_list);
         }
     }
     $map = $this->_search();
     $map['user_id'] = $id;
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $model = D("WorkLog");
     if (!empty($model)) {
         $this->_list($model, $map);
         //			$this -> _list($model,'');
     }
     $this->assign("uid", $id);
     $this->display();
 }
开发者ID:TipTimesPHP,项目名称:tyj_oa,代码行数:71,代码来源:WorkLogAction.class.php


示例20: sp_get_term

<?php 
$term = sp_get_term($_GET['id']);
$child_terms = sp_get_child_terms($term['parent']);
$pterm = sp_get_term($term['parent']);
$nav_label = $pterm['name'];
$lists = sp_sql_posts_paged_bycatid($_GET['id'], "order:post_modified DESC,listorder ASC;", 33, "{prev}{liststart}{list}{listend}{next}");
$kaoyan_img = sp_getslide('kaoyan_img');
$kyimg = $kaoyan_img[0];
$nav_label = isset($nav_label) ? $nav_label : $post_title;
$nid = sp_nav_id($nav_label);
$nav_cid = sp_nav_cid($nid);
if ($nav_cid == 1) {
    $navList = tree_to_list($navTree);
} else {
    $navT = sp_get_menu_tree($nav_cid);
    $navList = tree_to_list($navT);
}
$snav = getParents($navList, $nid);
$parent_sid = $snav[0]['id'];
$parent_slabel = $snav[0]['label'];
$parent_shref = $snav[0]['href'];
$child_snav = getChilds($navList, $parent_sid);
foreach ($child_snav as $key => $value) {
    if ($key % 2 == 0) {
        $ou[] = $value;
    } else {
        $ji[] = $value;
    }
}
$child_snav = array_merge($ou, $ji);
$child_snav_height = count($child_snav) * 35;
开发者ID:elinxer,项目名称:hualilibrary,代码行数:31,代码来源:a10e3ce8e32e7a44809beb5a1f6989dc.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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