コード例 #1
0
ファイル: tag.class.php プロジェクト: nioc/ampache
 public function display_art($thumb = 2)
 {
     if (Art::has_db($this->id, 'tag')) {
         Art::display('tag', $this->id, $this->get_fullname(), $thumb, $this->link);
     }
 }
コード例 #2
0
ファイル: shoutbox.class.php プロジェクト: nioc/ampache
 /**
  * get_image
  * This returns an image tag if the type of object we're currently rolling with
  * has an image associated with it
  */
 public function get_image()
 {
     $image_string = '';
     if (Art::has_db($this->object_id, $this->object_type)) {
         $image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . AmpConfig::get('web_path') . "/image.php?object_id=" . $this->object_id . "&object_type=" . $this->object_type . "&thumb=1\" />";
     }
     return $image_string;
 }
コード例 #3
0
ファイル: tvshow_episode.class.php プロジェクト: nioc/ampache
 public function display_art($thumb = 2)
 {
     $id = null;
     $type = null;
     if (Art::has_db($this->id, 'video')) {
         $id = $this->id;
         $type = 'video';
     } else {
         if (Art::has_db($this->season, 'tvshow_season')) {
             $id = $this->season;
             $type = 'tvshow_season';
         } else {
             $season = new TVShow_Season($this->season);
             if (Art::has_db($season->tvshow, 'tvshow')) {
                 $id = $season->tvshow;
                 $type = 'tvshow';
             }
         }
     }
     if ($id !== null && $type !== null) {
         Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);
     }
 }
