/**
  * 菜单列表
  */
 public function menu($id = 0, $page = 1, $rows = 10)
 {
     $menu_db = D('Menu');
     if (IS_POST) {
         $where = array('parentid' => $id);
         $limit = ($page - 1) * $rows . "," . $rows;
         $order = array('listorder' => 'asc');
         $total = $menu_db->where($where)->count();
         if ($id) {
             $limit = null;
         }
         $list = $total ? $menu_db->where($where)->order($order)->limit($limit)->select() : array();
         foreach ($list as &$info) {
             if ($menu_db->where(array('parentid' => $info['id']))->count()) {
                 $info['state'] = 'closed';
             }
             $info['display'] = $info['display'] ? '显示' : '<font color="red">隐藏</font>';
             $info['iconCls'] = menu_icon($info['level'], $info['icon']);
             if ($info['icon']) {
                 $info['iconCls'] = $info['icon'];
             }
         }
         $data = $id ? $list : array('total' => $total, 'rows' => $list);
         $this->ajaxReturn($data);
     } else {
         $menuid = I('get.menuid');
         $currentpos = $menu_db->currentPos(I('get.menuid'));
         //栏目位置
         $toolbars = $menu_db->getToolBar($menuid);
         $this->assign('title', $currentpos);
         $this->assign('toolbars', $toolbars);
         $this->display();
     }
 }
 /**
  * 左侧扩展菜单
  */
 public function public_leftExtend($id = 0)
 {
     if (IS_GET) {
         $addons_db = D('Addons');
         $data = array();
         $menu = $addons_db->where(array('status' => 1, 'show' => 1))->select();
         foreach ($menu as $v) {
             array_push($data, array('text' => $v['title'], 'id' => $v['id'], 'url' => U('Extend/load', array('name' => $v['name'], 'id' => $v['id'], 'menuid' => $id)), 'iconCls' => menu_icon(0, $v['icon'])));
         }
         $this->assign('data', $data);
         $this->display('left_extend');
     }
 }
Beispiel #3
0
 /**
  * 菜单下拉列表
  */
 public function getSelectTree($parentid = 0)
 {
     $field = array('id', '`name` as `text`', 'level', 'icon');
     $order = '`listorder` ASC,`id` DESC';
     $data = $this->field($field)->where(array('parentid' => $parentid, 'level' => array('LT', 4)))->order($order)->select();
     if (is_array($data)) {
         foreach ($data as &$arr) {
             $arr['iconCls'] = menu_icon($arr['level'], $arr['icon']);
             $arr['children'] = $this->getSelectTree($arr['id']);
         }
     } else {
         $data = array();
     }
     return $data;
 }