Exemple #1
0
 public function getIndex()
 {
     $year = Year::current_year();
     $sponsors = $year->sponsors()->orderBy('sponsor_year.sponsor_level', 'desc')->where('sponsor_year.sponsor_level', '!=', 'Affiliate')->get();
     $news = News::orderBy('updated_at', 'desc')->first();
     return View::make('home.index')->with('news', $news)->with('sponsors', $sponsors);
 }
Exemple #2
0
 public function index()
 {
     $advice = \SecurityTip::orderBy(DB::raw("RAND()"))->first();
     $news = \News::orderBy(DB::raw("RAND()"))->first();
     $work = \Work::orderBy(DB::raw("RAND()"))->first();
     return View::make('welcome/index', compact('news', 'work', 'advice'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     if (Session::get('user_level') < Config::get('cms.shopManager')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')));
     }
     $this->setLayout();
     if (Input::get('q')) {
         $products = Product::where(function ($query) {
             $query->where('title', 'LIKE', '%' . Input::get('q') . '%')->orwhere('long_content', 'LIKE', '%' . Input::get('q') . '%')->orwhere('short_content', 'LIKE', '%' . Input::get('q') . '%');
         })->orderBy('created_at', 'desc')->paginate(20);
     } else {
         $products = News::orderBy('created_at', 'desc')->paginate(20);
     }
     View::share('title', __(Lang::get('shop.products')));
     View::share('products', $products);
     $this->layout->content = View::make('backend.shop.product.index');
 }
Exemple #4
0
 /**
  * @param $limit
  * @return mixed
  */
 public function getLastNews($limit)
 {
     return $this->news->orderBy('created_at', 'desc')->where('lang', $this->getLang())->take($limit)->offset(0)->get();
 }
 public function getManageNews()
 {
     $query = News::orderBy('id', 'desc')->paginate(10);
     $this->layout->content = View::make('admin.manage_news')->with('news', $query);
 }
Exemple #6
0
 public function get_va()
 {
     //Pull our users VA data
     $record = User::where('cid', '=', Auth::user()->get()->cid)->first();
     //        //Figure out what the last 4 months are and append -1 for the first day of the month
     //        $month = date('Y-m');
     //        $month .= '-1';
     //        $month1before = date('Y-m', strtotime('-1 month'));
     //        $month1before .= '-1';
     //        $month2before = date('Y-m', strtotime('-2 month'));
     //        $month2before .= '-1';
     //        $month3before = date('Y-m', strtotime('-3 month'));
     //        $month3before .= '-1';
     //        //Convert to unix time stamps to compare with the DB
     //        $month = strtotime($month);
     //        $month1before = strtotime($month1before);
     //        $month2before = strtotime($month2before);
     //        $month3before = strtotime($month3before);
     //
     //        //Now let's store our month names in an array
     //        $clicks = array();
     //        $clicks['month_name'] = date("F", $month);
     //        $clicks['month1before_name'] = date("F", $month1before);
     //        $clicks['month2before_name'] = date("F", $month2before);
     //        $clicks['month3before_name'] = date("F", $month3before);
     //
     //
     //        //Count the data in the DB
     //        //Where data is greater than the first of this month and is associated with our logged in user.
     //        $month = Click::where('created_at', '>=', $month)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        //Where data is greater than the first of last month, but less than the first of this month and is associated with our logged in user.
     //        $month1before = Click::where('created_at', '>=', $month1before)->where('created_at', '<', $month)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        //You get the point :)
     //        $month2before = Click::where('created_at', '>=', $month2before)->where('created_at', '<', $month1before)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        $month3before = Click::where('created_at', '>=', $month3before)->where('created_at', '<', $month2before)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        //Add to our clicks array.
     //        $clicks['month'] = $month;
     //        $clicks['month1before'] = $month1before;
     //        $clicks['month2before'] = $month2before;
     //        $clicks['month3before'] = $month3before;
     //Let's just keep it simple for now and get the total number of clicks
     $clicks = Click::where('vid', '=', Auth::user()->get()->cid)->count();
     //Pull our ticket information
     $opentickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '1')->orderBy('created_at', 'DESC')->get();
     $openticketscount = count($opentickets);
     $closedtickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '0')->orderBy('created_at', 'DESC')->get();
     $closedticketscount = count($closedtickets);
     //Create our array
     $tickets = array();
     $tickets['opentickets'] = $opentickets;
     $tickets['opentickets_count'] = $openticketscount;
     $tickets['closedtickets'] = $closedtickets;
     $tickets['closedtickets_count'] = $closedticketscount;
     //Pull our replies
     $tickets_request = Ticket::where('vid', '=', Auth::user()->get()->cid)->get();
     $tids = array();
     foreach ($tickets_request as $ticket_request) {
         $tid = $ticket_request->id;
         $tids[$tid] = $tid;
     }
     if (!empty($tids)) {
         $replies = TicketReply::whereIn('tid', $tids)->orderBy('created_at', 'ASC')->get();
     } else {
         $replies = '';
     }
     $tickets['replies'] = $replies;
     //Pull our Category data
     $categories = Category::where('hidden', '!=', 1)->get();
     //Check to see if there is a banner if so provide the source for it
     if ($record->banner) {
         $banner = User::getBannerUrl(Auth::user()->get()->cid);
     } else {
         //No banner we will set this as false so the views no not to try and display it.
         $banner = FALSE;
     }
     //Get our news
     $news = News::orderBy("updated_at", "DESC")->get();
     //Create our view with the VA, clicks, categories and tickets data.
     return View::make('va')->with(array('news' => $news, 'record' => $record, 'clicks' => $clicks, 'tickets' => $tickets, 'categories' => $categories, 'banner' => $banner));
 }
