public function actionIndex() { $newsModules = AppbymePoralModule::getModuleList(); $forumList = ForumUtils::getForumListForHtml(); $navInfo = AppbymeUIDiyModel::getNavigationInfo(true); $tempModules = AppbymeUIDiyModel::getModules(true); // 初始化默认配置 if (empty($navInfo) || empty($navInfo['navItemList']) || empty($tempModules)) { $navInfo = AppbymeUIDiyModel::initNavigation(); $tempModules = AppbymeUIDiyModel::initModules(); } // 必须存在发现导航 $hasDiscoverNavItem = false; foreach ($navInfo['navItemList'] as $navItem) { if ($navItem['moduleId'] == AppbymeUIDiyModel::MODULE_ID_DISCOVER) { $hasDiscoverNavItem = true; break; } } !$hasDiscoverNavItem && array_unshift($navInfo['navItemList'], AppbymeUIDiyModel::initNavItemDiscover()); // 必须存在发现和快发模块 $isFindDiscover = $isFindFastpost = false; $discoverModule = AppbymeUIDiyModel::initDiscoverModule(); $fastpostModule = AppbymeUIDiyModel::initFastpostModule(); $modules = array(); foreach ($tempModules as $module) { switch ($module['id']) { case AppbymeUIDiyModel::MODULE_ID_DISCOVER: if (!$isFindDiscover) { $isFindDiscover = true; $discoverModule = $module; } break; case AppbymeUIDiyModel::MODULE_ID_FASTPOST: if (!$isFindFastpost) { $isFindFastpost = true; $fastpostModule = $module; } break; default: $modules[] = $module; break; } } array_unshift($modules, $discoverModule, $fastpostModule); // 检测浏览器信息 $mobileDetect = new Mobile_Detect(); $browserInfo = $mobileDetect->version('Chrome'); $this->renderPartial('index', array('navInfo' => $navInfo, 'modules' => $modules, 'newsModules' => $newsModules, 'forumList' => $forumList, 'browserInfo' => $browserInfo, 'appLevel' => AppUtils::getAppLevel(), 'topicTypeSortInfos' => $this->_getTopicTypeSortInfos())); }
/** * 门户资讯分类模块列表 * * @author HanPengyu * * @param mixed $count 截取列表的长度,老的接口使用6. * * @return array. */ public static function getModuleList($count) { $moduleList = AppbymePoralModule::getModuleList(); $moduleList = array_slice($moduleList, 0, $count); $lists = array(); foreach ($moduleList as $module) { $list['moduleId'] = (int) $module['mid']; $list['moduleName'] = (string) $module['name']; $lists[] = $list; } return $lists; }
protected function getResult($params) { extract($params); $res = $this->initWebApiArray(); if ($page == 1) { $res['piclist'] = $this->_getPicList($mid); } else { $res['piclist'] = array(); } $portals = AppbymePortalModuleSource::getPortalByMid($mid); $handCount = $this->_handCount($mid, $portals); $autoAdd = AppbymePortalModuleSource::getAutoAdd($mid); $params = unserialize(AppbymePoralModule::getModuleParam($mid)); $params == false && ($params = array()); // 对错误mid的处理 if (empty($portals)) { $res['list'] = array(); return $res; } $count = 0; // 自动添加的数目 if (!empty($autoAdd)) { if ($autoAdd[0]['idtype'] == 'fid') { // [add]板块设置用户组权限后,针对当前用户进行过滤(在列表中是否显示)Author:HanPengyu,Data:14.11.28 require_once libfile('function/forumlist'); foreach ($autoAdd as $auto) { $forum = DzForumForum::getForumFieldByFid($auto['id']); forum($forum) && ($fids[] = $auto['id']); } $count = DzForumThread::getByFidCount($fids, $params, $longitude, $latitude, $radius); // Mobcent::dumpSql(); } else { foreach ($autoAdd as $auto) { $catids[] = $auto['id']; } $count = DzPortalArticle::getByCatidCount($catids, $params); } } $total = $handCount + $count; // 没有查到数据 if ($total == 0) { $res['list'] = array(); return $res; } $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $total); $res = array_merge($res, $pageInfo); $offset = ($page - 1) * $pageSize; if ($page == 1) { if ($handCount <= self::HANDPAGE) { $autoData = array(); $handData = $handCount != 0 && ($page = 1) ? $this->_handData($mid, $offset, $handCount, $params) : array(); $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $handCount, $handCount); $res = array_merge($res, $pageInfo); if ($count != 0) { if ($autoAdd[0]['idtype'] == 'fid') { $autoData = $this->_autoFidData($fids, $offset, $pageSize, $params, $longitude, $latitude, $radius); } else { $autoData = $this->_autoCatidData($catids, $offset, $pageSize, $params); } $total = $count != 0 ? $count + $handCount : $handCount; $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $total); $res = array_merge($res, $pageInfo); } $rows = array_merge((array) $handData, (array) $autoData); $res['list'] = $rows; return $res; } $total = $count != 0 ? $count + $handCount : $handCount; $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $handCount, $total); $res = array_merge($res, $pageInfo); $res['list'] = $this->_handData($mid, $offset, $handCount); return $res; } $page = $handCount <= self::HANDPAGE ? $page : $page - 1; $offset = ($page - 1) * $pageSize; if ($count != 0) { if ($autoAdd[0]['idtype'] == 'fid') { $autoData = $this->_autoFidData($fids, $offset, $pageSize, $params, $longitude, $latitude, $radius); } else { $autoData = $this->_autoCatidData($catids, $offset, $pageSize, $params); } $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count); $res = array_merge($res, $pageInfo); $res['list'] = $autoData; } else { $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $handCount, $handCount); $res = array_merge($res, $pageInfo); $res['list'] = array(); } return $res; }