Esempio n. 1
0
 public function __invoke($slug = null)
 {
     $group_id_or_search = $slug;
     $forum = $this->getForum();
     // 获得论坛的分组信息
     $groups = GroupModel::allGroup(function (QueryBuilder $qb) use($forum) {
         $qb->andWhere($qb->expr()->eq('forum_id', ':forum_id'))->setParameter(':forum_id', $forum->id);
         $qb->addOrderBy('weight', 'desc');
         $qb->addOrderBy('create_timestamp');
     });
     // 优先search
     $group = GroupModel::search($group_id_or_search, $forum->id);
     if (!$group) {
         $group = GroupModel::getGroup($group_id_or_search);
     }
     // 分组下的一级版块
     $boards = BoardModel::allBoards(function (QueryBuilder $qb) use($group) {
         $qb->andWhere($qb->expr()->eq('forum_id', ':forum_id'))->setParameter(':forum_id', $group->forumId);
         $qb->andWhere($qb->expr()->eq('group_id', ':group_id'))->setParameter(':group_id', $group->id);
         $qb->andWhere($qb->expr()->eq('parent_id', 0));
         $qb->addOrderBy('weight', 'desc');
         $qb->addOrderBy('create_timestamp');
     });
     return $this->render('group/index.html.twig', array('forum' => $forum, 'groups' => $groups, 'group' => $group, 'boards' => $boards));
 }
Esempio n. 2
0
 protected function handle()
 {
     $group_id = $this->groupId;
     $group = GroupModel::getGroup($group_id);
     $boards = BoardModel::allBoards(function (QueryBuilder $qb) use($group_id) {
         $qb->andWhere($qb->expr()->eq('group_id', ':group_id'))->setParameter(':group_id', $group_id);
         $qb->andWhere($qb->expr()->eq('parent_id', 0));
         $qb->addOrderBy('weight', 'desc');
         $qb->addOrderBy('create_timestamp');
     });
     return $this->render('group/boards.html.twig', array('boards' => $boards, 'group' => $group));
 }
Esempio n. 3
0
 public function __invoke($group_slug = null, $board_slug = null)
 {
     $group_id_or_search = $group_slug;
     $board_id_or_search = $board_slug;
     $forum = $this->getForum();
     // 优先search
     $group = GroupModel::search($group_id_or_search, $forum->id);
     if (!$group) {
         $group = GroupModel::getGroup($group_id_or_search);
     }
     $board = BoardModel::search($board_id_or_search, $forum->id, $group->id);
     if (!$board) {
         $board = BoardModel::getBoard($board_id_or_search);
     }
     // 获得论坛的分组信息
     $groups = GroupModel::allGroup(function (QueryBuilder $qb) use($forum) {
         $qb->andWhere($qb->expr()->eq('forum_id', ':forum_id'))->setParameter(':forum_id', $forum->id);
         $qb->addOrderBy('weight', 'desc');
         $qb->addOrderBy('create_timestamp');
     });
     // 子版块
     $sub_boards = BoardModel::allBoards(function (QueryBuilder $qb) use($board) {
         $qb->andWhere($qb->expr()->eq('parent_id', ':parent_id'))->setParameter(':parent_id', $board->id);
         $qb->addOrderBy('weight', 'desc');
         $qb->addOrderBy('create_timestamp');
     });
     // 导航
     $breadcrumbs = array();
     $breadcrumbs[] = array('url' => $this->generateUrl('forum_group', array('slug' => $group_id_or_search)), 'title' => $group->name);
     if ($board->path) {
         $board_ids = explode(',', $board->path);
         foreach ($board_ids as $board_id) {
             $b = BoardModel::getBoard($board_id);
             $breadcrumbs[] = array('url' => $this->generateUrl('forum_board', array('group_slug' => $group_id_or_search, 'board_slug' => $b->search ? $b->search : $b->id)), 'title' => $b->name);
         }
     }
     // 自己
     $breadcrumbs[] = array('url' => $this->generateUrl('forum_board', array('group_slug' => $group_id_or_search, 'board_slug' => $board->search ? $board->search : $board->id)), 'title' => $board->name);
     return $this->render('board/index.html.twig', array('forum' => $forum, 'groups' => $groups, 'group' => $group, 'board' => $board, 'sub_boards' => $sub_boards, 'breadcrumbs' => $breadcrumbs));
 }
