Esempio n. 1
0
 public function get_posts($tid, $from, $topic_info)
 {
     $post = new \CODOF\Forum\Post($this->db);
     $posts = array();
     $num_pages = 'not_passed';
     $posts_per_page = \CODOF\Util::get_opt("num_posts_per_topic");
     $title = \CODOF\Filter::URL_safe($topic_info['title']);
     if (isset($_GET['str'])) {
         $num_pages = 'calc_count';
     }
     if (isset($_GET['str']) && $_GET['str'] != "") {
         $user = \CODOF\User\User::get();
         if (!$user->can('use search')) {
             exit('permission denied');
         }
         $search = new \CODOF\Search\Search();
         $search->str = $_GET['str'];
         $search->num_results = $posts_per_page;
         $search->from = $from * $search->num_results;
         if ($num_pages == 'calc_count') {
             $search->count_rows = true;
         }
         $search->tid = $tid;
         $search->match_titles = 'No';
         $search->order = $_GET['order'];
         $search->sort = $_GET['sort'];
         $search->time_within = $_GET['search_within'];
         $res = $search->search();
         if ($num_pages == 'calc_count') {
             $num_pages = $post->get_num_pages($search->get_total_count(), $search->num_results);
         }
         $post->topic_post_id = $topic_info['post_id'];
         $post->tuid = $topic_info['uid'];
         $post->cat_id = $topic_info['cat_id'];
         $post->tid = $tid;
         $post->safe_title = $title;
         $post->from = $from;
         $posts = $post->gen_posts_arr($res, $search);
         //var_dump($topics);
     } else {
         $topic = new \CODOF\Forum\Topic($this->db);
         $num_pages = $topic->get_num_pages($topic_info['no_posts'], $posts_per_page);
         $post->topic_post_id = $topic_info['post_id'];
         $post->tuid = $topic_info['uid'];
         $post->cat_id = $topic_info['cat_id'];
         $post->tid = $tid;
         $post->safe_title = $title;
         $post->from = $from;
         $posts = $post->get_posts($tid, $from);
     }
     return array("posts" => $posts, "num_pages" => $num_pages);
 }
Esempio n. 2
0
 public function listTaggedTopics($tag, $page = 1)
 {
     $posts_per_page = \CODOF\Util::get_opt("num_posts_all_topics");
     if ($page == null) {
         $page = 1;
     }
     $page = (int) $page;
     if ($page <= 1) {
         $from = 0;
     } else {
         $from = ($page - 1) * $posts_per_page;
     }
     $topics = new \Controller\Ajax\forum\topics();
     $taggedTopics = $topics->getTaggedTopics($tag, $from);
     $topic = new \CODOF\Forum\Topic($this->db);
     $num_pages = $topic->get_num_pages($topic->getTaggedTopicsCount($tag), $posts_per_page);
     $url = 'tags/' . $tag . '/';
     $curr_page = $page;
     //var_dump($taggedTopics);
     $this->smarty->assign('tag', $tag);
     $this->smarty->assign('curr_page', $curr_page);
     $this->smarty->assign('url', RURI . $url);
     $this->smarty->assign('num_pages', $num_pages);
     $this->smarty->assign('topics', json_encode($taggedTopics));
     $this->smarty->assign('tags', json_encode($taggedTopics['tags']));
     $this->css_files = array('tags');
     $this->js_files = array(array('tags/tags.js', array('type' => 'defer')));
     $this->view = 'forum/tags';
     \CODOF\Store::set('sub_title', $tag . ' - ' . _t('Tags'));
 }