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


PHP Poll::get方法代码示例

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


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

示例1: PollForm

 /**
  * If there is a poll available within range, take the last one and return that poll.
  * @return mixed:boolean|String False if none found. String of HTML if found.
  */
 public function PollForm()
 {
     $poll = Poll::get()->filter(array('Startdate:LessThan' => date('Y-m-d'), 'Enddate:GreaterThan' => date('Y-m-d')));
     if ($poll->count()) {
         return PollForm::create(Controller::curr(), 'PollForm', $poll->last());
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:firesphere-poll,代码行数:12,代码来源:PollContentControllerExtension.php

示例2: action_vote

 public static function action_vote($id = null)
 {
     if (!$id) {
         if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
             return Response::error(404);
         } else {
             $id = (int) Param::post('id');
             $answers = Param::post('answers');
             $poll = Poll::get($id);
             $poll->various_answers = '0' != $poll->various_answers;
             $cookiename = 'p_' . $poll->id . '_v';
             // Si no hay respuestas o hay más de una respuesta
             if (count($answers) === 0 || !$poll->various_answers && count($answers) > 1) {
                 Redirect::to(Url::get('vote', $id, 'vote_error=true'));
             }
             if (Vote::where('voter_ip', '=', CURRENT_USER_IP)->and_where('poll_id', '=', $id)->first() || Cookie::get($cookiename)) {
                 Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360);
                 Redirect::to(Url::get('view', $poll->slug, 'poll_already_voted=true'));
             }
             Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360);
             Vote::create(array('voter_ip' => CURRENT_USER_IP, 'poll_id' => $id, 'answer_id' => !$poll->various_answers ? $answers[0] : 0));
             foreach ($answers as $answer_id) {
                 Answer::find($answer_id)->set(array('nofilter:votes' => '`votes` + 1'));
             }
             Poll::find($id)->set(array('nofilter:total_votes' => '`total_votes` + 1'));
             Redirect::to(Url::get('view', $poll->slug, 'voted=true'));
         }
     } elseif (!is_numeric($id)) {
         return Response::error(404);
     }
     $id = intval($id, 10);
     if (!($poll = Poll::get($id))) {
         return Response::error(404);
     }
     $answers = Answer::where('poll_id', '=', $poll->id)->get();
     return View::make('vote')->add_var('poll', $poll)->add_var('answers', $answers);
 }
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:37,代码来源:home.php

示例3: action_edit

 public static function action_edit($id = null)
 {
     if (!IS_ADMIN) {
         Redirect::to(Url::get('admin@login', null, 'redirect-to=' . urlencode(Url::current())));
     }
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         if ($id === 'delete-answer') {
             if (($answer_id = Param::post('answer_id')) && is_numeric($answer_id)) {
                 $answer = Answer::get((int) $answer_id);
                 Answer::find((int) $answer_id)->delete();
                 $votes = Vote::where('answer_id', '=', $answer_id)->count();
                 if ($votes) {
                     Poll::find($answer->poll_id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
                 }
                 return Response::json(array('status' => 200, 'deleted' => true));
             } else {
                 return Response::json(array('status' => 0, 'deleted' => false));
             }
         } elseif ($id) {
             return Response::error(404);
         } else {
             $id = Param::post('id');
             if ($answer_id = Param::post('remove_answer')) {
                 Answer::find((int) $answer_id)->and_where('poll_id', '=', $id)->delete();
                 $votes = Vote::where('answer_id', '=', $answer_id)->count();
                 if ($votes) {
                     Poll::find($id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
                 }
                 Redirect::to(Url::get('admin@edit', $id, 'answer_deleted=true'));
             }
             if (Param::post('remove_poll')) {
                 Poll::find($id)->delete();
                 Redirect::to(Url::get('admin', null, 'poll_deleted=true'));
             }
             if (is_numeric($id) && ($poll = Poll::get((int) $id))) {
                 foreach ($_POST as $key => $value) {
                     if (isset($poll->{$key}) && (!empty($_POST[$key]) || $_POST[$key] === "0")) {
                         $poll->{$key} = is_numeric($_POST[$key]) ? intval($_POST[$key], 10) : $_POST[$key];
                     } elseif (false !== strpos($key, 'answer-')) {
                         $answer_id = explode('-', $key);
                         $answer_id = $answer_id[1];
                         if (is_numeric($answer_id)) {
                             Answer::find((int) $answer_id)->set(array('text' => $value));
                         }
                     } elseif ($key === 'new_answers') {
                         foreach ($value as $new_answer) {
                             if (!empty($new_answer)) {
                                 Answer::create(array('poll_id' => (int) $poll->id, 'text' => $new_answer));
                             }
                         }
                     }
                 }
                 Poll::save($poll);
                 Redirect::to(Url::get('admin', null, 'success=' . $_POST['id'] . '&updated=true'));
             } else {
                 return Response::error(500);
             }
         }
     }
     if (!$id || !is_numeric($id) || !($poll = Poll::get((int) $id))) {
         return Response::error(404);
     } else {
         $answers = Answer::where('poll_id', '=', $poll->id)->get();
         return View::make('admin.edit')->add_var('answers', $answers)->add_var('poll', $poll);
     }
 }
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:66,代码来源:admin.php

示例4: __construct

 public function __construct($pollId) {
     $this->poll = Poll::get($pollId);
     if (!$this->poll || !Team::isMember()) {
         HTMLResponse::exitWithRoute('/votaciones/');
     }
 }
开发者ID:xJakub,项目名称:LCE,代码行数:6,代码来源:ViewPoll.php


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