Example #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();
     });
 }
Example #2
0
 public function getIndex($pageNo = 0)
 {
     $pageNo = intval($pageNo);
     $itemsPerPage = intval(Config::get("custom.num_shows_per_page"));
     $itemOffset = $pageNo * $itemsPerPage;
     $numPlaylists = Show::accessible()->count();
     $numPages = ceil($numPlaylists / $itemsPerPage);
     $shows = Show::accessible()->orderBy("name", "asc")->orderBy("description", "asc")->skip($itemOffset)->take($itemsPerPage)->get();
     if ($pageNo > 0 && $shows->count() === 0) {
         App::abort(404);
     }
     $coverArtResolutions = Config::get("imageResolutions.coverArt");
     $playlistTableData = array();
     foreach ($shows as $i => $item) {
         $thumbnailUri = Config::get("custom.default_cover_uri");
         if (!Config::get("degradedService.enabled")) {
             $thumbnailUri = $item->getCoverArtUri($coverArtResolutions['thumbnail']['w'], $coverArtResolutions['thumbnail']['h']);
         }
         $playlistTableData[] = array("uri" => $item->getUri(), "title" => $item->name, "escapedDescription" => !is_null($item->description) ? e($item->description) : null, "playlistName" => null, "episodeNo" => null, "thumbnailUri" => $thumbnailUri, "thumbnailFooter" => null, "duration" => null, "active" => false);
     }
     $playlistFragment = count($playlistTableData) > 0 ? View::make("fragments.home.playlist", array("stripedTable" => true, "headerRowData" => null, "tableData" => $playlistTableData)) : null;
     $pageNumbers = array();
     for ($i = 0; $i < $numPages; $i++) {
         $pageNumbers[] = array("num" => $i + 1, "uri" => URL::route("shows", array($i)), "active" => $i === $pageNo);
     }
     $openGraphProperties = array();
     $openGraphProperties[] = array("name" => "video:release_date", "content" => null);
     foreach ($playlistTableData as $a) {
         $openGraphProperties[] = array("name" => "og:see_also", "content" => $a['uri']);
     }
     $view = View::make("home.shows.index");
     $view->playlistFragment = $playlistFragment;
     $view->pageSelectorFragment = View::make("fragments.home.pageSelector", array("nextUri" => $pageNo < $numPages - 1 ? URL::route("shows", array($pageNo + 1)) : null, "prevUri" => $pageNo > 0 ? URL::route("shows", array($pageNo - 1)) : null, "numbers" => $pageNumbers));
     $this->setContent($view, "shows", "shows", $openGraphProperties, "Shows");
 }
 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);
 }
Example #4
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);
 }