コード例 #4
0
ファイル: catalog.class.php プロジェクト: bl00m/ampache
 /**
  * update_song_from_tags
  * Updates the song info based on tags; this is called from a bunch of
  * different places and passes in a full fledged song object, so it's a
  * static function.
  * FIXME: This is an ugly mess, this really needs to be consolidated and
  * cleaned up.
  * @param array $results
  * @param \Song $song
  * @return array
  */
 public static function update_song_from_tags($results, Song $song)
 {
     /* Setup the vars */
     $new_song = new Song();
     $new_song->file = $results['file'];
     $new_song->title = $results['title'];
     $new_song->year = $results['year'];
     $new_song->comment = $results['comment'];
     $new_song->language = $results['language'];
     $new_song->lyrics = str_replace(array("\r\n", "\r", "\n"), '<br />', strip_tags($results['lyrics']));
     $new_song->bitrate = $results['bitrate'];
     $new_song->rate = $results['rate'];
     $new_song->mode = $results['mode'] == 'cbr' ? 'cbr' : 'vbr';
     $new_song->size = $results['size'];
     $new_song->time = $results['time'];
     $new_song->mime = $results['mime'];
     $new_song->track = intval($results['track']);
     $new_song->mbid = $results['mb_trackid'];
     $new_song->label = $results['publisher'];
     $new_song->composer = $results['composer'];
     $new_song->replaygain_track_gain = floatval($results['replaygain_track_gain']);
     $new_song->replaygain_track_peak = floatval($results['replaygain_track_peak']);
     $new_song->replaygain_album_gain = floatval($results['replaygain_album_gain']);
     $new_song->replaygain_album_peak = floatval($results['replaygain_album_peak']);
     $tags = Tag::get_object_tags('song', $song->id);
     if ($tags) {
         foreach ($tags as $tag) {
             $song->tags[] = $tag['name'];
         }
     }
     $new_song->tags = $results['genre'];
     $artist = $results['artist'];
     $artist_mbid = $results['mb_artistid'];
     $albumartist = $results['albumartist'] ?: $results['band'];
     $albumartist = $albumartist ?: null;
     $albumartist_mbid = $results['mb_albumartistid'];
     $album = $results['album'];
     $album_mbid = $results['mb_albumid'];
     $album_mbid_group = $results['mb_albumid_group'];
     $disk = $results['disk'];
     /*
      * We have the artist/genre/album name need to check it in the tables
      * If found then add & return id, else return id
      */
     $new_song->artist = Artist::check($artist, $artist_mbid);
     if ($albumartist) {
         $new_song->albumartist = Artist::check($albumartist, $albumartist_mbid);
     }
     $new_song->album = Album::check($album, $new_song->year, $disk, $album_mbid, $album_mbid_group, $new_song->albumartist);
     $new_song->title = self::check_title($new_song->title, $new_song->file);
     /* Since we're doing a full compare make sure we fill the extended information */
     $song->fill_ext_info();
     if (Song::isCustomMetadataEnabled()) {
         $ctags = self::get_clean_metadata($song, $results);
         if (method_exists($song, 'updateOrInsertMetadata') && $song::isCustomMetadataEnabled()) {
             $ctags = array_diff_key($ctags, array_flip($song->getDisabledMetadataFields()));
             foreach ($ctags as $tag => $value) {
                 $field = $song->getField($tag);
                 $song->updateOrInsertMetadata($field, $value);
             }
         }
     }
     $info = Song::compare_song_information($song, $new_song);
     if ($info['change']) {
         debug_event('update', "{$song->file} : differences found, updating database", 5);
         // Duplicate arts if required
         if ($song->artist != $new_song->artist) {
             if (!Art::has_db($new_song->artist, 'artist')) {
                 Art::duplicate('artist', $song->artist, $new_song->artist);
             }
         }
         if ($song->albumartist != $new_song->albumartist) {
             if (!Art::has_db($new_song->albumartist, 'artist')) {
                 Art::duplicate('artist', $song->albumartist, $new_song->albumartist);
             }
         }
         if ($song->album != $new_song->album) {
             if (!Art::has_db($new_song->album, 'album')) {
                 Art::duplicate('album', $song->album, $new_song->album);
             }
         }
         $song->update_song($song->id, $new_song);
         if ($song->tags != $new_song->tags) {
             Tag::update_tag_list(implode(',', $new_song->tags), 'song', $song->id, true);
             self::updateAlbumTags($song);
             self::updateArtistTags($song);
         }
         // Refine our reference
         //$song = $new_song;
     } else {
         debug_event('update', "{$song->file} : no differences found", 5);
     }
     // If song rating tag exists and is well formed (array user=>rating), update it
     if ($song->id && array_key_exists('rating', $results) && is_array($results['rating'])) {
         // For each user's ratings, call the function
         foreach ($results['rating'] as $user => $rating) {
             debug_event('Rating', "Updating rating for Song " . $song->id . " to {$rating} for user {$user}", 5);
             $o_rating = new Rating($song->id, 'song');
             $o_rating->set_rating($rating, $user);
         }
     }
     return $info;
 }
コード例 #5
0
ファイル: art.class.php プロジェクト: bl00m/ampache
 /**
  * Display an item art.
  * @param string $object_type
  * @param int $object_id
  * @param string $name
  * @param int $thumb
  * @param string $link
  * @param boolean $show_default
  * @param string $kind
  * @return boolean
  */
 public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
 {
     if (!self::is_valid_type($object_type)) {
         return false;
     }
     if (!$show_default) {
         // Don't show any image if not available
         if (!self::has_db($object_id, $object_type, $kind)) {
             return false;
         }
     }
     $size = self::get_thumb_size($thumb);
     $prettyPhoto = $link == null;
     if ($link == null) {
         $link = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type;
         if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
             $link .= "&auth=" . session_id();
         }
         if ($kind != 'default') {
             $link .= '&kind=' . $kind;
         }
     }
     echo "<div class=\"item_art\">";
     echo "<a href=\"" . $link . "\" title=\"" . $name . "\"";
     if ($prettyPhoto) {
         echo " rel=\"prettyPhoto\"";
     }
     echo ">";
     $imgurl = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type . "&thumb=" . $thumb;
     if ($kind != 'default') {
         $imgurl .= '&kind=' . $kind;
     }
     // This to keep browser cache feature but force a refresh in case image just changed
     if (Art::has_db($object_id, $object_type)) {
         $art = new Art($object_id, $object_type);
         if ($art->get_db()) {
             $imgurl .= '&fooid=' . $art->id;
         }
     }
     echo "<img src=\"" . $imgurl . "\" alt=\"" . $name . "\" height=\"" . $size['height'] . "\" width=\"" . $size['width'] . "\" />";
     if ($size['height'] > 150) {
         echo "<div class=\"item_art_play\">";
         echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id . '\' + getPagePlaySettings() + \'', '<span class="item_art_play_icon" title="' . T_('Play') . '" />', 'directplay_art_' . $object_type . '_' . $object_id);
         echo "</div>";
     }
     if ($prettyPhoto) {
         $libitem = new $object_type($object_id);
         echo "<div class=\"item_art_actions\">";
         if ($GLOBALS['user']->has_access(50) || $GLOBALS['user']->has_access(25) && $GLOBALS['user']->id == $libitem->get_user_owner()) {
             echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=find_art&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\">";
             echo UI::get_icon('edit', T_('Edit/Find Art'));
             echo "</a>";
             echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=clear_art&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\" onclick=\"return confirm('" . T_('Do you really want to reset art?') . "');\">";
             echo UI::get_icon('delete', T_('Reset Art'));
             echo "</a>";
         }
         echo "</div>";
     }
     echo "</a>\n";
     echo "</div>";
     return true;
 }
