示例#1
0
 public function build(array $topic_data, \phpbb\template\twig\twig &$template)
 {
     $this->user->add_lang('viewtopic');
     $forum_id = (int) $topic_data['forum_id'];
     $topic_id = (int) $topic_data['topic_id'];
     $cur_voted_id = $this->_get_users_votes($topic_id);
     $s_can_vote = $this->_user_can_vote($forum_id, $topic_data, $cur_voted_id);
     $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&t={$topic_id}");
     $poll_total = $poll_most = 0;
     $poll_info = $this->_get_poll_info($topic_data, $poll_total, $poll_most);
     $poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
     $this->_build_poll_options($cur_voted_id, $poll_info, $poll_total, $poll_most, $template);
     $template->assign_vars(array('POLL_QUESTION' => $topic_data['poll_title'], 'TOTAL_VOTES' => $poll_total, 'POLL_LEFT_CAP_IMG' => $this->user->img('poll_left'), 'POLL_RIGHT_CAP_IMG' => $this->user->img('poll_right'), 'L_MAX_VOTES' => $this->user->lang('MAX_OPTIONS_SELECT', (int) $topic_data['poll_max_options']), 'L_POLL_LENGTH' => $this->_get_poll_length_lang($topic_data['poll_length'], $poll_end), 'S_CAN_VOTE' => $s_can_vote, 'S_DISPLAY_RESULTS' => $this->_show_results($s_can_vote, $cur_voted_id), 'S_IS_MULTI_CHOICE' => $this->_poll_is_multiple_choice($topic_data['poll_max_options']), 'S_POLL_ACTION' => $viewtopic_url, 'S_FORM_TOKEN' => $this->sitemaker->get_form_key('posting'), 'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll'));
 }
 /**
  * {@inheritdoc}
  */
 public function display(array $bdata, $edit_mode = false)
 {
     $this->user->add_lang('viewtopic');
     $this->settings = $bdata['settings'];
     if (!($topic_data = $this->_get_topic_data())) {
         return array('title' => '', 'content' => '');
     }
     $forum_id = (int) $topic_data['forum_id'];
     $topic_id = (int) $topic_data['topic_id'];
     $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&t={$topic_id}");
     $cur_voted_id = $this->_get_users_votes($topic_id);
     $s_can_vote = $this->_user_can_vote($forum_id, $topic_data, $cur_voted_id);
     $poll_total = $poll_most = 0;
     $poll_info = $this->_get_poll_info($topic_data, $poll_total, $poll_most);
     $poll_info = $this->_parse_poll($topic_data, $poll_info);
     $poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
     $this->_build_poll_options($cur_voted_id, $poll_info, $poll_total, $poll_most);
     $this->ptemplate->assign_vars(array('POLL_QUESTION' => $topic_data['poll_title'], 'TOTAL_VOTES' => $poll_total, 'POLL_LEFT_CAP_IMG' => $this->user->img('poll_left'), 'POLL_RIGHT_CAP_IMG' => $this->user->img('poll_right'), 'L_MAX_VOTES' => $this->user->lang('MAX_OPTIONS_SELECT', (int) $topic_data['poll_max_options']), 'L_POLL_LENGTH' => $this->_get_poll_length_lang($topic_data['poll_length'], $poll_end), 'S_CAN_VOTE' => $s_can_vote, 'S_DISPLAY_RESULTS' => $this->_show_results($s_can_vote, $cur_voted_id), 'S_IS_MULTI_CHOICE' => $this->_poll_is_multiple_choice($topic_data['poll_max_options']), 'S_POLL_ACTION' => $viewtopic_url, 'S_FORM_TOKEN' => $this->sitemaker->get_form_key('posting'), 'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll'));
     return array('title' => 'POLL', 'content' => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/forum_poll.html', 'forum_poll_block'));
 }