r61171 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61170‎ | r61171 | r61172 >
Date:16:23, 17 January 2010
Author:siebrand
Status:deferred
Tags:
Comment:
stylize.php and remove trailing whitespace for non-external components.
Modified paths:
  • /trunk/extensions/QPoll/qp_i18n.php (modified) (history)
  • /trunk/extensions/QPoll/qp_pollstore.php (modified) (history)
  • /trunk/extensions/QPoll/qp_question.php (modified) (history)
  • /trunk/extensions/QPoll/qp_results.php (modified) (history)
  • /trunk/extensions/QPoll/qp_user.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/qp_user.php
@@ -8,7 +8,7 @@
99 * it under the terms of the GNU General Public License as published by
1010 * the Free Software Foundation; either version 2 of the License, or
1111 * (at your option) any later version.
12 - *
 12+ *
1313 * QPoll is distributed in the hope that it will be useful,
1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -21,13 +21,13 @@
2222 * ***** END LICENSE BLOCK *****
2323 *
2424 * QPoll is a poll tool for MediaWiki.
25 - *
 25+ *
2626 * To activate this extension :
2727 * * Create a new directory named QPoll into the directory "extensions" of MediaWiki.
2828 * * Place the files from the extension archive there.
2929 * * Add this line at the end of your LocalSettings.php file :
3030 * require_once "$IP/extensions/QPoll/qp_user.php";
31 - *
 31+ *
3232 * @version 0.6.4
3333 * @link http://www.mediawiki.org/wiki/Extension:QPoll
3434 * @author QuestPC <questpc@rambler.ru>
@@ -88,19 +88,19 @@
8989
9090 static function coreRequirements() {
9191 $required_classes_and_methods = array(
92 - array( 'Article'=>'doPurge' ),
93 - array( 'Linker'=>'link' ),
94 - array( 'OutputPage'=>'isPrintable' ),
95 - array( 'Parser'=>'getTitle' ),
96 - array( 'Parser'=>'setHook' ),
97 - array( 'Parser'=>'recursiveTagParse' ),
98 - array( 'ParserCache'=>'getKey' ),
99 - array( 'ParserCache'=>'singleton' ),
100 - array( 'Title'=>'getArticleID' ),
101 - array( 'Title'=>'getPrefixedText' ),
102 - array( 'Title'=>'makeTitle' ),
103 - array( 'Title'=>'makeTitleSafe' ),
104 - array( 'Title'=>'newFromID' )
 92+ array( 'Article' => 'doPurge' ),
 93+ array( 'Linker' => 'link' ),
 94+ array( 'OutputPage' => 'isPrintable' ),
 95+ array( 'Parser' => 'getTitle' ),
 96+ array( 'Parser' => 'setHook' ),
 97+ array( 'Parser' => 'recursiveTagParse' ),
 98+ array( 'ParserCache' => 'getKey' ),
 99+ array( 'ParserCache' => 'singleton' ),
 100+ array( 'Title' => 'getArticleID' ),
 101+ array( 'Title' => 'getPrefixedText' ),
 102+ array( 'Title' => 'makeTitle' ),
 103+ array( 'Title' => 'makeTitleSafe' ),
 104+ array( 'Title' => 'newFromID' )
105105 );
106106 foreach ( $required_classes_and_methods as &$check ) {
107107 list( $object, $method ) = each( $check );
@@ -124,10 +124,10 @@
125125 global $wgSpecialPages;
126126 global $wgHooks;
127127 self::coreRequirements();
128 - self::$ExtDir = str_replace( "\\", "/", dirname(__FILE__) );
 128+ self::$ExtDir = str_replace( "\\", "/", dirname( __FILE__ ) );
129129 $dirs = explode( '/', self::$ExtDir );
130130 $top_dir = array_pop( $dirs );
131 - self::$ScriptPath = $wgScriptPath . '/extensions' . ( ( $top_dir == 'extensions' ) ? '' : '/' . $top_dir );
 131+ self::$ScriptPath = $wgScriptPath . '/extensions' . ( ( $top_dir == 'extensions' ) ? '' : '/' . $top_dir );
132132 $wgExtensionMessagesFiles['QPoll'] = self::$ExtDir . '/qp_i18n.php';
133133 $wgAutoloadClasses['PollResults'] = self::$ExtDir . '/qp_results.php';
134134 $wgAutoloadClasses['qp_Question'] = self::$ExtDir . '/qp_question.php';
@@ -136,7 +136,7 @@
137137 $wgAutoloadClasses['qp_QuestionData'] = self::$ExtDir . '/qp_pollstore.php';
138138 $wgAutoloadClasses['qp_QueryPage'] = self::$ExtDir . '/qp_results.php';
139139 // TODO: Use the new technique for i18n of special page aliases
140 - $wgSpecialPages['PollResults'] = array('PollResults');
 140+ $wgSpecialPages['PollResults'] = array( 'PollResults' );
141141 // TODO: Use the new technique for i18n of magic words
142142 $wgHooks['LanguageGetMagic'][] = 'qp_Setup::languageGetMagic';
143143 $wgHooks['MediaWikiPerformAction'][] = 'qp_Setup::mediaWikiPerformAction';
@@ -147,14 +147,14 @@
148148 static function loadMessages() {
149149 if ( !self::$messagesLoaded ) {
150150 self::$messagesLoaded = true;
151 - wfLoadExtensionMessages('QPoll');
 151+ wfLoadExtensionMessages( 'QPoll' );
152152 }
153153 return true;
154154 }
155155
156156 static function ParserFunctionsWords( $lang ) {
157157 $words = array();
158 - $words[ 'en' ] = array( 'qpuserchoice'=>array( 0, 'qpuserchoice' ) );
 158+ $words[ 'en' ] = array( 'qpuserchoice' => array( 0, 'qpuserchoice' ) );
159159 # English is used as a fallback, and the English synonyms are
160160 # used if a translation has not been provided for a given word
161161 return ( $lang == 'en' || !array_key_exists( $lang, $words ) )
@@ -163,7 +163,7 @@
164164 }
165165
166166 static function languageGetMagic( &$magicWords, $langCode ) {
167 - foreach( self::ParserFunctionsWords( $langCode ) as $word => $trans )
 167+ foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans )
168168 $magicWords [$word ] = $trans;
169169 return true;
170170 }
@@ -174,7 +174,7 @@
175175 $parserCache->mMemc->delete( $key );
176176 self::$article->doPurge();
177177 }
178 -
 178+
179179 static function mediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki ) {
180180 global $wgCookiePrefix;
181181 global $qp_enable_showresults;
@@ -195,10 +195,10 @@
196196 } else {
197197 $qp_enable_showresults = 0;
198198 }
199 - if ( isset( $_COOKIE[$wgCookiePrefix.'QPoll'] ) ) {
 199+ if ( isset( $_COOKIE[$wgCookiePrefix . 'QPoll'] ) ) {
200200 $request->response()->setCookie( 'QPoll', '', time() - 86400 ); // clear cookie
201201 self::clearCache();
202 - } elseif ( $request->getVal('pollId') !== null ) {
 202+ } elseif ( $request->getVal( 'pollId' ) !== null ) {
203203 self::clearCache();
204204 }
205205 return true;
@@ -224,7 +224,7 @@
225225 $wgOut->addExtensionStyle( self::$ScriptPath . '/qp_user_rtl.css' );
226226 }
227227 # setup tag hook
228 - $wgParser->setHook("qpoll", "qp_Setup::renderPoll");
 228+ $wgParser->setHook( "qpoll", "qp_Setup::renderPoll" );
229229 $wgQPollFunctionsHook = new qp_FunctionsHook();
230230 # setup function hook
231231 $wgParser->setFunctionHook( 'qpuserchoice', array( &$wgQPollFunctionsHook, 'qpuserchoice' ), SFH_OBJECT_ARGS );
@@ -233,11 +233,11 @@
234234
235235 /**
236236 * Call the poll parser on an input text.
237 - *
 237+ *
238238 * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax.
239239 * @param $argv An array containing any arguments passed to the extension
240240 * @param &$parser The wikitext parser.
241 - *
 241+ *
242242 * @return An HTML poll.
243243 */
244244
@@ -284,14 +284,14 @@
285285 # the following showresults types are currently available:
286286 # 0 - none; 1 - percents; 2 - bars
287287 # may contain extra options (color, width) for selected display type
288 - var $showResults = Array( 'type'=>0 ); // hide showResults by default
 288+ var $showResults = Array( 'type' => 0 ); // hide showResults by default
