public function sitemap() { $sitemap = App::make("sitemap"); // set item's url, date, priority, freq $sitemap->add(Request::root(), '2012-08-25T20:10:00+02:00', '1.0', 'daily'); $sitemap->add(Request::root() . "/marketing", '2013-08-20T20:20:00+02:00', '1.0', 'monthly'); $sitemap->add(Request::root() . "/puskice", '2013-08-20T20:20:00+02:00', '1.0', 'monthly'); if (Cache::has('posts_query')) { $posts = Cache::get('posts_query'); } else { $posts = News::get(); Cache::put('posts_query', $posts, 10080); } foreach ($posts as $post) { if ($post->post_type == 1) { $sitemap->add(Request::root() . "/vest/" . Puskice::dateToUrl($post->created_at) . "/" . $post->permalink, $post->updated_at, '1.0', 'daily'); } if ($post->post_type == 2) { $sitemap->add(Request::root() . "/stranica/" . $post->permalink, $post->updated_at, '1.0', 'daily'); } if ($post->post_type == 3) { $subject = Subject::where('news_id', '=', $post->id)->first(); if ($subject != null) { $sitemap->add(Request::root() . "/" . Puskice::getYear($subject->semester) . "/" . Puskice::getDepartment($subject->department) . "/" . $post->permalink, $post->updated_at, '1.0', 'monthly'); } else { Log::info('Predmet za vest: ' . $post->id . ' nije definisan'); } } } if (Cache::has('meme_query')) { $memes = Cache::get('meme_query'); } else { $memes = MemeInstance::get(); Cache::put('meme_query', $memes, 10080); } foreach ($memes as $meme) { $sitemap->add(Request::root() . "/meme/" . $meme->id . "-" . $meme->permalink, $meme->updated_at, '1.0', 'daily'); } // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf') return $sitemap->render('xml'); }
public function singleSubject($year, $department, $permalink) { try { $permalink = str_replace("_", "-", $permalink); if (Session::get('user_level') >= Config::get('cms.viewAdminNews')) { $page = News::where('post_type', '=', 3)->where('published', '>=', 1)->where('permalink', '=', $permalink)->firstOrFail(); } else { $page = News::where('post_type', '=', 3)->where('published', '=', 2)->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('permalink', '=', $permalink)->firstOrFail(); } $subjects = Subject::where('news_id', '=', $page->id)->get(); $sub = Subject::where('news_id', '=', $page->id)->first(); $allow = false; foreach ($subjects as $key => $subject) { if ($year == Puskice::getYear($subject->semester) && Puskice::getDepartment($subject->department) == $department) { $allow = true; } } if (!$allow) { App::abort(404); } $articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get(); $featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get(); $results = News::inCategories(Config::get('settings.results'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get(); $featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get(); $didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get(); $magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get(); $ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get(); $feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4); $poll = null; $poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first(); if (isset($poll->id)) { $poll->pollOptions; } View::share('title', strip_tags($page->title) . " | Пушкице"); $ogimage = firstImage($page); $meta = "\t<meta property='og:image' content='" . str_replace(" ", "%20", $ogimage) . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __($page->title . " | Пушкице") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/" . Puskice::getYear($sub->semester) . "/" . Puskice::getDepartment($sub->department) . "/" . $page->permalink) . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __(dots(strip_tags($page->short_content), 500)) . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __($page->title . " | Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __(dots(strip_tags($page->short_content), 500)) . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . str_replace(" ", "%20", $ogimage) . "'>"; $page->view_count++; $page->save(); $data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'sub' => $sub, 'page' => $page); $this->setLayout($data); $this->layout->center = View::make('frontend.content.subject', $data); } catch (Exception $e) { return App::abort(404); } }