public function form() { Phalanx::loadClasses('Profile', 'PostCategory', 'Lists', 'GamerTags', 'NotificationSettings'); $this->views->data = Profile::get_profile($this->session->user->login, 1, 0, 1, 0, 0, 1, 1); $this->views->categories = PostCategory::get(); $this->views->lists = Lists::from_user($this->session->user->id); $this->views->notification_settings = NotificationSettings::from_user($this->session->user->id); $this->views->message = $this->session->message; $this->session->message = ''; $this->views->display("settings_form.phtml"); }
private function feed() { Phalanx::loadClasses('Profile', 'Lists', 'PostCategory'); $user_data = Profile::get_profile($this->session->user->login); #Correção p/ um bug com os nomes de usuários incorretos if (empty($user_data->login)) { Request::redirect(HOST); } else { #Reutilização do mesmo core para criação da timeline - F**k yeah Phalanx::loadController('TimelineController'); $Timeline = new TimelineController(); $posts = $Timeline->BuildFromList($this->cookies->active_list); #Pego os outros dados do usuário que são utilizados na página de feed $this->views = new Views(new Template("default")); $this->views->data = $user_data; $this->views->lists = Lists::from_user($this->session->user->id); $this->views->categories = PostCategory::get(); $this->views->posts = $posts; $this->views->display("feed.phtml"); } }
public static function build_from_list($uid, $list_id, stdClass $config) { Phalanx::loadClasses('Friendship'); $friends_ids = Friendship::get_friend_array($uid); $friends_ids = implode(', ', $friends_ids); $where = ""; if (property_exists($config, 'min')) { $where .= " AND p.id < '{$config->min}'"; } if (property_exists($config, 'max')) { $where .= " AND p.id < '{$config->max}'"; } Phalanx::loadClasses('Lists', 'SocialNetwork', 'Facebook', 'Twitter', 'twitteroauth', 'Instagram', 'PostCategory', 'Favorites', 'Profile'); $list = Lists::from_user($uid, $list_id); $categories = array(); foreach ($list->categories as $category) { $categories[] = $category->id; } if (sizeof($categories) > 0) { Phalanx::loadClasses('Posts', 'PostComments'); $categories_ids = implode("', '", $categories); $custom_tl = array(); $m = Model::Factory('posts p', false, 0); $m->fields('DISTINCT p.id AS id', 'p.original_posts_id AS original_id', 'p.user_id AS user_id', 'p.content AS content', 'p.date AS date', 'p.title AS title', 'p.promoted AS promoted', 'u.name AS name', 'u.login AS user', 'ud.avatar AS avatar', 'p.like_count AS likes', 'p.dislike_count AS dislikes', 'p.comment_count AS comments', 'p.reblog_count AS reblogs', 'p.reply_count AS replies'); $m->innerJoin('user u', 'u.id = p.user_id'); $m->innerJoin('user_data ud', 'ud.user_id = p.user_id'); $m->innerJoin('posts_has_category phc', 'p.id = phc.posts_id'); $m->where("p.user_id IN({$friends_ids}) AND phc.category_id IN ('{$categories_ids}') {$where} AND u.banned IS NULL AND p.status=1 AND p.date > DATE_SUB(NOW(), INTERVAL 1 MONTH)"); # $m->group("p.original_posts_id"); $m->order('p.id DESC'); $m->limit(NUMBER_OF_POSTS_LOADED_PER_TIME); $skynerd_posts = $m->all(); foreach ($skynerd_posts as $each) { $o = new stdClass(); $o->date = Date::RelativeTime($each->date); $o->id = $each->id; $o->user = $each->user; $o->name = $each->name; $o->title = $each->title; $o->avatar = $each->avatar; $o->user_id = $each->user_id; $o->rating = new stdClass(); $o->rating->megaboga = $each->likes; $o->rating->whatever = $each->dislikes; $o->my_rating = Posts::userRating($uid, $each->id); $o->content = trim($each->content); $o->comments = $v->comments; $o->replies = $v->replies; $o->categories = PostCategory::from_post($each->id); $o->is_reblogged = Posts::userHasReblogged($each->id, $uid); $o->is_favorite = Favorites::is_favorite($uid, $each->id); $o->user_points = Profile::experience($v->user_id); $o->promoted = (bool) $each->promoted; if (!empty($o->original_id)) { //Se o post for um reblog, então o conteúdo dele deve ser o do reblogado, mostrando as ações $originalPost = Posts::from_user(false, $o->original_id); $originalPost = reset($originalPost); $o->content = $originalPost->content; $o->title = $originalPost->title; $o->reblogged_from = $originalPost->user; $o->original_date = $originalPost->date; $o->rating->reblog_count = $originalPost->rating->reblog_count; $o->is_reblogged = Posts::userHasReblogged($originalPost->id, $uid); } $custom_tl[] = $o; } } return $custom_tl; }