function addShowResults2( $inp ) {
		self::$cellTemplateParam['percents'] = ' ';
		if ( ( $percents = $this->ctrl->getPercents( $this->proposalId, $this->catId ) ) !== false ) {
			# there is a stat in cell
			self::$cellTemplateParam['percents'] = $percents . '%';
			self::$cellTemplateParam['bar1style'] = 'width:' . $percents . 'px;' . self::$cellTemplate[ 'bar1showres' ];
			self::$cellTemplateParam['bar2style'] = 'width:' . ( 100 - $percents ) . 'px;' . self::$cellTemplate[ 'bar2showres' ];
			return qp_Renderer::renderTagArray( self::$cellTemplate['bar'] );
		} else {
			return '';
		}
	}
Ejemplo n.º 2
0
 /**
  * Show interpetation script source with line numbering (for debugging convenience)
  *
  * @param  $input				Text between <qpinterpret> and </qpinterper> tags, subset of PHP syntax.
  * @param  $argv				An array containing any arguments passed to the extension
  * @param  &$parser			The wikitext parser.
  * @param  &$frame			PPFrame object passed in MW 1.16+
  * @return 						script source with line numbering
  */
 static function showScript($input, $argv, $parser, $frame = false)
 {
     $lines_count = count(preg_split('`(\\r\\n|\\n|\\r)`', $input, -1));
     $line_numbers = '';
     if (!isset($argv['lang'])) {
         return '<strong class="error">' . wfMsg('qp_error_eval_missed_lang_attr') . '</strong>';
     }
     $lang = $argv['lang'];
     if (!array_key_exists($lang, self::$scriptLinesCount)) {
         self::$scriptLinesCount[$lang] = 1;
     }
     $slc =& self::$scriptLinesCount[$lang];
     for ($i = $slc; $i < $slc + $lines_count; $i++) {
         $line_numbers .= "{$i}\n";
     }
     $slc = $i;
     $out = array('__tag' => 'div', 'class' => 'qpoll', 0 => array());
     if (is_string($lintResult = qp_Interpret::lint($lang, $input))) {
         $out[0][] = array('__tag' => 'div', 'class' => 'interp_error', qp_Setup::specialchars($lintResult));
     }
     $out[0][] = array('__tag' => 'div', 'class' => 'line_numbers', $line_numbers);
     $out[0][] = array('__tag' => 'div', 'class' => 'script_view', qp_Setup::specialchars($input) . "\n");
     $markercount = count(self::$markerList);
     $marker = "!qpoll-script-view{$markercount}-qpoll!";
     self::$markerList[$markercount] = qp_Renderer::renderTagArray($out);
     return $marker;
 }
	/**
	 * Encloses the output of $this->renderQuestionViews() into the output tag wrappers
	 * @return  rendered "final" html
	 */
	function renderPoll() {
		# Generates the output.
		$qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll', 0 => $this->renderQuestionViews() );
		return qp_Renderer::renderTagArray( $qpoll_div );
	}
Ejemplo n.º 4
0
	function getPageHeader() {
		global $wgLang, $wgContLang;
		$link = "";
		if ( $this->pid !== null ) {
			$pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $this->pid ) );
			if ( $pollStore->pid !== null ) {
				$pollStore->loadQuestions();
				$poll_title = Title::makeTitle( intval( $this->ns ), $this->title, qp_AbstractPoll::s_getPollTitleFragment( $this->poll_id, '' ) );
				$pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
				$pollname = qp_Setup::specialchars( $this->poll_id );
				$head = array();
				$head[] = $this->showPollActionsList(
					$pollStore->pid,
					$pollStore->mPollId,
					$poll_title
				);
				$head[] = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname );
				$ques_found = false;
				foreach ( $pollStore->Questions as $qdata ) {
					if ( $qdata->question_id == $this->question_id ) {
						$ques_found = true;
						break;
					}
				}
				if ( $ques_found ) {
					$qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $qdata->CommonQuestion ) );
					if ( array_key_exists( $this->cat_id, $qdata->Categories ) ) {
						$categ = &$qdata->Categories[ $this->cat_id ];
						$proptext = $qdata->ProposalText[ $this->proposal_id ];
						$cat_name = $categ['name'];
						if ( array_key_exists( 'spanId', $categ ) ) {
							$cat_name =  wfMsg( 'qp_full_category_name', $cat_name, $qdata->CategorySpans[ $categ['spanId'] ]['name'] );
						}
						$head[] = wfMsg( 'qp_header_line_qucl',
							$this->question_id,
							qp_Setup::entities( $qdata->CommonQuestion ),
							qp_Setup::entities( $proptext ),
							qp_Setup::entities( $cat_name ) );
						qp_Renderer::applyAttrsToRow( $head, array( '__tag' => 'li', '__end' => "\n" ) );
						$head = array( '__tag' => 'ul', 'class' => 'head', $head );
						$link = PollResults::getPollsLink() .
							PollResults::getUsersLink() .
							qp_Renderer::renderTagArray( $head );
					}
				}
			}
		}
		return $link;
	}
	/**
	 * todo: unfortunately, rendering of the question also conditionally modifies
	 * state of poll controller
	 * @modifies parent controller
	 * @return  string  html representation of the question
	 */
	function renderQuestion() {
		$output_table = array( '__tag' => 'table', '__end' => "\n", 'class' => 'object' );
		if ( $this->propWidth !== '' ) {
			$output_table['style'] = 'width:100%;';
		}
		# Determine the side border color the question.
		if ( $this->ctrl->getState() != '' ) {
			if ( isset( $output_table['class'] ) ) {
				$output_table['class'] .= ' error_mark';
			} else {
				$output_table['class'] = 'error_mark';
			}
			# set poll controller state according to question controller state
			$this->ctrl->applyStateToParent();
		}
		$output_table[] = array( '__tag' => 'tbody', '__end' => "\n", 0 => $this->renderTable() );
		$tags = array();
		if ( $this->ctrl->poll->questions->usedCount() > 1 ) {
			# display question number only if there are more than one question in poll
			$tags[] = array(
				'__tag' => 'div', '__end' => "\n", 'class' => 'header',
					array( '__tag' => 'span', 'class' => 'questionId', 0 => $this->ctrl->usedId )
			);
		}
		if ( $this->headerErrorMessage !== '' ) {
			# either fatal or proposal error occured
			$tags[] = array(
				'__tag' => 'div',
				'class' => ( $this->ctrl->getState() === 'error' ) ? 'fatalerror' : 'proposalerror',
				qp_Setup::specialchars( $this->headerErrorMessage )
			);
		}
		$tags[] = array( '__tag' => 'div', $this->rtp( $this->ctrl->mCommonQuestion ) );
		# class 'question_mod4_[0-3]' is used to prettify question table cells;
		# todo: at some later point, when HTML5/CSS3 will take over, this will not be needed.
		$tags = array( '__tag' => 'div', '__end' => "\n", 'class' => 'question question_mod4_' . ( $this->ctrl->usedId % 4 ), $tags );
		$tags[] = &$output_table;
		return qp_Renderer::renderTagArray( $tags );
	}
