Esempio n. 1
0
 public static function from_user($uid, $list_id = false)
 {
     $m = Model::Factory('user_lists', true, 0);
     if ($list_id === false) {
         $m = Model::Factory('user_lists', true, 0, 'lists_' . $uid);
         $m->where("user_id='{$uid}'");
     } else {
         $m->where("user_id='{$uid}' AND id='{$list_id}'");
     }
     $lists = $m->all();
     $return = array();
     if (is_array($lists)) {
         foreach ($lists as $list) {
             $o = new stdClass();
             $o->id = $list->id;
             $o->name = $list->name;
             $c = Model::Factory('user_lists_has_category ulhc')->fields('ulhc.category_id AS id')->where("ulhc.user_lists_id='{$list->id}'")->all();
             if ($c) {
                 Phalanx::loadClasses('PostCategory');
                 $categories = array();
                 foreach ($c as $category) {
                     $categories[] = PostCategory::translate($category->id);
                 }
                 $o->categories = $categories;
             }
             $o->social_networks = Model::Factory('user_lists_has_social_network ulhsn')->fields('sn.id AS id', 'sn.name')->innerJoin('social_network sn', 'ulhsn.social_network_id = sn.id')->where("ulhsn.user_lists_id='{$list->id}'")->all();
             $return[] = $o;
         }
     }
     if ($list_id) {
         return $return[0];
     } else {
         return $return;
     }
 }
 public function editAction()
 {
     $categories = PostCategory::find(['type = "post" AND id_web = "' . $this->auth->id_web . '"']);
     // print_r($this->params);
     $post = Post::findFirst($this->params->id);
     $this->view->setVar("data", $post);
     $this->view->setVar("categories", $categories);
 }
