Пример #1
0
 /**
  * Use current dataprovider to perform seacrh
  * by given query and return view with results.
  * 
  * @return View
  */
 public function byQuery()
 {
     $input = (string) Input::get('q');
     if (!$input || Str::length($input) <= 1) {
         return View::make('search.results')->withTerm('');
     }
     if (is_a($this->search, 'Lib\\Services\\Search\\DbSearch')) {
         $encoded = $input;
     } else {
         $encoded = urlencode($input);
     }
     $clean = e($input);
     //make search cache section name
     $section = 'search' . $this->provider;
     if ($encoded) {
         if (Helpers::hasSuperAccess()) {
             $results = $this->search->byQuery($encoded);
         } else {
             if ($this->options->useCache()) {
                 $results = $this->cache->get($section, md5($encoded));
                 if (!$results || count($results) == 0) {
                     $results = $this->search->byQuery($encoded);
                     $this->cache->put($section, md5($encoded), $results);
                 }
             } else {
                 $results = $this->search->byQuery($encoded);
             }
         }
         return View::make('search.results')->withData($results)->withTerm($clean);
     }
     return View::make('search.results')->withTerm($clean);
 }
Пример #2
0
 public function __construct(Search $search, Auto $autocomplete)
 {
     $this->beforeFilter('csrf', array('on' => 'post'));
     $this->search = $search;
     $this->autocomplete = $autocomplete;
     //get search provider name for differianting between
     //different providers query caches
     $this->options = App::make('options');
     $this->provider = $this->options->getSearchProvider();
 }
Пример #3
0
 /**
  * Stores new user in database.
  *
  * @return View.
  */
 public function store()
 {
     $input = Input::except('_method', '_token');
     if (!$this->validator->with($input)->passes()) {
         return Redirect::back()->withErrors($this->validator->errors())->withInput($input);
     }
     if ($this->options->requireUserActivation()) {
         $this->user->register($input);
         return Redirect::back()->withSuccess(trans('users.registered successfully'));
     }
     $this->user->register($input, true);
     return Redirect::back()->withSuccess(trans('users.registered successfully no act'));
 }
Пример #4
0
 public function getJumboMenuColor()
 {
     //get the available rating
     $percent = $this->getRating();
     //get the color depending on rating
     if ($percent >= '70%' || $percent == '100%') {
         if ($dbColor = $this->options->getColor('success')) {
             $color = $dbColor;
         } else {
             $color = '#5D8C2E';
         }
     } elseif ($percent < '70%' && $percent > '50%') {
         if ($dbColor = $this->options->getColor('warning')) {
             $color = $dbColor;
         } else {
             $color = '#CB8820';
         }
     } else {
         if ($dbColor = $this->options->getColor('danger')) {
             $color = $dbColor;
         } else {
             $color = '#A43B2C';
             //#DE6C69
         }
     }
     return $color;
 }
Пример #5
0
 public function scopeGenres10($query)
 {
     $order = Helpers::getOrdering();
     $genre10 = $query->where('now_playing', 1)->limit(10)->orderBy($order, 'desc')->get();
     if ($this->options->getDataProvider() == 'db' || !$this->options->autoUpdateData()) {
         return $genre10;
     }
     if ($genre10->isEmpty() || $genre10->first()->updated_at->addDays(2) <= Carbon::now()) {
         $genre10 = $this->updatePlaying($order);
     }
     return $genre10;
 }
Пример #6
0
 /**
  * Inserts all the partially scraped titles from
  * performed tmdb api search query.
  * 
  * @param  array $titles
  * @return Collection
  */
 public function insertFromTmdbSearch(array $titles)
 {
     $first = head($titles);
     $tempId = $first['temp_id'];
     if ($this->options->saveTmdbImages()) {
         $urls = array();
         foreach ($titles as $k => $v) {
             if ($v['poster']) {
                 $id = $v['tmdb_id'] . $v['type'];
                 $titles[$k]['poster'] = "imdb/posters/{$id}.jpg";
                 $urls[$id] = $v['poster'];
             }
         }
         $this->images->saveMultiple($urls, null, 'imdb/posters/');
     }
     $this->compileBatchInsert('titles', $titles)->save();
     return Title::byTempId($tempId, 'tmdb_popularity');
 }
Пример #7
0
 /**
  * Checks if given title needs to be fully scraped.
  * 
  * @param  Title  $title
  * @return boolean
  */
 public function needsScraping(Title $title)
 {
     $needs = true;
     //first check for fully_scraped flag, if its true
     //we wont update
     if ($title->fully_scraped) {
         $needs = false;
     }
     //next check if it was 5 days  since last update
     //if so we'll update title now
     if (!$title->updated_at || $title->updated_at->addDays(5) <= Carbon::now() && $this->options->autoUpdateData()) {
         $needs = true;
     }
     $date = date('Y-m-d', strtotime($title->release_date));
     if ($title->review->isEmpty() && $date < Carbon::now()->toDateString()) {
         $needs = true;
     }
     //finally check for provider and if we're allowed to update
     //the title
     if ($this->provider->name == 'db' || !$title->allow_update) {
         return false;
     }
     return $needs;
 }
