本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}