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


PHP Poll类代码示例

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


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

示例1: render

 function render()
 {
     $pollObj = new Poll();
     // $current = $pollObj->load_current($_GET['gid']);
     $this->prev_polls = $pollObj->load_prev_polls(isset($_GET) && isset($_GET['gid']) ? $_GET['gid'] : null);
     if ($this->prev_polls) {
         foreach ($this->prev_polls as $poll) {
             $votes = $pollObj->load_vote($poll->poll_id);
             $poll->total_votes = count($votes);
             $options = array();
             foreach (unserialize($poll->options) as $option => $s) {
                 $options[$option]['title'] = $s;
                 $option_votes = $pollObj->load_vote_option($poll->poll_id, $s);
                 // echo "<pre>".print_r($option_votes,1)."</pre>";
                 $options[$option]['count'] = $option_votes[2]->counter;
                 $options[$option]['percent'] = $poll->total_votes != 0 ? round($option_votes[2]->counter / $poll->total_votes * 100, 1) : 0;
             }
             $poll->options = $options;
         }
         $this->inner_HTML = $this->generate_inner_html();
         $content = parent::render();
         return $content;
     } else {
         $this->do_skip = TRUE;
         return 'skip';
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:27,代码来源:PollArchiveModule.php

示例2: render

 function render()
 {
     global $login_uid;
     $obj = new Poll();
     $prev_poll = $obj->load_prevous_polls($_GET['gid']);
     $cnt = count($prev_poll);
     for ($i = 0; $i < $cnt; $i++) {
         $total_votes[$prev_poll[$i]->poll_id] = count($obj->load_vote($prev_poll[$i]->poll_id));
         $prev_options[$i] = unserialize($prev_poll[$i]->options);
         $num_option = count($prev_options[$i]);
         for ($j = 1; $j <= $num_option; $j++) {
             if ($prev_options[$i]['option' . $j] != '') {
                 $vote[] = $obj->load_vote_option($prev_poll[$i]->poll_id, $prev_options[$i]['option' . $j]);
             }
         }
     }
     $percentage = array();
     for ($i = 0; $i < count($vote); $i++) {
         $j = $vote[$i][0];
         if ($total_votes[$j] != 0) {
             $percentage[$j][] = round($vote[$i][2]->counter / $total_votes[$j] * 100, 1);
         }
     }
     $this->current_poll = $obj->load_current($_GET['gid']);
     $this->per_prev_poll = $percentage;
     $this->prev_poll = $prev_poll;
     $this->prev_options = $prev_options;
     $this->inner_HTML = $this->generate_inner_html();
     $content = parent::render();
     return $content;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:ViewPollModule.php

示例3: delete

 function delete($id)
 {
     if ($id) {
         $poll = new Poll($id);
         $poll->delete();
         set_notify('success', lang('delete_data_complete'));
     }
     redirect('polls/admin/polls');
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:9,代码来源:polls.php

示例4: mod_poll

function mod_poll($poll_id)
{
    require_once BASE_DIR . '/modules/poll/class.poll.php';
    require_once BASE_DIR . '/modules/poll/funcs/func.rewrite.php';
    $poll = new Poll();
    $tpl_dir = BASE_DIR . '/modules/poll/templates/';
    $lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt';
    $poll->pollShow($tpl_dir, $lang_file, stripslashes($poll_id));
}
开发者ID:laiello,项目名称:avecms,代码行数:9,代码来源:modul.php

示例5: pollView

 function pollView()
 {
     $vote = new Poll();
     $total = $vote->totalVote();
     $this->viewData();
     // var_dump($percent);die;
     F3::set("total", $total);
     F3::set('template', 'poll_detail');
     echo Template::serve("template/layout.htm");
 }
开发者ID:pshreez,项目名称:PHP,代码行数:10,代码来源:app.php

示例6: getAllPolls

 public function getAllPolls()
 {
     $rows = $this->db->get('Polls')->result();
     $list = array();
     foreach ($rows as $row) {
         $poll = new Poll();
         $poll->load($row);
         $list[] = $poll;
     }
     return json_encode($list);
 }
开发者ID:amckinney,项目名称:MyWebSite,代码行数:11,代码来源:poll.php

示例7: startPoll

 private function startPoll($sessionId, $topic)
 {
     $session = $this->getSession($sessionId);
     // Start new poll
     $poll = new Poll();
     $poll->setTopic($topic);
     $poll->setSession($session);
     // Update session
     $session->setLastAction(new DateTime());
     $session->setCurrentPoll($poll);
     // Save changes
     $this->saveAll([$session, $poll]);
     return $poll;
 }
开发者ID:Toxantron,项目名称:scrumonline,代码行数:14,代码来源:poll-controller.php

示例8: __construct

 /**
  * Creates a new PollEditor object.
  * 
  * @param	integer		$pollID
  * @param	integer		$messageID
  * @param	string		$messageType
  */
 public function __construct($pollID = 0, $messageID = 0, $messageType = 'post', $canStartPublicPoll = true)
 {
     $this->canStartPublicPoll = $pollID == 0 ? $canStartPublicPoll : false;
     $this->data['pollID'] = $pollID;
     $this->data['messageID'] = $messageID;
     $this->data['messageType'] = $messageType;
     $this->data['timeout'] = 0;
     $this->data['choiceCount'] = 1;
     $this->data['votesNotChangeable'] = 0;
     $this->data['sortByResult'] = 0;
     $this->data['isPublic'] = 0;
     if ($messageID != 0 || $pollID != 0) {
         // get poll
         $sql = "SELECT\t*\n\t\t\t\tFROM \twcf" . WCF_N . "_poll\n\t\t\t\tWHERE\t" . ($messageID != 0 ? "\n\t\t\t\t\tmessageID = " . $messageID . "\n\t\t\t\t\tAND messageType = '" . escapeString($messageType) . "'\t\t\t\t\t\n\t\t\t\t\tAND packageID = " . PACKAGE_ID : "pollID = " . $pollID . "\n\t\t\t\t\tAND packageID = " . PACKAGE_ID);
         $row = WCF::getDB()->getFirstRow($sql);
         if (isset($row['pollID'])) {
             parent::__construct(null, $row);
             // get poll options
             $sql = "SELECT\t\t*\n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_poll_option\n\t\t\t\t\tWHERE \t\tpollID = " . $this->pollID . "\n\t\t\t\t\tORDER BY \tshowOrder";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $pollOption = new PollOption($row, $this);
                 $this->pollOptionsArray[] = $pollOption->pollOption;
                 $this->addOption($pollOption);
             }
         }
     }
     $this->assign();
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:36,代码来源:PollEditor.class.php

示例9: loadModel

 public function loadModel($id)
 {
     if (($model = Poll::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:7,代码来源:PollBackendController.php

示例10: execute

	/**
	 * Show the special page
	 *
	 * @param $par Mixed: parameter passed to the page or null
	 */
	public function execute( $par ) {
		global $wgOut, $wgUser;

		$p = new Poll();

		$pollPage = $p->getRandomPollURL( $wgUser->getName() );
		if( $pollPage == 'error' ) {
			$wgOut->setPageTitle( wfMsg( 'poll-no-more-title' ) );
			$wgOut->addWikiMsg( 'poll-no-more-message' );
		} else {
			$pollTitle = Title::newFromText( $pollPage );
			$wgOut->redirect( $pollTitle->getFullURL() );
		}

		return $pollPage;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:21,代码来源:SpecialRandomPoll.php

示例11: run

 public function run()
 {
     $this->htmlOptions['style'] = 'width: ' . $this->width . 'px; height: ' . $this->height . 'px;';
     $this->htmlOptions['class'] = "poll";
     $poll = Poll::model()->findByPK($this->poll_id);
     $this->render('index', array('poll' => $poll));
 }
开发者ID:bahdall,项目名称:karbella_event,代码行数:7,代码来源:PollWidget.php

示例12: run

 /**
  * Запускаем отрисовку виджета
  *
  * @return void
  */
 public function run()
 {
     // Авторизован ли пользователь
     if (Yii::app()->user->isAuthenticated() === false) {
         return;
     }
     if (($user = Yii::app()->user->getProfile()) === null) {
         return;
     }
     $poll = Poll::model()->active()->with(array('questions' => array('scopes' => 'active'), 'questions.variants' => array('scopes' => 'active')))->findByPK((int) $this->model_id);
     if ($poll === null) {
         return;
     }
     // Подгружаем результаты пользователя
     $userId = $user->id;
     if (Yii::app()->user->isSuperUser() && Yii::app()->user->getState('adminUserId') !== null) {
         // Для администратора показываем результаты опроса пользователя в случае подмены
         $viewedUser = User::model()->findByPK((int) Yii::app()->user->getState('adminUserId'));
         if ($viewedUser) {
             $userId = $viewedUser->id;
         }
     }
     $result = Result::model()->with('answers')->find('t.user_id = :user_id AND t.poll_id = :poll_id', array(':user_id' => $userId, ':poll_id' => $poll->id));
     $this->render($this->view, array('model' => $poll, 'result' => $result));
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:30,代码来源:PollWidget.php

示例13: getInstance

 /**
  * Singleton Pattern
  *
  * Auto Create Object Instance.
  *
  */
 public static function getInstance()
 {
     if (null === self::$_objInstance) {
         self::$_objInstance = new Poll();
     }
     return self::$_objInstance;
 }
开发者ID:edupol,项目名称:examsystem,代码行数:13,代码来源:Poll.php

示例14: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     if ($this->boolean('ajax')) {
         GNUsocial::setApi(true);
     }
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown trying to respond to a poll while not logged in.
         throw new ClientException(_m('You must be logged in to respond to a poll.'), 403);
     }
     if ($this->isPost()) {
         $this->checkSessionToken();
     }
     $id = $this->trimmed('id');
     $this->poll = Poll::getKV('id', $id);
     if (empty($this->poll)) {
         // TRANS: Client exception thrown trying to respond to a non-existing poll.
         throw new ClientException(_m('Invalid or missing poll.'), 404);
     }
     $selection = intval($this->trimmed('pollselection'));
     if ($selection < 1 || $selection > count($this->poll->getOptions())) {
         // TRANS: Client exception thrown responding to a poll with an invalid answer.
         throw new ClientException(_m('Invalid poll selection.'));
     }
     $this->selection = $selection;
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:35,代码来源:respondpoll.php

示例15: show

 /**
  * Display the specified resource.
  * GET /frontend/publiccontact/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $contact = Contact::findOrFail($id);
         $articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get();
         $results = News::inCategories(Config::get('settings.results'))->distinct('permalink')->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->groupBy('permalink')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4);
         $poll = null;
         $poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first();
         if (isset($poll->id)) {
             $poll->pollOptions;
         }
         View::share('title', $contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице | Тачка спајања студената ФОН-а");
         $ogimage = Puskice::firstContactImage($contact);
         $meta = "\t<meta property='og:image' content='" . $ogimage . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __($contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице | Тачка спајања студената ФОН-а") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/ljudi/" . $contact->id) . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __($contact->description) . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __($contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __($contact->description) . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . $ogimage . "'>";
         $data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'contact' => $contact);
         $this->setLayout($data);
         $this->layout->center = View::make('frontend.content.contact', $data);
     } catch (Exception $e) {
         App::abort(404);
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:34,代码来源:PublicContactController.php


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