public static function generateSitemap($reGenerate = false)
 {
     // create new sitemap object
     $sitemap = App::make("sitemap");
     $sitemap->setCache('laravel.sitemap', 3600);
     if ($reGenerate) {
         Cache::forget($sitemap->model->getCacheKey());
     }
     // check if there is cached sitemap and build new only if is not
     if (!$sitemap->isCached()) {
         // add item to the sitemap (url, date, priority, freq)
         $sitemap->add(URL::to('/'), null, '1.0', 'daily');
         $categories = Category::get();
         foreach ($categories as $category) {
             $sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily');
         }
         // get all lists from db
         $lists = ViralList::orderBy('created_at', 'desc')->get();
         // add every post to the sitemap
         foreach ($lists as $list) {
             $sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly');
         }
     }
     // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
     return $sitemap->render('xml');
 }
 public static function generateRssFeed()
 {
     $config = Config::get('siteConfig');
     // create new feed
     $feed = Feed::make();
     // cache the feed for 10 minutes (second parameter is optional)
     $feed->setCache(10, 'list-rss-feed');
     // check if there is cached feed and build new only if is not
     if (!$feed->isCached()) {
         // creating rss feed with our most recent 20 posts
         $lists = ViralList::orderBy('created_at', 'desc')->take(20)->get();
         // set your feed's title, description, link, pubdate and language
         $feed->title = $config['main']['siteTitle'];
         $feed->description = @$config['main']['siteDescription'];
         $feed->logo = @asset($config['main']['logo']);
         $feed->link = URL::route('rssFeed');
         $feed->setDateFormat('datetime');
         // 'datetime', 'timestamp' or 'carbon'
         $feed->pubdate = $lists->count() ? $lists[0]->created_at : time();
         $feed->lang = $config['languages']['activeLanguage'];
         $feed->setShortening(true);
         // true or false
         $feed->setTextLimit(100);
         // maximum length of description text
         foreach ($lists as $list) {
             // set item's title, author, url, pubdate, description and content
             $listContentHtml = View::make('lists.rssFeedListContent', ['list' => $list]);
             $feed->add($list->title, $list->creator->name, ListHelpers::viewListUrl($list), $list->created_at->toDateTimeString(), $list->description, $listContentHtml);
         }
     }
     // first param is the feed format
     // optional: second param is cache duration (value of 0 turns off caching)
     // optional: you can set custom cache key with 3rd param as string
     return $feed->render('rss');
     // to return your feed as a string set second param to -1
     // $xml = $feed->render('atom', -1);
 }
示例#3
0
                if (isset($widgetItem['disabled']) && ($widgetItem['disabled'] === true || $widgetItem['disabled'] == "true")) {
                    return false;
                }
                return true;
            });
            $widgets[$widgetPlacement['id']] = $widgetItems;
        }
    }
    View::share('widgets', $widgets);
    if (Auth::check()) {
        View::share('userData', Auth::user());
    }
    //Load custom email config from database
    CustomEmailSettings::loadEmailConfigFromDB();
    //Activate notification system for edit list
    ViralList::observe(new \Notifications\EditListNotifier\EditListModelObserver());
    //Activate notification system for list approval
    \Notifications\ApprovedListNotifier\ApprovedListNotificationEventHandler::enable();
});
//Getting Categories
App::before(function ($request) {
    BaseController::loadCategories();
    BaseController::setupShortCodes();
});
App::after(function ($request, $response) {
    //
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
 public function disapproveList()
 {
     $admin = App::make('loggedInAdmin');
     $listId = Input::get('list-id');
     $redirectUrl = Input::get('redirect-url');
     $changesOnly = Input::get('changes-only');
     if (!$listId) {
         return 'List ID not passed';
     }
     try {
         $list = ViralList::findOrFail($listId);
         if ($changesOnly) {
             $list->pendingChanges()->delete();
         } else {
             $list->markAsDisapproved();
             $list->save();
         }
         return Redirect::to(Helpers::getUrlWithQuery(array('status' => 'awaiting_approval'), route('adminViewLists')));
     } catch (ModelNotFoundException $e) {
         return Response::error("Error finding list with id " . $listId);
     }
 }
 public static function populateView()
 {
     $itemsAwaitingApproval = ViralList::where('status', 'awaiting_approval')->count();
     $itemsAwaitingChangesApproval = ViralListChanges::all()->count();
     View::share(array('itemsAwaitingApproval' => $itemsAwaitingApproval + $itemsAwaitingChangesApproval));
 }
 public function publishList()
 {
     $listId = Input::get('list-id');
     if (!$listId) {
         return Response::notFound();
     }
     try {
         $list = ViralList::findOrFail($listId);
         $this->_ensurePermission($list);
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         if (Request::ajax()) {
             return Response::error($e->getMessage());
         } else {
             return Response::notFound();
         }
     }
     $this->_setApprovalStatusOnPublish($list);
     $list->save();
     return Response::json(array('success' => 1, 'status' => $list->status, 'list' => $list, 'viewListUrl' => ListHelpers::viewListUrl($list), 'previewListUrl' => route('previewList', array('list-id' => $list->id))));
 }