Example #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // presumes that media items already exist and ids from autoincrement
     DB::transaction(function () {
         $playlist = new Playlist(array("name" => "Roses 2014!", "enabled" => true, "description" => "Description about roses 2014 series.", "series_no" => 1, "scheduled_publish_time" => Carbon::now()));
         $playlist->show()->associate(Show::find(1));
         $playlist->save();
         $playlist->mediaItems()->attach(MediaItem::find(1), array("position" => 0));
         $playlist->mediaItems()->attach(MediaItem::find(2), array("position" => 1));
     });
     DB::transaction(function () {
         $playlist = Playlist::create(array("name" => "Top Shows", "enabled" => true, "description" => "LA1:TV's top shows for 2014.", "scheduled_publish_time" => Carbon::now()));
         $playlist->mediaItems()->attach(MediaItem::find(2), array("position" => 0));
     });
     $this->command->info('Playlists created and media items added!');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     LiveStream::truncate();
     MediaItem::truncate();
     MediaItemComment::truncate();
     MediaItemLike::truncate();
     MediaItemLiveStream::truncate();
     MediaItemVideo::truncate();
     Permission::truncate();
     PermissionGroup::truncate();
     QualityDefinition::truncate();
     LiveStreamUri::truncate();
     Playlist::truncate();
     Show::truncate();
     SiteUser::truncate();
     User::truncate();
     VideoFile::truncate();
     DB::table("media_item_to_playlist")->truncate();
     DB::table("permission_to_group")->truncate();
     DB::table("user_to_group")->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $this->command->info('Tables truncated!');
 }
 public function anyEdit($id = null)
 {
     Auth::getUser()->hasPermissionOr401(Config::get("permissions.playlists"), 1);
     $playlist = null;
     $editing = false;
     if (!is_null($id)) {
         $playlist = Playlist::with("coverFile", "sideBannerFile", "coverArtFile", "mediaItems", "customUri")->find($id);
         if (is_null($playlist)) {
             App::abort(404);
             return;
         }
         $editing = true;
     }
     $formSubmitted = isset($_POST['form-submitted']) && $_POST['form-submitted'] === "1";
     // has id 1
     // populate $formData with default values or received values
     $formData = FormHelpers::getFormData(array(array("enabled", ObjectHelpers::getProp(false, $playlist, "enabled") ? "y" : ""), array("show-id", ObjectHelpers::getProp("", $playlist, "show", "id")), array("series-no", ObjectHelpers::getProp("", $playlist, "series_no")), array("name", ObjectHelpers::getProp("", $playlist, "name")), array("description", ObjectHelpers::getProp("", $playlist, "description")), array("custom-uri", ObjectHelpers::getProp("", $playlist, "custom_uri_name")), array("cover-image-id", ObjectHelpers::getProp("", $playlist, "coverFile", "id")), array("side-banners-image-id", ObjectHelpers::getProp("", $playlist, "sideBannerFile", "id")), array("side-banners-fill-image-id", ObjectHelpers::getProp("", $playlist, "sideBannerFillFile", "id")), array("cover-art-id", ObjectHelpers::getProp("", $playlist, "coverArtFile", "id")), array("publish-time", ObjectHelpers::getProp("", $playlist, "scheduled_publish_time_for_input")), array("playlist-content", json_encode(array())), array("related-items", json_encode(array()))), !$formSubmitted);
     // this will contain any additional data which does not get saved anywhere
     $show = Show::find(intval($formData['show-id']));
     $additionalFormData = array("coverImageFile" => FormHelpers::getFileInfo($formData['cover-image-id']), "sideBannersImageFile" => FormHelpers::getFileInfo($formData['side-banners-image-id']), "sideBannersFillImageFile" => FormHelpers::getFileInfo($formData['side-banners-fill-image-id']), "coverArtFile" => FormHelpers::getFileInfo($formData['cover-art-id']), "showItemText" => !is_null($show) ? $show->name : "", "playlistContentInput" => null, "playlistContentInitialData" => null, "relatedItemsInput" => null, "relatedItemsInitialData" => null);
     if (!$formSubmitted) {
         $additionalFormData['playlistContentInput'] = ObjectHelpers::getProp(json_encode(array()), $playlist, "playlist_content_for_input");
         $additionalFormData['playlistContentInitialData'] = ObjectHelpers::getProp(json_encode(array()), $playlist, "playlist_content_for_reorderable_list");
         $additionalFormData['relatedItemsInput'] = ObjectHelpers::getProp(json_encode(array()), $playlist, "related_items_for_input");
         $additionalFormData['relatedItemsInitialData'] = ObjectHelpers::getProp(json_encode(array()), $playlist, "related_items_for_reorderable_list");
     } else {
         $additionalFormData['playlistContentInput'] = MediaItem::generateInputValueForAjaxSelectReorderableList(JsonHelpers::jsonDecodeOrNull($formData["playlist-content"], true));
         $additionalFormData['playlistContentInitialData'] = MediaItem::generateInitialDataForAjaxSelectReorderableList(JsonHelpers::jsonDecodeOrNull($formData["playlist-content"], true));
         $additionalFormData['relatedItemsInput'] = MediaItem::generateInputValueForAjaxSelectReorderableList(JsonHelpers::jsonDecodeOrNull($formData["related-items"], true));
         $additionalFormData['relatedItemsInitialData'] = MediaItem::generateInitialDataForAjaxSelectReorderableList(JsonHelpers::jsonDecodeOrNull($formData["related-items"], true));
     }
     $errors = null;
     if ($formSubmitted) {
         // validate input
         Validator::extend('valid_file_id', FormHelpers::getValidFileValidatorFunction());
         Validator::extend('my_date', FormHelpers::getValidDateValidatorFunction());
         Validator::extend('valid_show_id', function ($attribute, $value, $parameters) {
             return !is_null(Show::find(intval($value)));
         });
         Validator::extend('valid_playlist_content', function ($attribute, $value, $parameters) {
             return MediaItem::isValidIdsFromAjaxSelectReorderableList(JsonHelpers::jsonDecodeOrNull($value, true));
         });
         Validator::extend('valid_related_items', function ($attribute, $value, $parameters) {
             return MediaItem::isValidIdsFromAjaxSelectReorderableList(JsonHelpers::jsonDecodeOrNull($value, true));
         });
         Validator::extend('unique_custom_uri', function ($attribute, $value, $parameters) use(&$playlist) {
             $q = CustomUri::where("name", $value);
             if (!is_null($playlist)) {
                 $currentCustomUri = $playlist->custom_uri_name;
                 if (!is_null($currentCustomUri)) {
                     $q = $q->where("name", "!=", $currentCustomUri);
                 }
             }
             return $q->count() === 0;
         });
         $modelCreated = DB::transaction(function () use(&$formData, &$playlist, &$errors) {
             $validator = Validator::make($formData, array('show-id' => array('valid_show_id'), 'series-no' => array('required_with:show-id', 'integer'), 'name' => array('required_without:show-id', 'max:50'), 'description' => array('max:500'), 'custom-uri' => array('alpha_dash', 'max:50', 'unique_custom_uri'), 'cover-image-id' => array('valid_file_id'), 'side-banners-image-id' => array('valid_file_id'), 'side-banners-fill-image-id' => array('valid_file_id'), 'description' => array('max:500'), 'cover-art-id' => array('valid_file_id'), 'publish-time' => array('my_date'), 'playlist-content' => array('required', 'valid_playlist_content'), 'related-items' => array('required', 'valid_related_items')), array('show-id.valid_show_id' => FormHelpers::getGenericInvalidMsg(), 'series-no.required_with' => FormHelpers::getRequiredMsg(), 'series-no.integer' => FormHelpers::getMustBeIntegerMsg(), 'name.required_without' => FormHelpers::getRequiredMsg(), 'name.max' => FormHelpers::getLessThanCharactersMsg(50), 'description.max' => FormHelpers::getLessThanCharactersMsg(500), 'custom-uri.alpha_dash' => FormHelpers::getInvalidAlphaDashMsg(), 'custom-uri.max' => FormHelpers::getLessThanCharactersMsg(50), 'custom-uri.unique_custom_uri' => "This is already in use.", 'cover-image-id.valid_file_id' => FormHelpers::getInvalidFileMsg(), 'side-banners-image-id.valid_file_id' => FormHelpers::getInvalidFileMsg(), 'side-banners-fill-image-id.valid_file_id' => FormHelpers::getInvalidFileMsg(), 'cover-art-id.valid_file_id' => FormHelpers::getInvalidFileMsg(), 'publish-time.my_date' => FormHelpers::getInvalidTimeMsg(), 'playlist-content.required' => FormHelpers::getGenericInvalidMsg(), 'playlist-content.valid_playlist_content' => FormHelpers::getGenericInvalidMsg(), 'related-items.required' => FormHelpers::getGenericInvalidMsg(), 'related-items.valid_related_items' => FormHelpers::getGenericInvalidMsg()));
             if (!$validator->fails()) {
                 $show = $formData['show-id'] !== "" ? Show::find(intval($formData['show-id'])) : null;
                 Validator::extend('unique_series_no', function ($attribute, $value, $parameters) use(&$playlist, &$show) {
                     if (is_null($show)) {
                         return true;
                     }
                     $count = $show->playlists()->where("series_no", $value);
                     if (!is_null($playlist)) {
                         $count = $count->where("id", "!=", $playlist->id);
                     }
                     $count = $count->count();
                     return $count === 0;
                 });
                 $validator = Validator::make($formData, array('series-no' => array('unique_series_no')), array('series-no.unique_series_no' => "A series already exists with that number."));
                 if (!$validator->fails()) {
                     // everything is good. save/create model
                     if (is_null($playlist)) {
                         $playlist = new Playlist();
                     }
                     $playlist->name = FormHelpers::nullIfEmpty($formData['name']);
                     $playlist->description = FormHelpers::nullIfEmpty($formData['description']);
                     $playlist->enabled = FormHelpers::toBoolean($formData['enabled']);
                     // if the scheduled publish time is empty and this playlist is enabled, set it to the current time.
                     // an enabled playlist should always have a published time.
                     $scheduledPublishTime = FormHelpers::nullIfEmpty(strtotime($formData['publish-time']));
                     $playlist->scheduled_publish_time = !is_null($scheduledPublishTime) ? $scheduledPublishTime : Carbon::now();
                     EloquentHelpers::associateOrNull($playlist->show(), $show);
                     $playlist->series_no = !is_null($show) ? intval($formData['series-no']) : null;
                     $coverImageId = FormHelpers::nullIfEmpty($formData['cover-image-id']);
                     $file = Upload::register(Config::get("uploadPoints.coverImage"), $coverImageId, $playlist->coverFile);
                     EloquentHelpers::associateOrNull($playlist->coverFile(), $file);
                     $sideBannerFileId = FormHelpers::nullIfEmpty($formData['side-banners-image-id']);
                     $file = Upload::register(Config::get("uploadPoints.sideBannersImage"), $sideBannerFileId, $playlist->sideBannerFile);
                     EloquentHelpers::associateOrNull($playlist->sideBannerFile(), $file);
                     $sideBannerFillFileId = FormHelpers::nullIfEmpty($formData['side-banners-fill-image-id']);
                     $file = Upload::register(Config::get("uploadPoints.sideBannersFillImage"), $sideBannerFillFileId, $playlist->sideBannerFillFile);
                     EloquentHelpers::associateOrNull($playlist->sideBannerFillFile(), $file);
                     $coverArtFileId = FormHelpers::nullIfEmpty($formData['cover-art-id']);
                     $file = Upload::register(Config::get("uploadPoints.coverArt"), $coverArtFileId, $playlist->coverArtFile);
                     EloquentHelpers::associateOrNull($playlist->coverArtFile(), $file);
                     if ($playlist->save() === false) {
                         throw new Exception("Error saving Playlist.");
                     }
                     $customUri = FormHelpers::nullIfEmpty($formData['custom-uri']);
                     $currentCustomUriModel = $playlist->customUri;
                     if (!is_null($customUri)) {
                         if ($playlist->custom_uri_name !== $customUri) {
                             // change needed
                             if (!is_null($currentCustomUriModel)) {
                                 // remove the current one first
                                 $currentCustomUriModel->delete();
                             }
                             $customUriModel = new CustomUri(array("name" => $customUri));
                             $playlist->customUri()->save($customUriModel);
                         }
                     } else {
                         if (!is_null($currentCustomUriModel)) {
                             // remove the current one
                             $currentCustomUriModel->delete();
                         }
                     }
                     // touch so that their search index numbers will be incremented
                     // each media item in the search index has the playlists it's in stored with it
                     // so will therefore need reindexing
                     foreach ($playlist->mediaItems as $a) {
                         $a->touch();
                     }
                     $playlist->mediaItems()->detach();
                     // detaches all
                     $ids = json_decode($formData['playlist-content'], true);
                     if (count($ids) > 0) {
                         $mediaItems = MediaItem::whereIn("id", $ids)->get();
                         foreach ($mediaItems as $a) {
                             $a->touch();
                             // for same reason as touch above
                             $playlist->mediaItems()->attach($a, array("position" => array_search(intval($a->id), $ids, true)));
                         }
                     }
                     $playlist->relatedItems()->detach();
                     // detaches all
                     $ids = json_decode($formData['related-items'], true);
                     if (count($ids) > 0) {
                         $mediaItems = MediaItem::whereIn("id", $ids)->get();
                         foreach ($mediaItems as $a) {
                             $playlist->relatedItems()->attach($a, array("position" => array_search(intval($a->id), $ids, true)));
                         }
                     }
                     // the transaction callback result is returned out of the transaction function
                     return true;
                 } else {
                     $errors = $validator->messages();
                     return false;
                 }
             } else {
                 $errors = $validator->messages();
                 return false;
             }
         });
         if ($modelCreated) {
             return Redirect::to(Config::get("custom.admin_base_url") . "/playlists");
         }
         // if not valid then return form again with errors
     }
     $view = View::make('home.admin.playlists.edit');
     $view->editing = $editing;
     $view->form = $formData;
     $view->additionalForm = $additionalFormData;
     $view->formErrors = $errors;
     // used to uniquely identify these file upload points on the site. Must not be duplicated for different upload points.
     $view->coverImageUploadPointId = Config::get("uploadPoints.coverImage");
     $view->sideBannersImageUploadPointId = Config::get("uploadPoints.sideBannersImage");
     $view->sideBannersFillImageUploadPointId = Config::get("uploadPoints.sideBannersFillImage");
     $view->coverArtUploadPointId = Config::get("uploadPoints.coverArt");
     $view->cancelUri = Config::get("custom.admin_base_url") . "/playlists";
     $view->seriesAjaxSelectDataUri = Config::get("custom.admin_base_url") . "/shows/ajaxselect";
     $this->setContent($view, "playlists", "playlists-edit");
 }
 private function updateShowsIndex()
 {
     $entries = ["toAdd" => [], "toRemove" => []];
     $changedShows = DB::transaction(function () {
         return Show::needsReindexing()->get();
     });
     foreach ($changedShows as $show) {
         if ($show->getIsAccessible()) {
             $entries["toAdd"][] = ["model" => $show, "data" => $this->getShowData($show)];
         } else {
             // this item is no longer accessible so remove it from the index
             $entries["toRemove"][] = ["model" => $show];
         }
     }
     $this->syncIndexType("show", new Show(), $entries);
 }
 protected function setContent($content, $navPage, $cssPageId, $openGraphProperties = array(), $title = NULL, $statusCode = 200, $twitterProperties = null, $sideBannersImageUrl = null, $sideBannersFillImageUrl = null)
 {
     $description = Config::get("custom.site_description");
     $registerPushNotificationEndpointUrl = Config::get("pushNotifications.enabled") ? URL::route("ajax-registerPushNotificationEndpoint") : null;
     $view = View::make("layouts.home.master");
     $view->version = !is_null(DebugHelpers::getVersion()) ? DebugHelpers::getVersion() : "[Unknown]";
     $view->baseUrl = URL::to("/");
     $view->currentNavPage = $navPage;
     $view->cssPageId = $cssPageId;
     $view->title = "LA1:TV";
     if (!is_null($title)) {
         $view->title .= ": " . $title;
     }
     $view->description = $description;
     $view->content = $content;
     $view->allowRobots = true;
     $view->manifestUri = URL::route('manifest');
     $view->cssBootstrap = asset("assets/css/bootstrap/home.css");
     $view->requireJsBootstrap = asset("assets/scripts/bootstrap/home.js");
     $view->loggedIn = Facebook::isLoggedIn();
     $view->sideBannersImageUrl = $sideBannersImageUrl;
     $view->sideBannersFillImageUrl = $sideBannersFillImageUrl;
     $view->sideBannersOn = !is_null($sideBannersImageUrl) || !is_null($sideBannersFillImageUrl);
     $view->supportEmail = Config::get("contactEmails.development");
     $view->pageData = array("baseUrl" => URL::to("/"), "cookieDomain" => Config::get("cookies.domain"), "cookieSecure" => Config::get("ssl.enabled"), "assetsBaseUrl" => asset(""), "serviceWorkerUrl" => URL::route("home-service-worker"), "logUri" => Config::get("custom.log_uri"), "debugId" => DebugHelpers::getDebugId(), "sessionId" => Session::getId(), "csrfToken" => Csrf::getToken(), "loggedIn" => Facebook::isLoggedIn(), "gaEnabled" => Config::get("googleAnalytics.enabled"), "notificationServiceUrl" => Config::get("notificationService.url"), "registerPushNotificationEndpointUrl" => $registerPushNotificationEndpointUrl, "promoAjaxUri" => Config::get("custom.live_shows_uri"), "env" => App::environment(), "version" => DebugHelpers::getVersion(), "degradedService" => Config::get("degradedService.enabled"));
     $facebookAppId = Config::get("facebook.appId");
     $defaultOpenGraphProperties = array();
     if (!is_null($facebookAppId)) {
         $defaultOpenGraphProperties[] = array("name" => "fb:app_id", "content" => $facebookAppId);
     }
     $defaultOpenGraphProperties[] = array("name" => "og:title", "content" => "LA1:TV");
     $defaultOpenGraphProperties[] = array("name" => "og:url", "content" => Request::url());
     $defaultOpenGraphProperties[] = array("name" => "og:locale", "content" => "en_GB");
     $defaultOpenGraphProperties[] = array("name" => "og:site_name", "content" => "LA1:TV");
     $defaultOpenGraphProperties[] = array("name" => "og:description", "content" => $description);
     $defaultOpenGraphProperties[] = array("name" => "og:image", "content" => Config::get("custom.open_graph_logo_uri"));
     $finalOpenGraphProperties = $this->mergeProperties($defaultOpenGraphProperties, $openGraphProperties);
     $finalTwitterProperties = array();
     if (!is_null($twitterProperties)) {
         $defaultTwitterProperties = array(array("name" => "card", "content" => "summary"), array("name" => "site", "content" => "@LA1TV"), array("name" => "description", "content" => str_limit($description, 197, "...")), array("name" => "image", "content" => Config::get("custom.twitter_card_logo_uri")));
         $finalTwitterProperties = $this->mergeProperties($defaultTwitterProperties, $twitterProperties);
     }
     $view->openGraphProperties = $finalOpenGraphProperties;
     $view->twitterProperties = $finalTwitterProperties;
     $view->searchEnabled = Config::get("search.enabled");
     $view->searchQueryAjaxUri = Config::get("custom.search_query_uri");
     $view->loginUri = URLHelpers::generateLoginUrl();
     $view->homeUri = Config::get("custom.base_url");
     $view->guideUri = Config::get("custom.base_url") . "/guide";
     $view->blogUri = Config::get("custom.blog_url");
     $view->contactUri = Config::get("custom.base_url") . "/contact";
     $view->accountUri = Config::get("custom.base_url") . "/account";
     $view->adminUri = Config::get("custom.base_url") . "/admin";
     // recent shows in dropdown
     $shows = Show::getCachedActiveShows();
     $view->showsDropdown = array();
     foreach ($shows as $a) {
         $view->showsDropdown[] = array("uri" => Config::get("custom.base_url") . "/show/" . $a->id, "text" => $a->name);
     }
     $view->showsUri = Config::get("custom.base_url") . "/shows";
     // recent playlists dropdown
     $playlists = Playlist::getCachedActivePlaylists(false);
     $view->playlistsDropdown = array();
     foreach ($playlists as $a) {
         $view->playlistsDropdown[] = array("uri" => Config::get("custom.base_url") . "/playlist/" . $a->id, "text" => $a->name);
     }
     $view->playlistsUri = Config::get("custom.base_url") . "/playlists";
     $liveStreams = LiveStream::getCachedSiteLiveStreams();
     $view->liveStreamsDropdown = array();
     foreach ($liveStreams as $a) {
         $view->liveStreamsDropdown[] = array("uri" => Config::get("custom.base_url") . "/livestream/" . $a->id, "text" => $a->name);
     }
     $contentSecurityPolicyDomains = MediaItemLiveStream::getCachedLiveStreamDomains();
     $response = new MyResponse($view, $statusCode);
     // disable csp for main site because causing too many issues with live streams (and clappr uses unsafe evals etc)
     $response->enableContentSecurityPolicy(false);
     //$response->setContentSecurityPolicyDomains($contentSecurityPolicyDomains);
     $this->layout = $response;
 }
Example #10
0
 public function postAjaxselect()
 {
     Auth::getUser()->hasPermissionOr401(Config::get("permissions.shows"), 0);
     $resp = array("success" => false, "payload" => null);
     $searchTerm = FormHelpers::getValue("term", "");
     $shows = null;
     if (!empty($searchTerm)) {
         $shows = Show::search($searchTerm)->orderBy("created_at", "desc")->take(20)->get();
     } else {
         $shows = Show::orderBy("created_at", "desc")->take(20)->get();
     }
     $results = array();
     foreach ($shows as $a) {
         $results[] = array("id" => intval($a->id), "text" => $a->name);
     }
     $resp['payload'] = array("results" => $results, "term" => $searchTerm);
     $resp['success'] = true;
     return Response::json($resp);
 }