本文整理汇总了PHP中Rating::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::get方法的具体用法?PHP Rating::get怎么用?PHP Rating::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateRatingSuccess
public function testCreateRatingSuccess()
{
$_params = $this->_params;
$_params['user_id'] = $this->_user_id;
$response = $this->_getAuth($_params);
//get created login information
$rating_infor = Rating::get(array('user_id', 'wine_unique_id', 'rate', 'comment_count', 'like_count', 'is_my_wine', 'updated_at', 'created_at', 'id'))->last();
$this->assertNotNull($rating_infor);
$this->assertEquals(array("code" => ApiResponse::OK, "data" => $rating_infor->toArray()), json_decode($response->getContent(), true));
}
示例2: thumbs_rating
function thumbs_rating($rating_type, $type_id, $scale = 1)
{
// User can rate any entity . An entity can be User, content, comments etc
require_once 'api/Rating/Rating.php';
require_once 'api/PA_Rating/PA_Rating.php';
$return = array('overall' => null, 'new' => null);
$Rating = new Rating();
$Rating->set_rating_type($rating_type);
$Rating->set_type_id((int) $type_id);
$condition = " rating_type = '{$rating_type}' AND rating = -1 AND type_id = {$type_id} ";
$thumb_down = Rating::get($condition);
$condition = " rating_type = '{$rating_type}' AND rating = 1 AND type_id = {$type_id} ";
$thumb_up = Rating::get($condition);
$total = count($thumb_up) + count($thumb_down);
if ($total > 0) {
$recommended = count($thumb_up) / (count($thumb_up) + count($thumb_down)) * 100;
$not_recommended = count($thumb_down) / (count($thumb_up) + count($thumb_down)) * 100;
//Over all rating is showing count of thumb_up rating . Done for Radio-one pages.
$overall = 'Recommended:' . count($thumb_up) . '<br />';
$return['overall'] = $overall;
} else {
$overall = 'Recommended: 0<br />';
$return['overall'] = $overall;
}
$user_rating = 0;
if (!empty(PA::$login_uid)) {
$params = array('rating_type' => $rating_type, 'user_id' => PA::$login_uid, 'type_id' => $type_id);
$user_rating_details = Rating::get(NULL, $params);
$user_rating = @$user_rating_details[0]->rating;
if (!empty($user_rating)) {
// user give the rating to that content
if ($user_rating == 1) {
$return['new'] = 'Your Recommendation:<img src="' . PA::$theme_url . '/images/rec_yes1.png" alt="star" />';
} else {
$return['new'] = 'Your Recommendation:<img src="' . PA::$theme_url . '/images/rec_no1.png" alt="star" />';
}
return $return;
}
}
// image of thumbs up
$counter = 1;
$return['new'] = 'Make Recommendation:<b><img src="' . PA::$theme_url . '/images/rec_yes1.png" alt="star" id="star_' . $type_id . '_' . $counter . '" onclick="javascript:thumbs_rating.click(' . $counter . ', ' . $type_id . ', \'' . $rating_type . '\', ' . $scale . ',' . PA::$login_uid . ')" style="cursor:pointer" /></b>';
// image of thumbs down
$counter = -1;
$return['new'] .= '<b><img src="' . PA::$theme_url . '/images/rec_no1.png" alt="star" id="star_' . $type_id . '_' . $counter . '" onclick="javascript:thumbs_rating.click(' . $counter . ', ' . $type_id . ', \'' . $rating_type . '\', ' . $scale . ',' . PA::$login_uid . ')" style="cursor:pointer" /></b>';
return $return;
}
示例3: getRatingsFor
/**
* gets the rating objects for an object
* @param String $class DataObject ClassName
* @param Int $id DataObject ID
* @return DataList
**/
public function getRatingsFor($class, $id)
{
return Rating::get()->filter(array('ObjectClass' => $class, 'ObjectID' => $id));
}
示例4: getRating
public function getRating()
{
if ($this->_ratingId !== null && $this->_rating === null) {
$this->_rating = Rating::get($this->_ratingId);
}
return $this->_rating;
}