Beispiel #1
0
 public static function rss($news)
 {
     $string = "<rss version='2.0'>";
     $string .= "<channel>";
     $string .= "<title>Puškice</title>\n\t\t\t\t\t<link>" . Request::root() . "</link>\n\t\t\t\t\t<description>Tačka spajanja studenata FON-a</description>\n\t\t\t\t\t<language>sr-rs</language>\n\t\t\t\t\t<pubDate>" . date("D, d M Y H:i:s e", strtotime("now")) . "</pubDate>\n\t\t\t\t\t<lastBuildDate>" . date("D, d M Y H:i:s e", strtotime("now")) . "</lastBuildDate>\n\t\t\t\t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n\t\t\t\t\t<generator>Puškice generator</generator>\n\t\t\t\t\t<managingEditor>info@puskice.org</managingEditor>\n\t\t\t\t\t<webMaster>info@puskice.org</webMaster>";
     foreach ($news as $article) {
         $string .= "<item>\n\t\t\t\t\t\t\t<title>" . $article->title . "</title>\n\t\t\t\t\t\t\t<link>" . Request::root() . "/vest/" . Puskice::dateToUrl($article->created_at) . "/" . $article->permalink . "</link>\n\t\t\t\t\t\t\t<description><![CDATA[" . Trans::_t($article->short_content) . "]]></description>\n\t\t\t\t\t\t\t<pubDate>" . date("D, d M Y H:i:s e", strtotime($article->created_at)) . "</pubDate>\n\t\t\t\t\t\t\t<guid>" . Request::root() . "/vest/" . Puskice::dateToUrl($article->created_at) . "/" . $article->permalink . "</guid>\n\t\t\t\t\t\t</item>";
     }
     $string .= "</channel>";
     $string .= "</rss>";
     return $string;
 }
Beispiel #2
0
 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 postCreate($id)
 {
     try {
         $this->googleAnalytics('/comments/create/' . $id);
         $comment = new Comment();
         $news = News::findOrFail($id);
         if (Input::get('createdAt')) {
             $comment->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt')));
         } else {
             $comment->created_at = date("Y-m-d H:i:s", strtotime('now'));
         }
         $comment->comment_content = Input::get('commentContent');
         $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b');
         $akismet->setCommentAuthor($comment->username);
         $akismet->setCommentAuthorEmail($comment->email);
         $akismet->setCommentAuthorURL("");
         $akismet->setCommentContent($comment->comment_content);
         $akismet->setPermalink('http://www.puskice.org/vest/' . Puskice::dateToUrl($news->created_at) . '/' . $news->permalink);
         if ($akismet->isCommentSpam()) {
             $comment->deleted_at = date('Y-m-d H:i:s', strtotime('now'));
         }
         if (Input::get('user_id')) {
             $comment->published = 1;
         } else {
             $comment->published = 0;
         }
         if (Input::get('user_id')) {
             $user = User::find(Input::get('user_id'));
             $comment->username = $user->username;
             $comment->email = $user->email;
         } else {
             $comment->username = Input::get('username');
             $comment->email = Input::get('email');
         }
         if (Input::get('user_id')) {
             $comment->user_id = Input::get('user_id');
         } else {
             $comment->user_id = 0;
         }
         $comment->news_id = $id;
         $comment->ip_address = Puskice::getIP();
         $comment->save();
         if ($comment->deleted_at == null) {
             $user = array('email' => '*****@*****.**', 'name' => 'Info tim');
             // the data that will be passed into the mail view blade template
             $data = array('url' => "http://www.puskice.org/" . Config::get('settings.admin_url') . "/comments/edit/" . $comment->id, 'approve_url' => "http://www.puskice.org/" . Config::get('settings.admin_url') . "/comments/publish/" . $comment->id, 'delete_url' => "http://www.puskice.org/" . Config::get('settings.admin_url') . "/comments/trash/" . $comment->id, 'username' => $comment->username, 'email' => $comment->email, 'title' => $news->title, 'news' => 1, 'news_id' => $news->id, 'content' => $comment->comment_content);
             // use Mail::send function to send email passing the data and using the $user variable in the closure
             Mail::send('emails.new_comment', $data, function ($message) use($user) {
                 $message->from('*****@*****.**', "Puškice cenzura");
                 $message->to('*****@*****.**', 'Info tim Puškice')->subject('Novi komentar čeka moderaciju');
             });
         }
         return Response::json(array('status' => 'success', 'message' => __("Ваш коментар је успешно прослеђен")));
     } catch (Exception $e) {
         return Response::json(array('status' => 'fail'));
     }
 }
Beispiel #4
0
function dateToUrl($date)
{
    return Puskice::dateToUrl($date);
}