コード例 #6
0
 public function display_art($thumb = 2)
 {
     $id = null;
     $type = null;
     if (Art::has_db($this->id, 'podcast_episode')) {
         $id = $this->id;
         $type = 'podcast_episode';
     } else {
         if (Art::has_db($this->podcast, 'podcast')) {
             $id = $this->podcast;
             $type = 'podcast';
         }
     }
     if ($id !== null && $type !== null) {
         Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);
     }
 }
コード例 #7
0
ファイル: plex_xml_data.class.php プロジェクト: bl00m/ampache
 public static function addAlbumMeta(SimpleXMLElement $xml, Album $album)
 {
     $id = self::getAlbumId($album->id);
     $xml->addAttribute('allowSync', '1');
     $xml->addAttribute('type', 'album');
     $xml->addAttribute('summary', '');
     $xml->addAttribute('index', '1');
     if (Art::has_db($album->id, 'album')) {
         $xml->addAttribute('art', self::getMetadataUri($id) . '/thumb/' . $id);
         $xml->addAttribute('thumb', self::getMetadataUri($id) . '/thumb/' . $id);
     }
     if ($album->artist_id) {
         self::addArtistThumb($xml, $album->artist_id, 'parentThumb');
     }
     $xml->addAttribute('originallyAvailableAt', '');
     $xml->addAttribute('addedAt', '');
     $xml->addAttribute('updatedAt', '');
 }