Exemple #7
0
 public function home()
 {
     $news = News::orderBy('id', "DESC")->take(5)->get();
     $this->layout->content = View::make('home')->with("news", $news);
 }
 public static function returnShortCodes()
 {
     $tpl = static::returnTpl();
     shortcode::add("news", function ($params = null) use($tpl) {
         #print_r($params); die;
         if (!Allow::module('news')) {
             return false;
         }
         ## Параметры по-умолчанию
         $default = array('tpl' => Config::get('app-default.news_template', 'default'), 'limit' => Config::get('app-default.news_count_on_page', 3), 'order' => Helper::stringToArray(News::$order_by), 'pagination' => 1, 'type' => false, 'exclude_type' => false, 'include' => false, 'exclude' => false);
         ## Применяем переданные настройки
         $params = $params + $default;
         #dd($params);
         #echo $tpl.$params['tpl'];
         if (empty($params['tpl']) || !View::exists($tpl . $params['tpl'])) {
             throw new Exception('Template [' . $tpl . $params['tpl'] . '] not found.');
         }
         $news = News::orderBy('news.published_at', 'desc')->with('meta.photo', 'meta.gallery.photos', 'meta.seo');
         /*
         ## Получаем новости, делаем LEFT JOIN с news_meta, с проверкой языка и тайтла
         $selected_news = News::where('news.publication', 1)
                                 ->leftJoin('news_meta', 'news_meta.news_id', '=', 'news.id')
                                 ->where('news_meta.language', Config::get('app.locale'))
                                 ->where('news_meta.title', '!=', '')
                                 ->select('*', 'news.id AS original_id', 'news.published_at AS created_at')
                                 ->orderBy('news.published_at', 'desc');
         
         #$selected_news = $selected_news->where('news_meta.wtitle', '!=', '');
         
         ## Получаем новости с учетом пагинации
         #echo $selected_news->toSql(); die;
         #var_dump($params['limit']);
         $news = $selected_news->paginate($params['limit']); ## news list with pagination
         #$news = $selected_news->get(); ## all news, without pagination
         */
         /**
          * Показываем новости только определенных типов
          */
         if (@$params['type']) {
             $params['types'] = (array) explode(',', $params['type']);
             #Helper::d($params);
             if (isset($params['types']) && is_array($params['types']) && count($params['types']) && Allow::module('dictionaries') && class_exists('DicVal')) {
                 $types = DicVal::whereIn('slug', $params['types'])->get();
                 #Helper::tad($types);
                 if ($types->count()) {
                     $types = $types->lists('id');
                     #Helper::tad($types);
                     if (count($types)) {
                         $news = $news->whereIn('type_id', $types);
                     }
                 }
             }
         }
         /**
          * Исключаем новости определенных типов
          */
         if (@$params['exclude_type']) {
             $params['exclude_types'] = (array) explode(',', $params['exclude_type']);
             #Helper::d($params);
             if (isset($params['exclude_types']) && is_array($params['exclude_types']) && count($params['exclude_types']) && Allow::module('dictionaries') && class_exists('DicVal')) {
                 $types = DicVal::whereIn('slug', $params['exclude_types'])->get();
                 #Helper::tad($types);
                 if ($types->count()) {
                     $types = $types->lists('id');
                     #Helper::tad($types);
                     if (count($types)) {
                         $news = $news->whereNotIn('type_id', $types);
                     }
                 }
             }
         }
         /**
          * Будем выводить только новости, ID которых указаны
          */
         if (@$params['include']) {
             $params['includes'] = (array) explode(',', $params['include']);
             if (isset($params['includes']) && is_array($params['includes']) && count($params['includes'])) {
                 $news = $news->whereIn('id', $params['includes']);
             }
         }
         /**
          * Исключаем новости с заданными ID
          */
         if (@$params['exclude']) {
             $params['excludes'] = (array) explode(',', $params['exclude']);
             if (isset($params['excludes']) && is_array($params['excludes']) && count($params['excludes'])) {
                 $news = $news->whereNotIn('id', $params['excludes']);
             }
         }
         $news = $news->paginate($params['limit']);
         #Helper::tad($news);
         /*
         foreach ($news as $n => $new) {
             #print_r($new); die;
             $gall = Rel_mod_gallery::where('module', 'news')->where('unit_id', $new->original_id)->first();
             #foreach ($gall->photos as $photo) {
             #	print_r($photo->path());
             #}
             #print_r($gall->photos); die;
             $new->gall = @$gall;
             $new->image = is_object(@$gall->photos[0]) ? @$gall->photos[0]->path() : "";
             $news[$n]->$new;
         }
         */
         #echo $news->count(); die;
         if (!$news->count()) {
             return false;
         }
         return View::make($tpl . $params['tpl'], compact('news'));
     });
 }
 public function siteMap_xml()
 {
     try {
         $page = Pages::where("_name", "=", "sitemap")->get()->first();
         $pages = Pages::where('_dependsOn', "=", NULL)->where("_public", "=", "1")->orderBy('_priority', 'DESC')->get();
         $news = News::orderBy('_date', 'DESC')->get();
     } catch (Exception $e) {
         App::abort(500);
     }
     $header = '<?xml version="1.0" encoding="UTF-8"?>';
     // Renvoi de la vue avec les news et l'en-tête :
     $page = $this->layout->content = View::make('pages.sitemap.sitemap_xml', array("news" => $news, "pages" => $pages, "header" => $header));
     return Response::make($page, '200')->header('Content-Type', 'text/xml');
 }
 public function get_news()
 {
     $news = News::orderBy("updated_at", "DESC")->get();
     return View::make('console.news')->with(array("news" => $news));
 }