Exemplo n.º 1
0
 public function search()
 {
     $fields = 'menu_id, pid, title, ctrl_name, sort, create_uname, create_time';
     $query = $this->db->select($fields)->order_by('pid asc, sort asc')->get($this->table);
     $list = $query->result_array();
     $tree = array();
     create_tree_list($list, $tree, 0, 0, array('id_key' => 'menu_id', 'pid_key' => 'pid'));
     return array_values($tree);
 }
Exemplo n.º 2
0
 public function index()
 {
     $user_id = $this->session->userdata('user_id');
     $this->load->model('sys/pms_model');
     $is_admin = $this->session->userdata('is_admin');
     //$list		=$this->session->userdata('user_pms');
     $list = $this->pms_model->get_user_menu_pms($user_id, $is_admin);
     $tree = array();
     create_tree_list($list, $tree, 0, 0, array('id_key' => 'menu_id', 'pid_key' => 'pid'));
     // var_dump($this->session->all_userdata());exit;
     $this->load->view('index', array('app_menu' => $tree));
 }
Exemplo n.º 3
0
function create_tree_list(&$input, &$output, $pid = 0, $level = 0, $config = array('id_key' => 'id', 'pid_key' => 'pid'))
{
    $id_key = $config['id_key'];
    $pid_key = $config['pid_key'];
    $num = count($input);
    for ($i = 0; $i < $num; $i++) {
        if ($input[$i][$pid_key] == $pid) {
            $input[$i]['level'] = $level;
            $input[$i]['is_leaf'] = true;
            $output[$input[$i][$id_key]] = $input[$i];
            if ($pid > 0) {
                $output[$pid]['is_leaf'] = false;
            }
            create_tree_list($input, $output, $input[$i][$id_key], $level + 1, $config);
        }
    }
}
Exemplo n.º 4
0
 /**
  * 返回分店列表
  * @return [type] [description]
  */
 public function get_list()
 {
     $query = $this->db->select($this->fields)->order_by('pid asc, sort asc')->get($this->table);
     $list = $query->result_array();
     $tree = array();
     create_tree_list($list, $tree, 0, 0, array('id_key' => 'id', 'pid_key' => 'pid'));
     return array_values($tree);
 }