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


PHP Vote::getResult方法代码示例

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


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

示例1: index

 public function index()
 {
     $id = intval($this->params['id']);
     try {
         $vote = new Vote($id);
     } catch (VoteNullException $e) {
         $this->error("未知的投票");
     }
     $u = User::getInstance();
     if ($this->RequestHandler->isPost()) {
         $this->requestLogin();
         if ($vote->isDeleted()) {
             $this->error("此投票已删除");
         }
         if ($vote->isEnd()) {
             $this->error("此投票已截止");
         }
         if ($vote->getResult($u->userid) !== false) {
             $this->error("你已经投过票了");
         }
         if (!isset($this->params['form']['vote'])) {
             $this->error("未知的参数");
         }
         if ($vote->type == "0") {
             $viid = intval($this->params['form']['vote']);
             if (!$vote->hasItem($viid)) {
                 $this->error("未知的选项,投票失败");
             }
             $vote->vote($u->userid, $viid);
         } else {
             if ($vote->type == "1") {
                 $items = array_values((array) $this->params['form']['vote']);
                 if (count($items) == 0) {
                     $this->error("请至少选择一个选项");
                 }
                 if (count($items) > $vote->limit && $vote->limit != 0) {
                     $this->error("投票个数超过限制,投票失败");
                 }
                 foreach ($items as $v) {
                     if (!$vote->hasItem(intval($v))) {
                         $this->error("未知的选项,投票失败");
                     }
                 }
                 $vote->vote($u->userid, $items);
             } else {
                 $this->error("错误的投票");
             }
         }
     }
     if ($vote->isDeleted() && !$u->isAdmin()) {
         $this->error("此投票已删除");
     }
     $wrapper = Wrapper::getInstance();
     $data['vote'] = $wrapper->vote($vote, array('items' => true));
     $this->set('data', $data);
 }
开发者ID:tilitala,项目名称:nForum,代码行数:56,代码来源:vote_controller.php

