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


PHP Catalog::normalize_year方法代码示例

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


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

示例1: update

 /**
  * update
  * This takes a key'd array of data as input and updates a movie entry
  */
 public function update(array $data)
 {
     parent::update($data);
     if (isset($data['original_name'])) {
         $trimmed = Catalog::trim_prefix(trim($data['original_name']));
         $name = $trimmed['string'];
         $prefix = $trimmed['prefix'];
     } else {
         $name = $this->original_name;
         $prefix = $this->prefix;
     }
     $summary = isset($data['summary']) ? $data['summary'] : $this->summary;
     $year = Catalog::normalize_year(isset($data['year']) ? $data['year'] : $this->year);
     $sql = "UPDATE `movie` SET `original_name` = ?, `prefix` = ?, `summary` = ?, `year` = ? WHERE `id` = ?";
     Dba::write($sql, array($name, $prefix, $summary, $year, $this->id));
     $this->original_name = $name;
     $this->prefix = $prefix;
     $this->summary = $summary;
     $this->year = $year;
     return $this->id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:25,代码来源:movie.class.php

示例2: check

 /**
  * check
  *
  * Searches for an album; if none is found, insert a new one.
  * @param string $name
  * @param int $year
  * @param int $disk
  * @param string $mbid
  * @param string $mbid_group
  * @param string $album_artist
  * @param string $release_type
  * @param boolean $readonly
  * @return int|null
  */
 public static function check($name, $year = 0, $disk = 0, $mbid = null, $mbid_group = null, $album_artist = null, $release_type = null, $readonly = false)
 {
     $trimmed = Catalog::trim_prefix(trim($name));
     $name = $trimmed['string'];
     $prefix = $trimmed['prefix'];
     $album_artist = intval($album_artist);
     $album_artist = $album_artist <= 0 ? null : $album_artist;
     $mbid = empty($mbid) ? null : $mbid;
     $mbid_group = empty($mbid_group) ? null : $mbid_group;
     $release_type = empty($release_type) ? null : $release_type;
     // Not even sure if these can be negative, but better safe than llama.
     $year = Catalog::normalize_year($year);
     $disk = abs(intval($disk));
     if (!$name) {
         $name = T_('Unknown (Orphaned)');
         $year = 0;
         $disk = 0;
         $album_artist = null;
     }
     if (isset(self::$_mapcache[$name][$disk][$mbid][$album_artist])) {
         return self::$_mapcache[$name][$disk][$mbid][$album_artist];
     }
     $sql = 'SELECT `album`.`id` FROM `album` WHERE `album`.`name` = ? AND `album`.`disk` = ? ';
     $params = array($name, $disk);
     if ($mbid) {
         $sql .= 'AND `album`.`mbid` = ? ';
         $params[] = $mbid;
     } else {
         $sql .= 'AND `album`.`mbid` IS NULL ';
     }
     if ($prefix) {
         $sql .= 'AND `album`.`prefix` = ? ';
         $params[] = $prefix;
     }
     if ($album_artist) {
         $sql .= 'AND `album`.`album_artist` = ? ';
         $params[] = $album_artist;
     }
     $db_results = Dba::read($sql, $params);
     if ($row = Dba::fetch_assoc($db_results)) {
         $id = $row['id'];
         self::$_mapcache[$name][$disk][$mbid][$album_artist] = $id;
         return $id;
     }
     if ($readonly) {
         return null;
     }
     $sql = 'INSERT INTO `album` (`name`, `prefix`, `year`, `disk`, `mbid`, `mbid_group`, `release_type`, `album_artist`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)';
     $db_results = Dba::write($sql, array($name, $prefix, $year, $disk, $mbid, $mbid_group, $release_type, $album_artist));
     if (!$db_results) {
         return null;
     }
     $id = Dba::insert_id();
     // Remove from wanted album list if any request on it
     if (!empty($mbid) && AmpConfig::get('wanted')) {
         try {
             Wanted::delete_wanted_release($mbid);
         } catch (Exception $e) {
             debug_event('wanted', 'Cannot process wanted releases auto-removal check: ' . $e->getMessage(), '1');
         }
     }
     self::$_mapcache[$name][$disk][$mbid][$album_artist] = $id;
     return $id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:78,代码来源:album.class.php

示例3: update_artist_info

 /**
  * Update artist information.
  * @param string $summary
  * @param string $placeformed
  * @param int $yearformed
  * @return boolean
  */
 public function update_artist_info($summary, $placeformed, $yearformed, $manual = false)
 {
     $sql = "UPDATE `artist` SET `summary` = ?, `placeformed` = ?, `yearformed` = ?, `last_update` = ?, `manual_update` = ? WHERE `id` = ?";
     $sqlret = Dba::write($sql, array($summary, $placeformed, Catalog::normalize_year($yearformed), time(), $manual ? 1 : 0, $this->id));
     $this->summary = $summary;
     $this->placeformed = $placeformed;
     $this->yearformed = $yearformed;
     return $sqlret;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:16,代码来源:artist.class.php

示例4: insert

 /**
  * insert
  *
  * This inserts the song described by the passed array
  * @param array $results
  * @return int|boolean
  */
 public static function insert(array $results)
 {
     $catalog = $results['catalog'];
     $file = $results['file'];
     $title = trim($results['title']) ?: $file;
     $artist = $results['artist'];
     $album = $results['album'];
     $albumartist = $results['albumartist'] ?: $results['band'];
     $albumartist = $albumartist ?: null;
     $bitrate = $results['bitrate'] ?: 0;
     $rate = $results['rate'] ?: 0;
     $mode = $results['mode'];
     $size = $results['size'] ?: 0;
     $time = $results['time'] ?: 0;
     $track = $results['track'];
     $track_mbid = $results['mb_trackid'] ?: $results['mbid'];
     $track_mbid = $track_mbid ?: null;
     $album_mbid = $results['mb_albumid'];
     $album_mbid_group = $results['mb_albumid_group'];
     $artist_mbid = $results['mb_artistid'];
     $albumartist_mbid = $results['mb_albumartistid'];
     $disk = $results['disk'] ?: 0;
     $year = Catalog::normalize_year($results['year'] ?: 0);
     $comment = $results['comment'];
     $tags = $results['genre'];
     // multiple genre support makes this an array
     $lyrics = $results['lyrics'];
     $user_upload = isset($results['user_upload']) ? $results['user_upload'] : null;
     $license = isset($results['license']) ? $results['license'] : null;
     $composer = isset($results['composer']) ? $results['composer'] : null;
     $label = isset($results['publisher']) ? $results['publisher'] : null;
     $catalog_number = isset($results['catalog_number']) ? $results['catalog_number'] : null;
     $language = isset($results['language']) ? $results['language'] : null;
     $channels = $results['channels'] ?: 0;
     $release_type = isset($results['release_type']) ? $results['release_type'] : null;
     $replaygain_track_gain = isset($results['replaygain_track_gain']) ? $results['replaygain_track_gain'] : null;
     $replaygain_track_peak = isset($results['replaygain_track_peak']) ? $results['replaygain_track_peak'] : null;
     $replaygain_album_gain = isset($results['replaygain_album_gain']) ? $results['replaygain_album_gain'] : null;
     $replaygain_album_peak = isset($results['replaygain_album_peak']) ? $results['replaygain_album_peak'] : null;
     $albumartist_id = null;
     if (!isset($results['albumartist_id'])) {
         if ($albumartist) {
             $albumartist_id = Artist::check($albumartist, $albumartist_mbid);
         }
     } else {
         $albumartist_id = intval($results['albumartist_id']);
     }
     $artist_id = null;
     if (!isset($results['artist_id'])) {
         $artist_id = Artist::check($artist, $artist_mbid);
     } else {
         $artist_id = intval($results['artist_id']);
     }
     $album_id = null;
     if (!isset($results['album_id'])) {
         $album_id = Album::check($album, $year, $disk, $album_mbid, $album_mbid_group, $albumartist_id, $release_type);
     } else {
         $album_id = intval($results['album_id']);
     }
     $sql = 'INSERT INTO `song` (`file`, `catalog`, `album`, `artist`, ' . '`title`, `bitrate`, `rate`, `mode`, `size`, `time`, `track`, ' . '`addition_time`, `year`, `mbid`, `user_upload`, `license`, ' . '`composer`, `channels`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $db_results = Dba::write($sql, array($file, $catalog, $album_id, $artist_id, $title, $bitrate, $rate, $mode, $size, $time, $track, time(), $year, $track_mbid, $user_upload, $license, $composer, $channels));
     if (!$db_results) {
         debug_event('song', 'Unable to insert ' . $file, 2);
         return false;
     }
     $song_id = Dba::insert_id();
     if ($user_upload) {
         Useractivity::post_activity($this->id, 'upload', 'song', $song_id);
     }
     if (is_array($tags)) {
         // Allow scripts to populate new tags when injecting user uploads
         if (!defined('NO_SESSION')) {
             if ($user_upload && !Access::check('interface', 50, $user_upload)) {
                 $tags = Tag::clean_to_existing($tags);
             }
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 Tag::add('song', $song_id, $tag, false);
                 Tag::add('album', $album_id, $tag, false);
                 Tag::add('artist', $artist_id, $tag, false);
             }
         }
     }
     $sql = 'INSERT INTO `song_data` (`song_id`, `comment`, `lyrics`, `label`, `language`, `catalog_number`, `replaygain_track_gain`, `replaygain_track_peak`, `replaygain_album_gain`, `replaygain_album_peak`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
     Dba::write($sql, array($song_id, $comment, $lyrics, $label, $language, $catalog_number, $replaygain_track_gain, $replaygain_track_peak, $replaygain_album_gain, $replaygain_album_peak));
     return $song_id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:96,代码来源:song.class.php


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