本文整理汇总了PHP中Rating::addVote方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::addVote方法的具体用法?PHP Rating::addVote怎么用?PHP Rating::addVote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::addVote方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
switch ($this->owner) {
case 'active':
echo '<h1>Active polls</h1>';
$list = PollItem::getActivePolls(SITE);
// d($list);
foreach ($list as $p) {
echo ahref('u/polls/show/' . $p->id, $p->text) . '<br/>';
}
break;
case 'vote':
// child = vote id
// child2 = option id
if (!$session->id || !is_numeric($this->child) || !is_numeric($this->child2)) {
throw new \Exception('XXX');
}
Rating::addVote(POLL, $this->child, $this->child2);
$page->disableDesign();
echo '1';
break;
case 'show':
//child = poll id
if (!$this->child) {
throw new \Exception('no id set');
}
$poll = PollItem::get($this->child);
if (!$poll) {
die('meh');
}
$header = XhtmlHeader::getInstance();
$header->embedCss('.poll_item{' . 'background-color:#eee;' . 'padding:5px;' . 'cursor:pointer;' . '}');
$header->includeJs('http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js');
示例2: mt_rand
// 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
die('1');
}
break;
default:
echo 'no such view: ' . $this->view;
}