/**
  * 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.");
     }
 }