/**
  * 频道列表
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $result = $this->chanelService->getItems("", "id,name,pid,sort_num,add_time", "sort_num ASC");
     //提取一级频道
     $topChanels = ArrayUtils::filterArrayByKey('pid', 0, $result);
     foreach ($topChanels as $key => $value) {
         $topChanels[$key]['sub'] = ArrayUtils::filterArrayByKey('pid', $value['id'], $result);
     }
     $this->assign("items", $topChanels);
     $this->setView('admin/chanel_index');
 }
 /**
  * 系统配置列表
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $configService = Beans::get('admin.config.service');
     $items = $configService->getItems();
     //获取app配置文档
     $wepApp = WebApplication::getInstance();
     $groups = $wepApp->getConfig('system.config.group');
     //将数据分组
     $newItems = array();
     foreach ($groups as $key => $value) {
         $newItems[$key] = ArrayUtils::filterArrayByKey('groupkey', $key, $items);
     }
     $this->assign('items', $newItems);
     $this->assign('groups', $groups);
     $this->setView('system/config_index');
 }
 /**
  * @see \admin\service\interfaces\IChanelService::getChanelCache
  */
 public function getChanelCache($expr = 0)
 {
     //首先获取缓存
     $CACHE = CacheFactory::create('file');
     $items = $CACHE->get(self::CHANEL_ITEMS_KEY, $expr);
     //如果命中缓存了,则直接返回缓存
     if ($items) {
         return $items;
     }
     //获取全部频道
     $chanels = $this->getItems(null, 'id,pid,name,sort_num', 'sort_num ASC');
     //获取一级频道
     $levelOne = ArrayUtils::filterArrayByKey('pid', 0, $chanels);
     foreach ($levelOne as $key => $value) {
         $levelOne[$key]['sub'] = ArrayUtils::filterArrayByKey('pid', $value['id'], $chanels);
     }
     $CACHE->set(self::CHANEL_ITEMS_KEY, $levelOne);
     return $levelOne;
 }
 /**
  * 初始化方法
  */
 public function C_start()
 {
     parent::C_start();
     $this->setServiceBean('article.article.service');
     //获取所有的频道
     $chanelService = Beans::get('admin.chanel.service');
     $chanels = $chanelService->getItems(null, 'id,pid,name,seo_title', 'sort_num ASC');
     //提取一级频道
     $topChanels = ArrayUtils::filterArrayByKey('pid', 0, $chanels);
     $tchanelIds = array();
     foreach ($topChanels as $key => $value) {
         $topChanels[$key]['sub'] = ArrayUtils::filterArrayByKey('pid', $value['id'], $chanels);
         $tchanelIds[] = $value['id'];
     }
     //提取子频道
     $subChanels = ArrayUtils::filterArrayByKey('pid', $tchanelIds, $chanels);
     $this->assign('chanels', ArrayUtils::changeArrayKey($chanels, 'id'));
     $this->assign('topChanels', $topChanels);
     $this->assign('subChanels', $subChanels);
 }
 /**
  * @see \admin\service\interfaces\IMenuService::updateMenuCache
  */
 public function updateMenuCache()
 {
     //获取菜单分组
     $groupService = Beans::get('admin.menuGroup.service');
     $groups = $groupService->getItems(null, 'tkey');
     //获取所有的菜单
     $menus = $this->getItems('ishow=1', 'id,groupkey,name,url,pid');
     $menuData = array();
     foreach ($groups as $values) {
         //获取当前分组的一级菜单
         $conditions = array('pid' => 0, 'groupkey' => $values['tkey'], 'ishow' => 1);
         $topMemus = $this->getItems($conditions, 'id,groupkey,name,url,pid', 'sort_num ASC');
         foreach ($topMemus as $key => $val) {
             $topMemus[$key]['sub'] = ArrayUtils::filterArrayByKey('pid', $val['id'], $menus);
         }
         $menuData[$values['tkey']] = $topMemus;
     }
     $CACHER = CacheFactory::create('file');
     return $CACHER->set(self::$CACHE_KEY, $menuData);
 }