コード例 #8
0
ファイル: catalog.class.php プロジェクト: nioc/ampache
 /**
  * update_song_from_tags
  * Updates the song info based on tags; this is called from a bunch of
  * different places and passes in a full fledged song object, so it's a
  * static function.
  * FIXME: This is an ugly mess, this really needs to be consolidated and
  * cleaned up.
  * @param array $results
  * @param \Song $song
  * @return array
  */
 public static function update_song_from_tags($results, Song $song)
 {
     /* Setup the vars */
     $new_song = new Song();
     $new_song->file = $results['file'];
     $new_song->title = $results['title'];
     $new_song->year = $results['year'];
     $new_song->comment = $results['comment'];
     $new_song->language = $results['language'];
     $new_song->lyrics = str_replace(array("\r\n", "\r", "\n"), '<br />', strip_tags($results['lyrics']));
     $new_song->bitrate = $results['bitrate'];
     $new_song->rate = $results['rate'];
     $new_song->mode = $results['mode'] == 'cbr' ? 'cbr' : 'vbr';
     $new_song->size = $results['size'];
     $new_song->time = $results['time'];
     $new_song->mime = $results['mime'];
     $new_song->track = intval($results['track']);
     $new_song->mbid = $results['mb_trackid'];
     $new_song->label = $results['publisher'];
     $new_song->composer = $results['composer'];
     $new_song->replaygain_track_gain = floatval($results['replaygain_track_gain']);
     $new_song->replaygain_track_peak = floatval($results['replaygain_track_peak']);
     $new_song->replaygain_album_gain = floatval($results['replaygain_album_gain']);
     $new_song->replaygain_album_peak = floatval($results['replaygain_album_peak']);
     $tags = Tag::get_object_tags('song', $song->id);
     if ($tags) {
         foreach ($tags as $tag) {
             $song->tags[] = $tag['name'];
         }
     }
     $new_song->tags = $results['genre'];
     $artist = $results['artist'];
     $artist_mbid = $results['mb_artistid'];
     $albumartist = $results['albumartist'] ?: $results['band'];
     $albumartist = $albumartist ?: null;
     $albumartist_mbid = $results['mb_albumartistid'];
     $album = $results['album'];
     $album_mbid = $results['mb_albumid'];
     $album_mbid_group = $results['mb_albumid_group'];
     $disk = $results['disk'];
     /*
      * We have the artist/genre/album name need to check it in the tables
      * If found then add & return id, else return id
      */
     $new_song->artist = Artist::check($artist, $artist_mbid);
     if ($albumartist) {
         $new_song->albumartist = Artist::check($albumartist, $albumartist_mbid);
     }
     $new_song->album = Album::check($album, $new_song->year, $disk, $album_mbid, $album_mbid_group, $new_song->albumartist);
     $new_song->title = self::check_title($new_song->title, $new_song->file);
     /* Since we're doing a full compare make sure we fill the extended information */
     $song->fill_ext_info();
     $info = Song::compare_song_information($song, $new_song);
     if ($info['change']) {
         debug_event('update', "{$song->file} : differences found, updating database", 5);
         // Duplicate arts if required
         if ($song->artist != $new_song->artist) {
             if (!Art::has_db($new_song->artist, 'artist')) {
                 Art::duplicate('artist', $song->artist, $new_song->artist);
             }
         }
         if ($song->albumartist != $new_song->albumartist) {
             if (!Art::has_db($new_song->albumartist, 'artist')) {
                 Art::duplicate('artist', $song->albumartist, $new_song->albumartist);
             }
         }
         if ($song->album != $new_song->album) {
             if (!Art::has_db($new_song->album, 'album')) {
                 Art::duplicate('album', $song->album, $new_song->album);
             }
         }
         $song->update_song($song->id, $new_song);
         if ($song->tags != $new_song->tags) {
             Tag::update_tag_list(implode(',', $new_song->tags), 'song', $song->id, true);
             self::updateAlbumTags($song);
             self::updateArtistTags($song);
         }
         // Refine our reference
         //$song = $new_song;
     } else {
         debug_event('update', "{$song->file} : no differences found", 5);
     }
     return $info;
 }
コード例 #9
0
ファイル: album.class.php プロジェクト: bl00m/ampache
 public function display_art($thumb = 2)
 {
     $id = null;
     $type = null;
     if (Art::has_db($this->id, 'album')) {
         $id = $this->id;
         $type = 'album';
     } else {
         if (Art::has_db($this->artist_id, 'artist')) {
             $id = $this->artist_id;
             $type = 'artist';
         }
     }
     if ($id !== null && $type !== null) {
         Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);
     }
 }
