本文整理汇总了PHP中Rating::getAverage方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::getAverage方法的具体用法?PHP Rating::getAverage怎么用?PHP Rating::getAverage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::getAverage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
//XXX: make it read-only after you clicked it once
namespace cd;
switch ($this->view) {
case 'handle':
// handle user rating
// owner = item type
// child = item id
$type = $this->owner;
$id = $this->child;
$header->includeJs('http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js');
$header->includeCss($page->getRelativeCoreDevUrl() . 'js/ext/gallery-ratings/assets/gallery-ratings-core.css');
$widget_id = 'rate_' . mt_rand();
$max_stars = 5;
$js = 'YUI({' . 'modules:{' . '"gallery-ratings":{' . 'fullpath:"' . relurl($page->getRelativeCoreDevUrl()) . 'js/ext/gallery-ratings/gallery-ratings-min.js",' . 'requires:["base","widget"]' . '}' . '},' . 'filter: "raw"' . '}).use("gallery-ratings", function(Y){' . 'var ratings = new Y.Ratings({' . 'max:' . $max_stars . ',' . 'srcNode: "#' . $widget_id . '"' . '});' . 'Y.log("rator created");' . 'Y.on("ratings:ratingChange",function(e){' . 'Y.log("ww2");' . 'YUI().use("io-base", function(Y){' . 'var uri = "u/rate/vote/' . $type . '/' . $id . '/" + e.newVal;' . 'Y.log(uri);' . 'Y.on("io:complete", function(id,o){' . 'var id = id;' . 'var data = o.responseText;' . 'if (data==1) return;' . 'alert("Voting error " + data);' . '});' . 'var request = Y.io(uri);' . '});' . '});' . '});';
$avg = Rating::getAverage($type, $id);
echo js_embed($js) . '<span id="' . $widget_id . '">' . round($avg, 1) . '</span>';
break;
case 'vote':
// owner = type
// child = item id
// child2 = option id
echo 'WOWOWsls';
if (!empty($_GET['rate_vote']) && !empty($_GET['opt'])) {
if (!$session->id || !is_numeric($_GET['opt'])) {
die('XXX');
}
$page->disableDesign();
Rating::addVote($type, $_GET['rate_vote'], $_GET['opt']);
ob_clean();
// XXX hack.. removes previous output
示例2:
?>
</textarea>
</div>
</form>
<? } ?>
<h3><?php
echo Text::getText("AllRatings");
?>
</h3>
<?php
echo Text::getText("Average");
?>
: <?php
echo Rating::getAverage($r);
?>
/5
<ul>
<?
$ratings = Rating::getForRecipe($r, 'value DESC');
foreach ($ratings as $rating) {
$user_rating = $rating->getUser();
?>
<li><a href="<?php
echo $user_rating->href();
?>
"><?php
echo $user_rating->getFullName();
?>