示例#1
0
	function __construct( array $argv, qp_PollView $view ) {
		parent::__construct( $argv, $view );
		# Split header / body
		# Includes surrounding newlines and header's curly braces into match in parentheses
		# because raw question bodies has to be trimmed from single surrounding newlines.
		# Otherwise, these newlines will cause false positive detection of multiline proposals.
		self::$splitPattern = '/((?:$.^|^)\s*{' . self::$headerPattern . '\}\s*$.^)/msu';
		# match header
		# Does not include surrounding newlines and header's curly braces into match in parentheses
		# because we need to parse only the inner part (common question and optional categories).
		self::$matchPattern = '/^\s*{(' . self::$headerPattern . ')\}\s*$/msu';
		# dependance attr
		if ( array_key_exists( 'dependance', $argv ) ) {
			$this->dependsOn = trim( $argv['dependance'] );
			if ( $this->dependsOn === 'dependance' ) {
				$this->dependsOn = '';
			}
		}
		# interpretation attr
		if ( array_key_exists( 'interpretation', $argv ) ) {
			$this->interpretation = trim( $argv['interpretation'] );
		}
		# randomize attr
		if ( array_key_exists( 'randomize', $argv ) ) {
			if ( $argv['randomize'] === 'randomize' ) {
				$this->randomQuestionCount = 1;
			} else {
				$this->randomQuestionCount = intval( trim( $argv['randomize'] ) );
				if ( $this->randomQuestionCount < 0 ) {
					$this->randomQuestionCount = 0;
				}
			}
		}
		# max_attempts attr
		$this->maxAttempts = qp_Setup::$max_submit_attempts;
		if ( array_key_exists( 'max_attempts', $argv ) ) {
			$this->maxAttempts = intval( trim( $argv['max_attempts'] ) );
			# do not allow to specify more submit attempts than is set by global level in qp_Setup
			if ( qp_Setup::$max_submit_attempts > 0 &&
					# also does not allow to set infinite number ( < 1 ) when global level is finite ( > 0 )
					( $this->maxAttempts < 1 ||
						$this->maxAttempts > qp_Setup::$max_submit_attempts ) ) {
				$this->maxAttempts = qp_Setup::$max_submit_attempts;
			}
		}
		# negative values are possible however meaningless (<=0 is infinite, >0 is finite)
		if ( $this->maxAttempts < 0 ) {
			$this->maxAttempts = 0;
		}
		# order_id is used to sort out polls on the Special:PollResults statistics page
		$this->mOrderId = self::$sOrderId;
		# Determine if this poll is being corrected or not, according to the pollId
		$this->mBeingCorrected = ( qp_Setup::$request->wasPosted() && qp_Setup::$request->getVal( 'pollId' ) == $this->mPollId );
	}
示例#2
0
 static function showPoll($input, $argv, $parser, $frame = false)
 {
     if (!self::$cache_control) {
         $parser->disableCache();
     }
     if (array_key_exists('address', $argv)) {
         $qpoll = new qp_PollStats($argv, new qp_PollStatsView($parser, $frame));
     } else {
         $qpoll = new qp_Poll($argv, new qp_PollView($parser, $frame));
     }
     return $qpoll->parsePoll($input);
 }