/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (Input::has('o')) {
         $order = Input::get('o');
         switch ($order) {
             case 'v':
                 $orderBy = "fake_views";
                 $sortName = "Most Viewed";
                 break;
             case 'r':
                 $orderBy = "rating";
                 $sortName = "Top Rated";
                 break;
             case 'f':
                 $orderBy = "favorites";
                 $sortName = "Most Popular";
                 break;
             default:
                 $orderBy = "publish_date";
                 $sortName = "Newest";
                 break;
         }
     } else {
         $order = "";
         $orderBy = "publish_date";
         $sortName = "Newest";
     }
     $network = $this->network;
     $theme = $network->theme;
     $theme = check_for_tour_theme($theme);
     Theme::setActive($theme);
     $data = $this->data;
     $data['page_title'] = $network->name;
     $data['sliders'] = Content::ofNetwork($this->network->id)->published()->featured(1)->take(config('yppmembers.homepage_sliders'))->orderBy(\DB::raw("RAND()"))->get();
     $data['contents'] = Content::ofNetwork($this->network->id)->published()->featured(0)->take(config('yppmembers.homepage_contents'))->orderBy($orderBy, 'desc')->paginate(config('yppmembers.per_page'));
     $data['mostviews'] = Content::ofNetwork($this->network->id)->published()->featured(0)->take(config('yppmembers.homepage_mostviews'))->orderBy('views', 'desc')->get();
     $data['toprateds'] = Content::ofNetwork($this->network->id)->published()->featured(0)->take(config('yppmembers.homepage_toprateds'))->orderBy('rating', 'desc')->get();
     $data['most_used_tags'] = Tag::ofNetwork($this->network->id)->mostUsedInNetwork($this->network->id)->take(config('yppmembers.homepage_most_used_tags'))->get();
     $data['dvds'] = Dvd::ofNetwork($this->network->id)->take(config('yppmembers.homepage_dvds'))->orderBy('publish_date', 'desc')->get();
     $tags = Tag::ofNetwork($network->id)->mostUsedInNetwork($network->id)->paginate(config('yppmembers.per_page'));
     $ids = array(0);
     foreach ($tags as $tag) {
         $tag_data = $tag->getTopThumb($ids, $this->network->id);
         $tag->top_thumb = $tag_data['thumb'];
         $ids[] = $tag_data['id'];
     }
     $data['tags'] = $tags;
     $data['sortname'] = $sortName;
     return Theme::view('video.index', $data);
 }
 public function view($id, $slug = '')
 {
     $network = $this->network;
     $data = $this->data;
     $content = Content::find($id);
     if (!$content) {
         return redirect('/');
     }
     $job = new UpdateViewCount($id);
     $this->dispatch($job);
     $site = $content->sites()->ofNetwork($network->id)->first();
     $theme = $site->theme != '' ? $site->theme : $network->theme;
     $theme = check_for_tour_theme($theme);
     Theme::setActive($theme);
     $data['page_title'] = $content->title;
     $data['content'] = $content;
     $data['photos'] = $content->files()->photos()->get();
     $data['videos'] = $content->files()->videos()->get();
     $data['similar'] = Content::ofNetwork($this->network->id)->similar($content)->published()->take(12)->get();
     $data['type'] = 'stream';
     $data['site'] = $site;
     $data['content_sites'] = $content->sites()->ofNetwork($network->id)->orderBy('name', 'asc')->get();
     $data['content_tags'] = $content->tags()->ofNetwork($network->id)->orderBy('name', 'asc')->get();
     $data['content_models'] = $content->models()->ofNetwork($network->id)->orderBy('name', 'asc')->get();
     $data['content_dvds'] = $content->dvds()->ofNetwork($network->id)->orderBy('title', 'asc')->get();
     $this->breadcrumbs->addCrumb('Updates', url('updates'));
     $this->breadcrumbs->addCrumb($content->title);
     $username = \Request::server('PHP_AUTH_USER', 'sampleuser');
     $data['has_rated'] = $content->ratings()->where('username', $username)->first();
     $data['is_favorite'] = $username && Favorite::ofUsername($username)->hasFavorite('Content', $content->id)->count() ? 1 : 0;
     if (\Request::input('pl')) {
         $param = explode(':', \Request::input('pl'));
         if (isset($param[0]) && $param[0] == 'dvd') {
             $data['on_dvd'] = true;
             $dvd = $content->dvds()->find(isset($param[1]) ? $param[1] : 0);
             $data['dvd'] = $dvd;
             $data['dvd_contents'] = $dvd->contents()->get();
         }
         if (isset($param[0]) && $param[0] == 'member') {
             $data['on_playlist'] = true;
             $playlist = Playlist::find(isset($param[1]) ? $param[1] : 0);
             $data['playlist'] = $playlist;
             $data['playlist_contents'] = $playlist->contents()->get();
         }
     }
     $data['playlists'] = Playlist::ofUsername($username)->get();
     $data['piwik_tracker_ids'] = config('yppmembers.use_piwik') && $site->piwik_id != 0 ? array_merge($data['piwik_tracker_ids'], [$site->piwik_id]) : $data['piwik_tracker_ids'];
     return Theme::view('content.view', $data);
 }
