Esempio n. 1
0
 protected static function boot()
 {
     parent::boot();
     self::saving(function ($model) {
         // transaction ended in "saved" event
         // needed to make sure if search index version number is incremented it
         // takes effect at the same time that the rest of the media item is updated
         DB::beginTransaction();
         // assume that something has changed and force ths item to be reindexed
         $a = Show::with("playlists", "playlists.mediaItems")->find(intval($model->id));
         // $a may be null if this item is currently being created
         // when the item is being created pending_search_index_version defaults to 1
         // meaning the item will be indexed
         if (!is_null($a)) {
             // make sure get latest version number. The version in $model might have changed before the transaction started
             $currentPendingIndexVersion = intval($a->pending_search_index_version);
             $model->pending_search_index_version = $currentPendingIndexVersion + 1;
             // also force all playlists liked to this and media items in them to be reindexed
             // because media items and playlists contain show information in their indexes
             foreach ($a->playlists as $playlist) {
                 $playlist->pending_search_index_version += 1;
                 $playlist->save();
                 foreach ($playlist->mediaItems as $mediaItem) {
                     $mediaItem->pending_search_index_version += 1;
                     $mediaItem->save();
                 }
             }
         }
         return true;
     });
     self::saved(function ($model) {
         DB::commit();
     });
 }
 public function generateShowPlaylistsResponseData($id)
 {
     $show = Show::with("playlists")->accessible()->find(intval($id));
     if (is_null($show)) {
         return $this->generateNotFound();
     }
     $data = $this->playlistTransformer->transformCollection($show->playlists()->accessibleToPublic()->orderBy("id")->get()->all());
     return new ApiResponseData($data);
 }
Esempio n. 3
0
 public function getIndex($id = null)
 {
     if (is_null($id)) {
         App::abort(404);
     }
     $show = Show::with("playlists")->accessible()->find(intval($id));
     if (is_null($show)) {
         App::abort(404);
     }
     $coverArtResolutions = Config::get("imageResolutions.coverArt");
     $playlists = $show->playlists()->accessibleToPublic()->orderBy("series_no", "asc")->orderBy("name", "asc")->orderBy("description", "asc")->get();
     $showTableData = array();
     foreach ($playlists as $i => $item) {
         $thumbnailUri = Config::get("custom.default_cover_uri");
         if (!Config::get("degradedService.enabled")) {
             $thumbnailUri = $item->getCoverArtUri($coverArtResolutions['thumbnail']['w'], $coverArtResolutions['thumbnail']['h']);
         }
         $showTableData[] = array("uri" => $item->getUri(), "title" => $item->generateName(), "escapedDescription" => !is_null($item->description) ? e($item->description) : null, "playlistName" => null, "episodeNo" => null, "thumbnailUri" => $thumbnailUri, "thumbnailFooter" => null, "duration" => null, "active" => false);
     }
     $coverUri = null;
     $sideBannerUri = null;
     $sideBannerFillUri = null;
     if (!Config::get("degradedService.enabled")) {
         $coverImageResolutions = Config::get("imageResolutions.coverImage");
         $coverUri = $show->getCoverUri($coverImageResolutions['full']['w'], $coverImageResolutions['full']['h']);
         $sideBannerImageResolutions = Config::get("imageResolutions.sideBannerImage");
         $sideBannerUri = $show->getSideBannerUri($sideBannerImageResolutions['full']['w'], $sideBannerImageResolutions['full']['h']);
         $sideBannerFillImageResolutions = Config::get("imageResolutions.sideBannerFillImage");
         $sideBannerFillUri = $show->getSideBannerFillUri($sideBannerFillImageResolutions['full']['w'], $sideBannerFillImageResolutions['full']['h']);
     }
     $openGraphCoverArtUri = $show->getCoverArtUri($coverArtResolutions['fbOpenGraph']['w'], $coverArtResolutions['fbOpenGraph']['h']);
     $twitterCardCoverArtUri = $show->getCoverArtUri($coverArtResolutions['twitterCard']['w'], $coverArtResolutions['twitterCard']['h']);
     $twitterProperties = array();
     $twitterProperties[] = array("name" => "card", "content" => "summary_large_image");
     $openGraphProperties = array();
     if (!is_null($show->description)) {
         $openGraphProperties[] = array("name" => "og:description", "content" => $show->description);
         $twitterProperties[] = array("name" => "description", "content" => str_limit($show->description, 197, "..."));
     }
     $openGraphProperties[] = array("name" => "video:release_date", "content" => null);
     $twitterProperties[] = array("name" => "title", "content" => $show->name);
     $openGraphProperties[] = array("name" => "og:title", "content" => $show->name);
     $openGraphProperties[] = array("name" => "og:image", "content" => $openGraphCoverArtUri);
     $twitterProperties[] = array("name" => "image", "content" => $twitterCardCoverArtUri);
     foreach ($showTableData as $a) {
         $openGraphProperties[] = array("name" => "og:see_also", "content" => $a['uri']);
     }
     $view = View::make("home.show.index");
     $view->showTitle = $show->name;
     $view->escapedShowDescription = !is_null($show->description) ? nl2br(URLHelpers::escapeAndReplaceUrls($show->description)) : null;
     $view->coverImageUri = $coverUri;
     $view->showTableFragment = count($showTableData) > 0 ? View::make("fragments.home.playlist", array("stripedTable" => true, "headerRowData" => null, "tableData" => $showTableData)) : null;
     $this->setContent($view, "show", "show", $openGraphProperties, $show->name, 200, $twitterProperties, $sideBannerUri, $sideBannerFillUri);
 }