本文整理汇总了PHP中Rating::set_rating方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::set_rating方法的具体用法?PHP Rating::set_rating怎么用?PHP Rating::set_rating使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::set_rating方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
function render_for_ajax()
{
$this->anon = TRUE;
if (!empty(PA::$login_user)) {
$login_id = PA::$login_user->user_id;
$this->anon = FALSE;
}
switch ($this->params["op"]) {
/*
case "add_oneliner":
Oneliners::create(
@(int)$login_id,
$this->params['genre'],
(int)$this->params['rating'],
$this->params['body'],
TRUE); // change to FALSE for production once we have approval UI
$this->note = __("Your One-liner submission was received - thank you for participating!")
. " \n" . __("Your submisssion will appear if it is approved by our staff.");
break;
*/
case "add_rating":
if ($this->anon) {
$this->err = __("Please log in or register to add ratings!");
break;
}
$rating = new Rating();
$this->subject_type = $this->params['subject_type'];
$this->subject_id = $this->params['subject_id'];
$rating->set_rating_type($this->subject_type);
$rating->set_type_id($this->subject_id);
$rating->set_rating((int) $this->params['rating']);
$rating->set_max_rating(5);
$rating->set_user_id(@(int) $login_id);
try {
$rating->rate();
// for rivers of people
$activity = 'user_post_a_rating';
$extra = serialize(array('info' => PA::$login_user->login_name . ' posted a rating.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id));
Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
} catch (PAException $e) {
return $e->getMessage();
break;
}
$this->note = __("Rating was added - thank you for participating!");
// $this->add_oneliner = true; // flag it so we can ask for Onle-liner
break;
default:
// just ignore unknown ops
break;
}
return $this->render();
}
示例2: Rating
<?php
/** !
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* [filename] is a part of PeopleAggregator.
* [description including history]
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* @author [creator, or "Original Author"]
* @license http://bit.ly/aVWqRV PayAsYouGo License
* @copyright Copyright (c) 2010 Broadband Mechanics
* @package PeopleAggregator
*/
$login_required = TRUE;
//including necessary files
$use_theme = 'Beta';
//TODO : Remove this when new UI is completely implemented.
include_once "web/includes/page.php";
require 'api/Rating/Rating.php';
$Rating = new Rating();
if (!empty($_POST)) {
$Rating->set_rating_type(@$_POST['rating_type']);
$Rating->set_type_id(@(int) $_POST['type_id']);
$Rating->set_rating(@(int) $_POST['rating']);
$Rating->set_max_rating(@(int) $_POST['max_rating']);
$Rating->set_user_id(@(int) $login_uid);
$Rating->rate();
$rating = rating(@$_POST['rating_type'], @(int) $_POST['type_id']);
print $rating['overall'];
}
示例3: setrating
/**
* setRating
* Sets the rating for a music file.
* Takes the file id and rating in parameters.
*/
public static function setrating($input)
{
self::check_version($input, "1.6.0");
$id = self::check_parameter($input, 'id');
$rating = $input['rating'];
$robj = null;
if (Subsonic_XML_Data::isArtist($id)) {
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "artist");
} else {
if (Subsonic_XML_Data::isAlbum($id)) {
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "album");
} else {
if (Subsonic_XML_Data::isSong($id)) {
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "song");
}
}
}
if ($robj != null) {
$robj->set_rating($rating);
$r = Subsonic_XML_Data::createSuccessResponse();
} else {
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND, "Media not found.");
}
self::apiOutput($input, $r);
}
示例4: insert_local_song
/**
* insert_local_song
*
* Insert a song that isn't already in the database.
*/
private function insert_local_song($file, $options = array())
{
$vainfo = new vainfo($file, $this->get_gather_types('music'), '', '', '', $this->sort_pattern, $this->rename_pattern);
$vainfo->get_info();
$key = vainfo::get_tag_type($vainfo->tags);
$results = vainfo::clean_tag_info($vainfo->tags, $key, $file);
$results['catalog'] = $this->id;
if (isset($options['user_upload'])) {
$results['user_upload'] = $options['user_upload'];
}
if (isset($options['license'])) {
$results['license'] = $options['license'];
}
if (isset($options['artist_id'])) {
$results['artist_id'] = $options['artist_id'];
$results['albumartist_id'] = $options['artist_id'];
}
if (isset($options['album_id'])) {
$results['album_id'] = $options['album_id'];
}
$id = Song::insert($results);
// If song rating tag exists and is well formed (array user=>rating), add it
if ($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', "Setting rating for Song {$id} to {$rating} for user {$user}", 5);
$o_rating = new Rating($id, 'song');
$o_rating->set_rating($rating, $user);
}
}
// Extended metadata loading is not deferred, retrieve it now
if ($id && !AmpConfig::get('deferred_ext_metadata')) {
$song = new Song($id);
Recommendation::get_artist_info($song->artist);
}
if (Song::isCustomMetadataEnabled()) {
if (!$song) {
$song = new Song($id);
}
$results = array_diff_key($results, array_flip($song->getDisabledMetadataFields()));
self::add_metadata($song, $results);
}
$this->added_songs_to_gather[] = $id;
$this->_filecache[strtolower($file)] = $id;
return $id;
}
示例5: Rating
}
break;
case 'clear_all':
$GLOBALS['user']->playlist->clear();
break;
}
}
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
break;
/* Setting ratings */
/* Setting ratings */
case 'set_rating':
if (User::is_registered()) {
ob_start();
$rating = new Rating($_GET['object_id'], $_GET['rating_type']);
$rating->set_rating($_GET['rating']);
Rating::show($_GET['object_id'], $_GET['rating_type']);
$key = "rating_" . $_GET['object_id'] . "_" . $_GET['rating_type'];
$results[$key] = ob_get_contents();
ob_end_clean();
} else {
$results['rfc3514'] = '0x1';
}
break;
/* Setting userflags */
/* Setting userflags */
case 'set_userflag':
if (User::is_registered()) {
ob_start();
$userflag = new Userflag($_GET['object_id'], $_GET['userflag_type']);
$userflag->set_flag($_GET['userflag']);
示例6: rate
public static function rate($params)
{
$id = $_REQUEST['key'];
$identifier = $_REQUEST['identifier'];
$rating = $_REQUEST['rating'];
if ($identifier == 'com.plexapp.plugins.library') {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), Plex_XML_Data::getLibraryItemType($id));
$robj->set_rating($rating / 2);
}
}
示例7: update_song_from_tags
//.........这里部分代码省略.........
$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;
}
示例8: rate
public static function rate($params)
{
$id = $_REQUEST['key'];
$identifier = $_REQUEST['identifier'];
$rating = $_REQUEST['rating'];
if ($identifier == 'com.plexapp.plugins.library') {
$robj = null;
if (Plex_XML_Data::isArtist($id)) {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "artist");
} else {
if (Plex_XML_Data::isAlbum($id)) {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "album");
} else {
if (Plex_XML_Data::isTrack($id)) {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "song");
}
}
}
if ($robj != null) {
$robj->set_rating($rating / 2);
}
}
}
示例9: rate
/**
* rate
* This rate a library item
* @param array $input
*/
public static function rate($input)
{
ob_end_clean();
$type = $input['type'];
$id = $input['id'];
$rating = $input['rating'];
if (!Core::is_library_item($type) || !$id) {
echo XML_Data::error('401', T_('Wrong library item type.'));
} else {
$item = new $type($id);
if (!$item->id) {
echo XML_Data::error('404', T_('Library item not found.'));
} else {
$r = new Rating($id, $type);
$r->set_rating($rating);
echo XML_Data::single_string('success');
}
}
}