Esempio n. 3
0
 /**
  * Categories list
  */
 public static function listing()
 {
     $categories = PostCategory::all();
     $id_tree = [];
     foreach ($categories as $cat) {
         $id_tree[$cat->id] = $cat;
     }
     return $id_tree;
 }
 public function index()
 {
     if (\Input::get('theme')) {
         \Cookie::queue('theme', \Input::get('theme'), 100);
         return Redirect::to('/')->withCookie(cookie('theme', \Input::get('theme'), 100));
     }
     $data = array('videos' => Video::where('active', '=', '1')->orderBy('created_at', 'DESC')->simplePaginate($this->videos_per_page), 'current_page' => 1, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'pagination_url' => '/videos', 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
     //dd($data['videos']);
     return View::make('Theme::home', $data);
 }
 public function index()
 {
     $search_value = Input::get('value');
     if (empty($search_value)) {
         return Redirect::to('/');
     }
     $videos = Video::where('active', '=', 1)->where('title', 'LIKE', '%' . $search_value . '%')->orderBy('created_at', 'desc')->get();
     $posts = Post::where('active', '=', 1)->where('title', 'LIKE', '%' . $search_value . '%')->orderBy('created_at', 'desc')->get();
     $data = array('videos' => $videos, 'posts' => $posts, 'search_value' => $search_value, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
     return View::make('Theme::search-list', $data);
 }
 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");
 }
Esempio n. 7
0
 public static function get_or_create_main_category($taxonomy = 'Post')
 {
     $category = Doctrine_Query::create()->from('PostCategory o')->where('o.site_id = ? AND o.taxonomy = ? AND o.level = 0', array(SITE_ID, $taxonomy))->fetchOne();
     if (!$category) {
         $category = new PostCategory();
         $category->Translation['en']->name = $taxonomy . ' Main Category';
         $category->Translation['en']->slug = ucfirst($taxonomy) . '-main-category';
         $lng = pjango_ini_get('LANGUAGE_CODE');
         if ($lng != 'en') {
             $category->Translation[$lng]->name = $taxonomy . ' ' . __('Main Category');
             $category->Translation[$lng]->slug = ucfirst($taxonomy) . '-' . __('main-category');
         }
         $category->site_id = SITE_ID;
         $category->taxonomy = $taxonomy;
         $category->save();
         $treeObject = Doctrine_Core::getTable('PostCategory')->getTree();
         $treeObject->createRoot($category);
     }
     return $category;
 }
 public function category($category)
 {
     $page = Input::get('page');
     if (!empty($page)) {
         $page = Input::get('page');
     } else {
         $page = 1;
     }
     $cat = PostCategory::where('slug', '=', $category)->first();
     $data = array('posts' => Post::where('active', '=', '1')->where('post_category_id', '=', $cat->id)->orderBy('created_at', 'DESC')->simplePaginate($this->posts_per_page), 'current_page' => $page, 'category' => $cat, 'page_title' => 'Posts - ' . $cat->name, 'page_description' => 'Page ' . $page, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'pagination_url' => '/posts/category/' . $category, 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
     return View::make('Theme::post-list', $data);
 }
 public function show_favorites()
 {
     if (!Auth::guest()) {
         $page = Input::get('page');
         if (empty($page)) {
             $page = 1;
         }
         $favorites = Favorite::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->get();
         $favorite_array = array();
         foreach ($favorites as $key => $fave) {
             array_push($favorite_array, $fave->video_id);
         }
         $videos = Video::where('active', '=', '1')->whereIn('id', $favorite_array)->paginate(12);
         $data = array('videos' => $videos, 'page_title' => ucfirst(Auth::user()->username) . '\'s Favorite Videos', 'current_page' => $page, 'page_description' => 'Page ' . $page, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'pagination_url' => '/favorites', 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
         return View::make('Theme::video-list', $data);
     } else {
         return Redirect::to('videos');
     }
 }
Esempio n. 10
0
 public static function from_user($uid, stdClass $config)
 {
     $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('Posts', 'PostComments', 'PostCategory');
     $m = Model::Factory('posts p', true, 120);
     $m->fields('DISTINCT p.id 	AS id', 'p.user_id 		AS user_id', 'p.content 		AS content', 'p.date 		AS date', 'p.title		AS title', 'p.like_count		AS likes', 'p.dislike_count	AS dislikes', 'p.comment_count	AS comments', 'p.reply_count		AS replies', 'u.name 		AS name', 'u.login		AS user', 'ud.avatar 		AS avatar');
     $m->innerJoin('user u', 'u.id = p.user_id');
     $m->leftJoin('user_data ud', 'ud.user_id = p.user_id');
     $m->innerJoin('favorites f', 'f.posts_id = p.id');
     $m->order('p.date DESC');
     $m->where("f.user_id='{$uid}' AND wp_posts_ID IS NULL AND p.status=1 {$where}");
     $m->limit(NUMBER_OF_POSTS_LOADED_PER_TIME);
     $data = $m->all();
     $ret = array();
     foreach ($data as $v) {
         $o = new stdClass();
         $o->date = Date::RelativeTime($v->date);
         $o->id = $v->id;
         $o->name = $v->name;
         $o->title = $v->title;
         $o->avatar = $v->avatar;
         $o->user_id = $v->user_id;
         $o->rating = new stdClass();
         $o->rating->megaboga = $v->likes;
         $o->rating->whatever = $v->dislikes;
         $o->my_rating = Posts::userRating($uid, $v->id);
         $o->content = trim($v->content);
         $o->comments = $v->comments;
         $o->replies = $v->replies;
         $o->user = $v->user;
         $o->categories = PostCategory::from_post($v->id);
         $o->is_favorite = true;
         $ret[] = $o;
     }
     return $ret;
 }
Esempio n. 11
0
 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 function order()
 {
     $category_order = json_decode(Input::get('order'));
     $post_categories = PostCategory::all();
     $order = 1;
     foreach ($category_order as $category_level_1) {
         $level1 = PostCategory::find($category_level_1->id);
         if ($level1->id) {
             $level1->order = $order;
             $level1->parent_id = NULL;
             $level1->save();
             $order += 1;
         }
         if (isset($category_level_1->children)) {
             $children_level_1 = $category_level_1->children;
             foreach ($children_level_1 as $category_level_2) {
                 $level2 = PostCategory::find($category_level_2->id);
                 if ($level2->id) {
                     $level2->order = $order;
                     $level2->parent_id = $level1->id;
                     $level2->save();
                     $order += 1;
                 }
                 if (isset($category_level_2->children)) {
                     $children_level_2 = $category_level_2->children;
                     foreach ($children_level_2 as $category_level_3) {
                         $level3 = PostCategory::find($category_level_3->id);
                         if ($level3->id) {
                             $level3->order = $order;
                             $level3->parent_id = $level2->id;
                             $level3->save();
                             $order += 1;
                         }
                     }
                 }
             }
         }
     }
     return 1;
 }
 public function pages()
 {
     $data = array('pages' => Page::orderBy('created_at', 'DESC')->get(), 'page_title' => 'Pages', 'page_description' => 'All Pages', 'menu' => Menu::orderBy('order', 'ASC')->get(), 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
     return View::make('Theme::page-list', $data);
 }
Esempio n. 14
0
 function generate_menu($menu)
 {
     $previous_item = array();
     $first_parent_id = 0;
     $depth = 0;
     $output = '';
     foreach ($menu as $menu_item) {
         $hasChildren = $menu_item->hasChildren();
         if (isset($previous_item->id) && $menu_item->parent_id == $previous_item->parent_id || $menu_item->parent_id == NULL) {
             $output .= '</li>';
         }
         if (isset($previous_item->parent_id) && $previous_item->parent_id !== $menu_item->parent_id && $previous_item->id != $menu_item->parent_id) {
             if ($depth == 2) {
                 $output .= '</li></ul>';
                 $depth -= 1;
             }
             if ($depth == 1 && $menu_item->parent_id == $first_parent_id) {
                 $output .= '</li></ul>';
                 $depth -= 1;
             }
         }
         if ($menu_item->type == 'videos') {
             $active = '';
             if (Request::is('videos')) {
                 $active = ' active';
             }
             $output .= '<li class="dropdown' . $active . '">';
             $output .= '<a href="/videos" class="dropdown-toggle">' . $menu_item->name . ' <span class="caret"></span></a>';
             $output .= '<ul class="dropdown-menu multi-level" role="menu">';
             $output .= generate_video_post_menu(VideoCategory::orderBy('order', 'ASC')->get(), '/videos/category/');
             $output .= '</li></ul>';
             $output .= '</li>';
             continue;
         }
         if ($menu_item->type == 'posts') {
             $active = '';
             if (Request::is('posts')) {
                 $active = ' active';
             }
             $output .= '<li class="dropdown' . $active . '">';
             $output .= '<a href="/posts" class="dropdown-toggle">' . $menu_item->name . ' <span class="caret"></span></a>';
             $output .= '<ul class="dropdown-menu multi-level" role="menu">';
             $output .= generate_video_post_menu(PostCategory::orderBy('order', 'ASC')->get(), '/posts/category/');
             $output .= '</li></ul>';
             $output .= '</li>';
             continue;
         }
         $li_class = '';
         $caret = '';
         $dropdown_toggle = '';
         if ($hasChildren) {
             $dropdown_toggle = ' class="dropdown-toggle"';
         }
         if ($hasChildren && $depth == 0) {
             if (Request::is(str_replace('/', '', $menu_item->url))) {
                 $li_class .= ' class="active dropdown"';
             } else {
                 $li_class .= ' class="dropdown"';
             }
             $caret = ' <span class="caret"></span>';
         } elseif ($hasChildren && $depth > 0) {
             $li_class .= ' class="dropdown-submenu"';
         }
         if (!$hasChildren && $depth == 0 && Request::is(str_replace('/', '', $menu_item->url)) || $menu_item->url == '/' && Request::is('/')) {
             $li_class .= ' class="active"';
         }
         $output .= '<li' . $li_class . '>';
         $output .= '<a href="' . $menu_item->url . '"' . $dropdown_toggle . '>' . $menu_item->name . $caret . '</a>';
         if ($hasChildren) {
             $output .= '<ul class="dropdown-menu multi-level" role="menu">';
             $depth += 1;
         }
         $previous_item = $menu_item;
     }
     $output .= '</li></ul>';
     return $output;
 }
Esempio n. 15
0
 /**
  * Import videos from youtube
  *
  * @param Request $request
  * @param $match
  * @return string
  */
 public function import(Request $request, $match)
 {
     if ($request->isMethod('post')) {
         $items = [];
         $query = ['part' => 'snippet,id', 'channelId' => $request->get('channel')];
         // Fetch videos
         /** @var Google $sm */
         $sm = NCService::load('SocialMedia.Google');
         while ($response = $sm->request('https://www.googleapis.com/youtube/v3/search', $query)) {
             $response = json_decode($response, true);
             $items = array_merge($items, $response['items']);
             // Move to next page or break
             if (isset($response['nextPageToken']) && $response['nextPageToken']) {
                 $query['pageToken'] = $response['nextPageToken'];
             } else {
                 break;
             }
         }
         // Save videos
         foreach ($items as $video) {
             $id = $video['id']['videoId'];
             $url = 'https://www.youtube.com/watch?v=' . $id;
             $title = $video['snippet']['title'];
             $description = $video['snippet']['description'];
             $iframe = '<iframe class="youtube" width="560" height="315" src="https://www.youtube.com/embed/' . $id . '" frameborder="0" allowfullscreen></iframe>';
             $created_at = strtotime($video['snippet']['publishedAt']);
             // Get image url
             $preview_img = end(array_values($video['snippet']['thumbnails']))['url'];
             // Render import template
             $body = $this->view->render('@assets/templates/youtube.import.twig', ['title' => $title, 'description' => $description, 'player' => $iframe, 'url' => $url, 'short' => '#split#', 'preview' => $preview_img]);
             $entity = new \Post(['author_id' => $this->user->id, 'title' => $title, 'content' => str_replace('#split#', '<!-- split -->', $body), 'moderate' => 1, 'category_id' => $request->get('category'), 'created_at' => $created_at, 'updated_at' => $created_at]);
             $entity->save();
         }
         $this->view->assign('message', $this->lang->translate('post.youtube.done', count($items)));
     }
     return $this->view->render('posts/import.twig', ['title' => $this->lang->translate('post.import'), 'categories' => \PostCategory::as_array(\PostCategory::all())]);
 }
Esempio n. 16
0
 public static function exportFromUser($uid)
 {
     Phalanx::loadClasses('PostCategory', 'PostComments', 'Favorites');
     $m = Model::Factory('posts p', 0);
     $m->fields('p.id 					AS id', 'p.original_posts_id	AS original_id', 'p.title		AS title', 'p.user_id 		AS user_id', 'p.content 		AS content', 'p.date 		AS date', 'p.public		AS privacy', 'p.like_count		AS likes', 'p.dislike_count	AS dislikes', 'p.reblog_count		AS reblogs', 'p.comment_count	AS comments', 'p.reply_count		AS replies', 'p.promoted			AS promoted', 'u.name 		AS name', 'u.login		AS user', 'ud.avatar 		AS avatar');
     $m->innerJoin('user u', 'u.id = p.user_id');
     $m->innerJoin('user_data ud', 'ud.user_id = p.user_id');
     $m->order('p.id DESC');
     $where = array();
     $where[] = "p.status=1";
     $where[] = "p.original_posts_id IS NULL";
     if ($uid) {
         $where[] = "p.user_id = '{$uid}'";
     }
     $where = implode(" AND ", $where);
     $m->where($where);
     $data = $m->all();
     $ret = array();
     $Session = new Session();
     foreach ($data as $v) {
         $o = new stdClass();
         $o->date = Date::RelativeTime($v->date);
         $o->id = $v->id;
         $o->original_id = $v->original_id;
         $o->title = $v->title;
         $o->user = $v->user;
         $o->name = $v->name;
         $o->avatar = $v->avatar;
         $o->user_id = $v->user_id;
         $o->content = trim($v->content);
         $o->rating = new stdClass();
         $o->rating->whatever = (int) abs($v->dislikes);
         $o->rating->megaboga = (int) abs($v->likes);
         $o->rating->reblog_count = (int) abs($v->reblogs);
         $o->my_rating = self::userRating($Session->user->id, $v->id);
         $o->is_reblogged = self::userHasReblogged($o->original_id, $Session->user->id);
         $o->categories = PostCategory::from_post($v->id);
         $o->comments = $v->comments;
         $o->comments_array = PostComments::get($v->id);
         $o->replies = $v->replies;
         $o->privacy = $v->privacy;
         $o->promoted = $v->promoted;
         $o->is_favorite = Favorites::is_favorite($uid, $v->id);
         $o->user_points = Profile::experience($v->user_id);
         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 = self::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;
         }
         $ret[] = $o;
     }
     return $ret;
 }
Esempio n. 17
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PostCategory $value A PostCategory object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PostCategory $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Esempio n. 18
0
 public function Post()
 {
     if (!$this->isLoggedIn) {
         return;
     }
     if ($this->session->accept_token != REQUEST_TOKEN) {
         Request::redirect(HOST . 'login');
         return;
     }
     $content = stripslashes(Request::post(false)->content);
     #Faz a validação do HTML; HTMLPurifier <3
     require_once EXTENSIONS_DIR . 'HTMLPurifier/HTMLPurifier.includes.php';
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Cache.DefinitionImpl', null);
     $config->set('HTML.TargetBlank', true);
     $config->set('HTML.SafeObject', true);
     $config->set('HTML.SafeEmbed', true);
     $config->set('HTML.SafeIframe', true);
     $config->set('Output.FlashCompat', true);
     $config->set('HTML.FlashAllowFullScreen', true);
     $config->set('HTML.Allowed', 'i, b, a[href], p, ul, ol, li, span[style], img[src|style], strike, br, hr, blockquote, div, object, param[name|value], embed[src|type|width|height|allowscriptaccess], iframe[src|width|height]');
     $config->set('CSS.AllowedProperties', 'color, float, height, width, margin, border');
     $config->set('AutoFormat.Linkify', true);
     $config->set('URI.MungeResources', true);
     $config->set('URI.SafeIframeRegexp', '#^https://((www.)?youtube.com/embed/|player.vimeo.com/video/)#');
     $HTMLPurifier = new HTMLPurifier($config);
     $content = $HTMLPurifier->purify($content);
     $content = preg_replace('/(?<=^|\\s|>)@([A-Za-z0-9_]{1,20})/', '<a class="profile-link" href="' . HOST . 'perfil/$1" data-login="******">@$1</a>', $content);
     $bbCodeTags = array('spoiler' => array('<div class="spoiler-alert"><span class="alert"><b>SPOILER ALERT!</b> <a href="javascript:void(0);">Clique aqui</a> para exibir.</span><span class="spoiler-content">', '<span></div>'));
     $content = BBCode::parse($content, $bbCodeTags);
     Phalanx::loadClasses('Profile', 'Badges', 'PostCategory');
     $m = Model::Factory('posts');
     $m->user_id = $this->session->user->id;
     if (trim($this->post->title) != "") {
         $m->title = $this->post->title;
     }
     $m->content = $content;
     $m->public = $this->post->post_privacy;
     $m->date = date('Y-m-d H:i:s');
     $m->like_count = 0;
     $m->dislike_count = 0;
     $m->comment_count = 0;
     $post_id = $m->insert();
     if (isset($this->post->categories)) {
         $categories = explode(",", $this->post->categories);
         foreach ($categories as $category) {
             $category = trim($category);
             $categoryID = PostCategory::get($category);
             $m = Model::Factory('posts_has_category');
             $m->posts_id = $post_id;
             $m->category_id = $categoryID;
             $m->insert();
         }
     }
     $view = new Views();
     $view->title = $this->post->title;
     $view->content = $content;
     $view->user = $this->session->user->login;
     $view->avatar = $this->session->user->other_data->avatar;
     $view->when = ' agora';
     $view->post_id = $post_id;
     $view->rating = new stdClass();
     $view->rating->whatever = 0;
     $view->rating->megaboga = 0;
     $view->my_rating = null;
     $view->its_mine = true;
     $view->experience = Profile::experience($this->session->user->id);
     $view->badges = Badges::from_user($this->session->user->id, 4);
     preg_match_all('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', $this->post->content, $usernames);
     foreach ($usernames[1] as $username) {
         $user = Profile::get_user_info($username);
         if ($user) {
             $n = new Notification(Notification::TAGGED_IN_A_POST, $this->session->user->id, $post_id, $user->id);
         }
     }
     if ($this->post->post_to_twitter == 1 or $this->post->post_to_facebook == 1) {
         $o = new stdClass();
         $o->title = $this->post->title;
         $o->url = HOST . 'perfil/' . $this->session->user->login . '/post/' . $post_id . '-' . mb_strtolower(preg_replace('/--+/u', '-', preg_replace('/[^\\w\\-]+/u', '-', $this->post->title)));
         $o->uid = $this->session->user->id;
         $o->content = strip_tags($content);
         $o->avatar = MEDIA_DIR . 'images/avatar/big/' . $this->session->user->other_data->avatar;
         $o->post_id = $post_id;
         try {
             if ($this->post->post_to_facebook == 1) {
                 Phalanx::loadController('FacebookController');
                 $facebook = new FacebookController();
                 $facebook->callOpenGraphAction('write', array('article_' => $o->url));
             }
             if ($this->post->post_to_twitter == 1) {
                 Phalanx::loadController('TwitterController');
                 $twitter = new TwitterController();
                 $twitter->sharePost($o);
             }
         } catch (Exception $e) {
         }
     }
     header("Content-type: text/html; charset=utf-8");
     echo $view->render("post_body.phtml");
 }
Esempio n. 19
0
 protected function define_fields()
 {
     $this->parent_id = new DropDownField(__("Parent PostCategory"), \PostCategory::findAllAsChoice($this->taxonomy));
     $this->name = new TextField(__('PostCategory Name'), 25, 255);
     $this->slug = new TextField(__('PostCategory Slug'), 25, 255);
 }
Esempio n. 20
0
 function render($contxt, $stream)
 {
     $contentType = ContentType::get_for_model('Post', 'Pjango\\Contrib\\Post');
     $slug = false;
     if (isset($this->args[0])) {
         $slug = $this->clearQuotes($this->args[0]);
     }
     $q = Doctrine_Query::create()->from('PostCategory c')->leftJoin('c.Translation t')->where('c.site_id = ? AND c.taxonomy = ?', array(SITE_ID, Post::TYPE_POST));
     if ($slug) {
         $category = PostCategory::findBySlug($slug, Post::TYPE_POST);
         if ($category) {
             $q->andWhere('c.lft >= ? AND c.rgt <= ?', array($category->lft, $category->rgt));
         }
     }
     $results = $q->execute();
     //print_r($results->toArray());
     $htmlContent = '<div class="section post">';
     if ($pageLayout->show_title) {
         $htmlContent .= '<h2>' . __($pageLayout->title) . '</h2>';
     }
     $htmlContent .= '<div class="box-content">';
     //$htmlContent .= '<ul>'.implode('', $htmlItems).'</ul>';
     $htmlContent .= '</div>';
     $htmlContent .= '<div class="buttons"><div class="right"><a href="' . pjango_ini_get('SITE_URL') . '/post/">' . __('All Posts') . ' &raquo;</a></div></div>';
     $htmlContent .= '<div style="clear:both;"></div>';
     $htmlContent .= '</div>';
     //$stream->write($htmlContent);
 }
Esempio n. 21
0
 /**
  * @param Request $request
  * @param null $matches
  * @return mixed|string
  */
 public function create(Request $request, $matches = null)
 {
     $this->authenticated_only();
     if (!$this->user->can('publicate')) {
         return $this->error403($request);
     }
     $title = $this->lang->translate('post.create');
     // Get post for updating
     $id = intval($matches->get('id', $request->get('id')));
     if ($id > 0) {
         $post = \Post::find(['conditions' => ['id = ? AND author_id = ?', $id, $this->user->id]]);
         $title = $this->lang->translate('post.editing', $post->title);
     } else {
         $last_category = \PostCategory::last();
         if ($last_category) {
             $last_category = $last_category->to_array();
         } else {
             $last_category = null;
         }
         $post = ['title' => $this->lang->translate('post.name'), 'content' => '', 'category' => $last_category];
     }
     // Create or update page
     if ($request->isMethod('post')) {
         if ($post instanceof \Post) {
             $post->title = $request->get('title');
             $post->content = $request->get('content');
             $post->category_id = $request->get('category');
             $post->keywords = $request->get('keywords');
             $post->slug = $request->get('slug');
             $post->moderate = $this->user->can('premoderate_publ');
         } else {
             $post = new \Post(['title' => $request->get('title'), 'content' => $request->get('content'), 'category_id' => $request->get('category'), 'keywords' => $request->get('keywords'), 'slug' => $request->get('slug'), 'author_id' => $this->user->id, 'moderate' => $this->user->can('premoderate_publ')]);
         }
         // Updating instance
         $post->save();
         if (!$post->moderate) {
             // Exporting to social
             static::export($post, $this->view);
             // Ping sitemap
             NCService::load('SocialMedia.Ping');
         }
         return static::json_response(['success' => true, 'message' => $this->lang->translate('form.saved')]);
     }
     if ($post instanceof \Post) {
         $post = $post->to_array();
     }
     return $this->view->render('posts/create.twig', ['post' => $post, 'title' => $title, 'categories' => \PostCategory::as_array(\PostCategory::all())]);
 }
 /**
  * Declares an association between this object and a PostCategory object.
  *
  * @param      PostCategory $v
  * @return     PostCategoryRelation The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setPostCategory(PostCategory $v = null)
 {
     if ($v === null) {
         $this->setCategoryId(NULL);
     } else {
         $this->setCategoryId($v->getId());
     }
     $this->aPostCategory = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the PostCategory object, it will not be re-added.
     if ($v !== null) {
         $v->addPostCategoryRelation($this);
     }
     return $this;
 }
 public function password_reset_token($token)
 {
     $data = array('type' => 'reset_password', 'token' => $token, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'payment_settings' => PaymentSetting::first(), 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
     return View::make('Theme::auth', $data);
 }
Esempio n. 24
0
 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;
 }
 public function renew($username)
 {
     $user = User::where('username', '=', $username)->first();
     $payment_settings = PaymentSetting::first();
     if ($payment_settings->live_mode) {
         User::setStripeKey($payment_settings->live_secret_key);
     } else {
         User::setStripeKey($payment_settings->test_secret_key);
     }
     if (Auth::user()->username == $username) {
         $data = array('user' => $user, 'post_route' => URL::to('user') . '/' . $user->username . '/update', 'type' => 'renew_subscription', 'menu' => Menu::orderBy('order', 'ASC')->get(), 'payment_settings' => $payment_settings, 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
         return View::make('Theme::user', $data);
     } else {
         return Redirect::to('/');
     }
 }
Esempio n. 26
0
 function admin_category_addchange($request, $taxonomy = 'Post', $id = false)
 {
     $templateArr = array('current_admin_menu' => $taxonomy, 'current_admin_submenu' => $taxonomy, 'current_admin_submenu2' => 'PostCategory', 'title' => __('Post Category Add/Change'));
     if (!$request->user->has_perm($taxonomy . '.can_change_PostCategory')) {
         Messages::Error(__('Do not have permission to do this.'));
         HttpResponseRedirect($_SERVER['HTTP_REFERER']);
     }
     $modelClass = 'PostCategory';
     if ($taxonomy == 'Post') {
         $formClass = 'Pjango\\Contrib\\Post\\Forms\\PostCategoryForm';
     } else {
         $formClass = $taxonomy . '\\Forms\\PostCategoryForm';
     }
     $formData = array();
     $lng = pjango_ini_get('LANGUAGE_CODE');
     //eğer kategori yoksa ekle
     $catTest = Doctrine_Query::create()->from('PostCategory o')->where('o.site_id = ? AND o.taxonomy = ?', array(SITE_ID, $taxonomy))->count();
     if ($catTest <= 0) {
         $category = new PostCategory();
         $category->Translation[$lng]->name = __($taxonomy . ' Main Category');
         $category->Translation[$lng]->slug = __(ucfirst($taxonomy) . '-main-category');
         $category->site_id = SITE_ID;
         $category->taxonomy = $taxonomy;
         $category->save();
         $treeObject = Doctrine_Core::getTable('PostCategory')->getTree();
         $treeObject->createRoot($category);
     }
     if ($id) {
         $addchangeObj = Doctrine_Query::create()->from('PostCategory o')->leftJoin('o.Translation t')->addWhere('o.site_id = ? AND o.id = ?', array(SITE_ID, $id))->fetchOne();
         if ($addchangeObj) {
             $parent = $addchangeObj->getNode()->getParent();
             $formData = $addchangeObj->toArray();
             $templateArr['addchange_obj'] = $addchangeObj;
             $formData['parent_id'] = $parent->id;
             $formData['name'] = $addchangeObj->Translation[$lng]->name;
             $formData['slug'] = $addchangeObj->Translation[$lng]->slug;
         }
     }
     if ($request->POST) {
         $form = new $formClass($taxonomy, $request->POST);
         if ($form->is_valid()) {
             $formData = $form->cleaned_data();
             if (!$addchangeObj) {
                 $addchangeObj = new $modelClass();
             }
             try {
                 $parent = Doctrine::getTable($modelClass)->find($formData['parent_id']);
                 $addchangeObj->taxonomy = $taxonomy;
                 $addchangeObj->site_id = SITE_ID;
                 $addchangeObj->Translation[$lng]->name = $formData['name'];
                 $addchangeObj->Translation[$lng]->slug = $formData['slug'];
                 if ($addchangeObj->state() == Doctrine_Record::STATE_TDIRTY || $addchangeObj->state() == Doctrine_Record::STATE_TCLEAN) {
                     $addchangeObj->getNode()->insertAsLastChildOf($parent);
                 } else {
                     $addchangeObj->save();
                     $curParent = $addchangeObj->getNode()->getParent();
                     if ($curParent->id != $parent->id) {
                         $addchangeObj->getNode()->moveAsLastChildOf($parent);
                     }
                 }
                 Messages::Info(pjango_gettext('The operation completed successfully'));
                 HttpResponseRedirect('/admin/' . $taxonomy . '/' . $modelClass . '/');
             } catch (Exception $e) {
                 Messages::Error($e->getMessage());
             }
         }
     }
     if (!$form) {
         $form = new $formClass($taxonomy, $formData);
     }
     $templateArr['addchange_form'] = $form;
     $templateArr['taxonomy'] = $taxonomy;
     render_to_response('admin/addchange.html', $templateArr);
 }
 /**
  * Show the form for editing the specified video.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $post = Post::find($id);
     $data = array('headline' => '<i class="fa fa-edit"></i> Edit Post', 'post' => $post, 'post_route' => URL::to('admin/posts/update'), 'button_text' => 'Update Post', 'admin_user' => Auth::user(), 'post_categories' => PostCategory::all());
     return View::make('admin.posts.create_edit', $data);
 }