Ejemplo n.º 1
0
 public static function feedsID($post_id)
 {
     $ids = array();
     foreach (FeedPost::where('post_id', $post_id)->get() as $record) {
         $ids[] = $record->feed_id;
     }
     return $ids;
 }
Ejemplo n.º 2
0
 public function topost($id)
 {
     $post = Post::find($id);
     if ($post) {
         switch ($post->taxonomy_id) {
             case 1:
                 $uri = Post::getFullURI($post->id, true);
                 return Redirect::to($uri);
             case 2:
                 $feed = FeedPost::where('post_id', $post->id)->first();
                 if ($feed) {
                     $page = Post::where('feed_id', $feed->feed_id)->first();
                     if ($page) {
                         $viewmods = WebAPL\Template::getViewMethodList('page');
                         $uri = Post::getFullURI($page->id, true);
                         if (isset($viewmods[$page->view_mod]['support_item']) && $viewmods[$page->view_mod]['support_item']) {
                             $plang = PostLang::where('post_id', $post->id)->where('lang_id', \WebAPL\Language::getId())->first();
                             if ($plang) {
                                 $url = $uri . "?item=" . $plang->uri;
                             } else {
                                 $url = $uri;
                             }
                         } else {
                             $url = $uri;
                         }
                         return Redirect::to($url);
                     } else {
                         throw new Exception("Not found page, post #{$id}");
                     }
                 } else {
                     throw new Exception("Not found feed, post #{$id}");
                 }
                 break;
             default:
                 throw new Exception("Not found taxonomy, post #{$id}");
                 break;
         }
     } else {
         throw new Exception("Post not found #{$id}");
     }
 }
Ejemplo n.º 3
0
 public function postDeletefeed()
 {
     $id = Input::get('id');
     Feed::where('id', $id)->delete();
     FeedPost::where('feed_id', $id)->delete();
     FeedRel::where('feed_id', $id)->delete();
     return Redirect::to('feed');
 }
Ejemplo n.º 4
0
 public static function getYears($feed_id)
 {
     return Post::join(FeedPost::getTableName(), FeedPost::getField('post_id'), '=', Post::getField('id'))->distinct()->orderBy(Post::getField('created_at'), 'desc')->select(DB::raw("YEAR(" . Post::getField('created_at') . ") as year"))->where(FeedPost::getField('feed_id'), '=', $feed_id)->get();
 }
Ejemplo n.º 5
0
 public static function getPostCount($feed_id)
 {
     return Feed::join(FeedPost::getTableName(), FeedPost::getField('feed_id'), '=', Feed::getField('id'))->where(FeedPost::getField('feed_id'), '=', $feed_id)->count();
 }
 public static function FBPostToFeed($intUserId, $arrParams, $strTag = null)
 {
     $objFeedPost = new FeedPost();
     $objFeedPost->IdApp = SApplication::AppName();
     $objFeedPost->SenderFbuid = self::FBUid();
     $objFeedPost->ReciverFbuid = $intUserId;
     $objFeedPost->Data = json_encode($arrParams);
     $objFeedPost->CreDate = QDateTime::Now();
     $objFeedPost->Tag = $strTag;
     $objFeedPost->Save();
     $strCall = sprintf('/%s/feed', $intUserId);
     return self::FB($strCall, $arrParams);
 }
Ejemplo n.º 7
0
 public static function findExistsDates($feed_id)
 {
     $posts = Post::prepareQuery(2)->join(FeedPost::getTableName(), Post::getField("id"), '=', FeedPost::getField("post_id"))->where(FeedPost::getField("feed_id"), $feed_id)->where(PostLang::getField('enabled'), 1)->where(Post::getField('is_trash'), 0)->orderBy(DB::raw("DATE(" . Post::getField('created_at') . ")"), 'asc')->select(DB::raw("DATE(" . Post::getField('created_at') . ") as data"))->remember(SettingsModel::one('cachelife'))->get();
     $dates = ['years' => [], 'months' => []];
     foreach ($posts as $post) {
         $tmst = strtotime($post->data);
         $y = (int) date("Y", $tmst);
         $m = (int) date("m", $tmst);
         $d = (int) date("d", $tmst);
         $dates['years'][$y] = $y;
         if (isset($dates['months'][$y])) {
             if (isset($dates['months'][$y][$m])) {
                 $dates['months'][$y][$m]++;
             } else {
                 $dates['months'][$y][$m] = 1;
             }
         } else {
             $dates['months'][$y] = [$m => 1];
         }
     }
     return $dates;
 }