Пример #8
0
 /**
  * Show homepage.
  * 
  * @return View
  */
 public function index()
 {
     $view = ucfirst($this->options->getHomeView());
     $featured = Title::featured()->orderBy('created_at', 'desc')->paginate(20);
     $releases = Title::releases()->orderBy('created_at', 'desc')->paginate(6);
     $mostPopular = Title::mostPopular()->orderBy('tmdb_popularity', 'desc')->paginate(6);
     $lastAdded = Title::lastAdded()->orderBy('created_at', 'desc')->paginate(6);
     $reindexed = Title::reindexed()->orderBy('created_at', 'desc')->paginate(6);
     $playing = Title::nowPlaying();
     $news = News::news();
     if ($view == 'Rows') {
         // $upcoming = Title::upcoming();
         // $actors   = Actor::popular();
         // $latest   = Title::latest();
         // if (is_a($latest, 'Illuminate\Database\Eloquent\Builder'))
         // {
         // 	$latest = null;
         // }
         if (Request::ajax()) {
             $responseArray = array();
             $featuredCount = $featured->count();
             if ($featuredCount > 0) {
                 $featuredHtml = View::make('elements.titlesFigureAjax')->with('array', $featured)->render();
                 $responseArray = array_merge($responseArray, array('featuredCount' => $featuredCount, 'featured' => $featuredHtml, 'featuredLinks' => $featured->links()->render()));
             }
             $releasesCount = $releases->count();
             if ($releasesCount > 0) {
                 $releasesHtml = View::make('elements.titlesFigureAjax')->with('array', $releases)->render();
                 $responseArray = array_merge($responseArray, array('releasesCount' => $releasesCount, 'releases' => $releasesHtml, 'releasesLinks' => $releases->links()->render()));
             }
             $mostPopularCount = $mostPopular->count();
             if ($mostPopularCount > 0) {
                 $mostPopularHtml = View::make('elements.titlesFigureAjax')->with('array', $mostPopular)->render();
                 $responseArray = array_merge($responseArray, array('mostPopularCount' => $mostPopularCount, 'mostPopular' => $mostPopularHtml, 'mostPopularLinks' => $mostPopular->links()->render()));
             }
             $lastAddedCount = $lastAdded->count();
             if ($lastAddedCount > 0) {
                 $lastAddedHtml = View::make('elements.titlesFigureAjax')->with('array', $lastAdded)->render();
                 $responseArray = array_merge($responseArray, array('lastAddedCount' => $lastAddedCount, 'lastAdded' => $lastAddedHtml, 'lastAddedLinks' => $lastAdded->links()->render()));
             }
             $reindexedCount = $reindexed->count();
             if ($reindexedCount > 0) {
                 $reindexedHtml = View::make('elements.titlesFigureAjax')->with('array', $reindexed)->render();
                 $responseArray = array_merge($responseArray, array('reindexedCount' => $reindexedCount, 'reindexed' => $reindexedHtml, 'reindexedLinks' => $reindexed->links()->render()));
             }
             return Response::json($responseArray);
         }
         $featuredCount = $featured->count();
         $releasesCount = $releases->count();
         $mostPopularCount = $mostPopular->count();
         $lastAddedCount = $lastAdded->count();
         $reindexedCount = $reindexed->count();
         return View::make("home.home{$view}")->with('featured', $featured)->with('featuredCount', $featuredCount)->with('releases', $releases)->with('releasesCount', $releasesCount)->with('lastAdded', $lastAdded)->with('lastAddedCount', $lastAddedCount)->with('mostPopular', $mostPopular)->with('mostPopularCount', $mostPopularCount)->with('reindexed', $reindexed)->with('reindexedCount', $reindexedCount)->with('playing', $playing)->withBg($this->options->getBg('home'))->withFacebook($this->options->getFb())->withNews($news);
         // ->withUpcoming($upcoming)
         // ->withActors($actors)
         // ->withLatest($latest);
     } else {
         if (Request::ajax()) {
             $featuredHtml = View::make('elements.titlesFigure', $featured)->render();
             $responseArray = array('featured' => $featuredHtml);
             return Response::json($responseArray);
         }
         return View::make("Main.Themes.{$view}.Home")->with('featured', $featured)->with('releases', $releases)->with('lastAdded', $lastAdded)->with('mostPopular', $mostPopular)->with('reindexed', $reindexed)->with('playing', $playing)->withNews($news)->withBg($this->options->getBg('home'))->withFacebook($this->options->getFb());
     }
 }