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


PHP Rating::set_type_id方法代码示例

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


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

示例1: 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;
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:47,代码来源:uihelper.php

示例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'];
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:29,代码来源:rating.php

示例3: array

 function get_ratings($rating_type, $type_id)
 {
     $scale = 5;
     $return = array('overall' => null, 'new' => null);
     $this->rating_cnt = 0;
     $this->avg_rating = 0;
     $Rating = new Rating();
     $Rating->set_rating_type($rating_type);
     $Rating->set_type_id($type_id);
     $this->details = $details = $Rating->get_rating();
     if (!empty($details)) {
         foreach ($details as $entity) {
             $avg_rating = $entity->total_rating / $entity->total_max_rating * $scale;
             $stars_count = round($avg_rating);
             $this->rating_cnt = $entity->ratings;
             $this->avg_rating = round($avg_rating, 1);
             $faded_stars_count = $scale - $stars_count;
             for ($cnt = 0; $cnt < $stars_count; ++$cnt) {
                 $return['overall'] .= '<div class="star"></div>';
             }
             for ($cnt = 0; $cnt < $faded_stars_count; ++$cnt) {
                 $return['overall'] .= '<div class="starfaded"></div>';
             }
         }
     } else {
         for ($cnt = 0; $cnt < $scale; ++$cnt) {
             $return['overall'] .= '<div class="starfaded"></div>';
         }
     }
     if (!empty(PA::$login_user->user_id)) {
         $params = array('rating_type' => $rating_type, 'user_id' => PA::$login_user->user_id, 'type_id' => $type_id);
         $user_rating_details = PA_Rating::get($params);
     }
     $user_rating = @$user_rating_details[0]->rating ? $user_rating_details[0]->rating : 0;
     for ($counter = 1; $counter <= $user_rating; ++$counter) {
         $return['new'] .= '<div class="user_star';
         if ($counter == $user_rating) {
             $return['new'] .= ' current_rating';
         }
         $return['new'] .= ' star" id="star_' . $type_id . '_' . $counter . '" onmouseover="javascript:toggle_stars.mouseover(' . $counter . ', \'' . $type_id . '\')" onmouseout="javascript:toggle_stars.mouseout(' . $counter . ', \'' . $type_id . '\')" onclick="javascript:toggle_stars.click(' . $counter . ', \'' . $type_id . '\', \'' . $rating_type . '\', ' . $scale . ')" ></div>';
     }
     for (; $counter <= $scale; ++$counter) {
         $return['new'] .= '<div class="user_star starfaded" id="star_' . $type_id . '_' . $counter . '" onmouseover="javascript:toggle_stars.mouseover(' . $counter . ', \'' . $type_id . '\')" onmouseout="javascript:toggle_stars.mouseout(' . $counter . ', \'' . $type_id . '\')" onclick="javascript:toggle_stars.click(' . $counter . ', \'' . $type_id . '\', \'' . $rating_type . '\', ' . $scale . ')" ></div>';
     }
     return $return;
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:46,代码来源:RatingModule.php


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