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


PHP Vote::isEnd方法代码示例

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


在下文中一共展示了Vote::isEnd方法的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


//.........这里部分代码省略.........
     $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;
                                 $myres['time'] = date("Y-m-d H:i:s", $myres['time']);
                                 $this->set("myres", $myres);
                             }
                             $vinfo = array("vid" => $vote->vid, "title" => Sanitize::html($vote->subject), "desc" => nl2br(Sanitize::html($vote->desc)), "start" => date("Y-m-d H:i:s", $vote->start), "end" => date("Y-m-d", $vote->end), "num" => $vote->num, "type" => $vote->type, "limit" => $vote->limit, "aid" => $vote->aid, "isEnd" => $vote->isEnd(), "isDel" => $vote->isDeleted(), "voted" => $voted, "uid" => $vote->uid);
                             $item = $vote->items;
                             foreach ($item as $kk => $vv) {
                                 $item[$kk]["label"] = Sanitize::html($vv["label"]);
                                 $item[$kk]["percent"] = $vote->total === 0 ? 0 : round(intval($vv['num']) * 100 / $vote->total);
                                 $item[$kk]["on"] = $myres !== false && in_array($vv['viid'], $myres['items']);
                             }
                             $this->set("vinfo", $vinfo);
                             $this->set("vitems", $item);
                             $this->set("result_voted", $vote->result_voted);
                             $this->set("no_result", !($u->userid === $vote->uid || $u->isAdmin()) && $vote->result_voted && !$voted);
                         }
                     } catch (VoteNullException $e) {
                     }
                 }
             }
         }
         $info[] = array("id" => $v->ID, "owner" => $user, "op" => $v->OWNER == $u->userid || $bm ? 1 : 0, "pos" => $v->getPos(), "poster" => $v->OWNER, "content" => $content, "subject" => $v->isSubject(), 'g' => $v->isG(), 'm' => $v->isM(), 'l' => $v->isNoRe(), 'p' => $v->isPercent(), 's' => $v->isSharp(), 'x' => $v->isX());
     }
     $this->title = Sanitize::html($this->_threads->TITLE);
     $link = "{$this->base}/article/{$this->_board->NAME}/{$gid}?p=%page%";
     if (false !== $auF) {
         $link .= "&au={$au}";
     }
     $this->set("pageBar", $pagination->getPageBar($p, $link));
     $this->set("pagination", $pagination);
     $this->set("bName", $this->_board->NAME);
     $this->set("gid", $gid);
     $this->set("anony", $this->_board->isAnony());
     $this->set("tmpl", $this->_board->isTmplPost());
     $this->set("info", $info);
     $this->set("title", $this->title);
     $this->set('hasSyn', $hasSyn);
     $this->set("au", $au);
     $this->set("bm", $bm);
     //for the quick reply, raw encode the space
     $this->set("reid", $this->_threads->ID);
     if (!strncmp($this->_threads->TITLE, "Re: ", 4)) {
         $reTitle = $this->_threads->TITLE;
     } else {
         $reTitle = "Re: " . $this->_threads->TITLE;
     }
     //hack for post with ajax,need utf-8 encoding
     $reTitle = nforum_iconv($this->encoding, 'utf-8', $reTitle);
     $this->set("reTitle", rawurlencode($reTitle));
     //for default search day
     $this->set("searchDay", Configure::read("search.day"));
     $this->set("searchDay", Configure::read("search.day"));
     $this->jsr[] = "window.user_post=" . ($this->_board->hasPostPerm($u) && !$this->_board->isDeny($u) ? "true" : "false") . ";";
 }
开发者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::isEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。