コード例 #10
0
ファイル: xml_data.class.php プロジェクト: cheese1/ampache
 public static function podcast(library_item $libitem)
 {
     $xml = new SimpleXMLElement('<rss />');
     $xml->addAttribute("version", "2.0");
     $xml->addAttribute("xmlns:xmlns:atom", "http://www.w3.org/2005/Atom");
     $xml->addAttribute("xmlns:xmlns:itunes", "http://www.itunes.com/dtds/podcast-1.0.dtd");
     $xchannel = $xml->addChild("channel");
     $xchannel->addChild("title", $libitem->get_fullname() . " Podcast");
     $xlink = $xchannel->addChild("atom:link");
     $xlink->addAttribute("type", "text/html");
     $xlink->addAttribute("href", $libitem->link);
     if (Art::has_db($libitem->id, get_class($libitem))) {
         $ximg = $xchannel->addChild("xmlns:itunes:image");
         $ximg->addAttribute("href", Art::url($libitem->id, get_class($libitem)));
     }
     $summary = $libitem->get_description();
     if (!empty($summary)) {
         $xchannel->addChild("xmlns:itunes:summary", $summary);
     }
     $xchannel->addChild("xmlns:itunes:category", "Music");
     $owner = $libitem->get_user_owner();
     if ($owner) {
         $user_owner = new User($owner);
         $user_owner->format();
         $xowner = $xchannel->addChild("xmlns:itunes:owner");
         $xowner->addChild("xmlns:itunes:name", $user_owner->f_name);
     }
     $medias = $libitem->get_medias();
     foreach ($medias as $media_info) {
         $media = new $media_info['object_type']($media_info['object_id']);
         $media->format();
         $xitem = $xchannel->addChild("item");
         $xitem->addChild("title", $media->get_fullname());
         if ($media->f_artist) {
             $xitem->addChild("xmlns:itunes:author", $media->f_artist);
         }
         $xmlink = $xitem->addChild("link");
         $xmlink->addAttribute("href", $media->link);
         $xitem->addChild("guid", $media->link);
         if ($media->addition_time) {
             $xitem->addChild("pubDate", date("r", $media->addition_time));
         }
         $description = $media->get_description();
         if (!empty($description)) {
             $xitem->addChild("description", $description);
         }
         $xitem->addChild("xmlns:itunes:duration", $media->f_time);
         $xencl = $xitem->addChild("enclosure");
         $xencl->addAttribute("type", $media->mime);
         $xencl->addAttribute("length", $media->size);
         $surl = $media_info['object_type']::play_url($media_info['object_id']);
         $xencl->addAttribute("url", $surl);
     }
     $xmlstr = $xml->asXml();
     // Format xml output
     $dom = new DOMDocument();
     $dom->loadXML($xmlstr);
     $dom->formatOutput = true;
     return $dom->saveXML($dom->documentElement);
 }
コード例 #11
0
ファイル: video.class.php プロジェクト: ivan801/ampache
 public static function generate_preview($video_id, $overwrite = false)
 {
     if ($overwrite || !Art::has_db($video_id, 'video', 'preview')) {
         $artp = new Art($video_id, 'video', 'preview');
         $video = new Video($video_id);
         $image = Stream::get_image_preview($video);
         $artp->insert($image, 'image/png');
     }
 }
コード例 #12
0
 private static function addPodcastEpisode($xml, $episode, $elementName = 'episode')
 {
     $episode->format();
     $xepisode = $xml->addChild($elementName);
     $xepisode->addAttribute("id", self::getPodcastEpId($episode->id));
     $xepisode->addAttribute("channelId", self::getPodcastId($episode->podcast));
     $xepisode->addAttribute("title", $episode->f_title);
     $xepisode->addAttribute("album", $episode->f_podcast);
     $xepisode->addAttribute("description", $episode->f_description);
     $xepisode->addAttribute("duration", $episode->time);
     $xepisode->addAttribute("genre", "Podcast");
     $xepisode->addAttribute("isDir", "false");
     $xepisode->addAttribute("publishDate", date("c", $episode->pubdate));
     $xepisode->addAttribute("status", $episode->state);
     if (Art::has_db($episode->podcast, 'podcast')) {
         $xepisode->addAttribute("coverArt", self::getPodcastId($episode->podcast));
     }
     if ($episode->file) {
         $xepisode->addAttribute("streamId", self::getPodcastEpId($episode->id));
         $xepisode->addAttribute("size", $episode->size);
         $xepisode->addAttribute("suffix", $episode->type);
         $xepisode->addAttribute("contentType", $episode->mime);
         // Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
         $path = basename($episode->file);
         $xepisode->addAttribute("path", $path);
     }
 }