本文整理汇总了PHP中Rating::get_user_rating方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::get_user_rating方法的具体用法?PHP Rating::get_user_rating怎么用?PHP Rating::get_user_rating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::get_user_rating方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSong
public static function createSong($xml, $song, $elementName = 'song')
{
$xsong = $xml->addChild(htmlspecialchars($elementName));
$xsong->addAttribute('id', self::getSongId($song->id));
$xsong->addAttribute('parent', self::getAlbumId($song->album));
//$xsong->addAttribute('created', );
$xsong->addAttribute('title', $song->title);
$xsong->addAttribute('isDir', 'false');
$xsong->addAttribute('isVideo', 'false');
$xsong->addAttribute('type', 'music');
$album = new Album($song->album);
$xsong->addAttribute('albumId', self::getAlbumId($album->id));
$xsong->addAttribute('album', $album->name);
$artist = new Artist($song->artist);
$xsong->addAttribute('artistId', self::getArtistId($song->artist));
$xsong->addAttribute('artist', $artist->name);
$xsong->addAttribute('coverArt', self::getAlbumId($album->id));
$xsong->addAttribute('duration', $song->time);
$xsong->addAttribute('bitRate', intval($song->bitrate / 1000));
$rating = new Rating($song->id, "song");
$user_rating = $rating->get_user_rating();
if ($user_rating > 0) {
$xsong->addAttribute('userRating', ceil($user_rating));
}
$avg_rating = $rating->get_average_rating();
if ($avg_rating > 0) {
$xsong->addAttribute('averageRating', ceil($avg_rating));
}
if ($song->track > 0) {
$xsong->addAttribute('track', $song->track);
}
if ($song->year > 0) {
$xsong->addAttribute('year', $song->year);
}
$tags = Tag::get_object_tags('song', $song->id);
if (count($tags) > 0) {
$xsong->addAttribute('genre', $tags[0]['name']);
}
$xsong->addAttribute('size', $song->size);
if ($album->disk > 0) {
$xsong->addAttribute('discNumber', $album->disk);
}
$xsong->addAttribute('suffix', $song->type);
$xsong->addAttribute('contentType', $song->mime);
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
$path = $artist->name . '/' . $album->name . '/' . basename($song->file);
$xsong->addAttribute('path', $path);
// Set transcoding information if required
$transcode_cfg = AmpConfig::get('transcode');
$valid_types = Song::get_stream_types_for_type($song->type, 'api');
if ($transcode_cfg == 'always' || $transcode_cfg != 'never' && !in_array('native', $valid_types)) {
$transcode_settings = $song->get_transcode_settings(null, 'api');
if ($transcode_settings) {
$transcode_type = $transcode_settings['format'];
$xsong->addAttribute('transcodedSuffix', $transcode_type);
$xsong->addAttribute('transcodedContentType', Song::type_to_mime($transcode_type));
}
}
return $xsong;
}
示例2: democratic
/**
* democratic
*
* This handles creating an xml document for democratic items, this can be a little complicated
* due to the votes and all of that
*
* @param array $object_ids Object IDs
* @return string return xml
*/
public static function democratic($object_ids = array())
{
if (!is_array($object_ids)) {
$object_ids = array();
}
$democratic = Democratic::get_current_playlist();
$string = '';
foreach ($object_ids as $row_id => $data) {
$song = new $data['object_type']($data['object_id']);
$song->format();
//FIXME: This is duplicate code and so wrong, functions need to be improved
$tag = new Tag($song->tags['0']);
$song->genre = $tag->id;
$song->f_genre = $tag->name;
$tag_string = self::tags_string($song->tags);
$rating = new Rating($song->id, 'song');
$art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
$string .= "<song id=\"" . $song->id . "\">\n" . "\t<title><![CDATA[" . $song->title . "]]></title>\n" . "\t<artist id=\"" . $song->artist . "\"><![CDATA[" . $song->f_artist_full . "]]></artist>\n" . "\t<album id=\"" . $song->album . "\"><![CDATA[" . $song->f_album_full . "]]></album>\n" . "\t<genre id=\"" . $song->genre . "\"><![CDATA[" . $song->f_genre . "]]></genre>\n" . $tag_string . "\t<track>" . $song->track . "</track>\n" . "\t<time>" . $song->time . "</time>\n" . "\t<mime>" . $song->mime . "</mime>\n" . "\t<url><![CDATA[" . Song::play_url($song->id, '', 'api') . "]]></url>\n" . "\t<size>" . $song->size . "</size>\n" . "\t<art><![CDATA[" . $art_url . "]]></art>\n" . "\t<preciserating>" . $rating->get_user_rating() . "</preciserating>\n" . "\t<rating>" . $rating->get_user_rating() . "</rating>\n" . "\t<averagerating>" . $rating->get_average_rating() . "</averagerating>\n" . "\t<vote>" . $democratic->get_vote($row_id) . "</vote>\n" . "</song>\n";
}
// end foreach
$final = self::_header() . $string . self::_footer();
return $final;
}