289289
290290 // qp_pollStore instance that will be used to transfer poll data from/to DB
291291 var $pollStore = null;
292292
293 - /**
 293+ /**
294294 * Constructor
295 - *
 295+ *
296296 * @public
297297 */
298298 function __construct( $argv, &$parser ) {
@@ -325,24 +325,24 @@
326326 # every poll on the page should have unique poll id, to minimize the risk of collisions
327327 # it is required to be set manually via id="value" parameter
328328 # ( used only in "declaration" mode )
329 - $this->mPollId = array_key_exists('id', $argv) ? trim( $argv['id'] ) : null;
330 - if ( array_key_exists('dependance', $argv) ) {
 329+ $this->mPollId = array_key_exists( 'id', $argv ) ? trim( $argv['id'] ) : null;
 330+ if ( array_key_exists( 'dependance', $argv ) ) {
331331 $this->dependsOn = trim( $argv['dependance'] );
332332 }
333333 }
334334
335335 /**
336336 * Convert the input text to an HTML output.
337 - *
 337+ *
338338 * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax.
339339 */
340340 function parsePoll( $input ) {
341 - if ( ($result = $this->getPollStore() ) !== true ) {
 341+ if ( ( $result = $this->getPollStore() ) !== true ) {
342342 # error message box (invalid poll attributes)
343343 return $result;
344344 }
345 - if ( ($result = $this->parseInput( $input ) ) === true ) {
346 - # no output generation - due to active redirect or access denied
 345+ if ( ( $result = $this->parseInput( $input ) ) === true ) {
 346+ # no output generation - due to active redirect or access denied
347347 return '';
348348 } else {
349349 # generateOutput() assumes that the poll is not being submitted and is correctly declared
@@ -370,7 +370,7 @@
371371
372372 function isValidPollId( $pollId ) {
373373 // more non-allowed chars ?
374 - return !preg_match('`#`u', $pollId );
 374+ return !preg_match( '`#`u', $pollId );
375375 }
376376
377377 function isUniquePollId( $pollId ) {
@@ -380,17 +380,17 @@
381381 static function loadMessages() {
382382 if ( !self::$messagesLoaded ) {
383383 self::$messagesLoaded = true;
384 - wfLoadExtensionMessages('QPoll');
 384+ wfLoadExtensionMessages( 'QPoll' );
385385 }
386386 return true;
387 - }
 387+ }
388388
389389 static function currentUserName() {
390390 global $qp_AnonForwardedFor;
391391 global $wgUser, $wgSquidServers;
392392 global $wgUsePrivateIPs;
393393 if ( $qp_AnonForwardedFor === true && $wgUser->isAnon() ) {
394 - /* collect the originating IPs
 394+ /* collect the originating IPs
395395 borrowed from ProxyTools::wfGetIP
396396 bypass trusted proxies list check */
397397 # Client connecting to this webserver
@@ -411,7 +411,7 @@
412412 }
413413 $username = "";
414414 foreach ( $ipchain as $i => $curIP ) {
415 - if( $wgUsePrivateIPs || IP::isPublic( $curIP ) ) {
 415+ if ( $wgUsePrivateIPs || IP::isPublic( $curIP ) ) {
416416 $username .= IP::canonicalize( $curIP ) . '/';
417417 }
418418 }
@@ -448,7 +448,7 @@
449449 } else {
450450 return false;
451451 }
452 - }
 452+ }
453453 if ( $pollIdPart == '' ) {
454454 return false;
455455 }
@@ -460,7 +460,7 @@
461461 }
462462
463463 // parses source showresults xml parameter value and returns the corresponding showResults array
464 - // input: $str contains entries separated by ';'
 464+ // input: $str contains entries separated by ';'
465465 // entry 1 is a number of showresults type (always presented)
466466 // entries 2..n are optional css-style list of attributes and their values
467467 // returns showResults parsed array
@@ -474,7 +474,7 @@
475475 $showResults['type'] = 0;
476476 }
477477 if ( $showResults['type'] != 0 && count( $attrs ) > 0 ) {
478 - foreach( $attrs as &$attr ) {
 478+ foreach ( $attrs as &$attr ) {
479479 preg_match( '`([A-Za-z]+):([#\w]+)`u', $attr, $matches );
480480 if ( count( $matches ) == 3 ) {
481481 $showResults[ $matches[1] ] = $matches[2];
@@ -514,7 +514,7 @@
515515 return self::fatalError( 'qp_error_dependance_in_stats_mode' );
516516 }
517517 $this->pollStore = qp_PollStore::newFromAddr( $this->pollAddr );
518 - if ( !($this->pollStore instanceof qp_PollStore) || $this->pollStore->pid === null ) {
 518+ if ( !( $this->pollStore instanceof qp_PollStore ) || $this->pollStore->pid === null ) {
519519 return self::fatalError( 'qp_error_no_such_poll', $this->pollAddr );
520520 }
521521 if ( !$this->pollStore->loadQuestions() ) {
@@ -549,7 +549,7 @@
550550 } else {
551551 $attr_str = '';
552552 }
553 - if ( ($type = $question->parseAttributes( $attr_str )) != '' ) {
 553+ if ( ( $type = $question->parseAttributes( $attr_str ) ) != '' ) {
554554 # there cannot be type attribute of question in statistical display mode
555555 $question->setState( 'error', wfMsg( 'qp_error_type_in_stats_mode', $type ) );
556556 }
@@ -578,9 +578,9 @@
579579 # render the question statistics only when showResuls isn't 0 (suppress stats)
580580 if ( $question->showResults['type'] != 0 ) {
581581 if ( $this->perRow > 1 ) {
582 - $write_col[] = array( '__tag'=>'td', 'valign'=>'top', 0=>$this->parseStats( $question ), '__end'=>"\n" );
 582+ $write_col[] = array( '__tag' => 'td', 'valign' => 'top', 0 => $this->parseStats( $question ), '__end' => "\n" );
583583 if ( $this->currCol == 1 ) {
584 - $write_row[] = array( '__tag'=>'tr', 0=>$write_col, '__end'=>"\n" );
 584+ $write_row[] = array( '__tag' => 'tr', 0 => $write_col, '__end' => "\n" );
585585 $write_col = Array();
586586 }
587587 if ( --$this->currCol < 1 ) {
@@ -595,10 +595,10 @@
596596 }
597597 if ( $this->perRow > 1 && $this->currCol != $this->perRow ) {
598598 # add last incomplete row
599 - $write_row[] = array( '__tag'=>'tr', '__end'=>"\n", 0=>$write_col );
 599+ $write_row[] = array( '__tag' => 'tr', '__end' => "\n", 0 => $write_col );
600600 }
601601 if ( $this->perRow > 1 ) {
602 - $question_table = array( '__tag'=>'table', 0=>array( '__tag'=>'tbody', 0=>&$write_row, '__end'=>"\n" ), '__end'=>"\n" );
 602+ $question_table = array( '__tag' => 'table', 0 => array( '__tag' => 'tbody', 0 => &$write_row, '__end' => "\n" ), '__end' => "\n" );
603603 return qp_Renderer::renderHTMLobject( $question_table );
604604 } else {
605605 return qp_Renderer::renderHTMLobject( $write_row );
@@ -611,7 +611,7 @@
612612 function generateOutput( $input ) {
613613 global $wgOut;
614614 # Generates the output.
615 - $qpoll_div = array( '__tag'=>'div', 'class'=>'qpoll', 0=>$input );
 615+ $qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll', 0 => $input );
616616 return qp_Renderer::renderHTMLobject( $qpoll_div );
617617 }
618618
@@ -624,20 +624,20 @@
625625 if ( $question->getQuestionAnswer( $this->pollStore ) ) {
626626 # check whether the current global showresults level allows to display statistics
627627 if ( $qp_enable_showresults == 0 ||
628 - ($qp_enable_showresults <= 1 && !$question->alreadyVoted) ) {
 628+ ( $qp_enable_showresults <= 1 && !$question->alreadyVoted ) ) {
629629 # suppress the output
630630 return '';
631631 }
632632 $buffer = $question->renderStats();
633633 }
634 - $output_table = array( '__tag'=>'table', '__end'=>"\n", 'class'=>'object' );
 634+ $output_table = array( '__tag' => 'table', '__end' => "\n", 'class' => 'object' );
635635 # Determine the side border color the question.
636 - $output_table[] = array( '__tag'=>'tbody', '__end'=>"\n", 0=>$buffer );
637 - $tags = array( '__tag'=>'div', '__end'=>"\n", 'class'=>'question',
638 - 0=>array( '__tag'=>'div', '__end'=>"\n", 'class'=>'header',
639 - 0=>array( '__tag'=>'span', 'class'=>'questionId', 0=>$question->mQuestionId )
 636+ $output_table[] = array( '__tag' => 'tbody', '__end' => "\n", 0 => $buffer );
 637+ $tags = array( '__tag' => 'div', '__end' => "\n", 'class' => 'question',
 638+ 0 => array( '__tag' => 'div', '__end' => "\n", 'class' => 'header',
 639+ 0 => array( '__tag' => 'span', 'class' => 'questionId', 0 => $question->mQuestionId )
640640 ),
641 - 1=>$this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" )
 641+ 1 => $this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" )
642642 );
643643 $tags[] = &$output_table;
644644 return qp_Renderer::renderHTMLobject( $tags );
@@ -655,9 +655,9 @@
656656 # order_id is used to sort out polls on the Special:PollResults statistics page
657657 $this->mOrderId = self::$sOrderId;
658658 # Determine if this poll is being corrected or not, according to the pollId
659 - $this->mBeingCorrected = ( $this->mRequest->getVal('pollId') == $this->mPollId );
 659+ $this->mBeingCorrected = ( $this->mRequest->getVal( 'pollId' ) == $this->mPollId );
660660 }
661 -
 661+
662662 # prepare qp_PollStore object
663663 # @return true on success ($this->pollStore has been created successfully), error string on failure
664664 function getPollStore() {
@@ -691,27 +691,27 @@
692692 # return an error string
693693 # here we create a pollstore only to update poll attributes (order_id,dependance), in case these were changed
694694 $this->pollStore = new qp_PollStore( array(
695 - 'from'=>'poll_get',
696 - 'poll_id'=>$this->mPollId,
697 - 'order_id'=>$this->mOrderId,
698 - 'dependance'=>$this->dependsOn ) );
 695+ 'from' => 'poll_get',
 696+ 'poll_id' => $this->mPollId,
 697+ 'order_id' => $this->mOrderId,
 698+ 'dependance' => $this->dependsOn ) );
699699 return $dependanceResult;
700700 }
701701 if ( $this->mBeingCorrected ) {
702702 $this->pollStore = new qp_PollStore( array(
703 - 'from'=>'poll_post',
704 - 'poll_id'=>$this->mPollId,
705 - 'order_id'=>$this->mOrderId,
706 - 'dependance'=>$this->dependsOn ) );
 703+ 'from' => 'poll_post',
 704+ 'poll_id' => $this->mPollId,
 705+ 'order_id' => $this->mOrderId,
 706+ 'dependance' => $this->dependsOn ) );
707707 $this->pollStore->loadQuestions();
708 - $this->pollStore->setLastUser( $this->username, false );
 708+ $this->pollStore->setLastUser( $this->username, false );
709709 $this->pollStore->loadUserAlreadyVoted();
710710 } else {
711711 $this->pollStore = new qp_PollStore( array(
712 - 'from'=>'poll_get',
713 - 'poll_id'=>$this->mPollId,
714 - 'order_id'=>$this->mOrderId,
715 - 'dependance'=>$this->dependsOn ) );
 712+ 'from' => 'poll_get',
 713+ 'poll_id' => $this->mPollId,
 714+ 'order_id' => $this->mOrderId,
 715+ 'dependance' => $this->dependsOn ) );
716716 $this->pollStore->loadQuestions();
717717 $this->pollStore->setLastUser( $this->username, false );
718718 # to show previous choice of current user, if that's available
@@ -735,7 +735,7 @@
736736 $this->pollStore->setUserVote();
737737 }
738738 if ( $this->pollStore->voteDone ) {
739 - $this->mResponse->setcookie( 'QPoll', 'clearCache', time()+20 );
 739+ $this->mResponse->setcookie( 'QPoll', 'clearCache', time() + 20 );
740740 $this->mResponse->header( 'HTTP/1.0 302 Found' );
741741 $this->mResponse->header( 'Location: ' . $wgTitle->getFullURL() . self::getPollTitleFragment( $this->mPollId ) );
742742 return true;
@@ -752,27 +752,27 @@
753753 # (remember, we're in declaration mode, where 'order_id' is important
754754 self::$sOrderId++;
755755 # Generates the output.
756 - $qpoll_div = array( '__tag'=>'div', 'class'=>'qpoll' );
757 - $qpoll_div[] = array( '__tag'=>'a', 'name'=>self::getPollTitleFragment( $this->mPollId, '' ), 0=>'' );
758 - $qpoll_form = array( '__tag'=>'form', 'method'=>'post', 'action'=>self::getPollTitleFragment( $this->mPollId ), '__end'=>"\n" );
 756+ $qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll' );
 757+ $qpoll_div[] = array( '__tag' => 'a', 'name' => self::getPollTitleFragment( $this->mPollId, '' ), 0 => '' );
 758+ $qpoll_form = array( '__tag' => 'form', 'method' => 'post', 'action' => self::getPollTitleFragment( $this->mPollId ), '__end' => "\n" );
759759 $qpoll_div[] = &$qpoll_form;
760760 # Determine the content of the settings table.
761761 $settings = Array();
762762 if ( $this->mState != '' ) {
763 - $settings[0][] = array( '__tag'=>'td', 'class'=>'margin', 'style'=>'background: ' . QP_CSS_ERROR_COLOR2 . ';' );
764 - $settings[0][] = array( '__tag'=>'td', 0=>wfMsgHtml( 'qp_result_' . $this->mState ) );
 763+ $settings[0][] = array( '__tag' => 'td', 'class' => 'margin', 'style' => 'background: ' . QP_CSS_ERROR_COLOR2 . ';' );
 764+ $settings[0][] = array( '__tag' => 'td', 0 => wfMsgHtml( 'qp_result_' . $this->mState ) );
765765 }
766766 # Build the settings table.
767767 if ( count( $settings ) > 0 ) {
768 - $settingsTable = array( '__tag'=>'table', 'class'=>'settings', '__end'=>"\n" );
769 - foreach($settings as $settingsTr) {
770 - $settingsTable[] = array( '__tag'=>'tr', 0=> $settingsTr, '__end'=>"\n" );
771 - }
 768+ $settingsTable = array( '__tag' => 'table', 'class' => 'settings', '__end' => "\n" );
 769+ foreach ( $settings as $settingsTr ) {
 770+ $settingsTable[] = array( '__tag' => 'tr', 0 => $settingsTr, '__end' => "\n" );
 771+ }
772772 $qpoll_form[] = &$settingsTable;
773773 }
774 - $qpoll_form[] = array( '__tag'=>'input', 'type'=>'hidden', 'name'=>'pollId', 'value'=>$this->mPollId );
775 - $qpoll_form[] = array( '__tag'=>'div', 'class'=>'pollQuestions', 0=>$input );
776 - $submitBtn = array( '__tag'=>'input', 'type'=>'submit' );
 774+ $qpoll_form[] = array( '__tag' => 'input', 'type' => 'hidden', 'name' => 'pollId', 'value' => $this->mPollId );
 775+ $qpoll_form[] = array( '__tag' => 'div', 'class' => 'pollQuestions', 0 => $input );
 776+ $submitBtn = array( '__tag' => 'input', 'type' => 'submit' );
777777 $submitMsg = 'qp_vote_button';
778778 if ( $this->pollStore->isAlreadyVoted() ) {
779779 $submitMsg = 'qp_vote_again_button';
@@ -792,7 +792,7 @@
793793 $submitBtn[ 'disabled' ] = 'disabled';
794794 }
795795 $submitBtn[ 'value' ] = wfMsgHtml( $submitMsg );
796 - $p = array( '__tag'=>'p' );
 796+ $p = array( '__tag' => 'p' );
797797 $p[] = $submitBtn;
798798 $qpoll_form[] = &$p;
799799 return qp_Renderer::renderHTMLobject( $qpoll_div );
@@ -872,7 +872,7 @@
873873 # Replace questions from QPoll syntax to HTML
874874 # @param $input - A question in QPoll syntax
875875 # @return string representing rendered set of the questions / empty string "suggests" redirect
876 - function parseQuestions($input) {
 876+ function parseQuestions( $input ) {
877877 $write_row = Array();
878878 $write_col = Array();
879879 $questions = Array();
@@ -880,13 +880,13 @@
881881 $unparsedQuestions = preg_split( $splitPattern, $input, -1, PREG_SPLIT_NO_EMPTY );
882882 $questionPattern = '`(.*?[^|\}])\}[ \t]*(\n(.*)|$)`su';
883883 # first pass: parse the headers
884 - foreach( $unparsedQuestions as $unparsedQuestion ) {
 884+ foreach ( $unparsedQuestions as $unparsedQuestion ) {
885885 # If this "unparsedQuestion" is not a full question,
886886 # we put the text into a buffer to add it at the beginning of the next question.
887 - if( !empty( $buffer ) ) {
 887+ if ( !empty( $buffer ) ) {
888888 $unparsedQuestion = "$buffer\n\n{" . $unparsedQuestion;
889889 }
890 - if( preg_match( $questionPattern, $unparsedQuestion, $matches ) ) {
 890+ if ( preg_match( $questionPattern, $unparsedQuestion, $matches ) ) {
891891 $buffer = "";
892892 $header = isset( $matches[1] ) ? $matches[1] : '';
893893 $body = isset( $matches[3] ) ? $matches[3] : null;
@@ -898,7 +898,7 @@
899899 # analyze question headers
900900 # check for showresults attribute
901901 $questions_set = Array();
902 - foreach( $questions as &$question ) {
 902+ foreach ( $questions as &$question ) {
903903 if ( $question->showResults['type'] != 0 &&
904904 method_exists( 'qp_Question', 'addShowResults' . $question->showResults['type'] ) ) {
905905 $questions_set[] = $question->mQuestionId;
@@ -914,11 +914,11 @@
915915 $this->pollStore->calculateStatistics();
916916 }
917917 # second pass: parse the body
918 - foreach( $questions as &$question ) {
 918+ foreach ( $questions as &$question ) {
919919 if ( $this->perRow > 1 ) {
920 - $write_col[] = array( '__tag'=>'td', 'valign'=>'top', 0=>$this->parseQuestionBody( $question ), '__end'=>"\n" );
 920+ $write_col[] = array( '__tag' => 'td', 'valign' => 'top', 0 => $this->parseQuestionBody( $question ), '__end' => "\n" );
921921 if ( $this->currCol == 1 ) {
922 - $write_row[] = array( '__tag'=>'tr', 0=>$write_col, '__end'=>"\n" );
 922+ $write_row[] = array( '__tag' => 'tr', 0 => $write_col, '__end' => "\n" );
923923 $write_col = Array();
924924 }
925925 if ( --$this->currCol < 1 ) {
@@ -932,16 +932,16 @@
933933 }
934934 if ( $this->perRow > 1 && $this->currCol != $this->perRow ) {
935935 # add last incomplete row
936 - $write_row[] = array( '__tag'=>'tr', '__end'=>"\n", 0=>$write_col );
 936+ $write_row[] = array( '__tag' => 'tr', '__end' => "\n", 0 => $write_col );
937937 }
938938 if ( $this->perRow > 1 ) {
939 - $question_table = array( '__tag'=>'table', 0=>array( '__tag'=>'tbody', 0=>&$write_row, '__end'=>"\n" ), '__end'=>"\n" );
 939+ $question_table = array( '__tag' => 'table', 0 => array( '__tag' => 'tbody', 0 => &$write_row, '__end' => "\n" ), '__end' => "\n" );
940940 return qp_Renderer::renderHTMLobject( $question_table );
941941 } else {
942942 return qp_Renderer::renderHTMLobject( $write_row );
943943 }
944944 }
945 -
 945+
946946 # Convert a question on the page from QPoll syntax to HTML
947947 # @param $header : the text of question "main" header (common question and XML-like attrs)
948948 # $body : the text of question body (starting with body header which defines categories and spans, followed by proposal list)
@@ -978,12 +978,12 @@
979979 # to the users who hasn't voted
980980 if ( $qp_enable_showresults <= 1 && !$question->alreadyVoted ) {
981981 # suppress statistical results when the current user hasn't voted the question
982 - $question->showResults = Array( 'type'=>0 );
 982+ $question->showResults = Array( 'type' => 0 );
983983 }
984 - # parse the question body
 984+ # parse the question body
985985 # store the html result into the buffer to determine some parameters before outputing it
986986 # warning! parameters are passed only by value, not the reference
987 - $buffer = $question->{$question->mType . 'ParseBody'}();
 987+ $buffer = $question-> { $question->mType . 'ParseBody' } ();
988988 if ( $this->mBeingCorrected ) {
989989 if ( $question->getState() == '' ) {
990990 # question is OK, store it into pollStore
@@ -1002,7 +1002,7 @@
10031003 }
10041004 }
10051005 }
1006 - $output_table = array( '__tag'=>'table', '__end'=>"\n", 'class'=>'object' );
 1006+ $output_table = array( '__tag' => 'table', '__end' => "\n", 'class' => 'object' );
10071007 # Determine the side border color the question.
10081008 if ( $question->getState() != "" ) {
10091009 global $wgContLang;
@@ -1011,12 +1011,12 @@
10121012 $output_table[ 'style' ] = $style;
10131013 $this->mState = $question->getState();
10141014 }
1015 - $output_table[] = array( '__tag'=>'tbody', '__end'=>"\n", 0=>&$buffer );
1016 - $tags = array( '__tag'=>'div', '__end'=>"\n", 'class'=>'question',
1017 - 0=>array( '__tag'=>'div', '__end'=>"\n", 'class'=>'header',
1018 - 0=>array( '__tag'=>'span', 'class'=>'questionId', 0=>$question->mQuestionId )
 1015+ $output_table[] = array( '__tag' => 'tbody', '__end' => "\n", 0 => &$buffer );
 1016+ $tags = array( '__tag' => 'div', '__end' => "\n", 'class' => 'question',
 1017+ 0 => array( '__tag' => 'div', '__end' => "\n", 'class' => 'header',
 1018+ 0 => array( '__tag' => 'span', 'class' => 'questionId', 0 => $question->mQuestionId )
10191019 ),
1020 - 1=>$this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" )
 1020+ 1 => $this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" )
10211021 );
10221022 $tags[] = &$output_table;
10231023 return qp_Renderer::renderHTMLobject( $tags );
@@ -1038,7 +1038,7 @@
10391039 if ( array_key_exists( '__tag', $tag ) ) {
10401040 # list inside of tag
10411041 $tag_open .= "<" . $tag[ '__tag' ];
1042 - foreach( $tag as $attr_key=>&$attr_val ) {
 1042+ foreach ( $tag as $attr_key => &$attr_val ) {
10431043 if ( is_int( $attr_key ) ) {
10441044 if ( $tag_val === null )
10451045 $tag_val = "";
@@ -1069,7 +1069,7 @@
10701070 } else {
10711071 # tagless list
10721072 $tag_val = "";
1073 - foreach( $tag as $attr_key=>&$attr_val ) {
 1073+ foreach ( $tag as $attr_key => &$attr_val ) {
10741074 if ( is_int( $attr_key ) ) {
10751075 if ( is_array( $attr_val ) ) {
10761076 # recursive tags
@@ -1080,8 +1080,8 @@
10811081 }
10821082 } else {
10831083 ob_start();
1084 - var_dump($tag);
1085 - $tagdump=ob_get_contents();
 1084+ var_dump( $tag );
 1085+ $tagdump = ob_get_contents();
10861086 ob_end_clean();
10871087 $tag_val = "invalid argument: tagless list cannot have tag attribute values in key=$attr_key, $tagdump";
10881088 }
@@ -1102,13 +1102,13 @@
11031103 if ( count( $row ) > 0 ) {
11041104 foreach ( $row as &$cell ) {
11051105 if ( !is_array( $cell ) ) {
1106 - $cell = array( 0=>$cell );
 1106+ $cell = array( 0 => $cell );
11071107 }
11081108 $cell[ '__tag' ] = $celltag;
11091109 $cell[ '__end' ] = "\n";
11101110 if ( is_array( $attribute_maps ) ) {
11111111 # converts ("count"=>3) to ("colspan"=>3) in table headers - don't use frequently
1112 - foreach ( $attribute_maps as $key=>$val ) {
 1112+ foreach ( $attribute_maps as $key => $val ) {
11131113 if ( array_key_exists( $key, $cell ) ) {
11141114 $cell[ $val ] = $cell[ $key ];
11151115 unset( $cell[ $key ] );
@@ -1116,7 +1116,7 @@
11171117 }
11181118 }
11191119 }
1120 - $result = array( '__tag'=>'tr', 0=>$row, '__end'=>"\n" );
 1120+ $result = array( '__tag' => 'tr', 0 => $row, '__end' => "\n" );
11211121 if ( is_array( $rowattrs ) ) {
11221122 $result = array_merge( $rowattrs, $result );
11231123 } elseif ( $rowattrs !== "" ) {
@@ -1137,13 +1137,13 @@
11381138 $row = 0;
11391139 foreach ( $column as &$cell ) {
11401140 if ( !is_array( $cell ) ) {
1141 - $cell = array( 0=>$cell );
 1141+ $cell = array( 0 => $cell );
11421142 }
11431143 $cell[ '__tag' ] = $celltag;
11441144 $cell[ '__end' ] = "\n";
11451145 if ( is_array( $attribute_maps ) ) {
11461146 # converts ("count"=>3) to ("rowspan"=>3) in table headers - don't use frequently
1147 - foreach ( $attribute_maps as $key=>$val ) {
 1147+ foreach ( $attribute_maps as $key => $val ) {
11481148 if ( array_key_exists( $key, $cell ) ) {
11491149 $cell[ $val ] = $cell[ $key ];
11501150 unset( $cell[ $key ] );
@@ -1156,7 +1156,7 @@
11571157 $cell[ 0 ] = __METHOD__ . ':invalid rowattrs supplied';
11581158 }
11591159 if ( !array_key_exists( $row, $table ) ) {
1160 - $table[ $row ] = array( '__tag'=>'tr', '__end'=>"\n" );
 1160+ $table[ $row ] = array( '__tag' => 'tr', '__end' => "\n" );
11611161 }
11621162 $table[ $row ][] = $cell;
11631163 if ( array_key_exists( 'rowspan', $cell ) ) {
@@ -1165,7 +1165,7 @@
11661166 $row++;
11671167 }
11681168 }
1169 - $result = array( '__tag'=>'tr', 0=>$column, '__end'=>"\n" );
 1169+ $result = array( '__tag' => 'tr', 0 => $column, '__end' => "\n" );
11701170 }
11711171 }
11721172
@@ -1177,11 +1177,11 @@
11781178 // if you want to use the resulting row with renderHTMLobject(), don't forget to apply attrs=array('__tag'=>'td')
11791179 static function applyAttrsToRow( &$row, $attrs ) {
11801180 if ( is_array( $attrs ) && count( $attrs > 0 ) ) {
1181 - foreach( $row as &$cell ) {
 1181+ foreach ( $row as &$cell ) {
11821182 if ( !is_array( $cell ) ) {
11831183 $cell = array_merge( $attrs, array( $cell ) );
1184 - } else {
1185 - foreach( $attrs as $attr_key=>$attr_val ) {
 1184+ } else {
 1185+ foreach ( $attrs as $attr_key => $attr_val ) {
11861186 if ( !array_key_exists( $attr_key, $cell ) ) {
11871187 $cell[ $attr_key ] = $attr_val;
11881188 }
@@ -1259,7 +1259,7 @@
12601260 function qpuserchoiceValidResult( $qdata ) {
12611261 $result = '';
12621262 if ( array_key_exists( $this->proposal_id, $qdata->ProposalCategoryId ) ) {
1263 - foreach( $qdata->ProposalCategoryId[ $this->proposal_id ] as $id_key => $cat_id ) {
 1263+ foreach ( $qdata->ProposalCategoryId[ $this->proposal_id ] as $id_key => $cat_id ) {
12641264 if ( $result != '' ) {
12651265 $result .= '~';
12661266 }
Index: trunk/extensions/QPoll/qp_i18n.php
@@ -8,7 +8,7 @@
99 * it under the terms of the GNU General Public License as published by
1010 * the Free Software Foundation; either version 2 of the License, or
1111 * (at your option) any later version.
12 - *
 12+ *
1313 * QPoll is distributed in the hope that it will be useful,
1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -21,13 +21,13 @@
2222 * ***** END LICENSE BLOCK *****
2323 *
2424 * QPoll is a poll tool for MediaWiki.
25 - *
 25+ *
2626 * To activate this extension :
2727 * * Create a new directory named QPoll into the directory "extensions" of MediaWiki.
2828 * * Place the files from the extension archive there.
2929 * * Add this line at the end of your LocalSettings.php file :
3030 * require_once "$IP/extensions/QPoll/qp_user.php";
31 - *
 31+ *
3232 * @version 0.6.4
3333 * @link http://www.mediawiki.org/wiki/Extension:QPoll
3434 * @author QuestPC <questpc@rambler.ru>
Index: trunk/extensions/QPoll/qp_results.php
@@ -8,7 +8,7 @@
99 * it under the terms of the GNU General Public License as published by
1010 * the Free Software Foundation; either version 2 of the License, or
1111 * (at your option) any later version.
12 - *
 12+ *
1313 * QPoll is distributed in the hope that it will be useful,
1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -21,13 +21,13 @@
2222 * ***** END LICENSE BLOCK *****
2323 *
2424 * QPoll is a poll tool for MediaWiki.
25 - *
 25+ *
2626 * To activate this extension :
2727 * * Create a new directory named QPoll into the directory "extensions" of MediaWiki.
2828 * * Place the files from the extension archive there.
2929 * * Add this line at the end of your LocalSettings.php file :
3030 * require_once "$IP/extensions/QPoll/qp_user.php";
31 - *
 31+ *
3232 * @version 0.6.4
3333 * @link http://www.mediawiki.org/wiki/Extension:QPoll
3434 * @author QuestPC <questpc@rambler.ru>
@@ -40,7 +40,7 @@
4141
4242 public function __construct() {
4343 parent::__construct( 'PollResults', 'delete' );
44 - wfLoadExtensionMessages('QPoll');
 44+ wfLoadExtensionMessages( 'QPoll' );
4545 }
4646
4747 static $skin = null;
@@ -54,7 +54,7 @@
5555 global $wgScript; // "/subdirectory/of/wiki/index.php"
5656 global $wgUser;
5757 if ( !$wgUser->isAllowed( 'delete' ) ) {
58 - $wgOut->permissionRequired('delete');
 58+ $wgOut->permissionRequired( 'delete' );
5959 return;
6060 }
6161 $wgOut->addExtensionStyle( qp_Setup::$ScriptPath . '/qp_results.css' );
@@ -62,10 +62,10 @@
6363 self::$skin = $wgUser->getSkin();
6464 }
6565 if ( self::$UsersLink == "" ) {
66 - self::$UsersLink = self::$skin->link( $this->getTitle(), wfMsg( 'qp_users_list' ), array( "style"=>"font-weight:bold;" ), array( 'action'=>'users' ) );
 66+ self::$UsersLink = self::$skin->link( $this->getTitle(), wfMsg( 'qp_users_list' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'users' ) );
6767 }
6868 if ( self::$PollsLink == "" ) {
69 - self::$PollsLink = self::$skin->link( $this->getTitle(), wfMsg( 'qp_polls_list' ), array( "style"=>"font-weight:bold;" ) );
 69+ self::$PollsLink = self::$skin->link( $this->getTitle(), wfMsg( 'qp_polls_list' ), array( "style" => "font-weight:bold;" ) );
7070 }
7171 $wgOut->addHTML( '<div class="qpoll">' );
7272 $output = "";
@@ -88,9 +88,9 @@
8989 $question_id = $wgRequest->getVal( 'qid' );
9090 $proposal_id = $wgRequest->getVal( 'pid' );
9191 $cid = $wgRequest->getVal( 'cid' );
92 - switch ($cmd) {
 92+ switch ( $cmd ) {
9393 case 'stats':
94 - if ( $pid !==null ) {
 94+ if ( $pid !== null ) {
9595 $pid = intval( $pid );
9696 $output = self::getPollsLink();
9797 $output .= self::getUsersLink();
@@ -98,13 +98,13 @@
9999 }
100100 break;
101101 case 'stats_xls':
102 - if ( $pid !==null ) {
 102+ if ( $pid !== null ) {
103103 $pid = intval( $pid );
104104 $this->votesToXLS( $pid );
105105 }
106106 break;
107107 case 'uvote':
108 - if ( $pid !== null && $uid !==null ) {
 108+ if ( $pid !== null && $uid !== null ) {
109109 $pid = intval( $pid );
110110 $uid = intval( $uid );
111111 $output = self::getPollsLink();
@@ -113,7 +113,7 @@
114114 }
115115 break;
116116 case 'qpcusers':
117 - if ( $pid !==null && $question_id !==null && $proposal_id !== null && $cid !== null ) {
 117+ if ( $pid !== null && $question_id !== null && $proposal_id !== null && $cid !== null ) {
118118 $pid = intval( $pid );
119119 $question_id = intval( $question_id );
120120 $proposal_id = intval( $proposal_id );
@@ -163,7 +163,7 @@
164164 "qp_question_proposals",
165165 "qp_question_answers",
166166 "qp_users_polls",
167 - "qp_users");
 167+ "qp_users" );
168168 // check whether the tables were initialized
169169 $tablesFound = 0;
170170 $result = true;
@@ -176,7 +176,7 @@
177177 }
178178 if ( $tablesFound == 0 ) {
179179 # no tables were found, initialize the DB completely
180 - $r = $db->sourceFile( qp_Setup::$ExtDir . "/qpoll.src" );
 180+ $r = $db->sourceFile( qp_Setup::$ExtDir . "/qpoll.src" );
181181 if ( $r === true ) {
182182 $result = 'Tables were initialized.<br />Please <a href="#" onclick="window.location.reload()">reload</a> this page to view future page edits.';
183183 } else {
@@ -194,7 +194,7 @@
195195 private function showUserVote( $pid, $uid ) {
196196 $output = "";
197197 if ( $pid !== null && $uid !== null ) {
198 - $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $pid ) );
 198+ $pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $pid ) );
199199 if ( $pollStore->pid !== null ) {
200200 $pollStore->loadQuestions();
201201 $userName = $pollStore->getUserName( $uid );
@@ -226,20 +226,20 @@
227227
228228 private function displayUserQuestionVote( &$qdata ) {
229229 $output = "<div class=\"qpoll\">\n" . "<table class=\"pollresults\">\n";
230 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->CategorySpans ), array( 'class'=>'spans' ), 'th', array( 'count'=>'colspan', 'name'=>0 ) );
231 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->Categories ), '', 'th', array( 'name'=>0 ) );
 230+ $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->CategorySpans ), array( 'class' => 'spans' ), 'th', array( 'count' => 'colspan', 'name' => 0 ) );
 231+ $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->Categories ), '', 'th', array( 'name' => 0 ) );
232232 # multiple choice polls doesn't use real spans, instead, every column is like "span"
233233 $spansUsed = count( $qdata->CategorySpans ) > 0 || $qdata->type == "multipleChoice";
234 - foreach( $qdata->ProposalText as $propkey => &$proposal_text ) {
 234+ foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) {
235235 $row = Array();
236236 foreach ( $qdata->Categories as $catkey => &$cat_name ) {
237 - $cell = Array( 0=>"" );
 237+ $cell = Array( 0 => "" );
238238 if ( array_key_exists( $propkey, $qdata->ProposalCategoryId ) &&
239239 ( $id_key = array_search( $catkey, $qdata->ProposalCategoryId[ $propkey ] ) ) !== false ) {
240240 $text_answer = $qdata->ProposalCategoryText[ $propkey ][ $id_key ];
241241 if ( $text_answer != '' ) {
242242 if ( strlen( $text_answer ) > 20 ) {
243 - $cell[ 0 ] = array( '__tag'=>'div', 'style'=>'width:10em; height:5em; overflow:auto', 0=>qp_Setup::entities( $text_answer ) );
 243+ $cell[ 0 ] = array( '__tag' => 'div', 'style' => 'width:10em; height:5em; overflow:auto', 0 => qp_Setup::entities( $text_answer ) );
244244 } else {
245245 $cell[ 0 ] = qp_Setup::entities( $text_answer );
246246 }
@@ -258,7 +258,7 @@
259259 }
260260 $row[] = $cell;
261261 }
262 - $row[] = array( 0=>qp_Setup::entities( $proposal_text ), "style"=>"text-align:left;" );
 262+ $row[] = array( 0 => qp_Setup::entities( $proposal_text ), "style" => "text-align:left;" );
263263 $output .= qp_Renderer::displayRow( $row );
264264 }
265265 $output .= "</table>\n" . "</div>\n";
@@ -268,7 +268,7 @@
269269 private function showVotes( $pid ) {
270270 $output = "";
271271 if ( $pid !== null ) {
272 - $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $pid ) );
 272+ $pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $pid ) );
273273 if ( $pollStore->pid !== null ) {
274274 $pollStore->loadQuestions();
275275 $pollStore->loadTotals();
@@ -277,7 +277,7 @@
278278 # 'parentheses' is unavailable in 1.14.x
279279 $poll_link = self::$skin->link( $poll_title, $poll_title->getPrefixedText() . wfMsg( 'word-separator' ) . wfMsg( 'qp_parentheses', $pollStore->mPollId ) );
280280 $output .= wfMsg( 'qp_browse_to_poll', $poll_link ) . "<br />\n";
281 - $output .= self::$skin->link( $this->getTitle(), wfMsg( 'qp_export_to_xls' ), array( "style"=>"font-weight:bold;" ), array( 'action'=>'stats_xls', 'id'=>$pid ) );
 281+ $output .= self::$skin->link( $this->getTitle(), wfMsg( 'qp_export_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'stats_xls', 'id' => $pid ) );
282282 foreach ( $pollStore->Questions as $qkey => &$qdata ) {
283283 $output .= "<br />\n<b>" . $qkey . ".</b> " . qp_Setup::entities( $qdata->CommonQuestion ) . "<br />\n";
284284 $output .= $this->displayQuestionStats( $pid, $qdata );
@@ -290,7 +290,7 @@
291291 private function votesToXLS( $pid ) {
292292 $output = "";
293293 if ( $pid !== null ) {
294 - $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $pid ) );
 294+ $pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $pid ) );
295295 if ( $pollStore->pid !== null ) {
296296 $poll_id = $pollStore->getPollId();
297297 $pollStore->loadQuestions();
@@ -306,15 +306,15 @@
307307 $xls_worksheet->setPaper( 9 );
308308 $xls_rownum = 0;
309309 $percent_num_format = '[Blue]0.0%;[Red]-0.0%;[Black]0%';
310 - $format_heading = &$xls_workbook->addformat( array( 'bold'=>1 ) );
311 - $format_percent = &$xls_workbook->addformat( array( 'fgcolor'=>0x1A, 'border'=>1 ) );
312 - $format_percent->setAlign('left');
 310+ $format_heading = &$xls_workbook->addformat( array( 'bold' => 1 ) );
 311+ $format_percent = &$xls_workbook->addformat( array( 'fgcolor' => 0x1A, 'border' => 1 ) );
 312+ $format_percent->setAlign( 'left' );
313313 $format_percent->setNumFormat( $percent_num_format );
314 - $format_even = &$xls_workbook->addformat( array( 'fgcolor'=>0x2A, 'border'=>1 ) );
315 - $format_even->setAlign('left');
 314+ $format_even = &$xls_workbook->addformat( array( 'fgcolor' => 0x2A, 'border' => 1 ) );
 315+ $format_even->setAlign( 'left' );
316316 $format_even->setNumFormat( $percent_num_format );
317 - $format_odd = &$xls_workbook->addformat( array( 'fgcolor'=>0x23, 'border'=>1 ) );
318 - $format_odd->setAlign('left');
 317+ $format_odd = &$xls_workbook->addformat( array( 'fgcolor' => 0x23, 'border' => 1 ) );
 318+ $format_odd->setAlign( 'left' );
319319 $format_odd->setNumFormat( $percent_num_format );
320320 $first_question = true;
321321 foreach ( $pollStore->Questions as $qkey => &$qdata ) {
@@ -329,7 +329,7 @@
330330 $xls_worksheet->write( $xls_rownum++, 1, qp_Excel::prepareExcelString( $qdata->CommonQuestion ), $format_heading );
331331 if ( count( $qdata->CategorySpans ) > 0 ) {
332332 $row = array();
333 - foreach( $qdata->CategorySpans as &$span ) {
 333+ foreach ( $qdata->CategorySpans as &$span ) {
334334 $row[] = qp_Excel::prepareExcelString( $span[ "name" ] );
335335 for ( $i = 1; $i < $span[ "count" ]; $i++ ) {
336336 $row[] = "";
@@ -338,7 +338,7 @@
339339 $xls_worksheet->writerow( $xls_rownum++, 0, $row );
340340 }
341341 $row = array();
342 - foreach( $qdata->Categories as &$categ ) {
 342+ foreach ( $qdata->Categories as &$categ ) {
343343 $row[] = qp_Excel::prepareExcelString( $categ[ "name" ] );
344344 }
345345 $xls_worksheet->writerow( $xls_rownum++, 0, $row );
@@ -349,11 +349,11 @@
350350 */
351351 $percentsTable = Array();
352352 $spansUsed = count( $qdata->CategorySpans ) > 0 || $qdata->type == "multipleChoice";
353 - foreach( $qdata->ProposalText as $propkey => &$proposal_text ) {
 353+ foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) {
354354 if ( isset( $qdata->Percents[ $propkey ] ) ) {
355355 $row = $qdata->Percents[ $propkey ];
356356 foreach ( $row as $catkey => &$cell ) {
357 - $cell = array( 0=>$cell );
 357+ $cell = array( 0 => $cell );
358358 if ( $spansUsed ) {
359359 if ( $qdata->type == "multipleChoice" ) {
360360 $cell[ "format" ] = ( ( $catkey & 1 ) === 0 ) ? $format_even : $format_odd;
@@ -378,11 +378,11 @@
379379 $xls_workbook->close();
380380 header( 'Content-Type: application/x-msexcel; name="' . $poll_id . '.xls"' );
381381 header( 'Content-Disposition: inline; filename="' . $poll_id . '.xls"' );
382 - $fxls=@fopen( $xls_fname, "rb" );
 382+ $fxls = @fopen( $xls_fname, "rb" );
383383 @fpassthru( $fxls );
384384 @unlink( $xls_fname );
385385 exit();
386 - } catch( Exception $e ) {
 386+ } catch ( Exception $e ) {
387387 die( "Error while exporting poll statistics to Excel table\n" );
388388 }
389389 }
@@ -392,11 +392,11 @@
393393 private function displayQuestionStats( $pid, &$qdata ) {
394394 $current_title = $this->getTitle();
395395 $output = "<div class=\"qpoll\">\n" . "<table class=\"pollresults\">\n";
396 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->CategorySpans ), array( 'class'=>'spans' ), 'th', array( 'count'=>'colspan', 'name'=>0 ) );
397 - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->Categories ), '', 'th', array( 'name'=>0 ) );
 396+ $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->CategorySpans ), array( 'class' => 'spans' ), 'th', array( 'count' => 'colspan', 'name' => 0 ) );
 397+ $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $qdata->Categories ), '', 'th', array( 'name' => 0 ) );
398398 # multiple choice polls doesn't use real spans, instead, every column is like "span"
399399 $spansUsed = count( $qdata->CategorySpans ) > 0 || $qdata->type == "multipleChoice";
400 - foreach( $qdata->ProposalText as $propkey => &$proposal_text ) {
 400+ foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) {
401401 if ( isset( $qdata->Votes[ $propkey ] ) ) {
402402 if ( $qdata->Percents === null ) {
403403 $row = $qdata->Votes[ $propkey ];
@@ -405,12 +405,12 @@
406406 foreach ( $row as $catkey => &$cell ) {
407407 $formatted_cell = str_replace( " ", "&ensp;", sprintf( '%3d%%', intval( round( 100 * $cell ) ) ) );
408408 # only percents !=0 are displayed as link
409 - if ( $cell == 0.0 && $qdata->question_id !==null ) {
410 - $cell = array( 0=> $formatted_cell, "style"=>"color:gray" );
 409+ if ( $cell == 0.0 && $qdata->question_id !== null ) {
 410+ $cell = array( 0 => $formatted_cell, "style" => "color:gray" );
411411 } else {
412 - $cell = array( 0=>self::$skin->link( $current_title, $formatted_cell,
413 - array( "title"=>wfMsgExt( 'qp_votes_count', array( 'parsemag' ), $qdata->Votes[ $propkey ][ $catkey ] ) ),
414 - array( "action"=>"qpcusers", "id"=>$pid, "qid"=>$qdata->question_id, "pid"=>$propkey, "cid"=>$catkey ) ) );
 412+ $cell = array( 0 => self::$skin->link( $current_title, $formatted_cell,
 413+ array( "title" => wfMsgExt( 'qp_votes_count', array( 'parsemag' ), $qdata->Votes[ $propkey ][ $catkey ] ) ),
 414+ array( "action" => "qpcusers", "id" => $pid, "qid" => $qdata->question_id, "pid" => $propkey, "cid" => $catkey ) ) );
415415 }
416416 if ( $spansUsed ) {
417417 if ( $qdata->type == "multipleChoice" ) {
@@ -427,7 +427,7 @@
428428 # this proposal has no statistics (no votes)
429429 $row = array_fill( 0, count( $qdata->Categories ), '' );
430430 }
431 - $row[] = array( 0=>qp_Setup::entities( $proposal_text ), "style"=>"text-align:left;" );
 431+ $row[] = array( 0 => qp_Setup::entities( $proposal_text ), "style" => "text-align:left;" );
432432 $output .= qp_Renderer::displayRow( $row );
433433 }
434434 $output .= "</table>\n" . "</div>\n";
@@ -455,21 +455,21 @@
456456 }
457457 }
458458
459 - function doQuery( $offset, $limit, $shownavigation=true ) {
 459+ function doQuery( $offset, $limit, $shownavigation = true ) {
460460 global $wgUser, $wgOut, $wgLang, $wgContLang;
461461
462462 $res = $this->getIntervalResults( $offset, $limit );
463 - $num = count($res);
 463+ $num = count( $res );
464464
465465 $sk = $wgUser->getSkin();
466466 $sname = $this->getName();
467467
468 - if($shownavigation) {
 468+ if ( $shownavigation ) {
469469 $wgOut->addHTML( $this->getPageHeader() );
470470
471471 // if list is empty, display a warning
472 - if( $num == 0 ) {
473 - $wgOut->addHTML( '<p>' . wfMsgHTML('specialpage-empty') . '</p>' );
 472+ if ( $num == 0 ) {
 473+ $wgOut->addHTML( '<p>' . wfMsgHTML( 'specialpage-empty' ) . '</p>' );
474474 return;
475475 }
476476
@@ -489,7 +489,7 @@
490490 if ( ! $this->listoutput )
491491 $s[] = $this->openList( $offset );
492492
493 - foreach ($res as $r) {
 493+ foreach ( $res as $r ) {
494494 $format = $this->formatResult( $sk, $r );
495495 if ( $format ) {
496496 $s[] = $this->listoutput ? $format : "<li>{$format}</li>\n";
@@ -501,7 +501,7 @@
502502 $str = $this->listoutput ? $wgContLang->listToText( $s ) : implode( '', $s );
503503 $wgOut->addHTML( $str );
504504 }
505 - if($shownavigation) {
 505+ if ( $shownavigation ) {
506506 $wgOut->addHTML( "<p>{$sl}</p>\n" );
507507 }
508508 return $num;
@@ -532,10 +532,10 @@
533533 $this->cmd = $cmd;
534534 if ( $cmd == 'users' ) {
535535 $this->order_by = 'count(pid) DESC, name ASC ';
536 - $this->different_order_by_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_order_by_username' ), array(), array( "action"=>"users_a" ) );
 536+ $this->different_order_by_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_order_by_username' ), array(), array( "action" => "users_a" ) );
537537 } else {
538538 $this->order_by = 'name ';
539 - $this->different_order_by_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_order_by_polls_count' ), array(), array( "action"=>"users" ) );
 539+ $this->different_order_by_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_order_by_polls_count' ), array(), array( "action" => "users" ) );
540540 }
541541 }
542542
@@ -548,11 +548,11 @@
549549 array( 'qu.uid as uid', 'name as username', 'count(pid) as pidcount' ),
550550 'qu.uid=qup.uid',
551551 __METHOD__,
552 - array( 'GROUP BY'=>'qup.uid',
553 - 'ORDER BY'=>$this->order_by,
554 - 'OFFSET'=>intval( $offset ),
555 - 'LIMIT'=>intval( $limit ) ) );
556 - while( $row = $db->fetchObject( $res ) ) {
 552+ array( 'GROUP BY' => 'qup.uid',
 553+ 'ORDER BY' => $this->order_by,
 554+ 'OFFSET' => intval( $offset ),
 555+ 'LIMIT' => intval( $limit ) ) );
 556+ while ( $row = $db->fetchObject( $res ) ) {
557557 $result[] = $row;
558558 }
559559 return $result;
@@ -566,8 +566,8 @@
567567 $userName = $result->username;
568568 $userTitle = Title::makeTitleSafe( NS_USER, $userName );
569569 $user_link = self::$skin->link( $userTitle, $userName );
570 - $user_polls_link = self::$skin->link( $this->getTitle(), wfMsgExt( 'qp_user_polls_link', array( 'parsemag' ), $result->pidcount, $userName ) , array(), array( "uid"=>$uid, "action"=>"upolls" ) );
571 - $user_missing_polls_link = self::$skin->link( $this->getTitle(), wfMsgExt( 'qp_user_missing_polls_link', 'parsemag', $userName ) , array(), array( "uid"=>$uid, "action"=>"nupolls" ) );
 570+ $user_polls_link = self::$skin->link( $this->getTitle(), wfMsgExt( 'qp_user_polls_link', array( 'parsemag' ), $result->pidcount, $userName ) , array(), array( "uid" => $uid, "action" => "upolls" ) );
 571+ $user_missing_polls_link = self::$skin->link( $this->getTitle(), wfMsgExt( 'qp_user_missing_polls_link', 'parsemag', $userName ) , array(), array( "uid" => $uid, "action" => "nupolls" ) );
572572 $link = $user_link . ': ' . $user_polls_link . ', ' . $user_missing_polls_link;
573573 }
574574 return $link;
@@ -635,7 +635,7 @@
636636 $query .= "ORDER BY page_namespace, page_title, poll_id ";
637637 $query .= "LIMIT " . intval( $offset ) . ", " . intval( $limit );
638638 $res = $db->query( $query, __METHOD__ );
639 - while( $row = $db->fetchObject( $res ) ) {
 639+ while ( $row = $db->fetchObject( $res ) ) {
640640 $result[] = $row;
641641 }
642642 return $result;
@@ -647,7 +647,7 @@
648648 $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
649649 $pollname = qp_Setup::specialchars( $result->poll_id );
650650 $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) );
651 - $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ($this->inverse ? "_inv" : "") ), array(), array( "id"=>intval( $result->pid), "uid"=>$this->uid, "action"=>"uvote" ) );
 651+ $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ( $this->inverse ? "_inv" : "" ) ), array(), array( "id" => intval( $result->pid ), "uid" => $this->uid, "action" => "uvote" ) );
652652 $link = wfMsg( 'qp_results_line_qupl', $pagename, $pollname, $voice_link );
653653 return $link;
654654 }
@@ -673,10 +673,10 @@
674674 array( 'page_namespace as ns', 'page_title as title', 'pid', 'poll_id', 'order_id' ),
675675 'page_id=article_id',
676676 __METHOD__,
677 - array( 'ORDER BY'=>'page_namespace, page_title, order_id',
678 - 'OFFSET'=>intval( $offset ),
679 - 'LIMIT'=>intval( $limit ) ) );
680 - while( $row = $db->fetchObject( $res ) ) {
 677+ array( 'ORDER BY' => 'page_namespace, page_title, order_id',
 678+ 'OFFSET' => intval( $offset ),
 679+ 'LIMIT' => intval( $limit ) ) );
 680+ while ( $row = $db->fetchObject( $res ) ) {
681681 $result[] = $row;
682682 }
683683 return $result;
@@ -688,9 +688,9 @@
689689 $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
690690 $pollname = qp_Setup::specialchars( $result->poll_id );
691691 $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) );
692 - $voices_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_stats_link' ), array(), array( "id"=>intval( $result->pid), "action"=>"stats" ) );
693 - $users_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_users_link' ), array(), array( "id"=>intval( $result->pid), "action"=>"pulist" ) );
694 - $not_participated_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_not_participated_link' ), array(), array( "id"=>intval( $result->pid), "action"=>"npulist" ) );
 692+ $voices_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_stats_link' ), array(), array( "id" => intval( $result->pid ), "action" => "stats" ) );
 693+ $users_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_users_link' ), array(), array( "id" => intval( $result->pid ), "action" => "pulist" ) );
 694+ $not_participated_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_not_participated_link' ), array(), array( "id" => intval( $result->pid ), "action" => "npulist" ) );
695695 $link = wfMsg( 'qp_results_line_qpl', $pagename, $pollname, $goto_link, $voices_link, $users_link, $not_participated_link );
696696 return $link;
697697 }
@@ -729,10 +729,10 @@
730730 $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
731731 $pollname = qp_Setup::specialchars( $row->poll_id );
732732 $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) );
733 - $spec = wfMsg( 'qp_header_line_qpul', wfMsg( $this->inverse ? 'qp_not_participated_link' : 'qp_users_link'), $pagename, $pollname );
 733+ $spec = wfMsg( 'qp_header_line_qpul', wfMsg( $this->inverse ? 'qp_not_participated_link' : 'qp_users_link' ), $pagename, $pollname );
734734 $head[] = PollResults::getPollsLink();
735735 $head[] = PollResults::getUsersLink();
736 - $head[] = array( '__tag'=>'div', 'class'=>'head', 0=>$spec );
 736+ $head[] = array( '__tag' => 'div', 'class' => 'head', 0 => $spec );
737737 $head[] = ' (' . $goto_link . ')';
738738 $link = qp_Renderer::renderHTMLobject( $head );
739739 }
@@ -747,11 +747,11 @@
748748 $query = "SELECT uid, name as username ";
749749 $query .= "FROM $qp_users ";
750750 $query .= "WHERE uid " . ( $this->inverse ? "NOT " : "" ) . "IN ";
751 - $query .= "(SELECT uid FROM $qp_users_polls WHERE pid=" . $db->addQuotes($this->pid) . ") ";
 751+ $query .= "(SELECT uid FROM $qp_users_polls WHERE pid=" . $db->addQuotes( $this->pid ) . ") ";
752752 $query .= "ORDER BY uid ";
753753 $query .= "LIMIT " . intval( $offset ) . ", " . intval( $limit );
754754 $res = $db->query( $query, __METHOD__ );
755 - while( $row = $db->fetchObject( $res ) ) {
 755+ while ( $row = $db->fetchObject( $res ) ) {
756756 $result[] = $row;
757757 }
758758 return $result;
@@ -765,7 +765,7 @@
766766 $userName = $result->username;
767767 $userTitle = Title::makeTitleSafe( NS_USER, $userName );
768768 $user_link = self::$skin->link( $userTitle, $userName );
769 - $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ($this->inverse ? "_inv" : "") ), array(), array( "id"=>intval( $this->pid), "uid"=>$uid, "action"=>"uvote" ) );
 769+ $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ( $this->inverse ? "_inv" : "" ) ), array(), array( "id" => intval( $this->pid ), "uid" => $uid, "action" => "uvote" ) );
770770 $link = wfMsg( 'qp_results_line_qpul', $user_link, $voice_link );
771771 }
772772 return $link;
@@ -815,7 +815,7 @@
816816 $link = "";
817817 $db = & wfGetDB( DB_SLAVE );
818818 if ( $this->pid !== null ) {
819 - $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $this->pid ) );
 819+ $pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $this->pid ) );
820820 if ( $pollStore->pid !== null ) {
821821 $pollStore->loadQuestions();
822822 $poll_title = Title::makeTitle( intval( $this->ns ), $this->title, qp_AbstractPoll::getPollTitleFragment( $this->poll_id, '' ) );
@@ -825,7 +825,7 @@
826826 $spec = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname );
827827 $head[] = PollResults::getPollsLink();
828828 $head[] = PollResults::getUsersLink();
829 - $head[] = array( '__tag'=>'div', 'class'=>'head', 0=>$spec );
 829+ $head[] = array( '__tag' => 'div', 'class' => 'head', 0 => $spec );
830830 # 'parentheses' are unavailable in MW 1.14.x
831831 $head[] = wfMsg( 'qp_parentheses', $goto_link ) . '<br />';
832832 $ques_found = false;
@@ -849,7 +849,7 @@
850850 qp_Setup::entities( $ques->CommonQuestion ),
851851 qp_Setup::entities( $proptext ),
852852 qp_Setup::entities( $cat_name ) ) . '<br />';
853 - $head[] = array( '__tag'=>'div', 'class'=>'head', 'style'=>'padding-left:2em;', 0=>$qpa );
 853+ $head[] = array( '__tag' => 'div', 'class' => 'head', 'style' => 'padding-left:2em;', 0 => $qpa );
854854 $link = qp_Renderer::renderHTMLobject( $head );
855855 }
856856 }
@@ -869,7 +869,7 @@
870870 $query .= "WHERE pid=" . $db->addQuotes( $this->pid ) . " AND question_id=" . $db->addQuotes( $this->question_id ) . " AND proposal_id=" . $db->addQuotes( $this->proposal_id ) . " AND cat_id=" . $db->addQuotes( $this->cat_id ) . " ";
871871 $query .= "LIMIT " . intval( $offset ) . ", " . intval( $limit );
872872 $res = $db->query( $query, __METHOD__ );
873 - while( $row = $db->fetchObject( $res ) ) {
 873+ while ( $row = $db->fetchObject( $res ) ) {
874874 $result[] = $row;
875875 }
876876 return $result;
@@ -883,8 +883,8 @@
884884 $userName = $result->username;
885885 $userTitle = Title::makeTitleSafe( NS_USER, $userName );
886886 $user_link = self::$skin->link( $userTitle, $userName );
887 - $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ($this->inverse ? "_inv" : "" ) ), array(), array( "id"=>intval( $this->pid), "uid"=>$uid, "action"=>"uvote" ) );
888 - $text_answer = ($result->text_answer == '') ? '' : '<i>' . qp_Setup::entities( $result->text_answer ) . '</i>';
 887+ $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ( $this->inverse ? "_inv" : "" ) ), array(), array( "id" => intval( $this->pid ), "uid" => $uid, "action" => "uvote" ) );
 888+ $text_answer = ( $result->text_answer == '' ) ? '' : '<i>' . qp_Setup::entities( $result->text_answer ) . '</i>';
889889 $link = wfMsg( 'qp_results_line_qucl', $user_link, $voice_link, $text_answer );
890890 }
891891 return $link;
Index: trunk/extensions/QPoll/qp_pollstore.php
@@ -37,7 +37,7 @@
3838 $this->ProposalCategoryText = $argv[ 'proposal_category_text' ];
3939 break;
4040 case 'qid' :
41 - $this->question_id=$argv[ 'qid' ];
 41+ $this->question_id = $argv[ 'qid' ];
4242 $this->type = $argv[ 'type' ];
4343 $this->CommonQuestion = $argv[ 'common_question' ];
4444 $this->Categories = Array();
@@ -53,7 +53,7 @@
5454 // integrate spans into categories
5555 function packSpans() {
5656 if ( count( $this->CategorySpans ) > 0 ) {
57 - foreach( $this->Categories as &$Cat ) {
 57+ foreach ( $this->Categories as &$Cat ) {
5858 if ( array_key_exists( 'spanId', $Cat ) ) {
5959 $Cat['name'] = $this->CategorySpans[ $Cat['spanId'] ]['name'] . "\n" . $Cat['name'];
6060 unset( $Cat['spanId'] );
@@ -69,7 +69,7 @@
7070 if ( count( $this->CategorySpans ) == 0 ) {
7171 $prevSpanName = '';
7272 $spanId = -1;
73 - foreach( $this->Categories as &$Cat ) {
 73+ foreach ( $this->Categories as &$Cat ) {
7474 $a = explode( "\n", $Cat['name'] );
7575 if ( count( $a ) > 1 ) {
7676 if ( $prevSpanName != $a[0] ) {
@@ -133,14 +133,14 @@
134134 if ( self::$db == null ) {
135135 self::$db = & wfGetDB( DB_SLAVE );
136136 }
137 - if ( is_array($argv) && array_key_exists( "from", $argv ) ) {
 137+ if ( is_array( $argv ) && array_key_exists( "from", $argv ) ) {
138138 $this->Questions = Array();
139139 $this->mCompletedPostData = 'NA';
140140 $this->pid = null;
141141 $is_post = false;
142142 switch ( $argv[ 'from' ] ) {
143143 case 'poll_post' :
144 - $is_post= true;
 144+ $is_post = true;
145145 case 'poll_get' :
146146 if ( array_key_exists( 'title', $argv ) ) {
147147 $title = $argv[ 'title' ];
@@ -166,11 +166,11 @@
167167 if ( array_key_exists( 'pid', $argv ) ) {
168168 $pid = intval( $argv[ 'pid' ] );
169169 $res = self::$db->select( 'qp_poll_desc',
170 - array( 'article_id', 'poll_id','order_id', 'dependance' ),
171 - array( 'pid'=>$pid ),
 170+ array( 'article_id', 'poll_id', 'order_id', 'dependance' ),
 171+ array( 'pid' => $pid ),
172172 __METHOD__ . ":create from pid" );
173173 $row = self::$db->fetchObject( $res );
174 - if ( $row!=false ) {
 174+ if ( $row != false ) {
175175 $this->pid = $pid;
176176 $this->mArticleId = $row->article_id;
177177 $this->mPollId = $row->poll_id;
@@ -195,9 +195,9 @@
196196 $pollArticleId = intval( $pollTitle->getArticleID() );
197197 if ( $pollArticleId > 0 ) {
198198 return new qp_PollStore( array(
199 - 'from'=>'poll_get',
200 - 'title'=>$pollTitle,
201 - 'poll_id'=>$pollId ) );
 199+ 'from' => 'poll_get',
 200+ 'title' => $pollTitle,
 201+ 'poll_id' => $pollId ) );
202202 } else {
203203 return QP_ERROR_MISSED_TITLE;
204204 }
@@ -216,7 +216,7 @@
217217 # returns Title object, to get a URI path, use Title::getFullText()/getPrefixedText() on it
218218 function getTitle() {
219219 $res = null;
220 - if ( $this->mArticleId !==null && $this->mPollId !== null ) {
 220+ if ( $this->mArticleId !== null && $this->mPollId !== null ) {
221221 $res = Title::newFromID( $this->mArticleId );
222222 $res->setFragment( qp_AbstractPoll::getPollTitleFragment( $this->mPollId ) );
223223 }
@@ -226,7 +226,7 @@
227227 // warning: will work only after successful loadUserAlreadyVoted() or loadUserVote()
228228 function isAlreadyVoted() {
229229 if ( is_array( $this->Questions ) && count( $this->Questions > 0 ) ) {
230 - foreach( $this->Questions as &$qdata ) {
 230+ foreach ( $this->Questions as &$qdata ) {
231231 if ( $qdata->alreadyVoted )
232232 return true;
233233 }
@@ -245,14 +245,14 @@
246246 function loadQuestions() {
247247 $result = false;
248248 $typeFromVer0_5 = array(
249 - "singleChoicePoll"=>"singleChoice",
250 - "multipleChoicePoll"=>"multipleChoice",
251 - "mixedChoicePoll"=>"mixedChoice"
 249+ "singleChoicePoll" => "singleChoice",
 250+ "multipleChoicePoll" => "multipleChoice",
 251+ "mixedChoicePoll" => "mixedChoice"
252252 );
253253 if ( $this->pid !== null ) {
254254 $res = self::$db->select( 'qp_question_desc',
255255 array( 'question_id', 'type', 'common_question' ),
256 - array( 'pid'=>$this->pid ),
 256+ array( 'pid' => $this->pid ),
257257 __METHOD__ );
258258 if ( self::$db->numRows( $res ) > 0 ) {
259259 $result = true;
@@ -264,10 +264,10 @@
265265 }
266266 # create a qp_QuestionData object from DB fields
267267 $this->Questions[ $question_id ] = new qp_QuestionData( array(
268 - 'from'=>'qid',
269 - 'qid'=>$question_id,
270 - 'type'=>$row->type,
271 - 'common_question'=>$row->common_question ) );
 268+ 'from' => 'qid',
 269+ 'qid' => $question_id,
 270+ 'type' => $row->type,
 271+ 'common_question' => $row->common_question ) );
272272 }
273273 $this->getCategories();
274274 $this->getProposalText();
@@ -288,7 +288,7 @@
289289 }
290290 $res = self::$db->select( 'qp_question_answers',
291291 array( 'DISTINCT question_id' ),
292 - array( 'pid'=>$this->pid, 'uid'=>$this->last_uid ),
 292+ array( 'pid' => $this->pid, 'uid' => $this->last_uid ),
293293 __METHOD__ . ':load one user poll questions alreadyVoted values' );
294294 if ( self::$db->numRows( $res ) == 0 ) {
295295 return false;
@@ -314,7 +314,7 @@
315315 }
316316 $res = self::$db->select( 'qp_question_answers',
317317 array( 'question_id', 'proposal_id', 'cat_id', 'text_answer' ),
318 - array( 'pid'=>$this->pid, 'uid'=>$this->last_uid ),
 318+ array( 'pid' => $this->pid, 'uid' => $this->last_uid ),
319319 __METHOD__ . ':load one user single poll vote' );
320320 if ( self::$db->numRows( $res ) == 0 ) {
321321 return false;
@@ -341,7 +341,7 @@
342342 if ( is_array( $questions_set ) ) {
343343 $where .= ' AND question_id IN (';
344344 $first_elem = true;
345 - foreach( $questions_set as &$qid ) {
 345+ foreach ( $questions_set as &$qid ) {
346346 if ( $first_elem ) {
347347 $first_elem = false;
348348 } else {
@@ -379,7 +379,7 @@
380380 if ( $this->pid !== null ) {
381381 $res = self::$db->select( 'qp_question_answers',
382382 array( 'count(distinct uid)' ),
383 - array( 'pid'=>$this->pid, 'question_id'=>$qdata->question_id ),
 383+ array( 'pid' => $this->pid, 'question_id' => $qdata->question_id ),
384384 __METHOD__ );
385385 if ( $row = self::$db->fetchRow( $res ) ) {
386386 $result = intval( $row[ "count(distinct uid)" ] );
@@ -390,7 +390,7 @@
391391
392392 // try to calculate percents for every question where Votes[] are available
393393 function calculateStatistics() {
394 - foreach( $this->Questions as &$qdata ) {
 394+ foreach ( $this->Questions as &$qdata ) {
395395 $this->calculateQuestionStatistics( $qdata );
396396 }
397397 }
@@ -409,7 +409,7 @@
410410 } else {
411411 $votes_total = 0;
412412 }
413 - foreach( $qdata->Categories as $catkey => $cat ) {
 413+ foreach ( $qdata->Categories as $catkey => $cat ) {
414414 if ( isset( $votes_row[ $catkey ] ) ) {
415415 if ( $spansUsed ) {
416416 $row_totals[ intval( $cat[ "spanId" ] ) ] += $votes_row[ $catkey ];
@@ -421,7 +421,7 @@
422422 } else {
423423 $votes_total = $this->totalUsersAnsweredQuestion( $qdata );
424424 }
425 - foreach( $qdata->Categories as $catkey => $cat ) {
 425+ foreach ( $qdata->Categories as $catkey => $cat ) {
426426 $num_of_votes = '';
427427 if ( isset( $votes_row[ $catkey ] ) ) {
428428 $num_of_votes = $votes_row[ $catkey ];
@@ -441,7 +441,7 @@
442442 private function getCategories() {
443443 $res = self::$db->select( 'qp_question_categories',
444444 array( 'question_id', 'cat_id', 'cat_name' ),
445 - array( 'pid'=>$this->pid ),
 445+ array( 'pid' => $this->pid ),
446446 __METHOD__ );
447447 while ( $row = self::$db->fetchObject( $res ) ) {
448448 $question_id = intval( $row->question_id );
@@ -459,7 +459,7 @@
460460 private function getProposalText() {
461461 $res = self::$db->select( 'qp_question_proposals',
462462 array( 'question_id', 'proposal_id', 'proposal_text' ),
463 - array( 'pid'=>$this->pid ),
 463+ array( 'pid' => $this->pid ),
464464 __METHOD__ );
465465 while ( $row = self::$db->fetchObject( $res ) ) {
466466 $question_id = intval( $row->question_id );
@@ -499,11 +499,11 @@
500500
501501 function setLastUser( $username, $store_new_user_to_db = true ) {
502502 if ( $this->pid !== null ) {
503 - $res = self::$db->select( 'qp_users','uid','name=' . self::$db->addQuotes( $username ), __METHOD__ );
 503+ $res = self::$db->select( 'qp_users', 'uid', 'name=' . self::$db->addQuotes( $username ), __METHOD__ );
504504 $row = self::$db->fetchObject( $res );
505 - if ( $row==false ) {
 505+ if ( $row == false ) {
506506 if ( $store_new_user_to_db ) {
507 - self::$db->insert( 'qp_users', array( 'name'=>$username ), __METHOD__ . ':UpdateUser' );
 507+ self::$db->insert( 'qp_users', array( 'name' => $username ), __METHOD__ . ':UpdateUser' );
508508 $this->last_uid = self::$db->insertId();
509509 } else {
510510 $this->last_uid = null;
@@ -516,8 +516,8 @@
517517 }
518518
519519 function getUserName( $uid ) {
520 - if ( $uid !== null) {
521 - $res = self::$db->select( 'qp_users','name','uid=' . self::$db->addQuotes( intval( $uid ) ), __METHOD__ );
 520+ if ( $uid !== null ) {
 521+ $res = self::$db->select( 'qp_users', 'name', 'uid=' . self::$db->addQuotes( intval( $uid ) ), __METHOD__ );
522522 $row = self::$db->fetchObject( $res );
523523 if ( $row != false ) {
524524 return $row->name;
@@ -552,9 +552,9 @@
553553 'article_id=' . self::$db->addQuotes( $this->mArticleId ) . ' and ' .
554554 'poll_id=' . self::$db->addQuotes( $this->mPollId ) );
555555 $row = self::$db->fetchObject( $res );
556 - if ( $row==false ) {
 556+ if ( $row == false ) {
557557 self::$db->insert( 'qp_poll_desc',
558 - array( 'article_id'=>$this->mArticleId, 'poll_id'=>$this->mPollId, 'order_id'=>$this->mOrderId, 'dependance'=>$this->dependsOn ),
 558+ array( 'article_id' => $this->mArticleId, 'poll_id' => $this->mPollId, 'order_id' => $this->mOrderId, 'dependance' => $this->dependsOn ),
559559 __METHOD__ . ':update poll' );
560560 $this->pid = self::$db->insertId();
561561 } else {
@@ -568,16 +568,16 @@
569569 if ( $this->mOrderId != $row->order_id || $this->dependsOn != $row->dependance ) {
570570 $res = self::$db->replace( 'qp_poll_desc',
571571 '',
572 - array( 'pid'=>$this->pid, 'article_id'=>$this->mArticleId, 'poll_id'=>$this->mPollId, 'order_id'=>$this->mOrderId, 'dependance'=>$this->dependsOn ),
 572+ array( 'pid' => $this->pid, 'article_id' => $this->mArticleId, 'poll_id' => $this->mPollId, 'order_id' => $this->mOrderId, 'dependance' => $this->dependsOn ),
573573 __METHOD__ . ':poll attributes update'
574574 );
575575 }
576576 }
577 -
 577+
578578 private function setQuestionDesc() {
579579 $insert = array();
580580 foreach ( $this->Questions as $qkey => &$ques ) {
581 - $insert[] = array( 'pid'=>$this->pid, 'question_id'=>$qkey, 'type'=>$ques->type, 'common_question'=>$ques->CommonQuestion );
 581+ $insert[] = array( 'pid' => $this->pid, 'question_id' => $qkey, 'type' => $ques->type, 'common_question' => $ques->CommonQuestion );
582582 $ques->question_id = $qkey;
583583 }
584584 if ( count( $insert ) > 0 ) {
@@ -593,7 +593,7 @@
594594 foreach ( $this->Questions as $qkey => &$ques ) {
595595 $ques->packSpans();
596596 foreach ( $ques->Categories as $catkey => &$Cat ) {
597 - $insert[] = array( 'pid'=>$this->pid, 'question_id'=>$qkey, 'cat_id'=>$catkey, 'cat_name'=>$Cat["name"] );
 597+ $insert[] = array( 'pid' => $this->pid, 'question_id' => $qkey, 'cat_id' => $catkey, 'cat_name' => $Cat["name"] );
598598 }
599599 $ques->restoreSpans();
600600 }
@@ -608,8 +608,8 @@
609609 private function setProposals() {
610610 $insert = Array();
611611 foreach ( $this->Questions as $qkey => &$ques ) {
612 - foreach( $ques->ProposalText as $propkey => &$ptext ) {
613 - $insert[] = array( 'pid'=>$this->pid, 'question_id'=>$qkey, 'proposal_id'=>$propkey, 'proposal_text'=>$ptext );
 612+ foreach ( $ques->ProposalText as $propkey => &$ptext ) {
 613+ $insert[] = array( 'pid' => $this->pid, 'question_id' => $qkey, 'proposal_id' => $propkey, 'proposal_text' => $ptext );
614614 }
615615 }
616616 if ( count( $insert ) > 0 ) {
@@ -624,16 +624,16 @@
625625 private function setAnswers() {
626626 $insert = Array();
627627 foreach ( $this->Questions as $qkey => &$ques ) {
628 - foreach( $ques->ProposalCategoryId as $propkey => &$prop_answers ) {
629 - foreach( $prop_answers as $idkey => $catkey ) {
630 - $insert[] = array( 'uid'=>$this->last_uid, 'pid'=>$this->pid, 'question_id'=>$qkey, 'proposal_id'=>$propkey, 'cat_id'=>$catkey, 'text_answer'=>$ques->ProposalCategoryText[ $propkey ][ $idkey ] );
 628+ foreach ( $ques->ProposalCategoryId as $propkey => &$prop_answers ) {
 629+ foreach ( $prop_answers as $idkey => $catkey ) {
 630+ $insert[] = array( 'uid' => $this->last_uid, 'pid' => $this->pid, 'question_id' => $qkey, 'proposal_id' => $propkey, 'cat_id' => $catkey, 'text_answer' => $ques->ProposalCategoryText[ $propkey ][ $idkey ] );
631631 }
632632 }
633633 }
634634 # TODO: delete votes of all users, when the POST question header is incompatible with question header in DB ?
635635 # delete previous vote to make sure previous header of this poll was not incompatible with current vote
636636 self::$db->delete( 'qp_question_answers',
637 - array( 'uid'=>$this->last_uid, 'pid'=>$this->pid ),
 637+ array( 'uid' => $this->last_uid, 'pid' => $this->pid ),
638638 __METHOD__ . ':delete previous answers of current user to the same poll'
639639 );
640640 # vote
@@ -645,7 +645,7 @@
646646 __METHOD__ );
647647 self::$db->replace( 'qp_users_polls',
648648 '',
649 - array( 'uid'=>$this->last_uid, 'pid'=>$this->pid ),
 649+ array( 'uid' => $this->last_uid, 'pid' => $this->pid ),
650650 __METHOD__ );
651651 }
652652 ignore_user_abort( $old_user_abort );
@@ -653,7 +653,7 @@
654654
655655 # when the user votes and poll wasn't previousely voted yet, it also creates the poll in DB
656656 function setUserVote() {
657 - if ( $this->pid !==null &&
 657+ if ( $this->pid !== null &&
658658 $this->last_uid !== null &&
659659 $this->mCompletedPostData == "complete" &&
660660 is_array( $this->Questions ) && count( $this->Questions ) > 0 ) {
Index: trunk/extensions/QPoll/qp_question.php
@@ -55,7 +55,7 @@
5656
5757 /**
5858 * Mutator of the question state
59 - *
 59+ *
6060 * @protected
6161 * @param $pState - state of the question
6262 * @param $error_message - optional main_header_parsing error message
@@ -72,7 +72,7 @@
7373
7474 /**
7575 * Accessor of the question state.
76 - *
 76+ *
7777 * @protected
7878 */
7979 function getState() {
@@ -99,8 +99,8 @@
100100 # @return string : type of the question, empty when not defined
101101 function parseAttributes( $attr_str ) {
102102 global $qp_enable_showresults;
103 - $paramkeys = array( 't[yi]p[eo]'=>null, 'layout'=>null, 'textwidth'=>null, 'showresults'=>null );
104 - foreach( $paramkeys as $key=>&$val ) {
 103+ $paramkeys = array( 't[yi]p[eo]' => null, 'layout' => null, 'textwidth' => null, 'showresults' => null );
 104+ foreach ( $paramkeys as $key => &$val ) {
105105 preg_match( '`' . $key . '?="(.*?)"`u', $attr_str, $val );
106106 }
107107 $type = $paramkeys[ 't[yi]p[eo]' ];
@@ -109,20 +109,20 @@
110110 $textwidth = $paramkeys[ 'textwidth' ];
111111 $showresults = $paramkeys[ 'showresults' ];
112112 if ( count( $layout ) > 0 ) {
113 - $this->transposed = strpos( $layout[1], 'transpose' ) !== false;
114 - $this->proposalsFirst = strpos( $layout[1], 'proposals' ) !== false;
 113+ $this->transposed = strpos( $layout[1], 'transpose' ) !== false;
 114+ $this->proposalsFirst = strpos( $layout[1], 'proposals' ) !== false;
115115 }
116116 # setup question layout parameters
117117 if ( $this->transposed ) {
118118 $this->spanType = 'rowspan';
119119 $this->categoriesStyle = 'text-align:left; vertical-align:middle; ';
120 - $this->signClass = array( 'first'=>'signt', 'middle'=>'signm', 'last'=>'signb' );
 120+ $this->signClass = array( 'first' => 'signt', 'middle' => 'signm', 'last' => 'signb' );
121121 $this->proposalTextStyle = 'text-align:center; padding-left: 5px; padding-right: 5px; ';
122122 $this->proposalTextStyle .= ( $this->proposalsFirst ) ? ' vertical-align: bottom;' : 'vertical-align:top;';
123123 } else {
124124 $this->spanType = 'colspan';
125125 $this->categoriesStyle = '';
126 - $this->signClass = array( 'first'=>'signl', 'middle'=>'signc', 'last'=>'signr' );
 126+ $this->signClass = array( 'first' => 'signl', 'middle' => 'signc', 'last' => 'signr' );
127127 $this->proposalTextStyle = 'vertical-align:middle; ';
128128 $this->proposalTextStyle .= ( $this->proposalsFirst ) ? 'padding-right: 10px;' : 'padding-left: 10px;';
129129 }
@@ -137,7 +137,7 @@
138138 # use the value from the question
139139 $this->showResults = qp_AbstractPoll::parse_ShowResults( $showresults[1] );
140140 # apply undefined attributes from the poll's showresults definition
141 - foreach( $this->pollShowResults as $attr => $val ) {
 141+ foreach ( $this->pollShowResults as $attr => $val ) {
142142 if ( $attr != 'type' && !isset( $this->showResults[$attr] ) ) {
143143 $this->showResults[$attr] = $val;
144144 }
@@ -151,7 +151,7 @@
152152 # if needed to setup templates depending on question type
153153 # right now, cell templates depends only on input type and showresults type
154154 if ( $this->showResults['type'] != 0 ) {
155 - $this->{'cellTemplate' . $this->showResults['type']}();
 155+ $this-> { 'cellTemplate' . $this->showResults['type'] } ();
156156 }
157157 return $type;
158158 }
@@ -236,7 +236,7 @@
237237 $this->Percents = $qdata->Percents;
238238 } else {
239239 # no percents - no stats
240 - $this->showResults = Array( 'type'=>0 );
 240+ $this->showResults = Array( 'type' => 0 );
241241 }
242242 }
243243
@@ -257,14 +257,14 @@
258258 $row = Array();
259259 if ( $this->proposalsFirst ) {
260260 // add empty <th> at the begin of row to "compensate" proposal text
261 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 261+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
262262 }
263 - foreach( $this->mCategories as &$cat ) {
 263+ foreach ( $this->mCategories as &$cat ) {
264264 $row[] = $this->parser->recursiveTagParse( $cat['name'] );
265265 }
266266 if ( !$this->proposalsFirst ) {
267267 // add empty <th> at the end of row to "compensate" proposal text
268 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 268+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
269269 }
270270 return $row;
271271 }
@@ -275,14 +275,14 @@
276276 # real category spans have sense only for radiobuttons
277277 if ( $this->proposalsFirst ) {
278278 // add empty <th> at the begin of row to "compensate" proposal text
279 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 279+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
280280 }
281 - foreach( $this->mCategorySpans as &$span ) {
282 - $row[] = array( "count"=>$span['count'], 0=>$this->parser->recursiveTagParse( $span['name'] ) );
 281+ foreach ( $this->mCategorySpans as &$span ) {
 282+ $row[] = array( "count" => $span['count'], 0 => $this->parser->recursiveTagParse( $span['name'] ) );
283283 }
284284 if ( !$this->proposalsFirst ) {
285285 // add empty <th> at the end of row to "compensate" proposal text
286 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 286+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
287287 }
288288 }
289289 return $row;
@@ -300,18 +300,18 @@
301301 $this->categoriesStyle .= 'border:1px solid gray;';
302302 }
303303 if ( $this->categoriesStyle != '' ) {
304 - qp_Renderer::applyAttrsToRow( $spansRow, array( 'style'=>$this->categoriesStyle ) );
 304+ qp_Renderer::applyAttrsToRow( $spansRow, array( 'style' => $this->categoriesStyle ) );
305305 }
306 - $this->addRow( $spansRow, array( 'class'=>'spans'), 'th', array( 'count'=>$this->spanType, 'name'=>0 ) );
 306+ $this->addRow( $spansRow, array( 'class' => 'spans' ), 'th', array( 'count' => $this->spanType, 'name' => 0 ) );
307307 }
308308 if ( $this->categoriesStyle != '' ) {
309 - qp_Renderer::applyAttrsToRow( $catRow, array( 'style'=>$this->categoriesStyle ) );
 309+ qp_Renderer::applyAttrsToRow( $catRow, array( 'style' => $this->categoriesStyle ) );
310310 }
311 - $this->addRow( $catRow, array( 'class'=>'categories'), 'th', array( 'name'=>0 ) );
 311+ $this->addRow( $catRow, array( 'class' => 'categories' ), 'th', array( 'name' => 0 ) );
312312 foreach ( $this->mProposalText as $proposalId => $text ) {
313313 $row = Array();
314314 $rawClass = 'proposal';
315 - $spanState = (object) array( 'id'=>0, 'prevId'=>-1, 'wasChecked'=>true, 'isDrawing'=>false, 'cellsLeft'=>0, 'className'=>'sign' );
 315+ $spanState = (object) array( 'id' => 0, 'prevId' => -1, 'wasChecked' => true, 'isDrawing' => false, 'cellsLeft' => 0, 'className' => 'sign' );
316316 foreach ( $this->mCategories as $catId => $catDesc ) {
317317 $row[ $catId ] = Array();
318318 $spanState->className = 'sign';
@@ -324,12 +324,12 @@
325325 $row[ $catId ][ 'class' ] = $spanState->className;
326326 if ( $this->showResults['type'] != 0 ) {
327327 # there ars some stat in row (not necessarily all cells, because size of question table changes dynamically)
328 - $row[ $catId ][ 0 ] = $this->{'addShowResults' . $this->showResults['type']}( $proposalId, $catId );
 328+ $row[ $catId ][ 0 ] = $this-> { 'addShowResults' . $this->showResults['type'] } ( $proposalId, $catId );
329329 } else {
330330 $row[ $catId ][ 0 ] = '';
331331 }
332332 }
333 - $text = array( '__tag'=>'td', '__end'=>"\n", 'class'=>'proposaltext', 'style'=>$this->proposalTextStyle, 0=>$this->parser->recursiveTagParse( $text ) );
 333+ $text = array( '__tag' => 'td', '__end' => "\n", 'class' => 'proposaltext', 'style' => $this->proposalTextStyle, 0 => $this->parser->recursiveTagParse( $text ) );
334334 if ( $this->proposalsFirst ) {
335335 # first element is proposaltext
336336 array_unshift( $row, $text );
@@ -337,7 +337,7 @@
338338 # last element is proposaltext
339339 $row[] = $text;
340340 }
341 - $this->addRow( $row, array( 'class'=>$rawClass ), 'td' );
 341+ $this->addRow( $row, array( 'class' => $rawClass ), 'td' );
342342 }
343343 return qp_Renderer::renderHTMLobject( $this->mRenderTable );
344344 }
@@ -346,14 +346,14 @@
347347
348348 # cell templates for the selected showresults
349349 var $cellTemplate = Array();
350 - var $cellTemplateParam = Array( 'percents'=>'', 'bar1style'=>'', 'bar2style'=>'' );
 350+ var $cellTemplateParam = Array( 'percents' => '', 'bar1style' => '', 'bar2style' => '' );
351351
352352 # setup a template for showresults=1
353353 # showresults=1 cellTemplate has only one variant
354354 function cellTemplate1() {
355355 $this->cellTemplate =
356 - array(
357 - 0=>array( '__tag'=>'div', 'class'=>'stats', 0=>&$this->cellTemplateParam['percents'] )
 356+ array(
 357+ 0 => array( '__tag' => 'div', 'class' => 'stats', 0 => &$this->cellTemplateParam['percents'] )
358358 );
359359 if ( isset( $this->showResults['color'] ) ) {
360360 $this->cellTemplate[0]['style'] = 'color:' . $this->showResults['color'] . ';';
@@ -390,14 +390,14 @@
391391 }
392392 # has one available template ('bar')
393393 $this->cellTemplate = array(
394 - 'bar'=>array( '__tag'=>'div', 'class'=>'stats2',
395 - 0=>array( '__tag'=>'div', 'class'=>'bar1', 'style'=>&$this->cellTemplateParam['bar1style'], 0=>'&nbsp;' ),
396 - 1=>array( '__tag'=>'div', 'class'=>'bar2', 'style'=>&$this->cellTemplateParam['bar2style'], 0=>'&nbsp;' ),
397 - 2=>array( '__tag'=>'div', 'class'=>'bar3', 'style'=>$percentstyle, 0=>&$this->cellTemplateParam['percents'] )
 394+ 'bar' => array( '__tag' => 'div', 'class' => 'stats2',
 395+ 0 => array( '__tag' => 'div', 'class' => 'bar1', 'style' => &$this->cellTemplateParam['bar1style'], 0 => '&nbsp;' ),
 396+ 1 => array( '__tag' => 'div', 'class' => 'bar2', 'style' => &$this->cellTemplateParam['bar2style'], 0 => '&nbsp;' ),
 397+ 2 => array( '__tag' => 'div', 'class' => 'bar3', 'style' => $percentstyle, 0 => &$this->cellTemplateParam['percents'] )
398398 ),
399399 # the following entries are not real templates, but pre-calculated values of css attributes taken from showresults parameter
400 - 'bar1showres'=>'',
401 - 'bar2showres'=>''
 400+ 'bar1showres' => '',
 401+ 'bar2showres' => ''
402402 );
403403 # dynamical styles, width: in percents will be added during rendering in addShowResults
404404 if ( isset( $this->showResults['color'] ) ) {
@@ -416,7 +416,7 @@
417417 # there is a stat in cell
418418 $this->cellTemplateParam['percents'] = $percents . '%';
419419 $this->cellTemplateParam['bar1style'] = 'width:' . $percents . 'px;' . $this->cellTemplate[ 'bar1showres' ];
420 - $this->cellTemplateParam['bar2style'] = 'width:' . (100 - $percents) . 'px;' . $this->cellTemplate[ 'bar2showres' ];
 420+ $this->cellTemplateParam['bar2style'] = 'width:' . ( 100 - $percents ) . 'px;' . $this->cellTemplate[ 'bar2showres' ];
421421 return qp_Renderer::renderHTMLobject( $this->cellTemplate['bar'] );
422422 } else {
423423 return '';
@@ -449,7 +449,7 @@
450450 $this->Percents = $qdata->Percents;
451451 } else {
452452 # no percents - no stats
453 - $this->showResults = Array( 'type'=>0 );
 453+ $this->showResults = Array( 'type' => 0 );
454454 }
455455 }
456456
@@ -500,14 +500,14 @@
501501 function store( qp_PollStore &$pollStore ) {
502502 if ( $pollStore->pid !== null ) {
503503 $pollStore->Questions[ $this->mQuestionId ] = new qp_QuestionData( array(
504 - 'from'=>'postdata',
505 - 'type'=>$this->mType,
506 - 'common_question'=>$this->mCommonQuestion,
507 - 'categories'=>$this->mCategories,
508 - 'category_spans'=>$this->mCategorySpans,
509 - 'proposal_text'=>$this->mProposalText,
510 - 'proposal_category_id'=>$this->mProposalCategoryId,
511 - 'proposal_category_text'=>$this->mProposalCategoryText ) );
 504+ 'from' => 'postdata',
 505+ 'type' => $this->mType,
 506+ 'common_question' => $this->mCommonQuestion,
 507+ 'categories' => $this->mCategories,
 508+ 'category_spans' => $this->mCategorySpans,
 509+ 'proposal_text' => $this->mProposalText,
 510+ 'proposal_category_id' => $this->mProposalCategoryId,
 511+ 'proposal_category_text' => $this->mProposalCategoryText ) );
512512 }
513513 }
514514
@@ -556,10 +556,10 @@
557557 function parseBodyHeader( $input ) {
558558 $this->raws = preg_split( '`\n`su', $input, -1, PREG_SPLIT_NO_EMPTY );
559559 if ( array_key_exists( 1, $this->raws ) ) {
560 - $categorySpans = preg_match( $this->mCategoryPattern, $this->raws[1]."\n", $matches );
 560+ $categorySpans = preg_match( $this->mCategoryPattern, $this->raws[1] . "\n", $matches );
561561 }
562562 if ( !$categorySpans && array_key_exists( 0, $this->raws ) ) {
563 - preg_match( $this->mCategoryPattern, $this->raws[0]."\n", $matches );
 563+ preg_match( $this->mCategoryPattern, $this->raws[0] . "\n", $matches );
564564 }
565565 # parse the header - spans and categories
566566 $catString = isset( $matches[1] ) ? $matches[1] : '';
@@ -571,14 +571,14 @@
572572 $this->categoriesStyle .= 'border:1px solid gray;';
573573 }
574574 if ( $this->categoriesStyle != '' ) {
575 - qp_Renderer::applyAttrsToRow( $spansRow, array( 'style'=>$this->categoriesStyle ) );
 575+ qp_Renderer::applyAttrsToRow( $spansRow, array( 'style' => $this->categoriesStyle ) );
576576 }
577 - $this->addRow( $spansRow, array( 'class'=>'spans'), 'th', array( 'count'=>$this->spanType, 'name'=>0 ) );
 577+ $this->addRow( $spansRow, array( 'class' => 'spans' ), 'th', array( 'count' => $this->spanType, 'name' => 0 ) );
578578 }
579579 if ( $this->categoriesStyle != '' ) {
580 - qp_Renderer::applyAttrsToRow( $catRow, array( 'style'=>$this->categoriesStyle ) );
 580+ qp_Renderer::applyAttrsToRow( $catRow, array( 'style' => $this->categoriesStyle ) );
581581 }
582 - $this->addRow( $catRow, array( 'class'=>'categories'), 'th', array( 'name'=>0 ) );
 582+ $this->addRow( $catRow, array( 'class' => 'categories' ), 'th', array( 'name' => 0 ) );
583583 }
584584
585585 function singleChoiceParseBody() {
@@ -594,7 +594,7 @@
595595 function questionParseBody( $inputType ) {
596596 # Parameters used in some special cases.
597597 $proposalId = -1;
598 - foreach( $this->raws as $raw ) {
 598+ foreach ( $this->raws as $raw ) {
599599 if ( !preg_match( $this->mProposalPattern, $raw, $matches ) ) {
600600 continue;
601601 }
@@ -605,10 +605,10 @@
606606 $rawClass = 'proposal';
607607 $text = array_pop( $matches );
608608 $this->mProposalText[ $proposalId ] = trim( $text );
609 - $spanState = (object) array( 'id'=>0, 'prevId'=>-1, 'wasChecked'=>true, 'isDrawing'=>false, 'cellsLeft'=>0, 'className'=>'sign' );
 609+ $spanState = (object) array( 'id' => 0, 'prevId' => -1, 'wasChecked' => true, 'isDrawing' => false, 'cellsLeft' => 0, 'className' => 'sign' );
610610 foreach ( $this->mCategories as $catId => $catDesc ) {
611611 $row[ $catId ] = Array();
612 - $inp = Array( '__tag'=>'input' );
 612+ $inp = Array( '__tag' => 'input' );
613613 $spanState->className = 'sign';
614614 # Determine the input's name and value.
615615 switch( $this->mType ) {
@@ -623,9 +623,9 @@
624624 $this->renderSpan( $name, $catDesc, $text, $rawClass, $spanState );
625625 if ( $spanState->cellsLeft <= 1 ) {
626626 # end of new span
627 - if ( $this->mBeingCorrected &&
 627+ if ( $this->mBeingCorrected &&
628628 !$spanState->wasChecked &&
629 - $this->mRequest->getVal($name) != $value ) {
 629+ $this->mRequest->getVal( $name ) != $value ) {
630630 # the span (a part of proposal) was submitted but unanswered
631631 $text = $this->bodyErrorMessage( wfMsg( 'qp_error_unanswered_span' ), 'NA' ) . $text;
632632 # highlight current span to indicate an error
@@ -669,7 +669,7 @@
670670 if ( count( $this->mProposalText ) > count( $this->mCategories ) ) {
671671 # if there was no previous errors, hightlight the whole row
672672 if ( $this->getState() == '' ) {
673 - foreach( $row as &$cell ) {
 673+ foreach ( $row as &$cell ) {
674674 $cell[ 'style' ] = QP_CSS_ERROR_STYLE;
675675 }
676676 }
@@ -683,15 +683,15 @@
684684 $inp[ 'value' ] = $value;
685685 if ( $this->showResults['type'] != 0 ) {
686686 # there ars some stat in row (not necessarily all cells, because size of question table changes dynamically)
687 - $row[ $catId ][ 0 ] = $this->{'addShowResults' . $this->showResults['type']}( $inp, $proposalId, $catId );
 687+ $row[ $catId ][ 0 ] = $this-> { 'addShowResults' . $this->showResults['type'] } ( $inp, $proposalId, $catId );
688688 } else {
689689 $row[ $catId ][ 0 ] = $inp;
690690 }
691691 }
692692 # If the proposal text is empty, the question has a syntax error.
693 - if( trim( $text ) == '' ) {
 693+ if ( trim( $text ) == '' ) {
694694 $text = $this->bodyErrorMessage( wfMsg( 'qp_error_proposal_text_empty' ), 'error' );
695 - foreach( $row as &$cell ) {
 695+ foreach ( $row as &$cell ) {
696696 $cell[ 'style' ] = QP_CSS_ERROR_STYLE;
697697 }
698698 $rawClass = 'proposalerror';
@@ -700,7 +700,7 @@
701701 if ( $this->mBeingCorrected && !array_key_exists( $proposalId, $this->mProposalCategoryId ) ) {
702702 # if there was no previous errors, hightlight the whole row
703703 if ( $this->getState() == '' ) {
704 - foreach( $row as &$cell ) {
 704+ foreach ( $row as &$cell ) {
705705 $cell[ 'style' ] = QP_CSS_ERROR_STYLE;
706706 }
707707 }
@@ -708,7 +708,7 @@
709709 $rawClass = 'proposalerror';
710710 }
711711 if ( $text !== null ) {
712 - $text = array( '__tag'=>'td', '__end'=>"\n", 'class'=>'proposaltext', 'style'=>$this->proposalTextStyle, 0=>$this->parser->recursiveTagParse( $text ) );
 712+ $text = array( '__tag' => 'td', '__end' => "\n", 'class' => 'proposaltext', 'style' => $this->proposalTextStyle, 0 => $this->parser->recursiveTagParse( $text ) );
713713 if ( $this->proposalsFirst ) {
714714 # first element is proposaltext
715715 array_unshift( $row, $text );
@@ -716,7 +716,7 @@
717717 # last element is proposaltext
718718 $row[] = $text;
719719 }
720 - $this->addRow( $row, array( 'class'=>$rawClass ), 'td' );
 720+ $this->addRow( $row, array( 'class' => $rawClass ), 'td' );
721721 }
722722 }
723723 }
@@ -729,7 +729,7 @@
730730 }
731731 $this->mProposalPattern .= '(.*)`u';
732732 $proposalId = -1;
733 - foreach( $this->raws as $raw ) {
 733+ foreach ( $this->raws as $raw ) {
734734 # empty proposal text and row
735735 $text = null;
736736 $row = Array();
@@ -754,7 +754,7 @@
755755 foreach ( $this->mCategories as $catId => $catDesc ) {
756756 $typeId = $matches[ $catId ];
757757 $row[ $catId ] = Array();
758 - $inp = Array( '__tag'=>'input' );
 758+ $inp = Array( '__tag' => 'input' );
759759 # Determine the input's name and value.
760760 switch ( $typeId ) {
761761 case '<>':
@@ -819,15 +819,15 @@
820820 }
821821 if ( $this->showResults['type'] != 0 ) {
822822 # there ars some stat in row (not necessarily all cells, because size of question table changes dynamically)
823 - $row[ $catId ][ 0 ] = $this->{'addShowResults' . $this->showResults['type']}( $inp, $proposalId, $catId );
 823+ $row[ $catId ][ 0 ] = $this-> { 'addShowResults' . $this->showResults['type'] } ( $inp, $proposalId, $catId );
824824 } else {
825825 $row[ $catId ][ 0 ] = $inp;
826826 }
827827 }
828828 # If the proposal text is empty, the question has a syntax error.
829 - if( trim( $text ) == '' ) {
 829+ if ( trim( $text ) == '' ) {
830830 $text = $this->bodyErrorMessage( wfMsg( "qp_error_proposal_text_empty" ), "error" );
831 - foreach( $row as &$cell ) {
 831+ foreach ( $row as &$cell ) {
832832 $cell[ 'style' ] = QP_CSS_ERROR_STYLE;
833833 }
834834 $rawClass = 'proposalerror';
@@ -836,14 +836,14 @@
837837 if ( $this->mBeingCorrected && !array_key_exists( $proposalId, $this->mProposalCategoryId ) ) {
838838 # if there was no previous errors, hightlight the whole row
839839 if ( $this->getState() == '' ) {
840 - foreach( $row as &$cell ) {
 840+ foreach ( $row as &$cell ) {
841841 $cell[ 'style' ] = QP_CSS_ERROR_STYLE;
842842 }
843843 }
844844 $text = $this->bodyErrorMessage( wfMsg( 'qp_error_no_answer' ), 'NA' ) . $text;
845845 $rawClass = 'proposalerror';
846846 }
847 - $text = array( '__tag'=>'td', '__end'=>"\n", 'class'=>'proposaltext', 'style'=>$this->proposalTextStyle, 0=>$this->parser->recursiveTagParse( $text ) );
 847+ $text = array( '__tag' => 'td', '__end' => "\n", 'class' => 'proposaltext', 'style' => $this->proposalTextStyle, 0 => $this->parser->recursiveTagParse( $text ) );
848848 if ( $this->proposalsFirst ) {
849849 # first element is proposaltext
850850 array_unshift( $row, $text );
@@ -851,21 +851,21 @@
852852 # last element is proposaltext
853853 $row[] = $text;
854854 }
855 - $this->addRow( $row, array( 'class'=>$rawClass ), 'td' );
 855+ $this->addRow( $row, array( 'class' => $rawClass ), 'td' );
856856 }
857857 return qp_Renderer::renderHTMLobject( $this->mRenderTable );
858858 }
859859
860860 /**
861861 * build internal & visual representation of question categories
862 - *
 862+ *
863863 * @param $input the raw source of categories
864864 */
865865 function parseCategories( $input ) {
866866 $row = Array();
867867 if ( $this->proposalsFirst ) {
868868 // add empty <th> at the begin of row to "compensate" proposal text
869 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 869+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
870870 }
871871 # build "raw" categories array
872872 # split tokens
@@ -873,8 +873,8 @@
874874 $matching_braces = Array();
875875 $curr_elem = '';
876876 $categories = Array();
877 - foreach( $cat_split as $part ) {
878 - switch ($part) {
 877+ foreach ( $cat_split as $part ) {
 878+ switch ( $part ) {
879879 case '|' :
880880 if ( count( $matching_braces ) == 0 ) {
881881 # delimeters are working only when braces are completely closed
@@ -912,29 +912,29 @@
913913 if ( !array_key_exists( 1, $categories ) ) {
914914 $categories[0] .= $this->bodyErrorMessage( wfMsg( "qp_error_too_few_categories" ), "error" );
915915 }
916 - foreach( $categories as $catkey => $category ) {
 916+ foreach ( $categories as $catkey => $category ) {
917917 $category = trim( $category );
918918 # If a category name is empty, the question has a syntax error.
919 - if( $category == "") {
 919+ if ( $category == "" ) {
920920 $category = $this->bodyErrorMessage( wfMsg( "qp_error_category_name_empty" ), "error" );
921921 }
922922 $this->mCategories[ $catkey ]["name"] = $category;
923923 $row[] = $this->parser->recursiveTagParse( $category );
924924 }
925 -
 925+
926926 # cut unused categories rows which are presented in DB but were removed from article
927927 $this->mCategories = array_slice( $this->mCategories, 0, count( $categories ) );
928928 if ( !$this->proposalsFirst ) {
929929 // add empty <th> at the end of row to "compensate" proposal text
930 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 930+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
931931 }
932932 return $row;
933933 }
934 -
 934+
935935 /**
936936 * build internal & visual representation of question category spans
937937 * ( also known as metacategories or "category groups" )
938 - *
 938+ *
939939 * @param $input the raw source of category spans
940940 */
941941 # warning: parseCategorySpans() should be called after parseCategories()
@@ -952,7 +952,7 @@
953953 array_shift( $span_split );
954954 if ( isset( $span_split[0] ) && in_array( $span_split[0], array( '!', '|' ) ) ) {
955955 $delim = $span_split[0];
956 - foreach( $span_split as $part ) {
 956+ foreach ( $span_split as $part ) {
957957 if ( $part == $delim ) {
958958 if ( count( $matching_braces ) == 0 ) {
959959 # delimeters are working only when braces are completely closed
@@ -996,13 +996,13 @@
997997 }
998998 # analyze previousely build "raw" spans array
999999 # Less than one span is a syntax error.
1000 - if(!array_key_exists(0, $spans)) {
 1000+ if ( !array_key_exists( 0, $spans ) ) {
10011001 return $this->bodyErrorMessage( wfMsg( "qp_error_too_few_spans" ), "error" );
10021002 }
10031003 # fill undefined spans with the last span value
10041004 $SpanCategDelta = count( $this->mCategories ) - count( $spans[0] );
10051005 $lastDefinedSpanKey = array_pop( array_diff( array_keys( $spans[1] ), array_keys( $spans[1], "", true ) ) );
1006 - if ($lastDefinedSpanKey !== null) {
 1006+ if ( $lastDefinedSpanKey !== null ) {
10071007 if ( $SpanCategDelta > 0 ) {
10081008 # increase the length of last defined span value to match total lenth of categories
10091009 $lastSpanType = $spans[0][$lastDefinedSpanKey];
@@ -1014,32 +1014,32 @@
10151015 array_slice( $spans[1], $lastDefinedSpanKey ) );
10161016 } elseif ( $SpanCategDelta < 0 ) {
10171017 # cut unused but defined extra spans
1018 - $spans[0] = array_slice( $spans[0], count( $this->mCategories ), -$SpanCategDelta );
1019 - $spans[1] = array_slice( $spans[1], count( $this->mCategories ), -$SpanCategDelta );
 1018+ $spans[0] = array_slice( $spans[0], count( $this->mCategories ), - $SpanCategDelta );
 1019+ $spans[1] = array_slice( $spans[1], count( $this->mCategories ), - $SpanCategDelta );
10201020 }
10211021 } else {
10221022 # no valid category spans are defined
1023 - return $this->bodyErrorMessage( wfMsg( 'qp_error_too_few_spans' ), 'error' );
 1023+ return $this->bodyErrorMessage( wfMsg( 'qp_error_too_few_spans' ), 'error' );
10241024 }
10251025 # populate mCategorySpans and row
10261026 if ( $this->proposalsFirst ) {
10271027 // add empty <th> at the begin of row to "compensate" proposal text
1028 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 1028+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
10291029 }
10301030 $colspanBase = ( $lastDefinedSpanKey == 0 ) ? 1 : 0;
10311031 $colspan = 1;
10321032 $categorySpanId = 0;
1033 - foreach($spans[0] as $spanKey => $spanType) {
 1033+ foreach ( $spans[0] as $spanKey => $spanType ) {
10341034 $spanCategory = trim( $spans[1][$spanKey] );
1035 - if ( $spanCategory=="" ) {
 1035+ if ( $spanCategory == "" ) {
10361036 $colspan++;
10371037 } else {
1038 - $row[] = array( "count"=>$colspan + $colspanBase, 0=>$this->parser->recursiveTagParse( $spanCategory ) );
1039 - if ( $spanType == "|") { // "!" is a comment header, not a real category span
 1038+ $row[] = array( "count" => $colspan + $colspanBase, 0 => $this->parser->recursiveTagParse( $spanCategory ) );
 1039+ if ( $spanType == "|" ) { // "!" is a comment header, not a real category span
10401040 $this->mCategorySpans[ $categorySpanId ]['name'] = $spanCategory;
10411041 $this->mCategorySpans[ $categorySpanId ]['count'] = $colspan;
10421042 for ( $i = $spanKey;
1043 - $i >=0 && array_key_exists( $i, $this->mCategories ) && !array_key_exists( 'spanId', $this->mCategories[ $i ] );
 1043+ $i >= 0 && array_key_exists( $i, $this->mCategories ) && !array_key_exists( 'spanId', $this->mCategories[ $i ] );
10441044 $i-- ) {
10451045 $this->mCategories[$i]['spanId'] = $categorySpanId;
10461046 }
@@ -1050,14 +1050,14 @@
10511051 }
10521052 if ( !$this->proposalsFirst ) {
10531053 // add empty <th> at the end of row to "compensate" proposal text
1054 - $row[] = array( '__tag'=>'td', 0=>"", 'style'=>'border:none;', '__end'=>"\n" );
 1054+ $row[] = array( '__tag' => 'td', 0 => "", 'style' => 'border:none;', '__end' => "\n" );
10551055 }
10561056 }
10571057 return $row;
10581058 }
10591059
10601060 function isUniqueProposalCategoryId( $proposalId, $catId ) {
1061 - foreach( $this->mProposalCategoryId as $proposalCategoryId ) {
 1061+ foreach ( $this->mProposalCategoryId as $proposalCategoryId ) {
10621062 if ( in_array( $catId, $proposalCategoryId ) ) {
10631063 return false;
10641064 }
@@ -1069,15 +1069,15 @@
10701070
10711071 # cell templates for the selected showresults
10721072 var $cellTemplate = Array();
1073 - var $cellTemplateParam = Array( 'inp'=>'', 'percents'=>'', 'bar1style'=>'', 'bar2style'=>'' );
 1073+ var $cellTemplateParam = Array( 'inp' => '', 'percents' => '', 'bar1style' => '', 'bar2style' => '' );
10741074
10751075 # setup a template for showresults=1
10761076 # showresults=1 cellTemplate has only one variant
10771077 function cellTemplate1() {
10781078 $this->cellTemplate =
1079 - array(
1080 - 0=>array( '__tag'=>'div', 0=>&$this->cellTemplateParam['inp'] ),
1081 - 1=>array( '__tag'=>'div', 'class'=>'stats', 0=>&$this->cellTemplateParam['percents'] )
 1079+ array(
 1080+ 0 => array( '__tag' => 'div', 0 => &$this->cellTemplateParam['inp'] ),
 1081+ 1 => array( '__tag' => 'div', 'class' => 'stats', 0 => &$this->cellTemplateParam['percents'] )
10821082 );
10831083 if ( isset( $this->showResults['color'] ) ) {
10841084 $this->cellTemplate[1]['style'] = 'color:' . $this->showResults['color'] . ';';
@@ -1114,34 +1114,34 @@
11151115 $percentstyle .= 'background:' . $this->showResults['textbackground'] . ';';
11161116 }
11171117 # html arrays used in templates below
1118 - $bar = array( '__tag'=>'div', 'class'=>'stats1',
1119 - 0=>array( '__tag'=>'div', 'class'=>'bar0', 0=>&$this->cellTemplateParam['inp'] ),
1120 - 1=>array( '__tag'=>'div', 'class'=>'bar1', 'style'=>&$this->cellTemplateParam['bar1style'], 0=>'&nbsp;' ),
1121 - 2=>array( '__tag'=>'div', 'class'=>'bar2', 'style'=>&$this->cellTemplateParam['bar2style'], 0=>'&nbsp;' ),
1122 - 3=>array( '__tag'=>'div', 'class'=>'bar0', 'style'=>$percentstyle, 0=>&$this->cellTemplateParam['percents'] )
 1118+ $bar = array( '__tag' => 'div', 'class' => 'stats1',
 1119+ 0 => array( '__tag' => 'div', 'class' => 'bar0', 0 => &$this->cellTemplateParam['inp'] ),
 1120+ 1 => array( '__tag' => 'div', 'class' => 'bar1', 'style' => &$this->cellTemplateParam['bar1style'], 0 => '&nbsp;' ),
 1121+ 2 => array( '__tag' => 'div', 'class' => 'bar2', 'style' => &$this->cellTemplateParam['bar2style'], 0 => '&nbsp;' ),
 1122+ 3 => array( '__tag' => 'div', 'class' => 'bar0', 'style' => $percentstyle, 0 => &$this->cellTemplateParam['percents'] )
11231123 );
1124 - $bar2 = array( '__tag'=>'div', 'class'=>'stats1',
1125 - 0=>array( '__tag'=>'div', 'class'=>'bar0', 0=>'&nbsp;' ),
1126 - 1=>&$bar[1],
1127 - 2=>&$bar[2],
1128 - 3=>&$bar[3]
 1124+ $bar2 = array( '__tag' => 'div', 'class' => 'stats1',
 1125+ 0 => array( '__tag' => 'div', 'class' => 'bar0', 0 => '&nbsp;' ),
 1126+ 1 => &$bar[1],
 1127+ 2 => &$bar[2],
 1128+ 3 => &$bar[3]
11291129 );
11301130 # has two available templates ('bar','textinput')
11311131 $this->cellTemplate = array(
1132 - 'bar'=>$bar,
1133 - 'textinput'=>array( '__tag'=>'table', 'class'=>'stats',
1134 - 0=>array( '__tag'=>'tr',
1135 - 0=>array( '__tag'=>'td', 0=>&$this->cellTemplateParam['inp'] ),
 1132+ 'bar' => $bar,
 1133+ 'textinput' => array( '__tag' => 'table', 'class' => 'stats',
 1134+ 0 => array( '__tag' => 'tr',
 1135+ 0 => array( '__tag' => 'td', 0 => &$this->cellTemplateParam['inp'] ),
11361136 ),
1137 - 1=>array( '__tag'=>'tr',
1138 - 0=>array( '__tag'=>'td',
1139 - 0=>$bar2
 1137+ 1 => array( '__tag' => 'tr',
 1138+ 0 => array( '__tag' => 'td',
 1139+ 0 => $bar2
11401140 )
11411141 )
11421142 ),
11431143 # the following entries are not real templates, but pre-calculated values of css attributes taken from showresults parameter
1144 - 'bar1showres'=>'',
1145 - 'bar2showres'=>''
 1144+ 'bar1showres' => '',
 1145+ 'bar2showres' => ''
11461146 );
11471147 # dynamical styles, width: in percents will be added during rendering in addShowResults
11481148 if ( isset( $this->showResults['color'] ) ) {
@@ -1161,7 +1161,7 @@
11621162 # there is a stat in cell
11631163 $this->cellTemplateParam['percents'] = $percents . '%';
11641164 $this->cellTemplateParam['bar1style'] = 'width:' . $percents . 'px;' . $this->cellTemplate[ 'bar1showres' ];
1165 - $this->cellTemplateParam['bar2style'] = 'width:' . (100 - $percents) . 'px;' . $this->cellTemplate[ 'bar2showres' ];
 1165+ $this->cellTemplateParam['bar2style'] = 'width:' . ( 100 - $percents ) . 'px;' . $this->cellTemplate[ 'bar2showres' ];
11661166 if ( $inp['type'] == 'text' ) {
11671167 return qp_Renderer::renderHTMLobject( $this->cellTemplate['textinput'] );
11681168 } else {

Status & tagging log