/** * Load instance dashboard * @param str $username * @param str $network */ private function loadPublicInstanceDashboard($username, $network) { $instance_dao = DAOFactory::getDAO('InstanceDAO'); $instance = $instance_dao->getByUsernameOnNetwork($username, $network); if (isset($instance) && $instance->is_public) { $this->setPageTitle($instance->network_username . "'s Public Profile"); $this->addToView('instance', $instance); //user $user_dao = DAOFactory::getDAO('UserDAO'); $user = $user_dao->getDetails($instance->network_user_id, $instance->network); $this->addToView('user_details', $user); //posts $recent_posts = $this->post_dao->getAllPosts($instance->network_user_id, $instance->network, 5, true); $this->addToView('recent_posts', $recent_posts); $most_replied_to_alltime = $this->post_dao->getMostRepliedToPosts($instance->network_user_id, $network, 5); $this->addToView('most_replied_to_alltime', $most_replied_to_alltime); $most_retweeted_alltime = $this->post_dao->getMostRetweetedPosts($instance->network_user_id, $network, 5); $this->addToView('most_retweeted_alltime', $most_retweeted_alltime); $most_replied_to_1wk = $this->post_dao->getMostRepliedToPostsInLastWeek($instance->network_username, $instance->network, 5); $this->addToView('most_replied_to_1wk', $most_replied_to_1wk); $most_retweeted_1wk = $this->post_dao->getMostRetweetedPostsInLastWeek($instance->network_username, $instance->network, 5); $this->addToView('most_retweeted_1wk', $most_retweeted_1wk); $conversations = $this->post_dao->getPostsAuthorHasRepliedTo($instance->network_user_id, 5); $this->addToView('conversations', $conversations); //follows $follow_dao = DAOFactory::getDAO('FollowDAO'); $least_likely_followers = $follow_dao->getLeastLikelyFollowers($instance->network_user_id, 'twitter', 16); $this->addToView('least_likely_followers', $least_likely_followers); //follower count history $follower_count_dao = DAOFactory::getDAO('FollowerCountDAO'); $follower_count_history_by_day = $follower_count_dao->getHistory($instance->network_user_id, 'twitter', 'DAY'); $this->addToView('follower_count_history_by_day', $follower_count_history_by_day); $first_follower_count = $follower_count_history_by_day['history'][0]['count']; $last_follower_count = $follower_count_history_by_day['history'][sizeof($follower_count_history_by_day['history']) - 1]['count']; $this->addToView('follower_count_by_day_trend', ($last_follower_count - $first_follower_count) / sizeof($follower_count_history_by_day['history'])); $follower_count_history_by_week = $follower_count_dao->getHistory($instance->network_user_id, 'twitter', 'WEEK'); $this->addToView('follower_count_history_by_week', $follower_count_history_by_week); $first_follower_count = $follower_count_history_by_week['history'][0]['count']; $last_follower_count = $follower_count_history_by_week['history'][sizeof($follower_count_history_by_week['history']) - 1]['count']; $this->addToView('follower_count_by_week_trend', ($last_follower_count - $first_follower_count) / sizeof($follower_count_history_by_week['history'])); $post_dao = DAOFactory::getDAO('PostDAO'); list($all_time_clients_usage, $latest_clients_usage) = $post_dao->getClientsUsedByUserOnNetwork($instance->network_user_id, $instance->network); // Only show the top 10 most used clients, since forever $all_time_clients_usage = array_merge(array_slice($all_time_clients_usage, 0, 10), array('Others' => array_sum(array_slice($all_time_clients_usage, 10)))); $this->addToView('all_time_clients_usage', $all_time_clients_usage); // Only show the two most used clients for the last 25 posts $latest_clients_usage = array_slice($latest_clients_usage, 0, 2); $this->addToView('latest_clients_usage', $latest_clients_usage); } else { $this->addErrorMessage($username . " on " . ucwords($network) . " isn't set up on this ThinkUp installation."); } }
switch ($_REQUEST['d']) { case "tweets-all": $s->assign('header', 'All Posts'); $s->assign('all_tweets', $pd->getAllPosts($i->network_user_id, 15)); break; case "tweets-mostreplies": $s->assign('header', 'Most Replied-To Posts'); $s->assign('most_replied_to_tweets', $pd->getMostRepliedToPosts($i->network_user_id, 15)); break; case "tweets-mostretweeted": $s->assign('header', 'Most Forwarded'); $s->assign('most_retweeted', $pd->getMostRetweetedPosts($i->network_user_id, 15)); break; case "tweets-convo": $s->assign('header', 'Conversations'); $s->assign('author_replies', $pd->getPostsAuthorHasRepliedTo($i->network_user_id, 15)); break; case "mentions-all": $s->assign('header', 'All Mentions'); $s->assign('description', 'Any post that mentions you'); $s->assign('all_mentions', $pd->getAllMentions($i->network_username, 15)); $s->assign('all_tweets', $pd->getAllPosts($cfg->twitter_user_id, 15)); break; case "mentions-allreplies": $s->assign('header', 'Replies'); $s->assign('description', 'Posts that directly reply to you (i.e., start with your name)'); $s->assign('all_replies', $pd->getAllReplies($i->network_user_id, 15)); break; case "mentions-orphan": $s->assign('header', 'Not Replies or Forwards'); $s->assign('description', 'Mentions that are not associated with a specific post');