Ejemplo n.º 6
0
	/**
	 * Encloses the output of $this->renderQuestionViews() into the output tag wrappers
	 * @return  rendered "final" html
	 */
	function renderPoll() {
		$pollStore = $this->ctrl->pollStore;
		# Generates the output.
		$qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll' );
		$qpoll_div[] = array( '__tag' => 'a', 'name' => $this->ctrl->getPollTitleFragment( null, '' ), 0 => '' );
		# output script-generated error, when available
		# render short/long/structured result, when permitted and available
		$interpResultView = qp_InterpResultView::newFromBaseView( $this );
		$interpResultView->showInterpResults( $qpoll_div, $pollStore->interpResult );
		# unused anymore
		unset( $interpResultView );
		# create voting form and fill it with messages and inputs
		$qpoll_form = array( '__tag' => 'form', 'method' => 'post', 'action' => $this->ctrl->getPollTitleFragment(), 'autocomplete' => 'off', '__end' => "\n" );
		$qpoll_div[] = &$qpoll_form;
		# Determine the content of the settings table.
		$settings = Array();
		if ( $this->ctrl->mState != '' ) {
			$settings[0][] = array( '__tag' => 'td', 'class' => 'margin object_error' );
			$settings[0][] = array( '__tag' => 'td', 0 => wfMsgHtml( 'qp_result_' . $this->ctrl->mState ) );
		}
		# Build the settings table.
		if ( count( $settings ) > 0 ) {
			$settingsTable = array( '__tag' => 'table', 'class' => 'settings', '__end' => "\n" );
			foreach ( $settings as $settingsTr ) {
				$settingsTable[] = array( '__tag' => 'tr', 0 => $settingsTr, '__end' => "\n" );
			}
			$qpoll_form[] = &$settingsTable;
		}
		$qpoll_form[] = array( '__tag' => 'input', 'type' => 'hidden', 'name' => 'pollId', 'value' => $this->ctrl->mPollId );
		$qpoll_form[] = array( '__tag' => 'div', 'class' => 'pollQuestions', 0 => $this->renderQuestionViews() );
		$submitBtn = array( '__tag' => 'input', 'type' => 'submit' );
		$submitMsg = 'qp_vote_button';
		if ( $pollStore->isAlreadyVoted() ) {
			$submitMsg = 'qp_vote_again_button';
		}
		if ( $this->ctrl->mBeingCorrected ) {
			if ( $pollStore->getState() == "complete" ) {
				$submitMsg = 'qp_vote_again_button';
			}
		} else {
			if ( $pollStore->getState() == "error" ) {
				$submitBtn['disabled'] = 'disabled';
			}
		}
		$atLeft = $this->ctrl->attemptsLeft();
		if ( $atLeft === false ) {
			$submitBtn['disabled'] = 'disabled';
		}
		# disable submit button in preview mode & printable version
		if ( qp_Setup::$request->getVal( 'action' ) == 'parse' ||
				qp_Setup::$output->isPrintable() ) {
			$submitBtn['disabled'] = 'disabled';
		}
		$submitBtn['value'] = wfMsgHtml( $submitMsg );
		$p = array( '__tag' => 'p' );
		$p[] = $submitBtn;
		# output "no more attempts" message, when applicable
		if ( $atLeft === false ) {
			$p[] = array( '__tag' => 'span', 'class' => 'attempts_counter', qp_Setup::specialchars( wfMsg( 'qp_error_no_more_attempts' ) ) );
		} elseif ( $atLeft !== true ) {
			$p[] = array( '__tag' => 'span', 'class' => 'attempts_counter', qp_Setup::specialchars( wfMsgExt( 'qp_submit_attempts_left', array( 'parsemag' ), intval( $atLeft ) ) ) );
		}

		$qpoll_form[] = &$p;
		return qp_Renderer::renderTagArray( $qpoll_div );
	}