Esempio n. 1
0
 /**
  * 获取子版块列表
  *
  * @param int $fid 版块id
  * @return array
  */
 public static function getForumSubList($fid)
 {
     return DzForumForum::getSubForumsByFid($fid);
 }
Esempio n. 2
0
 private static function __getTopTopicsByFid($fid, $page, $pageSize, $params)
 {
     // return DbUtils::getDzDbUtils(true)->queryAll('
     //     SELECT *
     //     FROM %t
     //     WHERE
     //         (fid IN (%n) AND displayorder=%s) OR
     //         (fid IN (%n) AND displayorder=%s) OR
     //         (fid IN (%n) AND (displayorder=%s OR stamp=%s OR icon=%s))
     //     ORDER BY displayorder DESC, dateline DESC
     //     LIMIT %d, %d
     //     ',
     //     array(
     //         'forum_thread',
     //         self::_getFids(0),
     //         self::DISPLAY_ORDER_GLOBAL,
     //         DzForumForum::getFidsByGid(DzForumForum::getGidByFid($fid)),
     //         self::DISPLAY_ORDER_GROUP,
     //         self::_getFids($fid),
     //         self::DISPLAY_ORDER_FORUM,
     //         self::STAMP_TOP, self::ICON_TOP,
     //         $pageSize * ($page-1), $pageSize
     //     )
     // );
     // 不取置顶的图章,图标
     // -- 以下注释 -- //
     return DbUtils::getDzDbUtils(true)->queryAll('
         SELECT *
         FROM %t
         WHERE 
             (fid IN (%n) AND displayorder=%s) OR
             (fid IN (%n) AND displayorder=%s) OR
             (fid IN (%n) AND displayorder=%s)
         ORDER BY displayorder DESC, dateline DESC
         LIMIT %d, %d
         ', array('forum_thread', self::_getFids(0), self::DISPLAY_ORDER_GLOBAL, DzForumForum::getFidsByGid(DzForumForum::getGidByFid($fid)), self::DISPLAY_ORDER_GROUP, self::_getFids($fid), self::DISPLAY_ORDER_FORUM, $pageSize * ($page - 1), $pageSize));
     // $offset = ($page - 1) * $pageSize;
     // $params['topic_stick'] = array(1,2,3);
     // $params['topic_orderby'] = 'displayorder DESC, dateline';
     // return self::getByFidData(self::_getFids(), $offset, $pageSize, $params);
 }
Esempio n. 3
0
 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 _getTopicInfos($fid, $page, $pageSize, $sort, $filterType = '', $filterId = '', $isImageList = '', $topOrder = '')
 {
     $infos = array('count' => 0, 'list' => array(), 'topTopicList' => array());
     // global $_G;
     // $forum = $_G['forum'];
     $count = $this->_getTopicCount($fid, $sort, $filterType, $filterId);
     $topicList = $this->_getTopicList($fid, $page, $pageSize, $sort, $filterType, $filterId);
     $topTopicList = $topTopicListTmp = $topList = array();
     if ($page == 1 && $topOrder != 0) {
         $status = $_GET['topOrder'];
         $fids = array();
         switch ($status) {
             case DzForumThread::DISPLAY_ORDER_GLOBAL:
                 $fids = ForumUtils::getForumShowFids();
                 break;
             case DzForumThread::DISPLAY_ORDER_GROUP:
                 $fids = DzForumForum::getFidsByGid(DzForumForum::getGidByFid($fid));
                 break;
             case DzForumThread::DISPLAY_ORDER_FORUM:
                 $fids = array($fid);
                 break;
             default:
                 break;
         }
         $topTopicListTmp = DzForumThread::getByFidData($fids, 0, 3, array('topic_stick' => array($status)));
         foreach ($topTopicListTmp as $top) {
             $topList['id'] = (int) $top['tid'];
             $topList['title'] = (string) $top['subject'];
             $topTopicList[] = $topList;
         }
     }
     // $topTopicList = $this->_getListField($topTopicList);
     $list = $this->_getListField($topicList);
     $infos['count'] = $count;
     $infos['list'] = $list;
     $infos['topTopicList'] = $topTopicList;
     return $infos;
 }
 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;
 }
Esempio n. 6
0
 private function _getTopicTypeSortInfos()
 {
     $infos = array();
     $fields = DbUtils::getDzDbUtils(true)->queryAll('
         SELECT fid, threadtypes, threadsorts
         FROM %t
         WHERE fid IN (%n)
         ', array('forum_forumfield', DzForumForum::getFids()));
     foreach ($fields as $field) {
         if (!empty($field)) {
             $info = array('fid' => (int) $field['fid'], 'types' => array(), 'sorts' => array());
             $types = unserialize($field['threadtypes']);
             if (!empty($types['types'])) {
                 foreach ($types['types'] as $key => $value) {
                     // 控制管理组专用
                     // if ($types['moderators'][$key] == 1) {
                     // continue;
                     // }
                     $info['types'][] = array('id' => $key, 'title' => WebUtils::emptyHtml($value));
                 }
             }
             $sorts = unserialize($field['threadsorts']);
             if (!empty($sorts['types'])) {
                 foreach ($sorts['types'] as $key => $value) {
                     $info['sorts'][] = array('id' => $key, 'title' => WebUtils::emptyHtml($value));
                 }
             }
             $infos[$info['fid']] = $info;
         }
     }
     return $infos;
 }