Exemplo n.º 1
0
 function __construct($params = '')
 {
     parent::__construct($params);
     if ($this->auto_prefix) {
         $this->t = $this->getPrefix($this->t);
     }
 }
Exemplo n.º 2
0
 /**
  * 初始化菜单
  *
  * @return mixed
  */
 function initMenuList()
 {
     //过滤的类名称
     $ingot_controller = array('Cross\\MVC\\Controller', 'Cross\\Core\\FrameBase', 'app\\admin\\controllers\\Admin');
     //过滤的方法
     $ingot_action = array('__construct', '__destruct', '__toString', '__call', '__set', '__isset', '__unset', '__sleep', '__wakeup', '__invoke', '__clone', '__set_state', '__debug_info', '__get');
     /**
      * 所有导航菜单
      */
     $menu_list = $this->getMenuList(0);
     foreach ($menu_list as &$m) {
         $controller_name = ucfirst($m["link"]);
         /**
          * 控制器文件物理路径
          */
         $controller_file = Loader::getFilePath("app::controllers/{$controller_name}.php");
         /**
          * 获取子菜单数据及整理菜单格式
          */
         $c_menu_data = $this->getMenuList($m["id"]);
         $c_menu_list = array();
         foreach ($c_menu_data as $cm) {
             $c_menu_list[$cm['link']]['id'] = $cm['id'];
             $c_menu_list[$cm['link']]['pid'] = $cm['pid'];
             $c_menu_list[$cm['link']]['name'] = $cm['name'];
             $c_menu_list[$cm['link']]['order'] = $cm['order'];
             $c_menu_list[$cm['link']]['display'] = $cm['display'];
         }
         /**
          * 判断物理文件是否存在
          */
         if (file_exists($controller_file)) {
             /**
              * 使用反射API 取得类中的名称
              */
             $fullName = "app\\" . parent::getConfig()->get('app', 'name') . '\\controllers\\' . $controller_name;
             $rc = new ReflectionClass($fullName);
             $method = $rc->getMethods(ReflectionMethod::IS_PUBLIC);
             /**
              * 清除类中不存在但存在数据库中的方法
              */
             foreach ($c_menu_list as $cm_key => $cm_value) {
                 if (!$rc->hasMethod($cm_key)) {
                     unset($c_menu_list[$cm_key]);
                     $this->delNav($cm_value['id']);
                 }
             }
             foreach ($method as $mm) {
                 if (in_array($mm->class, $ingot_controller)) {
                     continue;
                 }
                 //过滤
                 if (!in_array($mm->name, $ingot_action)) {
                     if (isset($c_menu_list[$mm->name])) {
                         $m["method"][$mm->name] = $c_menu_list[$mm->name];
                     } else {
                         $add_data = array();
                         $this->addClassMethodMenu($mm->class, $mm->name, $add_data);
                         $m["method"][$mm->name] = $add_data;
                     }
                 }
             }
         } else {
             $m["error"] = "-1";
             $m["method"] = array();
         }
     }
     return $menu_list;
 }