Esempio n. 4
0
 public function __invoke()
 {
     $forum = $this->getForum();
     // 获得论坛的分组信息
     $groups = GroupModel::allGroup(function (QueryBuilder $qb) use($forum) {
         $qb->andWhere($qb->expr()->eq('forum_id', ':forum_id'))->setParameter(':forum_id', $forum->id);
         $qb->addOrderBy('weight', 'desc');
         $qb->addOrderBy('create_timestamp');
     });
     // 获得各个分组下的一级版块信息
     foreach ($groups as $k => $group) {
         $boards = BoardModel::allBoards(function (QueryBuilder $qb) use($group) {
             $qb->andWhere($qb->expr()->eq('forum_id', ':forum_id'))->setParameter(':forum_id', $group['forum_id']);
             $qb->andWhere($qb->expr()->eq('group_id', ':group_id'))->setParameter(':group_id', $group['id']);
             $qb->andWhere($qb->expr()->eq('parent_id', 0));
             $qb->addOrderBy('weight', 'desc');
             $qb->addOrderBy('create_timestamp');
         });
         $group['boards'] = $boards;
         $groups[$k] = $group;
     }
     return $this->render('homepage/index.html.twig', array('forum' => $forum, 'groups' => $groups));
 }
Esempio n. 5
0
    protected function handle()
    {
        $board_id = $this->id;
        $board = BoardModel::getBoard($board_id);
        $group = GroupModel::getGroup($board->groupId);
        $forum = ForumModel::getForum($group->forumId);
        // 子版块
        $sub_boards = BoardModel::allBoards(function (QueryBuilder $qb) use($board) {
            $qb->andWhere($qb->expr()->eq('parent_id', ':parent_id'))->setParameter(':parent_id', $board->id);
            $qb->addOrderBy('weight', 'desc');
            $qb->addOrderBy('create_timestamp');
        });
        $columns = array('ID', '标题', '作者', '回复');
        // 主题
        $request = $this->getRequest();
        if ($request->isXmlHttpRequest()) {
            $posts = $request->request;
            $page_offset = $posts->get('start');
            $page_offset = intval($page_offset);
            $page_size = $posts->get('length');
            $page_size = intval($page_size);
            $is_all = false;
            if ($page_size < 0) {
                $is_all = true;
            }
            $s_echo = $posts->get('draw');
            $s_echo = intval($s_echo);
            $search = $posts->get('search');
            $search_value = $search['value'];
            $records = array();
            $records['data'] = array();
            $records['draw'] = $s_echo;
            $records['recordsTotal'] = 0;
            $records['recordsFiltered'] = 0;
            if ($is_all) {
                $page_size = ThreadModel::getCount(function (QueryBuilder $qb) use($board, $search_value) {
                    $qb->andWhere($qb->expr()->eq('board_id', ':board_id'))->setParameter(':board_id', $board->id);
                    if ($search_value) {
                        $qb->orWhere($qb->expr()->like("`title`", ":title"))->setParameter(":title", "%{$search_value}%");
                    }
                    $qb->addOrderBy('update_timestamp', 'desc');
                    $qb->addOrderBy('create_timestamp', 'desc');
                });
            }
            $page = $page_offset / $page_size + 1;
            $pager = ThreadModel::listThreads($page, $page_size, function (QueryBuilder $qb) use($board, $search_value) {
                $qb->andWhere($qb->expr()->eq('board_id', ':board_id'))->setParameter(':board_id', $board->id);
                if ($search_value) {
                    $qb->orWhere($qb->expr()->like("`title`", ":title"))->setParameter(":title", "%{$search_value}%");
                }
                $qb->addOrderBy('update_timestamp', 'desc');
                $qb->addOrderBy('create_timestamp', 'desc');
            });
            $total = $pager->getCount();
            $records['recordsTotal'] = $total;
            $records['recordsFiltered'] = $total;
            $data = $pager->getData();
            /*$columns = array(
                  'ID', '标题', '作者', '回复',
              );*/
            foreach ($data as $k => $v) {
                $line = array();
                $line[] = '<input type="checkbox" name="id[]" value="' . $v['id'] . '">';
                $line[] = $v['id'];
                $line[] = $v['title'];
                $line[] = $v['author_name'] . '(' . date('Y-m-d H:i:s', $v['create_timestamp']) . ')';
                $line[] = $v['reply_author_name'] . '(' . date('Y-m-d H:i:s', $v['reply_timestamp']) . ')';
                $operation = '<div class="btn-group">
<a href="javascript:void(0);" data-toggle="dropdown" aria-expanded="false">操作 <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu pull-right" role="menu">
</ul>
</div>';
                $line[] = $operation;
                $records['data'][] = $line;
            }
            return new JsonResponse($records);
        } else {
            return $this->render('board/index.html.twig', array('forum' => $forum, 'group' => $group, 'board' => $board, 'sub_boards' => $sub_boards, 'columns' => $columns));
        }
    }