当前位置: 首页>>代码示例>>PHP>>正文


PHP Album::check方法代码示例

本文整理汇总了PHP中Album::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::check方法的具体用法?PHP Album::check怎么用?PHP Album::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Album的用法示例。


在下文中一共展示了Album::check方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_song_from_tags

 /**
  * 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.
  */
 public static function update_song_from_tags($results, $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 = $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'];
     $artist = $results['artist'];
     $artist_mbid = $results['mb_artistid'];
     $album = $results['album'];
     $album_mbid = $results['mb_albumid'];
     $disk = $results['disk'];
     $tags = $results['genre'];
     // multiple genre support makes this an array
     /*
      * 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);
     $new_song->f_artist = $artist;
     $new_song->album = Album::check($album, $new_song->year, $disk, $album_mbid);
     $new_song->f_album = $album . " - " . $new_song->year;
     $new_song->title = self::check_title($new_song->title, $new_song->file);
     // Nothing to assign here this is a multi-value doodly
     // multiple genre support
     if (is_array($tags)) {
         foreach ($tags as $tag) {
             $tag = trim($tag);
             //self::check_tag($tag,$song->id);
             //self::check_tag($tag,$new_song->album,'album');
             //self::check_tag($tag,$new_song->artist,'artist');
         }
     }
     /* 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);
         $song->update_song($song->id, $new_song);
         // Refine our reference
         //$song = $new_song;
     } else {
         debug_event('update', "{$song->file} : no differences found", 5);
     }
     return $info;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:65,代码来源:catalog.class.php

示例2: update_song_from_tags

 /**
  * 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;
//.........这里部分代码省略.........
开发者ID:bl00m,项目名称:ampache,代码行数:101,代码来源:catalog.class.php

示例3: process

 public static function process()
 {
     header('Content-Type: application/json');
     ob_start();
     define('CLI', true);
     $catalog_id = AmpConfig::get('upload_catalog');
     if ($catalog_id > 0) {
         $catalog = Catalog::create_from_id($catalog_id);
         if ($catalog->catalog_type == "local") {
             $allowed = explode('|', AmpConfig::get('catalog_file_pattern'));
             if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
                 $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
                 if (!in_array(strtolower($extension), $allowed)) {
                     debug_event('upload', 'File extension `' . $extension . '` not allowed.', '2');
                     return self::rerror();
                 }
                 $rootdir = self::get_root($catalog);
                 $targetdir = $rootdir;
                 $folder = $_POST['folder'];
                 if ($folder == '..') {
                     $folder = '';
                 }
                 if (!empty($folder)) {
                     $targetdir .= DIRECTORY_SEPARATOR . $folder;
                 }
                 $targetdir = realpath($targetdir);
                 if (strpos($targetdir, $rootdir) === FALSE) {
                     debug_event('upload', 'Something wrong with final upload path.', '1');
                     return self::rerror();
                 }
                 $targetfile = $targetdir . DIRECTORY_SEPARATOR . time() . '_' . $_FILES['upl']['name'];
                 if (Core::is_readable($targetfile)) {
                     debug_event('upload', 'File `' . $targetfile . '` already exists.', '1');
                     return self::rerror();
                 }
                 if (move_uploaded_file($_FILES['upl']['tmp_name'], $targetfile)) {
                     debug_event('upload', 'File uploaded to `' . $targetfile . '`.', '5');
                     if (AmpConfig::get('upload_script')) {
                         chdir($targetdir);
                         exec(AmpConfig::get('upload_script'));
                     }
                     $options = array();
                     $options['user_upload'] = $GLOBALS['user']->id;
                     if (isset($_POST['license'])) {
                         $options['license'] = $_POST['license'];
                     }
                     $artist_id = intval($_REQUEST['artist']);
                     $album_id = intval($_REQUEST['album']);
                     // Override artist information with artist's user
                     if (AmpConfig::get('upload_user_artist')) {
                         $artists = $GLOBALS['user']->get_artists();
                         $artist = null;
                         // No associated artist yet, we create a default one for the user sender
                         if (count($artists) == 0) {
                             $artists[] = Artist::check($GLOBALS['user']->f_name);
                             $artist = new Artist($artists[0]);
                             $artist->update_artist_user($GLOBALS['user']->id);
                         } else {
                             $artist = new Artist($artists[0]);
                         }
                         $artist_id = $artist->id;
                     } else {
                         // Try to create a new artist
                         if (isset($_REQUEST['artist_name'])) {
                             $artist_id = Artist::check($_REQUEST['artist_name'], null, true);
                             if ($artist_id && !Access::check('interface', 50)) {
                                 debug_event('upload', 'An artist with the same name already exists, uploaded song skipped.', 3);
                                 return self::rerror($targetfile);
                             } else {
                                 $artist_id = Artist::check($_REQUEST['artist_name']);
                                 $artist = new Artist($artist_id);
                                 if (!$artist->get_user_owner()) {
                                     $artist->update_artist_user($GLOBALS['user']->id);
                                 }
                             }
                         }
                         if (!Access::check('interface', 50)) {
                             // If the user doesn't have privileges, check it is assigned to an artist he owns
                             if (!$artist_id) {
                                 debug_event('upload', 'Artist information required, uploaded song skipped.', 3);
                                 return self::rerror($targetfile);
                             }
                             $artist = new Artist($artist_id);
                             if ($artist->get_user_owner() != $GLOBALS['user']->id) {
                                 debug_event('upload', 'Artist owner doesn\'t match the current user.', 3);
                                 return self::rerror($targetfile);
                             }
                         }
                     }
                     // Try to create a new album
                     if (isset($_REQUEST['album_name'])) {
                         $album_id = Album::check($_REQUEST['album_name'], 0, 0, null, null, $artist_id);
                     }
                     if (!Access::check('interface', 50)) {
                         // If the user doesn't have privileges, check it is assigned to an album he owns
                         if (!$album_id) {
                             debug_event('upload', 'Album information required, uploaded song skipped.', 3);
                             return self::rerror($targetfile);
                         }
                         $album = new Album($album_id);
//.........这里部分代码省略.........
开发者ID:nioc,项目名称:ampache,代码行数:101,代码来源:upload.class.php

示例4: update_song_from_tags

 /**
  * 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;
 }
开发者ID:nioc,项目名称:ampache,代码行数:95,代码来源:catalog.class.php

示例5: update

 /**
  * update
  * This takes a key'd array of data does any cleaning it needs to
  * do and then calls the helper functions as needed.
  * @param array $data
  * @return int
  */
 public function update(array $data)
 {
     foreach ($data as $key => $value) {
         debug_event('song.class.php', $key . '=' . $value, '5');
         switch ($key) {
             case 'artist_name':
                 // Need to create new artist according the name
                 $new_artist_id = Artist::check($value);
                 $this->artist = $new_artist_id;
                 self::update_artist($new_artist_id, $this->id);
                 break;
             case 'album_name':
                 // Need to create new album according the name
                 $new_album_id = Album::check($value);
                 $this->album = $new_album_id;
                 self::update_album($new_album_id, $this->id);
                 break;
             case 'year':
             case 'title':
             case 'track':
             case 'artist':
             case 'album':
             case 'mbid':
             case 'license':
             case 'composer':
             case 'label':
             case 'language':
             case 'comment':
                 // Check to see if it needs to be updated
                 if ($value != $this->{$key}) {
                     $function = 'update_' . $key;
                     self::$function($value, $this->id);
                     $this->{$key} = $value;
                 }
                 break;
             case 'edit_tags':
                 Tag::update_tag_list($value, 'song', $this->id, true);
                 $this->tags = Tag::get_top_tags('song', $this->id);
                 break;
             default:
                 break;
         }
         // end whitelist
     }
     // end foreach
     $this->write_id3();
     return $this->id;
 }
开发者ID:nioc,项目名称:ampache,代码行数:55,代码来源:song.class.php

示例6: update

 /**
  * update
  * This takes a key'd array of data does any cleaning it needs to
  * do and then calls the helper functions as needed.
  */
 public function update($data)
 {
     foreach ($data as $key => $value) {
         debug_event('song.class.php', $key . '=' . $value, '5');
         switch ($key) {
             case 'artist_name':
                 // Need to create new artist according the name
                 $new_artist_id = Artist::check($value);
                 self::update_artist($new_artist_id, $this->id);
                 break;
             case 'album_name':
                 // Need to create new album according the name
                 $new_album_id = Album::check($value);
                 self::update_album($new_album_id, $this->id);
                 break;
             case 'title':
             case 'track':
             case 'artist':
             case 'album':
             case 'mbid':
                 // Check to see if it needs to be updated
                 if ($value != $this->{$key}) {
                     $function = 'update_' . $key;
                     self::$function($value, $this->id);
                     $this->{$key} = $value;
                 }
                 break;
             case 'edit_tags':
                 Tag::update_tag_list($value, 'song', $this->id);
                 break;
             default:
                 break;
         }
         // end whitelist
     }
     // end foreach
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:43,代码来源:song.class.php


注:本文中的Album::check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。