You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
use think\Controller;
|
|
use think\Request;
|
|
use think\Db;
|
|
class Common extends Controller
|
|
{
|
|
public function _initialize(){
|
|
if(!session('id') ||!session('name')){
|
|
$this->error('您尚未登录系统',url('/index/login'));
|
|
}
|
|
$auth=new Auth();
|
|
$request=Request::instance();
|
|
$con=$request->controller();
|
|
$action=$request->action();
|
|
$name=$con.'/';
|
|
$notCheck=array('Admin/');
|
|
if(session('id')!=1){
|
|
if(!in_array($name,$notCheck)){
|
|
if(!$auth->check($name,session('id'))){
|
|
$this->error('没有权限');
|
|
}
|
|
}
|
|
}
|
|
$data=Db::query("select * from sys_menu order by id ");
|
|
$menu= $this->getTree($data,0);
|
|
$this->assign('topmenus',$menu);
|
|
}
|
|
public function getTree($data,$ppd)
|
|
{
|
|
$html = '';
|
|
$ppid=-1;
|
|
foreach($data as $k =>$v)
|
|
{
|
|
if($v['pid'] == $ppd)
|
|
{
|
|
if($v['linkurl']!=null &&$v['linkurl']!="")
|
|
{
|
|
$html .= "<li ><a href=\"".url($v['linkurl'])."\" >".$v['pidname']."</a>";
|
|
}
|
|
else
|
|
{
|
|
$html .= "<li ><a href=\"#\" >".$v['pidname']."</a>";
|
|
}
|
|
$ppid=$v['ppid'];
|
|
$html .= $this->getTree($data,$v['id']);
|
|
$html = $html ."</li>";
|
|
}
|
|
}
|
|
if($ppd==0) {
|
|
return $html ?'<ul class="nav1">'.$html .'</ul>': $html;
|
|
}
|
|
else
|
|
{
|
|
return $html ?'<ul >'.$html .'</ul>': $html;
|
|
}
|
|
}
|
|
}
|
|
?>
|