/**
  * 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']);
 }
Exemplo n.º 2
0
                $totals = $pd->getTotalPhotoPagesAndPostsByPublicInstances($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->getPhotoPostsByPublicInstances($page, $count));
                $s->assign('site_root', $THINKTANK_CFG['site_root_path']);
            }
            $s->assign('header', 'Photos');
            $s->assign('description', 'Posted photos');
            $s->display('public.tpl', 'photos-' . $i->network_username . "-" . $_u . "-" . $page);
            break;
        case 'links':
            if (!$s->is_cached('public.tpl', 'links-' . $page)) {
                $totals = $pd->getTotalLinkPagesAndPostsByPublicInstances($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->getLinkPostsByPublicInstances($page, $count));
                $s->assign('site_root', $THINKTANK_CFG['site_root_path']);
            }
            $s->assign('header', 'Links');
            $s->assign('description', 'Posted links');
            $s->display('public.tpl', 'links-' . $i->network_username . "-" . $_u . "-" . $page);
            break;
    }
} else {
    if (!$s->is_cached('public.tpl', 'timeline-' . $i->network_username . "-" . $_u . "-" . $page)) {
Exemplo n.º 3
0
 function testGetTotalLinkPagesAndPostsByPublicInstances()
 {
     $pdao = new PostDAO($this->db, $this->logger);
     $totals = $pdao->getTotalLinkPagesAndPostsByPublicInstances(15);
     $this->assertTrue($totals["total_posts"] == 40);
     $this->assertTrue($totals["total_pages"] == 3);
 }