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


PHP tree_to_list函数代码示例

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


在下文中一共展示了tree_to_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 <yangweijiester@gmail.com>
 */
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 3792535@qq.com
  */
 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


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