45 lines
1.3 KiB
PHP
Executable File
45 lines
1.3 KiB
PHP
Executable File
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model;
|
|
|
|
use think\facade\Cache;
|
|
use think\Model;
|
|
use think\Request;
|
|
|
|
/**
|
|
* @title: ²Ëµ¥Ä£ÐÍ
|
|
*/
|
|
class Menu extends Model {
|
|
|
|
/**
|
|
* @title ÏÔʾ²Ëµ¥
|
|
*/
|
|
public function getAuthMenuList(Request $request) {
|
|
$list = [];
|
|
$current_controller = '/' . str_replace('.', '/', strtolower($request->controller()));
|
|
$current_url = $request->url;
|
|
$menu = Cache::get('menu');
|
|
if (!$menu) {
|
|
$res = self::where('is_menu', 1)->order('sort asc, id asc')->select()->toArray();
|
|
foreach ($res as $key => $item) {
|
|
$menu[$item['id']] = $item;
|
|
}
|
|
Cache::set('menu', $menu);
|
|
}
|
|
foreach ($menu as $key => $value) {
|
|
if ($request->isAdmin || in_array($value['id'], array())) {
|
|
$list[$value['id']] = $value;
|
|
}
|
|
}
|
|
|
|
$menuList = list_to_tree($list);
|
|
return $menuList;
|
|
}
|
|
} |