示例#3
0
 public function index()
 {
     $network = $this->network;
     $theme = $network->theme;
     $theme = check_for_tour_theme($theme);
     Theme::setActive($theme);
     $data = $this->data;
     $data['page_title'] = $network->name;
     $data['sliders'] = Content::ofNetwork($this->network->id)->published()->featured(1)->take(config('yppmembers.homepage_sliders'))->orderBy(\DB::raw("RAND()"))->get();
     $data['contents'] = Content::ofNetwork($this->network->id)->published()->featured(0)->take(config('yppmembers.homepage_contents'))->orderBy('publish_date', 'desc')->get();
     $data['mostviews'] = Content::ofNetwork($this->network->id)->published()->featured(0)->take(config('yppmembers.homepage_mostviews'))->orderBy('views', 'desc')->get();
     $data['toprateds'] = Content::ofNetwork($this->network->id)->published()->featured(0)->take(config('yppmembers.homepage_toprateds'))->orderBy('rating', 'desc')->get();
     $data['most_used_tags'] = Tag::ofNetwork($this->network->id)->mostUsedInNetwork($this->network->id)->take(config('yppmembers.homepage_most_used_tags'))->get();
     $data['dvds'] = Dvd::ofNetwork($this->network->id)->take(config('yppmembers.homepage_dvds'))->orderBy('publish_date', 'desc')->get();
     return Theme::view('network.home', $data);
 }
 public function xhrSearch(Request $request)
 {
     $q = Request::input('q', '');
     $q = strip_tags(str_replace("'", " ", $q));
     $response = [];
     if (!empty($q)) {
         $contents = Content::ofNetwork($this->network->id)->published()->search($q)->paginate(10);
         $models = Model::ofNetwork($this->network->id)->where('name', 'LIKE', "%{$q}%")->paginate(10);
         $tags = Tag::ofNetwork($this->network->id)->where('name', 'LIKE', "%{$q}%")->paginate(10);
         $items = $contents->merge($models)->merge($tags);
         foreach ($items as $item) {
             $response[] = ['title' => $item->getAttribute('title') ? $item->title : $item->name, 'url' => $item->link, 'thumb' => $item->thumb, 'type' => class_basename(get_class($item))];
         }
         $this->dispatch(new UpdateSearchKeywords($q));
     }
     return \Response::json($response);
 }
 public function index($type = '')
 {
     if (Input::has('o')) {
         $order = Input::get('o');
         switch ($order) {
             case 'v':
                 $orderBy = "fake_views";
                 $sortName = "Most Viewed";
                 break;
             case 'r':
                 $orderBy = "rating";
                 $sortName = "Top Rated";
                 break;
             case 'f':
                 $orderBy = "favorites";
                 $sortName = "Most Popular";
                 break;
             default:
                 $orderBy = "publish_date";
                 $sortName = "Newest";
                 break;
         }
     } else {
         $order = "";
         $orderBy = "publish_date";
         $sortName = "Newest";
     }
     $network = $this->network;
     $theme = $network->theme;
     $theme = check_for_tour_theme($theme);
     Theme::setActive($theme);
     $data = $this->data;
     $contents = Content::ofNetwork($this->network->id)->published();
     $type_heading = 'All Updates';
     $show_filter = true;
     if ($type != '') {
         $show_filter = false;
         if ($type == 'photos') {
             $contents->hasType('photos');
             $type_heading = 'Updates with Photos';
         } else {
             $contents->hasType('videos');
             $type_heading = 'Updates with Videos';
         }
     }
     $data['page_title'] = $this->network->name . ' Updates';
     $data['type_heading'] = $type_heading;
     $data['show_filter'] = $show_filter;
     $data['contents'] = $contents->orderBy($orderBy, 'desc')->paginate(config('yppmembers.per_page'));
     $this->breadcrumbs->addCrumb($type_heading);
     $tags = Tag::ofNetwork($network->id)->mostUsedInNetwork($network->id)->paginate(config('yppmembers.per_page'));
     $ids = array(0);
     foreach ($tags as $tag) {
         $tag_data = $tag->getTopThumb($ids, $this->network->id);
         $tag->top_thumb = $tag_data['thumb'];
         $ids[] = $tag_data['id'];
     }
     $data['tags'] = $tags;
     $data['sortname'] = $sortName;
     return Theme::view('update.index', $data);
 }