<?php

class menuMod extends commonMod
{
    public function __construct()
    {
        parent::__construct();
    }

    // 显示后台管理菜单
    public function menu($pid)
    {
        
        return $this->model->table('admin_menu')->where('pid='.$pid.' AND status=1 AND hide=0 AND id<>1')->order('sorter desc,id asc')->select();
        
    }    

    // 菜单
    public function menu_left()
    {
        $pid = intval($_GET[0]);
        $condition['pid'] = $pid;
        $condition['status']=1;
        $condition['hide']=0;
        $menu_list = $this->model->table('admin_menu')->where($condition)->order('sorter desc,id asc')->select();
        $this->assign('menu_list', $menu_list);
        $this->display();
    }

    // 首页菜单
    public function index_left()
    {
        $condition['pid'] = 1;
        $condition['status']=1;
        $condition['hide']=0;
        $menu_list = $this->model->table('admin_menu')->where($condition)->order('sorter desc,id asc')->select();
        $this->assign('menu_list', $menu_list);
        $this->display();
    }


	// 分类菜单
    public function channel_left()
    {
       $menu = $this->model->table('model')->where('channel_status=0 AND switch=1')->order('id asc')->select();
	   $this->assign('menu', $menu);
	   $this->display();
    } 
	// 内容菜单
    public function content_left()
    {
       //$content_menu = $this->model->table('model')->where('content_status=0 AND switch=1')->order('id asc')->select();
	   //$this->assign('content_menu', $content_menu);
       $this->assign('channel', $this->getCat());
	   $this->display();
    }

    //获取分类树
    public function getCat($id = 0)
    {
        $langid=$this->getlangid();
        if(!empty($langid)){
        $where= 'WHERE lang='.$langid;
        }

        // 查询分类信息
        $sql = "SELECT A.*,B.content_status,B.list_url,B.edit_url FROM {$this->model->pre}channel A LEFT JOIN {$this->model->pre}model B ON A.mid = B.id {$where} ORDER BY A.sorter DESC,A.id ASC";
        $data = $this->model->query($sql);

        $cat = new Category(array(
            'id',
            'pid',
            'name',
            'cname')); //初始化无限分类
        return $cat->getTree($data, $id); //获取分类数据树结构
    }

	// 插件菜单
    public function extend_left()
    {
       $menu = $this->model->table('extend')->where('OPEN=1')->order('id asc')->select();
       $this->assign('menu', $menu);
       $this->display();
    }

}

?>