示例2: index

 public function index()
 {
     $this->cache(false);
     $this->css[] = "article.css";
     $this->js[] = "forum.share.js";
     $this->js[] = "forum.article.js";
     $this->_getNotice();
     $this->notice[] = array("url" => "", "text" => "阅读文章");
     App::import('Sanitize');
     App::import('vendor', array("inc/pagination", "inc/astro"));
     if (!isset($this->params['gid']) || $this->params['gid'] == '0') {
         $this->error(ECode::$ARTICLE_NONE);
     }
     try {
         $gid = $this->params['gid'];
         $this->_threads = Threads::getInstance($gid, $this->_board);
     } catch (ThreadsNullException $e) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     //article jump
     if (isset($this->params['url']['s'])) {
         $article = $this->_threads->getArticleById(intval($this->params['url']['s']));
         if (null !== $article) {
             $pos = $article->getPos();
             $page = ceil(($pos + 1) / Configure::read("pagination.article"));
             $this->redirect("/article/{$this->_board->NAME}/{$gid}?p={$page}#a{$pos}");
         }
         $this->redirect("/article/{$this->_board->NAME}/{$gid}");
     }
     //filter author
     $auF = $au = false;
     if (isset($this->params['url']['au'])) {
         $tmp = $this->_threads->getRecord(1, $this->_threads->getTotalNum());
         $auF = array();
         $au = trim($this->params['url']['au']);
         foreach ($tmp as $v) {
             if ($v->OWNER == $au) {
                 $auF[] = $v;
             }
         }
         $auF = new ArrayPageableAdapter($auF);
     }
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     $pagination = new Pagination(false !== $au ? $auF : $this->_threads, Configure::read("pagination.article"));
     $articles = $pagination->getPage($p);
     $u = User::getInstance();
     if ($bm = $u->isBM($this->_board) || $u->isAdmin()) {
         $this->js[] = "forum.manage.js";
     }
     $info = array();
     $curTime = strtotime(date("Y-m-d", time()));
     $isUbb = Configure::read("ubb.parse");
     $isSyn = Configure::read("ubb.syntax");
     $hasSyn = false;
     foreach ($articles as $v) {
         try {
             $own = User::getInstance($v->OWNER);
             $astro = Astro::getAstro($own->birthmonth, $own->birthday);
             if ($own->getCustom("userdefine0", 29) == 0) {
                 $hide = true;
                 $gender = -1;
             } else {
                 $hide = false;
                 $gender = $own->gender == "77" ? 0 : 1;
             }
             $user = array("id" => $own->userid, "name" => Sanitize::html($own->username), "gender" => $gender, "furl" => Sanitize::html($own->getFace()), "width" => $own->userface_width === 0 ? "" : $own->userface_width, "height" => $own->userface_height === 0 ? "" : $own->userface_height, "post" => $own->numposts, "astro" => $astro['name'], "online" => $own->isOnline(), "level" => $own->getLevel(), "time" => date($curTime > $own->lastlogin ? "Y-m-d" : "H:i:s", $own->lastlogin), "first" => date("Y-m-d", $own->firstlogin), "hide" => $hide);
         } catch (UserNullException $e) {
             $user = false;
         }
         $content = $v->getHtml(true);
         //hard to match all the format of ip
         //$pattern = '/<font class="f[0-9]+">※( |&nbsp;)来源:·.+?\[FROM:( |&nbsp;)[0-9a-zA-Z.:*]+\]<\/font><font class="f000">( +<br \/>)+ +<\/font>/';
         //preg_match($pattern, $content, $match);
         //$content = preg_replace($pattern, "", $content);
         if ($isUbb) {
             //remove ubb of nickname in first and title second line
             preg_match("'^(.*?<br \\/>.*?<br \\/>)'", $content, $res);
             $content = preg_replace("'(^.*?<br \\/>.*?<br \\/>)'", '', $content);
             $content = XUBB::remove($res[1]) . $content;
             $content = XUBB::parse($content);
             //check syntax
             if (!empty($isSyn) && preg_match("/<pre class=\"brush:/", $content)) {
                 $hasSyn = true;
             }
             //parse vote
             if ($v->OWNER === 'deliver' && in_array('vote', Configure::read('plugins.install'))) {
                 $vid = array();
                 if (preg_match("'\\[vote=(\\d+)\\]\\[/vote\\]'", $content, $vid)) {
                     $content = preg_replace("'\\[vote=\\d+\\]\\[/vote\\]'", '', $content);
                     App::import("vendor", array("inc/db", "vote.vote"));
                     $vid = $vid[1];
                     try {
                         $vote = new Vote($vid);
                         if (!$vote->isDeleted()) {
                             $this->css['plugin']['vote'][] = "vote.css";
                             $this->js['plugin']['vote'][] = "vote.js";
                             $myres = $vote->getResult($u->userid);
                             $voted = false;
                             if ($myres !== false) {
                                 $voted = true;
//.........这里部分代码省略.........
开发者ID:rainsun,项目名称:nForum,代码行数:101,代码来源:article_controller.php

示例3: ajax_vote

 public function ajax_vote()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     $this->requestLogin();
     if (!isset($this->params['vid'])) {
         $this->error("未知的投票");
     }
     $vid = intval($this->params['vid']);
     try {
         $vote = new Vote($vid);
     } catch (VoteNullException $e) {
         $this->error("未知的投票");
     }
     $u = User::getInstance();
     if ($vote->isDeleted() && !$u->isAdmin()) {
         $this->error("此投票已删除");
     }
     $myres = $vote->getResult($u->userid);
     if ($myres !== false) {
         $this->error("你已经投过票了");
     }
     if ($vote->isDeleted()) {
         $this->error("此投票已删除");
     }
     if ($vote->isEnd()) {
         $this->error("此投票已截止");
     }
     if ($vote->type == "0") {
         @($viid = $this->params['form']['v' . $vote->vid]);
         if (!$vote->hasItem($viid)) {
             $this->error("未知的选项,投票失败");
         }
         $vote->vote($u->userid, $viid);
     } else {
         if ($vote->type == "1") {
             $items = array_keys($this->params['form']);
             if (count($items) > $vote->limit && $vote->limit != 0) {
                 $this->error("投票个数超过限制,投票失败");
             }
             $items = preg_replace("/v{$vote->vid}_/", "", $items);
             foreach ($items as $v) {
                 if (!$vote->hasItem($v)) {
                     $this->error("未知的选项,投票失败");
                 }
             }
             $vote->vote($u->userid, $items);
         } else {
             $this->error("错误的投票");
         }
     }
 }
开发者ID:rainsun,项目名称:nForum,代码行数:53,代码来源:index_controller.php


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