/** * Load view with appropriate public post list. Default to reverse chronological order. * @param string $list */ private function loadPublicPostList($list) { $totals = $this->post_dao->getTotalPagesAndPostsByPublicInstances($this->total_posts_per_page); switch ($list) { case 'timeline': $this->addToView('posts', $this->post_dao->getPostsByPublicInstances($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Latest'); $this->addToView('description', 'Latest public posts and public replies'); break; case 'mostretweets': $this->addToView('posts', $this->post_dao->getMostRetweetedPostsByPublicInstances($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Most forwarded'); $this->addToView('description', 'Posts that have been forwarded most often'); break; case 'mostretweets1wk': $this->addToView('posts', $this->post_dao->getMostRetweetedPostsByPublicInstancesInLastWeek($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Most forwarded this week'); $this->addToView('description', 'Posts that have been forwarded most often this week'); $totals = $this->post_dao->getTotalPagesAndPostsByPublicInstances($this->total_posts_per_page, 7); break; case 'mostreplies': $this->addToView('posts', $this->post_dao->getMostRepliedToPostsByPublicInstances($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Most replied to'); $this->addToView('description', 'Posts that have been replied to most often'); break; case 'mostreplies1wk': $this->addToView('posts', $this->post_dao->getMostRepliedToPostsByPublicInstancesInLastWeek($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Most replied to this week'); $this->addToView('description', 'Posts that have been replied to most often this week'); $totals = $this->post_dao->getTotalPagesAndPostsByPublicInstances($this->total_posts_per_page, 7); break; case 'photos': $this->addToView('posts', $this->post_dao->getPhotoPostsByPublicInstances($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Photos'); $this->addToView('description', 'Posted photos'); break; case 'links': $totals = $this->post_dao->getTotalLinkPagesAndPostsByPublicInstances($this->total_posts_per_page); $this->addToView('posts', $this->post_dao->getLinkPostsByPublicInstances($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Links'); $this->addToView('description', 'Posted links'); break; default: $this->addToView('posts', $this->post_dao->getPostsByPublicInstances($this->current_page, $this->total_posts_per_page)); $this->addToView('header', 'Latest'); $this->addToView('description', 'Latest public posts and public replies'); break; } if ($totals['total_pages'] > $this->current_page) { $this->addToView('next_page', $this->current_page + 1); } $this->addToView('total_pages', $totals['total_pages']); }
$s->assign('rtreach', $rtreach); $s->assign('site_root', $THINKTANK_CFG['site_root_path']); } $s->display('public.tpl', $_REQUEST['t']); } elseif (isset($_REQUEST['v'])) { $view = $_REQUEST['v']; switch ($view) { case 'timeline': if (!$s->is_cached('public.tpl', $page)) { $totals = $pd->getTotalPagesAndPostsByPublicInstances($count); if ($totals['total_pages'] > $page) { $s->assign('next_page', $page + 1); } $s->assign('current_page', $page); $s->assign('total_pages', $totals['total_pages']); $s->assign('posts', $pd->getPostsByPublicInstances($page, $count)); $s->assign('site_root', $THINKTANK_CFG['site_root_path']); } $s->assign('header', 'Latest'); $s->assign('description', 'Latest public posts and public replies'); $s->display('public.tpl', 'timeline-' . $i->network_username . "-" . $_u . "-" . $page); break; case 'mostretweets': if (!$s->is_cached('public.tpl', 'mostretweets-' . $page)) { $totals = $pd->getTotalPagesAndPostsByPublicInstances($count); if ($totals['total_pages'] > $page) { $s->assign('next_page', $page + 1); } $s->assign('current_page', $page); $s->assign('total_pages', $totals['total_pages']); $s->assign('posts', $pd->getMostRetweetedPostsByPublicInstances($page, $count));
function testGetPageThreeOfPublicPosts() { $pdao = new PostDAO($this->db, $this->logger); $page_of_posts = $pdao->getPostsByPublicInstances(3, 15); //Assert DAO returns 10 posts $this->assertTrue(sizeof($page_of_posts) == 10); $this->assertTrue($page_of_posts[0]->post_text == "This is post 9"); $this->assertTrue($page_of_posts[9]->post_text == "This is post 0"); }