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


PHP Poll::getAnswers方法代码示例

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


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

示例1: Poll

$poll = new Poll($f_fk_language_id, $f_poll_nr);

if ($poll->exists()) {
    // edit existing poll
    $parent_poll_nr = $poll->getProperty('parent_poll_nr');
    $is_extended = $poll->isExtended();
    $title = $poll->getProperty('title');
    $question = $poll->getProperty('question');
    $date_begin = $poll->getProperty('date_begin');
    $date_end = $poll->getProperty('date_end');
    $nr_of_answers = $poll->getProperty('nr_of_answers');
    $fk_language_id = $poll->getProperty('fk_language_id');
    $votes_per_user = $poll->getProperty('votes_per_user');

    $poll_answers = $poll->getAnswers();

    foreach ($poll_answers as $poll_answer) {
        $answers[$poll_answer->getProperty('nr_answer')] = $poll_answer->getProperty('answer');
    }

} else {
    // language_id may preset from from assign_popup.php
    $fk_language_id = Input::Get('f_language_id', 'int');
}

if (empty($GLOBALS['_popup'])) {
    $title = $poll->exists() ? getGS('Edit Poll') : getGS('Add new Poll');
    echo camp_html_breadcrumbs(array(
        array(getGS('Plugins'), $Campsite['WEBSITE_URL'] . '/admin/plugins/manage.php'),
        array(getGS('Polls'), $Campsite['WEBSITE_URL'] . '/admin/poll/index.php'),
开发者ID:nistormihai,项目名称:Newscoop,代码行数:30,代码来源:edit.php

示例2: __construct

 /**
  * Reads the input parameters and vote the poll
  *
  * @param array $p_input
  */
 public function __construct(array $p_input)
 {
     $this->m_defined = true;
     $this->m_name = 'poll';
     
     if (!isset($p_input['f_poll_nr']) || empty($p_input['f_poll_nr'])) {
         $this->m_error = new PEAR_Error('The poll number is missing.', ACTION_POLL_ERR_NO_POLL_NUMBER);
         return false;
     }
     $this->m_properties['poll_nr'] = $p_input['f_poll_nr'];
     
     if (!isset($p_input['f_poll_language_id']) || empty($p_input['f_poll_language_id'])) {
         $this->m_error = new PEAR_Error('The poll language is missing.', ACTION_POLL_ERR_NO_LANGUAGE_ID);
         return false;
     }
     $this->m_properties['poll_language_id'] = $p_input['f_poll_language_id'];
     
     if ($p_input['f_poll_mode'] !== 'standard' && $p_input['f_poll_mode'] !== 'ajax') {
         $this->m_error = new PEAR_Error('The poll mode parameter is invalid.', ACTION_POLL_ERR_INVLID_MODE);
         return false;
     }
     $this->m_properties['poll_mode'] = $p_input['f_poll_mode'];
     
     $Poll = new Poll($this->m_properties['poll_language_id'], $this->m_properties['poll_nr']);
     
     if (!$Poll->exists()) {
         $this->m_error = new PEAR_Error('Poll does not exists.', ACTION_POLL_ERR_NOT_EXISTS);
         return false;
     }
     
     if (!$Poll->isVotable()) {
         $this->m_error = new PEAR_Error('Poll is not votable.', ACTION_POLL_ERR_NOT_VOTABLE);
         return false; 
          
     } else {
         switch($p_input['f_poll_mode']) {
             case 'ajax':            
                 $allowed_values = $_SESSION['camp_poll_maxvote'][$this->m_properties['poll_nr']][$this->m_properties['poll_language_id']];
                 
                 if (!is_array($allowed_values)) {
                     $this->m_error = new PEAR_Error('Invalid poll voting value.', ACTION_POLL_ERR_INVALID_VALUE);
                     return false;   
                 }
                 
                 foreach ($Poll->getAnswers() as $PollAnswer) {
                     $nr = $PollAnswer->getNumber();
                     
                     if (isset($p_input['f_pollanswer_'.$nr]) && !empty($p_input['f_pollanswer_'.$nr])) {
                         
                         // check if value is valid
                         if (!array_key_exists($p_input['f_pollanswer_'.$nr], $allowed_values[$nr])) {
                             $this->m_error = new PEAR_Error('Invalid poll voting value.', ACTION_POLL_ERR_INVALID_VALUE);
                             return false;   
                         }
                         $this->m_properties['pollanswer_nr'] = $nr;
                         $this->m_properties['value'] = $p_input['f_pollanswer_'.$nr];
                         break;
                     }
                 }
                 if (!$this->m_properties['value']) {
                     $this->m_error = new PEAR_Error('No answer value was given.', ACTION_POLL_ERR_NOANSWER_VALUE);
                     return false;
                 }
             break;
             
             case 'standard':
                 if (!isset($p_input['f_pollanswer_nr']) || empty($p_input['f_pollanswer_nr'])) {
                     $this->m_error = new PEAR_Error('Invalid poll voting value.', ACTION_POLL_ERR_INVALID_VALUE);
                     return false;
                 }
                 $this->m_properties['pollanswer_nr'] = $p_input['f_pollanswer_nr'];
                 $this->m_properties['value'] = 1;
             break;
         }
     }
     
     $this->m_poll = $Poll;
 }
开发者ID:nistormihai,项目名称:Newscoop,代码行数:83,代码来源:MetaActionPoll.php

示例3: CreateCopySet

 /**
  * Create a copy of an answer set.
  *
  * @param int $p_fk_poll_nr
  * @param int $p_parent_nr
  * @param array $p_answers
  * @return Article
  */
 function CreateCopySet($p_poll_nr, $p_language_id, $p_parent_nr)
 {
     $ParentPoll = new Poll($p_language_id, $p_parent_nr);
     $parentAnswers = $ParentPoll->getAnswers();
     foreach ($parentAnswers as $ParentPollAnswer) {
         $TargetPollAnswer = new PollAnswer($p_language_id, $p_poll_nr, $ParentPollAnswer->getNumber());
         if ($TargetPollAnswer->exists()) {
             $parentPollAnswerAttachments = $ParentPollAnswer->getPollAnswerAttachments();
             foreach ($parentPollAnswerAttachments as $ParentPollAnswerAttachment) {
                 $TargetPollAnswerAttachment = new PollAnswerAttachment($p_poll_nr, $ParentPollAnswerAttachment->getProperty('fk_pollanswer_nr'), $ParentPollAnswerAttachment->getProperty('fk_attachment_id'));
                 $TargetPollAnswerAttachment->create();
             }
         }
     }
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:23,代码来源:PollAnswerAttachment.php

示例4: putGS

            </TD>
        </TR>
        <tr>
            <TD ALIGN="RIGHT" ><?php  putGS("Title"); ?>:</TD>
            <TD>
            <INPUT TYPE="TEXT" NAME="f_title" SIZE="40" MAXLENGTH="255" class="input_text" alt="blank" emsg="<?php putGS('You must fill in the $1 field.', getGS('Title')); ?>" value="<?php echo htmlspecialchars($title); ?>">
            </TD>
        </TR>
        <tr>
            <TD ALIGN="RIGHT" ><?php  putGS("Question"); ?>:</TD>
            <TD>
            <TEXTAREA NAME="f_question" class="input_textarea" cols="28" alt="blank" emsg="<?php putGS('You must fill in the $1 field.', getGS('Question')); ?>"><?php echo htmlspecialchars($question); ?></TEXTAREA>
            </TD>
        </TR>
        <?php
        foreach ($poll->getAnswers() as $answer) {
            ?>
            <tr>
                <TD ALIGN="RIGHT" ><?php  putGS("Answer $1", $answer->getNumber()); ?>:</TD>
                <TD>
                <INPUT TYPE="TEXT" NAME="f_answer[<?php p($answer->getNumber()); ?>]" SIZE="40" MAXLENGTH="255" class="input_text" alt="blank" emsg="<?php putGS('You must fill in the $1 field.', getGS('Answer $1', $answer->getNumber())); ?>" value="<?php p(htmlspecialchars($answer->getProperty('answer'))); ?>">
                </TD>
            </TR>
            <?php
        }
        ?>
      </table>
    </td>
</tr>
<TR>
    <TD COLSPAN="2" align="center">
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:translate.php


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