/**
  * Load view with individual post and replies and retweets
  * @param int $post_id
  * @param str $network
  */
 private function loadSinglePostThread($post_id, $network)
 {
     $this->setPageTitle('Public Post Replies');
     $this->post_dao->isPostByPublicInstance($_GET['t'], $network);
     $post = $this->post_dao->getPost($post_id, $network);
     if (!isset($post)) {
         $this->addErrorMessage("Post " . $post_id . " on " . ucwords($network) . " is not in ThinkUp.");
     } else {
         $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
         $options = $plugin_option_dao->getOptionsHash('geoencoder', true);
         if (isset($options['distance_unit']->option_value)) {
             $distance_unit = $options['distance_unit']->option_value;
         } else {
             $distance_unit = 'km';
         }
         $public_tweet_replies = $this->post_dao->getPublicRepliesToPost($post->post_id, $network, 'default', $distance_unit);
         $public_retweets = $this->post_dao->getRetweetsOfPost($post->post_id, $network, 'default', $distance_unit, true);
         $this->addToView('post', $post);
         $this->addToView('replies', $public_tweet_replies);
         $this->addToView('retweets', $public_retweets);
         $this->addToView('unit', $distance_unit);
         $rtreach = 0;
         foreach ($public_retweets as $t) {
             $rtreach += $t->author->follower_count;
         }
         $this->addToView('rtreach', $rtreach);
     }
 }
 /**
  * Show either timeline of public posts with counts, or an individual post thread with replies and retweets
  * @return string rendered view markup
  */
 public function control()
 {
     $this->setViewTemplate('public.tpl');
     $this->addToView('logo_link', 'public.php');
     if (isset($_REQUEST['page']) && is_numeric($_REQUEST['page'])) {
         $this->current_page = $_REQUEST['page'];
     } else {
         $this->current_page = 1;
     }
     if ($this->current_page > 1) {
         $this->addToView('prev_page', $this->current_page - 1);
     }
     $this->addToView('current_page', $this->current_page);
     $this->addToViewCacheKey($this->current_page);
     //if $_REQUEST["t"], load individual post + replies + retweets
     //TODO: change the t (for tweet) to p (for post)
     if (isset($_REQUEST['t']) && $this->post_dao->isPostByPublicInstance($_REQUEST['t'])) {
         $this->addToViewCacheKey($_REQUEST['t']);
         $this->loadSinglePostThread($_REQUEST['t']);
     } elseif (isset($_REQUEST["v"])) {
         //else if $_REQUEST["v"], display correct listing
         $this->addToViewCacheKey($_REQUEST['v']);
         $this->loadPublicPostList($_REQUEST["v"]);
     } else {
         //else default to public timeline list
         $this->addToViewCacheKey('timeline');
         $this->loadPublicPostList('timeline');
     }
     return $this->generateView();
 }
Exemplo n.º 3
0
//Pagination
$count = 15;
if (isset($_REQUEST['page'])) {
    $page = $_REQUEST['page'];
} else {
    $page = 1;
}
if ($page > 1) {
    $s->assign('prev_page', $page - 1);
}
$s->assign('cfg', $cfg);
$i = $id->getInstanceFreshestOne();
$s->assign('crawler_last_run', $i->crawler_last_run);
$s->assign('i', $_i);
// show tweet with public replies
if (isset($_REQUEST['t']) && $pd->isPostByPublicInstance($_REQUEST['t'])) {
    if (!$s->is_cached('public.tpl', $_REQUEST['t'])) {
        $post = $pd->getPost($_REQUEST['t']);
        $public_tweet_replies = $pd->getPublicRepliesToPost($post->post_id);
        $public_retweets = $pd->getRetweetsOfPost($post->post_id, true);
        $s->assign('post', $post);
        $s->assign('replies', $public_tweet_replies);
        $s->assign('retweets', $public_retweets);
        $rtreach = 0;
        foreach ($public_retweets as $t) {
            $rtreach += $t->author->follower_count;
        }
        $s->assign('rtreach', $rtreach);
        $s->assign('site_root', $THINKTANK_CFG['site_root_path']);
    }
    $s->display('public.tpl', $_REQUEST['t']);