/** * Constructor * * @public */ function __construct( array $argv, qp_AbstractPollView $view ) { global $wgLanguageCode; $this->mResponse = qp_Setup::$request->response(); # Determine which messages will be used, according to the language. qp_Setup::onLoadAllMessages(); $view->setController( $this ); # *** get visual style poll attributes *** $perRow = intval( array_key_exists( 'perrow', $argv ) ? $argv['perrow'] : 1 ); if ( $perRow < 1 ) { $perRow = 1; } $view->setPerRow( $perRow ); $this->view = $view; # reset the unique index number of the question in the current poll (used to instantiate the questions) $this->mQuestionId = 0; // ( corresponds to 'question_id' DB field ) $this->username = qp_Setup::getCurrUserName(); # setup poll view showresults if ( array_key_exists( 'showresults', $argv ) && qp_Setup::$global_showresults != 0 ) { if ( $argv['showresults'] == 'showresults' ) { # default showresults for the empty value of xml attribute $argv['showresults'] = '1'; } $this->view->showResults = self::parseShowResults( $argv['showresults'] ); } # get default question attributes, if any foreach ( $this->defaultQuestionAttributes as $attr => &$val ) { if ( array_key_exists( $attr, $argv ) ) { $val = $argv[$attr]; } } # every poll on the page should have unique poll id, to minimize the risk of collisions # it is required to be set manually via id="value" parameter # ( used only in "declaration" mode ) $this->mPollId = array_key_exists( 'id', $argv ) ? trim( $argv['id'] ) : null; }
/** * Returns either scalar or associative array with structured interpretation * of the specified poll for the current user * * @return scalar/array when success; null when there is no structured interpretation */ function qp_getStructuredInterpretation($poll_address) { $pollStore = qp_PollStore::newFromAddr($poll_address); if (!$pollStore instanceof qp_PollStore || $pollStore->pid === null) { return null; } $username = qp_Setup::getCurrUserName(); $pollStore->loadQuestions(); $pollStore->setLastUser($username); if ($pollStore->interpResult->structured === '') { return null; } return unserialize($pollStore->interpResult->structured); }
function getQuestionData($qid) { $this->question_id = $qid; $this->error_message = 'invalid_question_id'; if (preg_match(qp_Setup::PREG_POSITIVE_INT4_MATCH, $this->question_id)) { $this->question_id = intval($this->question_id); $this->pollStore->loadQuestions(); $this->pollStore->setLastUser(qp_Setup::getCurrUserName()); $this->pollStore->loadUserVote(); $this->error_message = 'missing_question_id'; if (array_key_exists($this->question_id, $this->pollStore->Questions)) { return $this->pollStore->Questions[$this->question_id]; } } return false; }