/** * indexAction * * Index action of tracker controller forum module * * @return null */ public function indexAction() { \View::addLanguageItem('forumTrackerController'); // validate request params $gtfFilter = new \modules\forum\forms\GetTrackerFilter(); $gtfFilter->validate(); // invalid request params if (!$gtfFilter->isValid()) { throw new \SystemErrorException(array('title' => \View::$language->forum_tracker_error, 'description' => \View::$language->forum_tracker_request_invalid)); } // get request data $gtfData = $gtfFilter->getData(); // get limit settings $gtfData->limit = \App::getConfig('forum')->topics_per_page; // TODO topics per page from member custom settings // calculate offset $gtfData->offset = ($gtfData->page - 1) * $gtfData->limit; // get tracker topics by filter type $topics = helpers\TrackerTopicsHelper::getTopics($gtfData->by, $gtfData->offset, $gtfData->limit); if ($gtfData->page > 1 && !$topics) { throw new \MemberErrorException(array('code' => 404, 'title' => \View::$language->forum_tracker_error, 'description' => \View::$language->forum_tracker_page_not_found)); } // normalize tracker filter url $trackerUrl = '/forum/tracker'; $filterUrl = $trackerUrl; if ($gtfData->by != 'last') { $filterUrl = '/forum/tracker?by=' . $gtfData->by; } // get posts pagination $pagination = array(); $allTopicsCnt = helpers\TrackerTopicsHelper::getAllTopicsCount(); if ($allTopicsCnt > $gtfData->limit) { $pagination = \common\PaginationHelper::getItems($filterUrl, $gtfData->page, $gtfData->limit, $allTopicsCnt); } // normalize tracker filter title $filterTitle = 'forum_tracker_by_' . $gtfData->by . '_title'; $filterTitle = \View::$language->{$filterTitle}; // append breadcrumbs \common\BreadCrumbs::appendItems(array(new \common\BreadCrumbsItem($trackerUrl, \View::$language->forum_tracker_breadcrumbs_name), new \common\BreadCrumbsItem(null, $filterTitle))); // assign data into view $filters = helpers\TrackerFilterLinksHelper::getLinks($gtfData->by); \View::assign(array('title' => $filterTitle, 'filters' => $filters, 'topics' => $topics, 'pagination' => $pagination)); // set output layout \View::setLayout('forum-tracker.phtml'); }
/** * indexAction * * Index action of topic controller forum module * * @return null */ public function indexAction() { \View::addLanguageItem('forumTopicController'); // validate request params $gtForm = new forms\GetTopic(); $gtForm->validate(); // invalid request params if (!$gtForm->isValid()) { throw new \SystemErrorException(array('title' => \View::$language->forum_topic_error, 'description' => \View::$language->forum_topic_request_invalid)); } // get request data $gtData = $gtForm->getData(); // get limit settings $gtData->limit = \App::getConfig('forum')->posts_per_page; // TODO posts per page from member custom settings // calculate offset $gtData->offset = ($gtData->page - 1) * $gtData->limit; // get topic $topic = helpers\TopicHelper::getTopicById($gtData->id); if (!$topic) { throw new \MemberErrorException(array('code' => 404, 'title' => \View::$language->forum_topic_error, 'description' => \View::$language->forum_topic_topic_not_found)); } // get topic posts $posts = helpers\TopicPostsHelper::getPostsByTopicId($gtData->id, $gtData->offset, $gtData->limit); if (!$posts) { $description = $gtData->page == 1 ? \View::$language->forum_topic_first_post_not_found : \View::$language->forum_topic_page_not_found; throw new \SystemErrorException(array('title' => \View::$language->forum_topic_error, 'description' => $description)); } // get posts pagination $pagination = array(); if ($topic->posts_count > $gtData->limit) { $pagination = \common\PaginationHelper::getItems('/forum/topic?id=' . $topic->id, $gtData->page, $gtData->limit, $topic->posts_count); } // append breadcrumbs \common\BreadCrumbs::appendItems(array(new \common\BreadCrumbsItem('/forum/forum?id=' . $topic->forum_id, $topic->forum_title), new \common\BreadCrumbsItem('/forum/sub-forum?id=' . $topic->subforum_id, $topic->subforum_title), new \common\BreadCrumbsItem(null, $topic->topic_title))); // assign data into view \View::assign(array('title' => $topic->topic_title, 'topic' => $topic, 'posts' => $posts, 'postsCountOffset' => $gtData->offset + 1, 'pagination' => $pagination)); // set output layout \View::setLayout('forum-topic.phtml'); }
/** * indexAction * * Index action of subforum controller forum module * * @return null */ public function indexAction() { \View::addLanguageItem('forumSubForumController'); // validate request params $gsfForm = new forms\GetSubForum(); $gsfForm->validate(); // invalid request params if (!$gsfForm->isValid()) { throw new \SystemErrorException(array('title' => \View::$language->forum_sub_forum_error, 'description' => \View::$language->forum_sub_forum_request_invalid)); } // get request data $gsfData = $gsfForm->getData(); // get limit settings $gsfData->limit = \App::getConfig('forum')->topics_per_page; // TODO topics per page from member custom settings // calculate offset $gsfData->offset = ($gsfData->page - 1) * $gsfData->limit; // get subforum $subForum = helpers\SubForumHelper::getSubForumById($gsfData->id); if (!$subForum) { throw new \MemberErrorException(array('code' => 404, 'title' => \View::$language->forum_sub_forum_error, 'description' => \View::$language->forum_sub_forum_sub_forum_not_found)); } // get subforum topics $topics = helpers\SubForumTopicsHelper::getTopics($gsfData->id, $gsfData->offset, $gsfData->limit); if ($gsfData->page > 1 && !$topics) { throw new \SystemErrorException(array('title' => \View::$language->forum_sub_forum_error, 'description' => \View::$language->forum_sub_forum_page_not_found)); } // get posts pagination $pagination = array(); if ($subForum->topics_count > $gsfData->limit) { $pagination = \common\PaginationHelper::getItems('/forum/sub-forum?id=' . $subForum->id, $gsfData->page, $gsfData->limit, $subForum->topics_count); } // append breadcrumbs \common\BreadCrumbs::appendItems(array(new \common\BreadCrumbsItem('/forum/forum?id=' . $subForum->forum_id, $subForum->forum_title), new \common\BreadCrumbsItem(null, $subForum->title))); // assign data into view \View::assign(array('title' => $subForum->title, 'subForum' => $subForum, 'topics' => $topics, 'pagination' => $pagination)); // set output layout \View::setLayout('forum-sub-forum.phtml'); }