예제 #1
0
파일: episode.php 프로젝트: rthees/podlove
 public function refetch_files()
 {
     foreach (EpisodeAsset::all() as $asset) {
         if ($file = MediaFile::find_by_episode_id_and_episode_asset_id($this->id, $asset->id)) {
             $file->determine_file_size();
             $file->save();
         }
     }
 }
예제 #2
0
 /**
  * Dynamically return file url from release, format and show.
  *
  * @return string
  */
 public function get_file_url()
 {
     $podcast = Podcast::get_instance();
     $episode = $this->episode();
     $episode_asset = EpisodeAsset::find_by_id($this->episode_asset_id);
     $file_type = FileType::find_by_id($episode_asset->file_type_id);
     if (!$episode_asset || !$file_type || !$episode->slug) {
         return '';
     }
     $template = $episode_asset->url_template;
     $template = str_replace('%media_file_base_url%', $podcast->media_file_base_uri, $template);
     $template = str_replace('%episode_slug%', $episode->slug, $template);
     $template = str_replace('%format_extension%', $file_type->extension, $template);
     return $template;
 }
예제 #3
0
 /**
  * Find all post_ids associated with this feed.
  * 
  * @return array
  */
 function post_ids()
 {
     global $wpdb;
     $allowed_status = array("publish");
     $allowed_status = apply_filters("podlove_feed_post_ids_allowed_status", $allowed_status);
     $sql = "\n\t\t\tSELECT\n\t\t\t\tp.ID\n\t\t\tFROM\n\t\t\t\t" . $wpdb->posts . " p\n\t\t\t\tINNER JOIN " . Episode::table_name() . " e ON e.post_id = p.ID\n\t\t\t\tINNER JOIN " . MediaFile::table_name() . " mf ON mf.`episode_id` = e.id\n\t\t\t\tINNER JOIN " . EpisodeAsset::table_name() . " a ON a.id = mf.`episode_asset_id`\n\t\t\tWHERE\n\t\t\t\ta.id = %d\n\t\t\t\tAND\n\t\t\t\tp.post_status IN (" . implode(',', array_map(function ($s) {
         return "'{$s}'";
     }, $allowed_status)) . ")\n\t\t\tORDER BY\n\t\t\t\tp.post_date DESC\n\t\t";
     return $wpdb->get_col($wpdb->prepare($sql, $this->episode_asset()->id));
 }
예제 #4
0
파일: feed.php 프로젝트: rthees/podlove
 /**
  * Find the related episode asset model.
  * 
  * @return \Podlove\Model\EpisodeAsset|NULL
  */
 public function episode_asset()
 {
     return $this->episode_asset_id ? EpisodeAsset::find_by_id($this->episode_asset_id) : NULL;
 }
     *
     * Can only be deleted if all of the following applies to the asset:
     * - has no active media file
     * - has no asset assignment
     * - is not connected to any feed
     * - is not connected to web player
     * 
     * @return boolean true if it should be deleted, otherwise false.
     */
    public function is_deletable()
    {
        return !$this->has_active_media_files() && !$this->has_asset_assignments() && !$this->is_connected_to_feed() && !$this->is_connected_to_web_player();
    }
    /**
     * @override \Podlove\Model\Base::delete();
     */
    public function delete()
    {
        foreach ($this->media_files() as $media_file) {
            $media_file->delete();
        }
        parent::delete();
    }
}
EpisodeAsset::property('id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
EpisodeAsset::property('title', 'VARCHAR(255)');
EpisodeAsset::property('file_type_id', 'INT');
EpisodeAsset::property('suffix', 'VARCHAR(255)');
EpisodeAsset::property('downloadable', 'INT');
EpisodeAsset::property('position', 'FLOAT');
예제 #6
0
     *
     * @return \Podlove\Model\FileType|NULL
     */
    public function file_type()
    {
        return FileType::find_by_id($this->file_type_id);
    }
    /**
     * Fine all media file models in this location.
     * 
     * @return array|NULL
     */
    function media_files()
    {
        return MediaFile::find_all_by_episode_asset_id($this->id);
    }
    public function title()
    {
        if ($this->file_type_id) {
            return $this->file_type()->title();
        } else {
            return __('Notice: No file format defined.', 'podlove');
        }
    }
}
EpisodeAsset::property('id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
EpisodeAsset::property('title', 'VARCHAR(255)');
EpisodeAsset::property('file_type_id', 'INT');
EpisodeAsset::property('url_template', 'VARCHAR(255)');
EpisodeAsset::property('downloadable', 'INT');
 /**
  * Fetch all valid feeds.
  * 
  * A feed is valid if...
  * 
  * - it has an asset assigned (and the asset has a filetype assigned)
  * - the slug in not empty
  * 
  * @return array list of feeds
  */
 public function feeds()
 {
     return $this->with_blog_scope(function () {
         $sql = "\n\t\t\t\tSELECT\n\t\t\t\t\tf.*\n\t\t\t\tFROM\n\t\t\t\t\t" . Feed::table_name() . " f\n\t\t\t\t\tJOIN " . EpisodeAsset::table_name() . " a ON a.id = f.episode_asset_id\n\t\t\t\t\tJOIN " . FileType::table_name() . " ft ON ft.id = a.file_type_id\n\t\t\t\tWHERE\n\t\t\t\t\tf.slug IS NOT NULL\n\t\t\t\tORDER BY \n\t\t\t\t\tposition ASC\n\t\t\t";
         return Feed::find_all_by_sql($sql);
     });
 }