public function page() { if (isset($_REQUEST['message'])) { if ($_REQUEST['message'] == 'media_file_batch_enabled_notice') { ?> <div class="updated"> <p><?php echo __('<strong>Media Files enabled.</strong> These Media Files have been enabled for all existing episodes.'); ?> </p> </div> <?php } if ($_REQUEST['message'] == 'media_file_relation_warning') { $asset = Model\EpisodeAsset::find_one_by_id((int) $_REQUEST['deleted_id']); ?> <div class="error"> <p> <?php echo __('<strong>The asset has not been deleted. Are you aware that the asset is still in use?</strong>', 'podlove'); ?> <ul class="ul-disc"> <?php if ($asset->has_active_media_files()) { ?> <li> <?php echo sprintf(__('There are %s connected media files.', 'podlove'), count($asset->active_media_files())); ?> </li> <?php } ?> <?php if ($asset->has_asset_assignments()) { ?> <li> <?php echo __('This asset is assigned to episode images or episode chapters.', 'podlove'); ?> </li> <?php } ?> <?php if ($asset->is_connected_to_feed()) { ?> <li> <?php echo __('A feed uses this asset.', 'podlove'); ?> </li> <?php } ?> <?php if ($asset->is_connected_to_web_player()) { ?> <li> <?php echo __('The web player uses this asset.', 'podlove'); ?> </li> <?php } ?> </ul> <a href="?page=<?php echo $_REQUEST['page']; ?> &action=delete&episode_asset=<?php echo $asset->id; ?> &force=1"> <?php echo __('delete anyway', 'podlove'); ?> </a> </p> </div> <?php } } ?> <div class="wrap"> <?php screen_icon('podlove-podcast'); ?> <h2><?php echo __('Episode Assets', 'podlove'); ?> <a href="?page=<?php echo $_REQUEST['page']; ?> &action=new" class="add-new-h2"><?php echo __('Add New', 'podlove'); ?> </a></h2> <?php $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : NULL; switch ($action) { case 'new': $this->new_template(); break; case 'edit': $this->edit_template(); break; case 'index': $this->view_template(); break; default: $this->view_template(); break; } ?> </div> <?php }
public function cover_art() { return $this->with_blog_scope(function () { $podcast = Podcast::get(); $asset_assignment = AssetAssignment::get_instance(); if (!$asset_assignment->image) { return false; } if ($asset_assignment->image == 'manual') { $cover_art = trim($this->cover_art); if (empty($cover_art)) { return false; } else { return new Image($cover_art, $this->title()); } } $cover_art_file_id = $asset_assignment->image; if (!($asset = EpisodeAsset::find_one_by_id($cover_art_file_id))) { return false; } if (!($file = MediaFile::find_by_episode_id_and_episode_asset_id($this->id, $asset->id))) { return false; } return $file->size > 0 ? new Image($file->get_file_url(), $this->title()) : false; }); }
private function get_chapters_object() { if (!$this->chapters_raw) { $this->chapters_raw = $this->get_raw_chapters_string(); } if (!$this->chapters_raw) { return NULL; } $asset_assignment = Model\AssetAssignment::get_instance(); if ($asset_assignment->chapters == 'manual') { return Parser\Mp4chaps::parse($this->chapters_raw); } if (!($chapters_asset = Model\EpisodeAsset::find_one_by_id($asset_assignment->chapters))) { return NULL; } $mime_type = $chapters_asset->file_type()->mime_type; $chapters = false; switch ($mime_type) { case 'application/xml': $chapters = Parser\PSC::parse($this->chapters_raw); break; case 'application/json': $chapters = Parser\JSON::parse($this->chapters_raw); break; case 'text/plain': switch ($this->chapters_raw[0]) { case '[': case '{': $chapters = Parser\JSON::parse($this->chapters_raw); break; case '<': $chapters = Parser\PSC::parse($this->chapters_raw); break; default: $chapters = Parser\Mp4chaps::parse($this->chapters_raw); break; } break; } return $chapters; }