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; }
private function _getForumInfo($forum) { $fid = (int) $forum['fid']; $forum = array_merge($forum, DzForumForum::getForumFieldByFid($fid)); $dateline = $this->_getDateLine($forum); // 判断该版块是否有权限访问 if (!forum($forum)) { return array(); } $matches = array(); preg_match('/<img src="(.+?)"/', $forum['icon'], $matches); $image = !empty($matches[1]) ? $matches[1] : ''; // $dateline = '0'; // if (is_array($forum['lastpost'])) { // $matches = array(); // preg_match('/<span title="(.+?)"/', $forum['lastpost']['dateline'], $matches); // $dateline = !empty($matches[1]) ? $matches[1] : $forum['lastpost']['dateline']; // $dateline = strtotime($dateline); // $dateline !== false or $dateline = '0'; // } $forumSubList = ForumUtils::getForumSubList($fid); $forumInfo = array(); $forumInfo['board_id'] = (int) $fid; $forumInfo['board_name'] = WebUtils::emptyHtml($forum['name']); $forumInfo['description'] = (string) WebUtils::emptyHtml($forum['description']); $forumInfo['board_child'] = count($forumSubList) > 0 ? 1 : 0; $forumInfo['board_img'] = WebUtils::getHttpFileName($image); $forumInfo['last_posts_date'] = !empty($dateline) ? $dateline . '000' : ''; $forumInfo['board_content'] = $forum['threads'] != 0 && !($forum['simple'] & 1) ? 1 : 0; $forumInfo['forumRedirect'] = $forum['redirect']; $todayPosts = (int) $forum['todayposts']; $threads = (int) $forum['threads']; $posts = (int) $forum['posts']; foreach ($forumSubList as $value) { $todayPosts += $value['todayposts']; $threads += $value['threads']; $posts += $value['posts']; } $forumInfo['td_posts_num'] = $todayPosts; $forumInfo['topic_total_num'] = $threads; $forumInfo['posts_total_num'] = $posts; return $forumInfo; }