Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * it under the terms of the GNU General Public License as published by |
10 | 10 | * the Free Software Foundation; either version 2 of the License, or |
11 | 11 | * (at your option) any later version. |
12 | | - * |
| 12 | + * |
13 | 13 | * QPoll is distributed in the hope that it will be useful, |
14 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
— | — | @@ -21,13 +21,13 @@ |
22 | 22 | * ***** END LICENSE BLOCK ***** |
23 | 23 | * |
24 | 24 | * QPoll is a poll tool for MediaWiki. |
25 | | - * |
| 25 | + * |
26 | 26 | * To activate this extension : |
27 | 27 | * * Create a new directory named QPoll into the directory "extensions" of MediaWiki. |
28 | 28 | * * Place the files from the extension archive there. |
29 | 29 | * * Add this line at the end of your LocalSettings.php file : |
30 | 30 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
31 | | - * |
| 31 | + * |
32 | 32 | * @version 0.6.4 |
33 | 33 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
34 | 34 | * @author QuestPC <questpc@rambler.ru> |
— | — | @@ -88,19 +88,19 @@ |
89 | 89 | |
90 | 90 | static function coreRequirements() { |
91 | 91 | $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' ) |
105 | 105 | ); |
106 | 106 | foreach ( $required_classes_and_methods as &$check ) { |
107 | 107 | list( $object, $method ) = each( $check ); |
— | — | @@ -124,10 +124,10 @@ |
125 | 125 | global $wgSpecialPages; |
126 | 126 | global $wgHooks; |
127 | 127 | self::coreRequirements(); |
128 | | - self::$ExtDir = str_replace( "\\", "/", dirname(__FILE__) ); |
| 128 | + self::$ExtDir = str_replace( "\\", "/", dirname( __FILE__ ) ); |
129 | 129 | $dirs = explode( '/', self::$ExtDir ); |
130 | 130 | $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 ); |
132 | 132 | $wgExtensionMessagesFiles['QPoll'] = self::$ExtDir . '/qp_i18n.php'; |
133 | 133 | $wgAutoloadClasses['PollResults'] = self::$ExtDir . '/qp_results.php'; |
134 | 134 | $wgAutoloadClasses['qp_Question'] = self::$ExtDir . '/qp_question.php'; |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | $wgAutoloadClasses['qp_QuestionData'] = self::$ExtDir . '/qp_pollstore.php'; |
138 | 138 | $wgAutoloadClasses['qp_QueryPage'] = self::$ExtDir . '/qp_results.php'; |
139 | 139 | // TODO: Use the new technique for i18n of special page aliases |
140 | | - $wgSpecialPages['PollResults'] = array('PollResults'); |
| 140 | + $wgSpecialPages['PollResults'] = array( 'PollResults' ); |
141 | 141 | // TODO: Use the new technique for i18n of magic words |
142 | 142 | $wgHooks['LanguageGetMagic'][] = 'qp_Setup::languageGetMagic'; |
143 | 143 | $wgHooks['MediaWikiPerformAction'][] = 'qp_Setup::mediaWikiPerformAction'; |
— | — | @@ -147,14 +147,14 @@ |
148 | 148 | static function loadMessages() { |
149 | 149 | if ( !self::$messagesLoaded ) { |
150 | 150 | self::$messagesLoaded = true; |
151 | | - wfLoadExtensionMessages('QPoll'); |
| 151 | + wfLoadExtensionMessages( 'QPoll' ); |
152 | 152 | } |
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | |
156 | 156 | static function ParserFunctionsWords( $lang ) { |
157 | 157 | $words = array(); |
158 | | - $words[ 'en' ] = array( 'qpuserchoice'=>array( 0, 'qpuserchoice' ) ); |
| 158 | + $words[ 'en' ] = array( 'qpuserchoice' => array( 0, 'qpuserchoice' ) ); |
159 | 159 | # English is used as a fallback, and the English synonyms are |
160 | 160 | # used if a translation has not been provided for a given word |
161 | 161 | return ( $lang == 'en' || !array_key_exists( $lang, $words ) ) |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | } |
165 | 165 | |
166 | 166 | static function languageGetMagic( &$magicWords, $langCode ) { |
167 | | - foreach( self::ParserFunctionsWords( $langCode ) as $word => $trans ) |
| 167 | + foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans ) |
168 | 168 | $magicWords [$word ] = $trans; |
169 | 169 | return true; |
170 | 170 | } |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | $parserCache->mMemc->delete( $key ); |
176 | 176 | self::$article->doPurge(); |
177 | 177 | } |
178 | | - |
| 178 | + |
179 | 179 | static function mediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki ) { |
180 | 180 | global $wgCookiePrefix; |
181 | 181 | global $qp_enable_showresults; |
— | — | @@ -195,10 +195,10 @@ |
196 | 196 | } else { |
197 | 197 | $qp_enable_showresults = 0; |
198 | 198 | } |
199 | | - if ( isset( $_COOKIE[$wgCookiePrefix.'QPoll'] ) ) { |
| 199 | + if ( isset( $_COOKIE[$wgCookiePrefix . 'QPoll'] ) ) { |
200 | 200 | $request->response()->setCookie( 'QPoll', '', time() - 86400 ); // clear cookie |
201 | 201 | self::clearCache(); |
202 | | - } elseif ( $request->getVal('pollId') !== null ) { |
| 202 | + } elseif ( $request->getVal( 'pollId' ) !== null ) { |
203 | 203 | self::clearCache(); |
204 | 204 | } |
205 | 205 | return true; |
— | — | @@ -224,7 +224,7 @@ |
225 | 225 | $wgOut->addExtensionStyle( self::$ScriptPath . '/qp_user_rtl.css' ); |
226 | 226 | } |
227 | 227 | # setup tag hook |
228 | | - $wgParser->setHook("qpoll", "qp_Setup::renderPoll"); |
| 228 | + $wgParser->setHook( "qpoll", "qp_Setup::renderPoll" ); |
229 | 229 | $wgQPollFunctionsHook = new qp_FunctionsHook(); |
230 | 230 | # setup function hook |
231 | 231 | $wgParser->setFunctionHook( 'qpuserchoice', array( &$wgQPollFunctionsHook, 'qpuserchoice' ), SFH_OBJECT_ARGS ); |
— | — | @@ -233,11 +233,11 @@ |
234 | 234 | |
235 | 235 | /** |
236 | 236 | * Call the poll parser on an input text. |
237 | | - * |
| 237 | + * |
238 | 238 | * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. |
239 | 239 | * @param $argv An array containing any arguments passed to the extension |
240 | 240 | * @param &$parser The wikitext parser. |
241 | | - * |
| 241 | + * |
242 | 242 | * @return An HTML poll. |
243 | 243 | */ |
244 | 244 | |
— | — | @@ -284,14 +284,14 @@ |
285 | 285 | # the following showresults types are currently available: |
286 | 286 | # 0 - none; 1 - percents; 2 - bars |
287 | 287 | # 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 |
289 | 289 | |
290 | 290 | // qp_pollStore instance that will be used to transfer poll data from/to DB |
291 | 291 | var $pollStore = null; |
292 | 292 | |
293 | | - /** |
| 293 | + /** |
294 | 294 | * Constructor |
295 | | - * |
| 295 | + * |
296 | 296 | * @public |
297 | 297 | */ |
298 | 298 | function __construct( $argv, &$parser ) { |
— | — | @@ -325,24 +325,24 @@ |
326 | 326 | # every poll on the page should have unique poll id, to minimize the risk of collisions |
327 | 327 | # it is required to be set manually via id="value" parameter |
328 | 328 | # ( 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 ) ) { |
331 | 331 | $this->dependsOn = trim( $argv['dependance'] ); |
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
336 | 336 | * Convert the input text to an HTML output. |
337 | | - * |
| 337 | + * |
338 | 338 | * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. |
339 | 339 | */ |
340 | 340 | function parsePoll( $input ) { |
341 | | - if ( ($result = $this->getPollStore() ) !== true ) { |
| 341 | + if ( ( $result = $this->getPollStore() ) !== true ) { |
342 | 342 | # error message box (invalid poll attributes) |
343 | 343 | return $result; |
344 | 344 | } |
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 |
347 | 347 | return ''; |
348 | 348 | } else { |
349 | 349 | # generateOutput() assumes that the poll is not being submitted and is correctly declared |
— | — | @@ -370,7 +370,7 @@ |
371 | 371 | |
372 | 372 | function isValidPollId( $pollId ) { |
373 | 373 | // more non-allowed chars ? |
374 | | - return !preg_match('`#`u', $pollId ); |
| 374 | + return !preg_match( '`#`u', $pollId ); |
375 | 375 | } |
376 | 376 | |
377 | 377 | function isUniquePollId( $pollId ) { |
— | — | @@ -380,17 +380,17 @@ |
381 | 381 | static function loadMessages() { |
382 | 382 | if ( !self::$messagesLoaded ) { |
383 | 383 | self::$messagesLoaded = true; |
384 | | - wfLoadExtensionMessages('QPoll'); |
| 384 | + wfLoadExtensionMessages( 'QPoll' ); |
385 | 385 | } |
386 | 386 | return true; |
387 | | - } |
| 387 | + } |
388 | 388 | |
389 | 389 | static function currentUserName() { |
390 | 390 | global $qp_AnonForwardedFor; |
391 | 391 | global $wgUser, $wgSquidServers; |
392 | 392 | global $wgUsePrivateIPs; |
393 | 393 | if ( $qp_AnonForwardedFor === true && $wgUser->isAnon() ) { |
394 | | - /* collect the originating IPs |
| 394 | + /* collect the originating IPs |
395 | 395 | borrowed from ProxyTools::wfGetIP |
396 | 396 | bypass trusted proxies list check */ |
397 | 397 | # Client connecting to this webserver |
— | — | @@ -411,7 +411,7 @@ |
412 | 412 | } |
413 | 413 | $username = ""; |
414 | 414 | foreach ( $ipchain as $i => $curIP ) { |
415 | | - if( $wgUsePrivateIPs || IP::isPublic( $curIP ) ) { |
| 415 | + if ( $wgUsePrivateIPs || IP::isPublic( $curIP ) ) { |
416 | 416 | $username .= IP::canonicalize( $curIP ) . '/'; |
417 | 417 | } |
418 | 418 | } |
— | — | @@ -448,7 +448,7 @@ |
449 | 449 | } else { |
450 | 450 | return false; |
451 | 451 | } |
452 | | - } |
| 452 | + } |
453 | 453 | if ( $pollIdPart == '' ) { |
454 | 454 | return false; |
455 | 455 | } |
— | — | @@ -460,7 +460,7 @@ |
461 | 461 | } |
462 | 462 | |
463 | 463 | // 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 ';' |
465 | 465 | // entry 1 is a number of showresults type (always presented) |
466 | 466 | // entries 2..n are optional css-style list of attributes and their values |
467 | 467 | // returns showResults parsed array |
— | — | @@ -474,7 +474,7 @@ |
475 | 475 | $showResults['type'] = 0; |
476 | 476 | } |
477 | 477 | if ( $showResults['type'] != 0 && count( $attrs ) > 0 ) { |
478 | | - foreach( $attrs as &$attr ) { |
| 478 | + foreach ( $attrs as &$attr ) { |
479 | 479 | preg_match( '`([A-Za-z]+):([#\w]+)`u', $attr, $matches ); |
480 | 480 | if ( count( $matches ) == 3 ) { |
481 | 481 | $showResults[ $matches[1] ] = $matches[2]; |
— | — | @@ -514,7 +514,7 @@ |
515 | 515 | return self::fatalError( 'qp_error_dependance_in_stats_mode' ); |
516 | 516 | } |
517 | 517 | $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 ) { |
519 | 519 | return self::fatalError( 'qp_error_no_such_poll', $this->pollAddr ); |
520 | 520 | } |
521 | 521 | if ( !$this->pollStore->loadQuestions() ) { |
— | — | @@ -549,7 +549,7 @@ |
550 | 550 | } else { |
551 | 551 | $attr_str = ''; |
552 | 552 | } |
553 | | - if ( ($type = $question->parseAttributes( $attr_str )) != '' ) { |
| 553 | + if ( ( $type = $question->parseAttributes( $attr_str ) ) != '' ) { |
554 | 554 | # there cannot be type attribute of question in statistical display mode |
555 | 555 | $question->setState( 'error', wfMsg( 'qp_error_type_in_stats_mode', $type ) ); |
556 | 556 | } |
— | — | @@ -578,9 +578,9 @@ |
579 | 579 | # render the question statistics only when showResuls isn't 0 (suppress stats) |
580 | 580 | if ( $question->showResults['type'] != 0 ) { |
581 | 581 | 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" ); |
583 | 583 | 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" ); |
585 | 585 | $write_col = Array(); |
586 | 586 | } |
587 | 587 | if ( --$this->currCol < 1 ) { |
— | — | @@ -595,10 +595,10 @@ |
596 | 596 | } |
597 | 597 | if ( $this->perRow > 1 && $this->currCol != $this->perRow ) { |
598 | 598 | # 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 ); |
600 | 600 | } |
601 | 601 | 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" ); |
603 | 603 | return qp_Renderer::renderHTMLobject( $question_table ); |
604 | 604 | } else { |
605 | 605 | return qp_Renderer::renderHTMLobject( $write_row ); |
— | — | @@ -611,7 +611,7 @@ |
612 | 612 | function generateOutput( $input ) { |
613 | 613 | global $wgOut; |
614 | 614 | # Generates the output. |
615 | | - $qpoll_div = array( '__tag'=>'div', 'class'=>'qpoll', 0=>$input ); |
| 615 | + $qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll', 0 => $input ); |
616 | 616 | return qp_Renderer::renderHTMLobject( $qpoll_div ); |
617 | 617 | } |
618 | 618 | |
— | — | @@ -624,20 +624,20 @@ |
625 | 625 | if ( $question->getQuestionAnswer( $this->pollStore ) ) { |
626 | 626 | # check whether the current global showresults level allows to display statistics |
627 | 627 | if ( $qp_enable_showresults == 0 || |
628 | | - ($qp_enable_showresults <= 1 && !$question->alreadyVoted) ) { |
| 628 | + ( $qp_enable_showresults <= 1 && !$question->alreadyVoted ) ) { |
629 | 629 | # suppress the output |
630 | 630 | return ''; |
631 | 631 | } |
632 | 632 | $buffer = $question->renderStats(); |
633 | 633 | } |
634 | | - $output_table = array( '__tag'=>'table', '__end'=>"\n", 'class'=>'object' ); |
| 634 | + $output_table = array( '__tag' => 'table', '__end' => "\n", 'class' => 'object' ); |
635 | 635 | # 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 ) |
640 | 640 | ), |
641 | | - 1=>$this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" ) |
| 641 | + 1 => $this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" ) |
642 | 642 | ); |
643 | 643 | $tags[] = &$output_table; |
644 | 644 | return qp_Renderer::renderHTMLobject( $tags ); |
— | — | @@ -655,9 +655,9 @@ |
656 | 656 | # order_id is used to sort out polls on the Special:PollResults statistics page |
657 | 657 | $this->mOrderId = self::$sOrderId; |
658 | 658 | # 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 ); |
660 | 660 | } |
661 | | - |
| 661 | + |
662 | 662 | # prepare qp_PollStore object |
663 | 663 | # @return true on success ($this->pollStore has been created successfully), error string on failure |
664 | 664 | function getPollStore() { |
— | — | @@ -691,27 +691,27 @@ |
692 | 692 | # return an error string |
693 | 693 | # here we create a pollstore only to update poll attributes (order_id,dependance), in case these were changed |
694 | 694 | $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 ) ); |
699 | 699 | return $dependanceResult; |
700 | 700 | } |
701 | 701 | if ( $this->mBeingCorrected ) { |
702 | 702 | $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 ) ); |
707 | 707 | $this->pollStore->loadQuestions(); |
708 | | - $this->pollStore->setLastUser( $this->username, false ); |
| 708 | + $this->pollStore->setLastUser( $this->username, false ); |
709 | 709 | $this->pollStore->loadUserAlreadyVoted(); |
710 | 710 | } else { |
711 | 711 | $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 ) ); |
716 | 716 | $this->pollStore->loadQuestions(); |
717 | 717 | $this->pollStore->setLastUser( $this->username, false ); |
718 | 718 | # to show previous choice of current user, if that's available |
— | — | @@ -735,7 +735,7 @@ |
736 | 736 | $this->pollStore->setUserVote(); |
737 | 737 | } |
738 | 738 | if ( $this->pollStore->voteDone ) { |
739 | | - $this->mResponse->setcookie( 'QPoll', 'clearCache', time()+20 ); |
| 739 | + $this->mResponse->setcookie( 'QPoll', 'clearCache', time() + 20 ); |
740 | 740 | $this->mResponse->header( 'HTTP/1.0 302 Found' ); |
741 | 741 | $this->mResponse->header( 'Location: ' . $wgTitle->getFullURL() . self::getPollTitleFragment( $this->mPollId ) ); |
742 | 742 | return true; |
— | — | @@ -752,27 +752,27 @@ |
753 | 753 | # (remember, we're in declaration mode, where 'order_id' is important |
754 | 754 | self::$sOrderId++; |
755 | 755 | # 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" ); |
759 | 759 | $qpoll_div[] = &$qpoll_form; |
760 | 760 | # Determine the content of the settings table. |
761 | 761 | $settings = Array(); |
762 | 762 | 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 ) ); |
765 | 765 | } |
766 | 766 | # Build the settings table. |
767 | 767 | 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 | + } |
772 | 772 | $qpoll_form[] = &$settingsTable; |
773 | 773 | } |
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' ); |
777 | 777 | $submitMsg = 'qp_vote_button'; |
778 | 778 | if ( $this->pollStore->isAlreadyVoted() ) { |
779 | 779 | $submitMsg = 'qp_vote_again_button'; |
— | — | @@ -792,7 +792,7 @@ |
793 | 793 | $submitBtn[ 'disabled' ] = 'disabled'; |
794 | 794 | } |
795 | 795 | $submitBtn[ 'value' ] = wfMsgHtml( $submitMsg ); |
796 | | - $p = array( '__tag'=>'p' ); |
| 796 | + $p = array( '__tag' => 'p' ); |
797 | 797 | $p[] = $submitBtn; |
798 | 798 | $qpoll_form[] = &$p; |
799 | 799 | return qp_Renderer::renderHTMLobject( $qpoll_div ); |
— | — | @@ -872,7 +872,7 @@ |
873 | 873 | # Replace questions from QPoll syntax to HTML |
874 | 874 | # @param $input - A question in QPoll syntax |
875 | 875 | # @return string representing rendered set of the questions / empty string "suggests" redirect |
876 | | - function parseQuestions($input) { |
| 876 | + function parseQuestions( $input ) { |
877 | 877 | $write_row = Array(); |
878 | 878 | $write_col = Array(); |
879 | 879 | $questions = Array(); |
— | — | @@ -880,13 +880,13 @@ |
881 | 881 | $unparsedQuestions = preg_split( $splitPattern, $input, -1, PREG_SPLIT_NO_EMPTY ); |
882 | 882 | $questionPattern = '`(.*?[^|\}])\}[ \t]*(\n(.*)|$)`su'; |
883 | 883 | # first pass: parse the headers |
884 | | - foreach( $unparsedQuestions as $unparsedQuestion ) { |
| 884 | + foreach ( $unparsedQuestions as $unparsedQuestion ) { |
885 | 885 | # If this "unparsedQuestion" is not a full question, |
886 | 886 | # 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 ) ) { |
888 | 888 | $unparsedQuestion = "$buffer\n\n{" . $unparsedQuestion; |
889 | 889 | } |
890 | | - if( preg_match( $questionPattern, $unparsedQuestion, $matches ) ) { |
| 890 | + if ( preg_match( $questionPattern, $unparsedQuestion, $matches ) ) { |
891 | 891 | $buffer = ""; |
892 | 892 | $header = isset( $matches[1] ) ? $matches[1] : ''; |
893 | 893 | $body = isset( $matches[3] ) ? $matches[3] : null; |
— | — | @@ -898,7 +898,7 @@ |
899 | 899 | # analyze question headers |
900 | 900 | # check for showresults attribute |
901 | 901 | $questions_set = Array(); |
902 | | - foreach( $questions as &$question ) { |
| 902 | + foreach ( $questions as &$question ) { |
903 | 903 | if ( $question->showResults['type'] != 0 && |
904 | 904 | method_exists( 'qp_Question', 'addShowResults' . $question->showResults['type'] ) ) { |
905 | 905 | $questions_set[] = $question->mQuestionId; |
— | — | @@ -914,11 +914,11 @@ |
915 | 915 | $this->pollStore->calculateStatistics(); |
916 | 916 | } |
917 | 917 | # second pass: parse the body |
918 | | - foreach( $questions as &$question ) { |
| 918 | + foreach ( $questions as &$question ) { |
919 | 919 | 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" ); |
921 | 921 | 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" ); |
923 | 923 | $write_col = Array(); |
924 | 924 | } |
925 | 925 | if ( --$this->currCol < 1 ) { |
— | — | @@ -932,16 +932,16 @@ |
933 | 933 | } |
934 | 934 | if ( $this->perRow > 1 && $this->currCol != $this->perRow ) { |
935 | 935 | # 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 ); |
937 | 937 | } |
938 | 938 | 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" ); |
940 | 940 | return qp_Renderer::renderHTMLobject( $question_table ); |
941 | 941 | } else { |
942 | 942 | return qp_Renderer::renderHTMLobject( $write_row ); |
943 | 943 | } |
944 | 944 | } |
945 | | - |
| 945 | + |
946 | 946 | # Convert a question on the page from QPoll syntax to HTML |
947 | 947 | # @param $header : the text of question "main" header (common question and XML-like attrs) |
948 | 948 | # $body : the text of question body (starting with body header which defines categories and spans, followed by proposal list) |
— | — | @@ -978,12 +978,12 @@ |
979 | 979 | # to the users who hasn't voted |
980 | 980 | if ( $qp_enable_showresults <= 1 && !$question->alreadyVoted ) { |
981 | 981 | # suppress statistical results when the current user hasn't voted the question |
982 | | - $question->showResults = Array( 'type'=>0 ); |
| 982 | + $question->showResults = Array( 'type' => 0 ); |
983 | 983 | } |
984 | | - # parse the question body |
| 984 | + # parse the question body |
985 | 985 | # store the html result into the buffer to determine some parameters before outputing it |
986 | 986 | # warning! parameters are passed only by value, not the reference |
987 | | - $buffer = $question->{$question->mType . 'ParseBody'}(); |
| 987 | + $buffer = $question-> { $question->mType . 'ParseBody' } (); |
988 | 988 | if ( $this->mBeingCorrected ) { |
989 | 989 | if ( $question->getState() == '' ) { |
990 | 990 | # question is OK, store it into pollStore |
— | — | @@ -1002,7 +1002,7 @@ |
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | } |
1006 | | - $output_table = array( '__tag'=>'table', '__end'=>"\n", 'class'=>'object' ); |
| 1006 | + $output_table = array( '__tag' => 'table', '__end' => "\n", 'class' => 'object' ); |
1007 | 1007 | # Determine the side border color the question. |
1008 | 1008 | if ( $question->getState() != "" ) { |
1009 | 1009 | global $wgContLang; |
— | — | @@ -1011,12 +1011,12 @@ |
1012 | 1012 | $output_table[ 'style' ] = $style; |
1013 | 1013 | $this->mState = $question->getState(); |
1014 | 1014 | } |
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 ) |
1019 | 1019 | ), |
1020 | | - 1=>$this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" ) |
| 1020 | + 1 => $this->parser->recursiveTagParse( $question->mCommonQuestion . "\n" ) |
1021 | 1021 | ); |
1022 | 1022 | $tags[] = &$output_table; |
1023 | 1023 | return qp_Renderer::renderHTMLobject( $tags ); |
— | — | @@ -1038,7 +1038,7 @@ |
1039 | 1039 | if ( array_key_exists( '__tag', $tag ) ) { |
1040 | 1040 | # list inside of tag |
1041 | 1041 | $tag_open .= "<" . $tag[ '__tag' ]; |
1042 | | - foreach( $tag as $attr_key=>&$attr_val ) { |
| 1042 | + foreach ( $tag as $attr_key => &$attr_val ) { |
1043 | 1043 | if ( is_int( $attr_key ) ) { |
1044 | 1044 | if ( $tag_val === null ) |
1045 | 1045 | $tag_val = ""; |
— | — | @@ -1069,7 +1069,7 @@ |
1070 | 1070 | } else { |
1071 | 1071 | # tagless list |
1072 | 1072 | $tag_val = ""; |
1073 | | - foreach( $tag as $attr_key=>&$attr_val ) { |
| 1073 | + foreach ( $tag as $attr_key => &$attr_val ) { |
1074 | 1074 | if ( is_int( $attr_key ) ) { |
1075 | 1075 | if ( is_array( $attr_val ) ) { |
1076 | 1076 | # recursive tags |
— | — | @@ -1080,8 +1080,8 @@ |
1081 | 1081 | } |
1082 | 1082 | } else { |
1083 | 1083 | ob_start(); |
1084 | | - var_dump($tag); |
1085 | | - $tagdump=ob_get_contents(); |
| 1084 | + var_dump( $tag ); |
| 1085 | + $tagdump = ob_get_contents(); |
1086 | 1086 | ob_end_clean(); |
1087 | 1087 | $tag_val = "invalid argument: tagless list cannot have tag attribute values in key=$attr_key, $tagdump"; |
1088 | 1088 | } |
— | — | @@ -1102,13 +1102,13 @@ |
1103 | 1103 | if ( count( $row ) > 0 ) { |
1104 | 1104 | foreach ( $row as &$cell ) { |
1105 | 1105 | if ( !is_array( $cell ) ) { |
1106 | | - $cell = array( 0=>$cell ); |
| 1106 | + $cell = array( 0 => $cell ); |
1107 | 1107 | } |
1108 | 1108 | $cell[ '__tag' ] = $celltag; |
1109 | 1109 | $cell[ '__end' ] = "\n"; |
1110 | 1110 | if ( is_array( $attribute_maps ) ) { |
1111 | 1111 | # 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 ) { |
1113 | 1113 | if ( array_key_exists( $key, $cell ) ) { |
1114 | 1114 | $cell[ $val ] = $cell[ $key ]; |
1115 | 1115 | unset( $cell[ $key ] ); |
— | — | @@ -1116,7 +1116,7 @@ |
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | } |
1120 | | - $result = array( '__tag'=>'tr', 0=>$row, '__end'=>"\n" ); |
| 1120 | + $result = array( '__tag' => 'tr', 0 => $row, '__end' => "\n" ); |
1121 | 1121 | if ( is_array( $rowattrs ) ) { |
1122 | 1122 | $result = array_merge( $rowattrs, $result ); |
1123 | 1123 | } elseif ( $rowattrs !== "" ) { |
— | — | @@ -1137,13 +1137,13 @@ |
1138 | 1138 | $row = 0; |
1139 | 1139 | foreach ( $column as &$cell ) { |
1140 | 1140 | if ( !is_array( $cell ) ) { |
1141 | | - $cell = array( 0=>$cell ); |
| 1141 | + $cell = array( 0 => $cell ); |
1142 | 1142 | } |
1143 | 1143 | $cell[ '__tag' ] = $celltag; |
1144 | 1144 | $cell[ '__end' ] = "\n"; |
1145 | 1145 | if ( is_array( $attribute_maps ) ) { |
1146 | 1146 | # 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 ) { |
1148 | 1148 | if ( array_key_exists( $key, $cell ) ) { |
1149 | 1149 | $cell[ $val ] = $cell[ $key ]; |
1150 | 1150 | unset( $cell[ $key ] ); |
— | — | @@ -1156,7 +1156,7 @@ |
1157 | 1157 | $cell[ 0 ] = __METHOD__ . ':invalid rowattrs supplied'; |
1158 | 1158 | } |
1159 | 1159 | if ( !array_key_exists( $row, $table ) ) { |
1160 | | - $table[ $row ] = array( '__tag'=>'tr', '__end'=>"\n" ); |
| 1160 | + $table[ $row ] = array( '__tag' => 'tr', '__end' => "\n" ); |
1161 | 1161 | } |
1162 | 1162 | $table[ $row ][] = $cell; |
1163 | 1163 | if ( array_key_exists( 'rowspan', $cell ) ) { |
— | — | @@ -1165,7 +1165,7 @@ |
1166 | 1166 | $row++; |
1167 | 1167 | } |
1168 | 1168 | } |
1169 | | - $result = array( '__tag'=>'tr', 0=>$column, '__end'=>"\n" ); |
| 1169 | + $result = array( '__tag' => 'tr', 0 => $column, '__end' => "\n" ); |
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
— | — | @@ -1177,11 +1177,11 @@ |
1178 | 1178 | // if you want to use the resulting row with renderHTMLobject(), don't forget to apply attrs=array('__tag'=>'td') |
1179 | 1179 | static function applyAttrsToRow( &$row, $attrs ) { |
1180 | 1180 | if ( is_array( $attrs ) && count( $attrs > 0 ) ) { |
1181 | | - foreach( $row as &$cell ) { |
| 1181 | + foreach ( $row as &$cell ) { |
1182 | 1182 | if ( !is_array( $cell ) ) { |
1183 | 1183 | $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 ) { |
1186 | 1186 | if ( !array_key_exists( $attr_key, $cell ) ) { |
1187 | 1187 | $cell[ $attr_key ] = $attr_val; |
1188 | 1188 | } |
— | — | @@ -1259,7 +1259,7 @@ |
1260 | 1260 | function qpuserchoiceValidResult( $qdata ) { |
1261 | 1261 | $result = ''; |
1262 | 1262 | 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 ) { |
1264 | 1264 | if ( $result != '' ) { |
1265 | 1265 | $result .= '~'; |
1266 | 1266 | } |
Index: trunk/extensions/QPoll/qp_i18n.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * it under the terms of the GNU General Public License as published by |
10 | 10 | * the Free Software Foundation; either version 2 of the License, or |
11 | 11 | * (at your option) any later version. |
12 | | - * |
| 12 | + * |
13 | 13 | * QPoll is distributed in the hope that it will be useful, |
14 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
— | — | @@ -21,13 +21,13 @@ |
22 | 22 | * ***** END LICENSE BLOCK ***** |
23 | 23 | * |
24 | 24 | * QPoll is a poll tool for MediaWiki. |
25 | | - * |
| 25 | + * |
26 | 26 | * To activate this extension : |
27 | 27 | * * Create a new directory named QPoll into the directory "extensions" of MediaWiki. |
28 | 28 | * * Place the files from the extension archive there. |
29 | 29 | * * Add this line at the end of your LocalSettings.php file : |
30 | 30 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
31 | | - * |
| 31 | + * |
32 | 32 | * @version 0.6.4 |
33 | 33 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
34 | 34 | * @author QuestPC <questpc@rambler.ru> |
Index: trunk/extensions/QPoll/qp_results.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * it under the terms of the GNU General Public License as published by |
10 | 10 | * the Free Software Foundation; either version 2 of the License, or |
11 | 11 | * (at your option) any later version. |
12 | | - * |
| 12 | + * |
13 | 13 | * QPoll is distributed in the hope that it will be useful, |
14 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
— | — | @@ -21,13 +21,13 @@ |
22 | 22 | * ***** END LICENSE BLOCK ***** |
23 | 23 | * |
24 | 24 | * QPoll is a poll tool for MediaWiki. |
25 | | - * |
| 25 | + * |
26 | 26 | * To activate this extension : |
27 | 27 | * * Create a new directory named QPoll into the directory "extensions" of MediaWiki. |
28 | 28 | * * Place the files from the extension archive there. |
29 | 29 | * * Add this line at the end of your LocalSettings.php file : |
30 | 30 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
31 | | - * |
| 31 | + * |
32 | 32 | * @version 0.6.4 |
33 | 33 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
34 | 34 | * @author QuestPC <questpc@rambler.ru> |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | |
42 | 42 | public function __construct() { |
43 | 43 | parent::__construct( 'PollResults', 'delete' ); |
44 | | - wfLoadExtensionMessages('QPoll'); |
| 44 | + wfLoadExtensionMessages( 'QPoll' ); |
45 | 45 | } |
46 | 46 | |
47 | 47 | static $skin = null; |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | global $wgScript; // "/subdirectory/of/wiki/index.php" |
56 | 56 | global $wgUser; |
57 | 57 | if ( !$wgUser->isAllowed( 'delete' ) ) { |
58 | | - $wgOut->permissionRequired('delete'); |
| 58 | + $wgOut->permissionRequired( 'delete' ); |
59 | 59 | return; |
60 | 60 | } |
61 | 61 | $wgOut->addExtensionStyle( qp_Setup::$ScriptPath . '/qp_results.css' ); |
— | — | @@ -62,10 +62,10 @@ |
63 | 63 | self::$skin = $wgUser->getSkin(); |
64 | 64 | } |
65 | 65 | 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' ) ); |
67 | 67 | } |
68 | 68 | 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;" ) ); |
70 | 70 | } |
71 | 71 | $wgOut->addHTML( '<div class="qpoll">' ); |
72 | 72 | $output = ""; |
— | — | @@ -88,9 +88,9 @@ |
89 | 89 | $question_id = $wgRequest->getVal( 'qid' ); |
90 | 90 | $proposal_id = $wgRequest->getVal( 'pid' ); |
91 | 91 | $cid = $wgRequest->getVal( 'cid' ); |
92 | | - switch ($cmd) { |
| 92 | + switch ( $cmd ) { |
93 | 93 | case 'stats': |
94 | | - if ( $pid !==null ) { |
| 94 | + if ( $pid !== null ) { |
95 | 95 | $pid = intval( $pid ); |
96 | 96 | $output = self::getPollsLink(); |
97 | 97 | $output .= self::getUsersLink(); |
— | — | @@ -98,13 +98,13 @@ |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case 'stats_xls': |
102 | | - if ( $pid !==null ) { |
| 102 | + if ( $pid !== null ) { |
103 | 103 | $pid = intval( $pid ); |
104 | 104 | $this->votesToXLS( $pid ); |
105 | 105 | } |
106 | 106 | break; |
107 | 107 | case 'uvote': |
108 | | - if ( $pid !== null && $uid !==null ) { |
| 108 | + if ( $pid !== null && $uid !== null ) { |
109 | 109 | $pid = intval( $pid ); |
110 | 110 | $uid = intval( $uid ); |
111 | 111 | $output = self::getPollsLink(); |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | } |
115 | 115 | break; |
116 | 116 | 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 ) { |
118 | 118 | $pid = intval( $pid ); |
119 | 119 | $question_id = intval( $question_id ); |
120 | 120 | $proposal_id = intval( $proposal_id ); |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | "qp_question_proposals", |
165 | 165 | "qp_question_answers", |
166 | 166 | "qp_users_polls", |
167 | | - "qp_users"); |
| 167 | + "qp_users" ); |
168 | 168 | // check whether the tables were initialized |
169 | 169 | $tablesFound = 0; |
170 | 170 | $result = true; |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | } |
178 | 178 | if ( $tablesFound == 0 ) { |
179 | 179 | # 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" ); |
181 | 181 | if ( $r === true ) { |
182 | 182 | $result = 'Tables were initialized.<br />Please <a href="#" onclick="window.location.reload()">reload</a> this page to view future page edits.'; |
183 | 183 | } else { |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | private function showUserVote( $pid, $uid ) { |
196 | 196 | $output = ""; |
197 | 197 | 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 ) ); |
199 | 199 | if ( $pollStore->pid !== null ) { |
200 | 200 | $pollStore->loadQuestions(); |
201 | 201 | $userName = $pollStore->getUserName( $uid ); |
— | — | @@ -226,20 +226,20 @@ |
227 | 227 | |
228 | 228 | private function displayUserQuestionVote( &$qdata ) { |
229 | 229 | $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 ) ); |
232 | 232 | # multiple choice polls doesn't use real spans, instead, every column is like "span" |
233 | 233 | $spansUsed = count( $qdata->CategorySpans ) > 0 || $qdata->type == "multipleChoice"; |
234 | | - foreach( $qdata->ProposalText as $propkey => &$proposal_text ) { |
| 234 | + foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) { |
235 | 235 | $row = Array(); |
236 | 236 | foreach ( $qdata->Categories as $catkey => &$cat_name ) { |
237 | | - $cell = Array( 0=>"" ); |
| 237 | + $cell = Array( 0 => "" ); |
238 | 238 | if ( array_key_exists( $propkey, $qdata->ProposalCategoryId ) && |
239 | 239 | ( $id_key = array_search( $catkey, $qdata->ProposalCategoryId[ $propkey ] ) ) !== false ) { |
240 | 240 | $text_answer = $qdata->ProposalCategoryText[ $propkey ][ $id_key ]; |
241 | 241 | if ( $text_answer != '' ) { |
242 | 242 | 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 ) ); |
244 | 244 | } else { |
245 | 245 | $cell[ 0 ] = qp_Setup::entities( $text_answer ); |
246 | 246 | } |
— | — | @@ -258,7 +258,7 @@ |
259 | 259 | } |
260 | 260 | $row[] = $cell; |
261 | 261 | } |
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;" ); |
263 | 263 | $output .= qp_Renderer::displayRow( $row ); |
264 | 264 | } |
265 | 265 | $output .= "</table>\n" . "</div>\n"; |
— | — | @@ -268,7 +268,7 @@ |
269 | 269 | private function showVotes( $pid ) { |
270 | 270 | $output = ""; |
271 | 271 | if ( $pid !== null ) { |
272 | | - $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $pid ) ); |
| 272 | + $pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $pid ) ); |
273 | 273 | if ( $pollStore->pid !== null ) { |
274 | 274 | $pollStore->loadQuestions(); |
275 | 275 | $pollStore->loadTotals(); |
— | — | @@ -277,7 +277,7 @@ |
278 | 278 | # 'parentheses' is unavailable in 1.14.x |
279 | 279 | $poll_link = self::$skin->link( $poll_title, $poll_title->getPrefixedText() . wfMsg( 'word-separator' ) . wfMsg( 'qp_parentheses', $pollStore->mPollId ) ); |
280 | 280 | $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 ) ); |
282 | 282 | foreach ( $pollStore->Questions as $qkey => &$qdata ) { |
283 | 283 | $output .= "<br />\n<b>" . $qkey . ".</b> " . qp_Setup::entities( $qdata->CommonQuestion ) . "<br />\n"; |
284 | 284 | $output .= $this->displayQuestionStats( $pid, $qdata ); |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | private function votesToXLS( $pid ) { |
292 | 292 | $output = ""; |
293 | 293 | if ( $pid !== null ) { |
294 | | - $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $pid ) ); |
| 294 | + $pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $pid ) ); |
295 | 295 | if ( $pollStore->pid !== null ) { |
296 | 296 | $poll_id = $pollStore->getPollId(); |
297 | 297 | $pollStore->loadQuestions(); |
— | — | @@ -306,15 +306,15 @@ |
307 | 307 | $xls_worksheet->setPaper( 9 ); |
308 | 308 | $xls_rownum = 0; |
309 | 309 | $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' ); |
313 | 313 | $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' ); |
316 | 316 | $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' ); |
319 | 319 | $format_odd->setNumFormat( $percent_num_format ); |
320 | 320 | $first_question = true; |
321 | 321 | foreach ( $pollStore->Questions as $qkey => &$qdata ) { |
— | — | @@ -329,7 +329,7 @@ |
330 | 330 | $xls_worksheet->write( $xls_rownum++, 1, qp_Excel::prepareExcelString( $qdata->CommonQuestion ), $format_heading ); |
331 | 331 | if ( count( $qdata->CategorySpans ) > 0 ) { |
332 | 332 | $row = array(); |
333 | | - foreach( $qdata->CategorySpans as &$span ) { |
| 333 | + foreach ( $qdata->CategorySpans as &$span ) { |
334 | 334 | $row[] = qp_Excel::prepareExcelString( $span[ "name" ] ); |
335 | 335 | for ( $i = 1; $i < $span[ "count" ]; $i++ ) { |
336 | 336 | $row[] = ""; |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | $xls_worksheet->writerow( $xls_rownum++, 0, $row ); |
340 | 340 | } |
341 | 341 | $row = array(); |
342 | | - foreach( $qdata->Categories as &$categ ) { |
| 342 | + foreach ( $qdata->Categories as &$categ ) { |
343 | 343 | $row[] = qp_Excel::prepareExcelString( $categ[ "name" ] ); |
344 | 344 | } |
345 | 345 | $xls_worksheet->writerow( $xls_rownum++, 0, $row ); |
— | — | @@ -349,11 +349,11 @@ |
350 | 350 | */ |
351 | 351 | $percentsTable = Array(); |
352 | 352 | $spansUsed = count( $qdata->CategorySpans ) > 0 || $qdata->type == "multipleChoice"; |
353 | | - foreach( $qdata->ProposalText as $propkey => &$proposal_text ) { |
| 353 | + foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) { |
354 | 354 | if ( isset( $qdata->Percents[ $propkey ] ) ) { |
355 | 355 | $row = $qdata->Percents[ $propkey ]; |
356 | 356 | foreach ( $row as $catkey => &$cell ) { |
357 | | - $cell = array( 0=>$cell ); |
| 357 | + $cell = array( 0 => $cell ); |
358 | 358 | if ( $spansUsed ) { |
359 | 359 | if ( $qdata->type == "multipleChoice" ) { |
360 | 360 | $cell[ "format" ] = ( ( $catkey & 1 ) === 0 ) ? $format_even : $format_odd; |
— | — | @@ -378,11 +378,11 @@ |
379 | 379 | $xls_workbook->close(); |
380 | 380 | header( 'Content-Type: application/x-msexcel; name="' . $poll_id . '.xls"' ); |
381 | 381 | header( 'Content-Disposition: inline; filename="' . $poll_id . '.xls"' ); |
382 | | - $fxls=@fopen( $xls_fname, "rb" ); |
| 382 | + $fxls = @fopen( $xls_fname, "rb" ); |
383 | 383 | @fpassthru( $fxls ); |
384 | 384 | @unlink( $xls_fname ); |
385 | 385 | exit(); |
386 | | - } catch( Exception $e ) { |
| 386 | + } catch ( Exception $e ) { |
387 | 387 | die( "Error while exporting poll statistics to Excel table\n" ); |
388 | 388 | } |
389 | 389 | } |
— | — | @@ -392,11 +392,11 @@ |
393 | 393 | private function displayQuestionStats( $pid, &$qdata ) { |
394 | 394 | $current_title = $this->getTitle(); |
395 | 395 | $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 ) ); |
398 | 398 | # multiple choice polls doesn't use real spans, instead, every column is like "span" |
399 | 399 | $spansUsed = count( $qdata->CategorySpans ) > 0 || $qdata->type == "multipleChoice"; |
400 | | - foreach( $qdata->ProposalText as $propkey => &$proposal_text ) { |
| 400 | + foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) { |
401 | 401 | if ( isset( $qdata->Votes[ $propkey ] ) ) { |
402 | 402 | if ( $qdata->Percents === null ) { |
403 | 403 | $row = $qdata->Votes[ $propkey ]; |
— | — | @@ -405,12 +405,12 @@ |
406 | 406 | foreach ( $row as $catkey => &$cell ) { |
407 | 407 | $formatted_cell = str_replace( " ", " ", sprintf( '%3d%%', intval( round( 100 * $cell ) ) ) ); |
408 | 408 | # 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" ); |
411 | 411 | } 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 ) ) ); |
415 | 415 | } |
416 | 416 | if ( $spansUsed ) { |
417 | 417 | if ( $qdata->type == "multipleChoice" ) { |
— | — | @@ -427,7 +427,7 @@ |
428 | 428 | # this proposal has no statistics (no votes) |
429 | 429 | $row = array_fill( 0, count( $qdata->Categories ), '' ); |
430 | 430 | } |
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;" ); |
432 | 432 | $output .= qp_Renderer::displayRow( $row ); |
433 | 433 | } |
434 | 434 | $output .= "</table>\n" . "</div>\n"; |
— | — | @@ -455,21 +455,21 @@ |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | | - function doQuery( $offset, $limit, $shownavigation=true ) { |
| 459 | + function doQuery( $offset, $limit, $shownavigation = true ) { |
460 | 460 | global $wgUser, $wgOut, $wgLang, $wgContLang; |
461 | 461 | |
462 | 462 | $res = $this->getIntervalResults( $offset, $limit ); |
463 | | - $num = count($res); |
| 463 | + $num = count( $res ); |
464 | 464 | |
465 | 465 | $sk = $wgUser->getSkin(); |
466 | 466 | $sname = $this->getName(); |
467 | 467 | |
468 | | - if($shownavigation) { |
| 468 | + if ( $shownavigation ) { |
469 | 469 | $wgOut->addHTML( $this->getPageHeader() ); |
470 | 470 | |
471 | 471 | // 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>' ); |
474 | 474 | return; |
475 | 475 | } |
476 | 476 | |
— | — | @@ -489,7 +489,7 @@ |
490 | 490 | if ( ! $this->listoutput ) |
491 | 491 | $s[] = $this->openList( $offset ); |
492 | 492 | |
493 | | - foreach ($res as $r) { |
| 493 | + foreach ( $res as $r ) { |
494 | 494 | $format = $this->formatResult( $sk, $r ); |
495 | 495 | if ( $format ) { |
496 | 496 | $s[] = $this->listoutput ? $format : "<li>{$format}</li>\n"; |
— | — | @@ -501,7 +501,7 @@ |
502 | 502 | $str = $this->listoutput ? $wgContLang->listToText( $s ) : implode( '', $s ); |
503 | 503 | $wgOut->addHTML( $str ); |
504 | 504 | } |
505 | | - if($shownavigation) { |
| 505 | + if ( $shownavigation ) { |
506 | 506 | $wgOut->addHTML( "<p>{$sl}</p>\n" ); |
507 | 507 | } |
508 | 508 | return $num; |
— | — | @@ -532,10 +532,10 @@ |
533 | 533 | $this->cmd = $cmd; |
534 | 534 | if ( $cmd == 'users' ) { |
535 | 535 | $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" ) ); |
537 | 537 | } else { |
538 | 538 | $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" ) ); |
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
— | — | @@ -548,11 +548,11 @@ |
549 | 549 | array( 'qu.uid as uid', 'name as username', 'count(pid) as pidcount' ), |
550 | 550 | 'qu.uid=qup.uid', |
551 | 551 | __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 ) ) { |
557 | 557 | $result[] = $row; |
558 | 558 | } |
559 | 559 | return $result; |
— | — | @@ -566,8 +566,8 @@ |
567 | 567 | $userName = $result->username; |
568 | 568 | $userTitle = Title::makeTitleSafe( NS_USER, $userName ); |
569 | 569 | $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" ) ); |
572 | 572 | $link = $user_link . ': ' . $user_polls_link . ', ' . $user_missing_polls_link; |
573 | 573 | } |
574 | 574 | return $link; |
— | — | @@ -635,7 +635,7 @@ |
636 | 636 | $query .= "ORDER BY page_namespace, page_title, poll_id "; |
637 | 637 | $query .= "LIMIT " . intval( $offset ) . ", " . intval( $limit ); |
638 | 638 | $res = $db->query( $query, __METHOD__ ); |
639 | | - while( $row = $db->fetchObject( $res ) ) { |
| 639 | + while ( $row = $db->fetchObject( $res ) ) { |
640 | 640 | $result[] = $row; |
641 | 641 | } |
642 | 642 | return $result; |
— | — | @@ -647,7 +647,7 @@ |
648 | 648 | $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
649 | 649 | $pollname = qp_Setup::specialchars( $result->poll_id ); |
650 | 650 | $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" ) ); |
652 | 652 | $link = wfMsg( 'qp_results_line_qupl', $pagename, $pollname, $voice_link ); |
653 | 653 | return $link; |
654 | 654 | } |
— | — | @@ -673,10 +673,10 @@ |
674 | 674 | array( 'page_namespace as ns', 'page_title as title', 'pid', 'poll_id', 'order_id' ), |
675 | 675 | 'page_id=article_id', |
676 | 676 | __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 ) ) { |
681 | 681 | $result[] = $row; |
682 | 682 | } |
683 | 683 | return $result; |
— | — | @@ -688,9 +688,9 @@ |
689 | 689 | $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
690 | 690 | $pollname = qp_Setup::specialchars( $result->poll_id ); |
691 | 691 | $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" ) ); |
695 | 695 | $link = wfMsg( 'qp_results_line_qpl', $pagename, $pollname, $goto_link, $voices_link, $users_link, $not_participated_link ); |
696 | 696 | return $link; |
697 | 697 | } |
— | — | @@ -729,10 +729,10 @@ |
730 | 730 | $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
731 | 731 | $pollname = qp_Setup::specialchars( $row->poll_id ); |
732 | 732 | $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 ); |
734 | 734 | $head[] = PollResults::getPollsLink(); |
735 | 735 | $head[] = PollResults::getUsersLink(); |
736 | | - $head[] = array( '__tag'=>'div', 'class'=>'head', 0=>$spec ); |
| 736 | + $head[] = array( '__tag' => 'div', 'class' => 'head', 0 => $spec ); |
737 | 737 | $head[] = ' (' . $goto_link . ')'; |
738 | 738 | $link = qp_Renderer::renderHTMLobject( $head ); |
739 | 739 | } |
— | — | @@ -747,11 +747,11 @@ |
748 | 748 | $query = "SELECT uid, name as username "; |
749 | 749 | $query .= "FROM $qp_users "; |
750 | 750 | $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 ) . ") "; |
752 | 752 | $query .= "ORDER BY uid "; |
753 | 753 | $query .= "LIMIT " . intval( $offset ) . ", " . intval( $limit ); |
754 | 754 | $res = $db->query( $query, __METHOD__ ); |
755 | | - while( $row = $db->fetchObject( $res ) ) { |
| 755 | + while ( $row = $db->fetchObject( $res ) ) { |
756 | 756 | $result[] = $row; |
757 | 757 | } |
758 | 758 | return $result; |
— | — | @@ -765,7 +765,7 @@ |
766 | 766 | $userName = $result->username; |
767 | 767 | $userTitle = Title::makeTitleSafe( NS_USER, $userName ); |
768 | 768 | $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" ) ); |
770 | 770 | $link = wfMsg( 'qp_results_line_qpul', $user_link, $voice_link ); |
771 | 771 | } |
772 | 772 | return $link; |
— | — | @@ -815,7 +815,7 @@ |
816 | 816 | $link = ""; |
817 | 817 | $db = & wfGetDB( DB_SLAVE ); |
818 | 818 | 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 ) ); |
820 | 820 | if ( $pollStore->pid !== null ) { |
821 | 821 | $pollStore->loadQuestions(); |
822 | 822 | $poll_title = Title::makeTitle( intval( $this->ns ), $this->title, qp_AbstractPoll::getPollTitleFragment( $this->poll_id, '' ) ); |
— | — | @@ -825,7 +825,7 @@ |
826 | 826 | $spec = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname ); |
827 | 827 | $head[] = PollResults::getPollsLink(); |
828 | 828 | $head[] = PollResults::getUsersLink(); |
829 | | - $head[] = array( '__tag'=>'div', 'class'=>'head', 0=>$spec ); |
| 829 | + $head[] = array( '__tag' => 'div', 'class' => 'head', 0 => $spec ); |
830 | 830 | # 'parentheses' are unavailable in MW 1.14.x |
831 | 831 | $head[] = wfMsg( 'qp_parentheses', $goto_link ) . '<br />'; |
832 | 832 | $ques_found = false; |
— | — | @@ -849,7 +849,7 @@ |
850 | 850 | qp_Setup::entities( $ques->CommonQuestion ), |
851 | 851 | qp_Setup::entities( $proptext ), |
852 | 852 | 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 ); |
854 | 854 | $link = qp_Renderer::renderHTMLobject( $head ); |
855 | 855 | } |
856 | 856 | } |
— | — | @@ -869,7 +869,7 @@ |
870 | 870 | $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 ) . " "; |
871 | 871 | $query .= "LIMIT " . intval( $offset ) . ", " . intval( $limit ); |
872 | 872 | $res = $db->query( $query, __METHOD__ ); |
873 | | - while( $row = $db->fetchObject( $res ) ) { |
| 873 | + while ( $row = $db->fetchObject( $res ) ) { |
874 | 874 | $result[] = $row; |
875 | 875 | } |
876 | 876 | return $result; |
— | — | @@ -883,8 +883,8 @@ |
884 | 884 | $userName = $result->username; |
885 | 885 | $userTitle = Title::makeTitleSafe( NS_USER, $userName ); |
886 | 886 | $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>'; |
889 | 889 | $link = wfMsg( 'qp_results_line_qucl', $user_link, $voice_link, $text_answer ); |
890 | 890 | } |
891 | 891 | return $link; |
Index: trunk/extensions/QPoll/qp_pollstore.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | $this->ProposalCategoryText = $argv[ 'proposal_category_text' ]; |
39 | 39 | break; |
40 | 40 | case 'qid' : |
41 | | - $this->question_id=$argv[ 'qid' ]; |
| 41 | + $this->question_id = $argv[ 'qid' ]; |
42 | 42 | $this->type = $argv[ 'type' ]; |
43 | 43 | $this->CommonQuestion = $argv[ 'common_question' ]; |
44 | 44 | $this->Categories = Array(); |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | // integrate spans into categories |
55 | 55 | function packSpans() { |
56 | 56 | if ( count( $this->CategorySpans ) > 0 ) { |
57 | | - foreach( $this->Categories as &$Cat ) { |
| 57 | + foreach ( $this->Categories as &$Cat ) { |
58 | 58 | if ( array_key_exists( 'spanId', $Cat ) ) { |
59 | 59 | $Cat['name'] = $this->CategorySpans[ $Cat['spanId'] ]['name'] . "\n" . $Cat['name']; |
60 | 60 | unset( $Cat['spanId'] ); |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | if ( count( $this->CategorySpans ) == 0 ) { |
71 | 71 | $prevSpanName = ''; |
72 | 72 | $spanId = -1; |
73 | | - foreach( $this->Categories as &$Cat ) { |
| 73 | + foreach ( $this->Categories as &$Cat ) { |
74 | 74 | $a = explode( "\n", $Cat['name'] ); |
75 | 75 | if ( count( $a ) > 1 ) { |
76 | 76 | if ( $prevSpanName != $a[0] ) { |
— | — | @@ -133,14 +133,14 @@ |
134 | 134 | if ( self::$db == null ) { |
135 | 135 | self::$db = & wfGetDB( DB_SLAVE ); |
136 | 136 | } |
137 | | - if ( is_array($argv) && array_key_exists( "from", $argv ) ) { |
| 137 | + if ( is_array( $argv ) && array_key_exists( "from", $argv ) ) { |
138 | 138 | $this->Questions = Array(); |
139 | 139 | $this->mCompletedPostData = 'NA'; |
140 | 140 | $this->pid = null; |
141 | 141 | $is_post = false; |
142 | 142 | switch ( $argv[ 'from' ] ) { |
143 | 143 | case 'poll_post' : |
144 | | - $is_post= true; |
| 144 | + $is_post = true; |
145 | 145 | case 'poll_get' : |
146 | 146 | if ( array_key_exists( 'title', $argv ) ) { |
147 | 147 | $title = $argv[ 'title' ]; |
— | — | @@ -166,11 +166,11 @@ |
167 | 167 | if ( array_key_exists( 'pid', $argv ) ) { |
168 | 168 | $pid = intval( $argv[ 'pid' ] ); |
169 | 169 | $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 ), |
172 | 172 | __METHOD__ . ":create from pid" ); |
173 | 173 | $row = self::$db->fetchObject( $res ); |
174 | | - if ( $row!=false ) { |
| 174 | + if ( $row != false ) { |
175 | 175 | $this->pid = $pid; |
176 | 176 | $this->mArticleId = $row->article_id; |
177 | 177 | $this->mPollId = $row->poll_id; |
— | — | @@ -195,9 +195,9 @@ |
196 | 196 | $pollArticleId = intval( $pollTitle->getArticleID() ); |
197 | 197 | if ( $pollArticleId > 0 ) { |
198 | 198 | 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 ) ); |
202 | 202 | } else { |
203 | 203 | return QP_ERROR_MISSED_TITLE; |
204 | 204 | } |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | # returns Title object, to get a URI path, use Title::getFullText()/getPrefixedText() on it |
218 | 218 | function getTitle() { |
219 | 219 | $res = null; |
220 | | - if ( $this->mArticleId !==null && $this->mPollId !== null ) { |
| 220 | + if ( $this->mArticleId !== null && $this->mPollId !== null ) { |
221 | 221 | $res = Title::newFromID( $this->mArticleId ); |
222 | 222 | $res->setFragment( qp_AbstractPoll::getPollTitleFragment( $this->mPollId ) ); |
223 | 223 | } |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | // warning: will work only after successful loadUserAlreadyVoted() or loadUserVote() |
228 | 228 | function isAlreadyVoted() { |
229 | 229 | if ( is_array( $this->Questions ) && count( $this->Questions > 0 ) ) { |
230 | | - foreach( $this->Questions as &$qdata ) { |
| 230 | + foreach ( $this->Questions as &$qdata ) { |
231 | 231 | if ( $qdata->alreadyVoted ) |
232 | 232 | return true; |
233 | 233 | } |
— | — | @@ -245,14 +245,14 @@ |
246 | 246 | function loadQuestions() { |
247 | 247 | $result = false; |
248 | 248 | $typeFromVer0_5 = array( |
249 | | - "singleChoicePoll"=>"singleChoice", |
250 | | - "multipleChoicePoll"=>"multipleChoice", |
251 | | - "mixedChoicePoll"=>"mixedChoice" |
| 249 | + "singleChoicePoll" => "singleChoice", |
| 250 | + "multipleChoicePoll" => "multipleChoice", |
| 251 | + "mixedChoicePoll" => "mixedChoice" |
252 | 252 | ); |
253 | 253 | if ( $this->pid !== null ) { |
254 | 254 | $res = self::$db->select( 'qp_question_desc', |
255 | 255 | array( 'question_id', 'type', 'common_question' ), |
256 | | - array( 'pid'=>$this->pid ), |
| 256 | + array( 'pid' => $this->pid ), |
257 | 257 | __METHOD__ ); |
258 | 258 | if ( self::$db->numRows( $res ) > 0 ) { |
259 | 259 | $result = true; |
— | — | @@ -264,10 +264,10 @@ |
265 | 265 | } |
266 | 266 | # create a qp_QuestionData object from DB fields |
267 | 267 | $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 ) ); |
272 | 272 | } |
273 | 273 | $this->getCategories(); |
274 | 274 | $this->getProposalText(); |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | } |
290 | 290 | $res = self::$db->select( 'qp_question_answers', |
291 | 291 | array( 'DISTINCT question_id' ), |
292 | | - array( 'pid'=>$this->pid, 'uid'=>$this->last_uid ), |
| 292 | + array( 'pid' => $this->pid, 'uid' => $this->last_uid ), |
293 | 293 | __METHOD__ . ':load one user poll questions alreadyVoted values' ); |
294 | 294 | if ( self::$db->numRows( $res ) == 0 ) { |
295 | 295 | return false; |
— | — | @@ -314,7 +314,7 @@ |
315 | 315 | } |
316 | 316 | $res = self::$db->select( 'qp_question_answers', |
317 | 317 | 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 ), |
319 | 319 | __METHOD__ . ':load one user single poll vote' ); |
320 | 320 | if ( self::$db->numRows( $res ) == 0 ) { |
321 | 321 | return false; |
— | — | @@ -341,7 +341,7 @@ |
342 | 342 | if ( is_array( $questions_set ) ) { |
343 | 343 | $where .= ' AND question_id IN ('; |
344 | 344 | $first_elem = true; |
345 | | - foreach( $questions_set as &$qid ) { |
| 345 | + foreach ( $questions_set as &$qid ) { |
346 | 346 | if ( $first_elem ) { |
347 | 347 | $first_elem = false; |
348 | 348 | } else { |
— | — | @@ -379,7 +379,7 @@ |
380 | 380 | if ( $this->pid !== null ) { |
381 | 381 | $res = self::$db->select( 'qp_question_answers', |
382 | 382 | array( 'count(distinct uid)' ), |
383 | | - array( 'pid'=>$this->pid, 'question_id'=>$qdata->question_id ), |
| 383 | + array( 'pid' => $this->pid, 'question_id' => $qdata->question_id ), |
384 | 384 | __METHOD__ ); |
385 | 385 | if ( $row = self::$db->fetchRow( $res ) ) { |
386 | 386 | $result = intval( $row[ "count(distinct uid)" ] ); |
— | — | @@ -390,7 +390,7 @@ |
391 | 391 | |
392 | 392 | // try to calculate percents for every question where Votes[] are available |
393 | 393 | function calculateStatistics() { |
394 | | - foreach( $this->Questions as &$qdata ) { |
| 394 | + foreach ( $this->Questions as &$qdata ) { |
395 | 395 | $this->calculateQuestionStatistics( $qdata ); |
396 | 396 | } |
397 | 397 | } |
— | — | @@ -409,7 +409,7 @@ |
410 | 410 | } else { |
411 | 411 | $votes_total = 0; |
412 | 412 | } |
413 | | - foreach( $qdata->Categories as $catkey => $cat ) { |
| 413 | + foreach ( $qdata->Categories as $catkey => $cat ) { |
414 | 414 | if ( isset( $votes_row[ $catkey ] ) ) { |
415 | 415 | if ( $spansUsed ) { |
416 | 416 | $row_totals[ intval( $cat[ "spanId" ] ) ] += $votes_row[ $catkey ]; |
— | — | @@ -421,7 +421,7 @@ |
422 | 422 | } else { |
423 | 423 | $votes_total = $this->totalUsersAnsweredQuestion( $qdata ); |
424 | 424 | } |
425 | | - foreach( $qdata->Categories as $catkey => $cat ) { |
| 425 | + foreach ( $qdata->Categories as $catkey => $cat ) { |
426 | 426 | $num_of_votes = ''; |
427 | 427 | if ( isset( $votes_row[ $catkey ] ) ) { |
428 | 428 | $num_of_votes = $votes_row[ $catkey ]; |
— | — | @@ -441,7 +441,7 @@ |
442 | 442 | private function getCategories() { |
443 | 443 | $res = self::$db->select( 'qp_question_categories', |
444 | 444 | array( 'question_id', 'cat_id', 'cat_name' ), |
445 | | - array( 'pid'=>$this->pid ), |
| 445 | + array( 'pid' => $this->pid ), |
446 | 446 | __METHOD__ ); |
447 | 447 | while ( $row = self::$db->fetchObject( $res ) ) { |
448 | 448 | $question_id = intval( $row->question_id ); |
— | — | @@ -459,7 +459,7 @@ |
460 | 460 | private function getProposalText() { |
461 | 461 | $res = self::$db->select( 'qp_question_proposals', |
462 | 462 | array( 'question_id', 'proposal_id', 'proposal_text' ), |
463 | | - array( 'pid'=>$this->pid ), |
| 463 | + array( 'pid' => $this->pid ), |
464 | 464 | __METHOD__ ); |
465 | 465 | while ( $row = self::$db->fetchObject( $res ) ) { |
466 | 466 | $question_id = intval( $row->question_id ); |
— | — | @@ -499,11 +499,11 @@ |
500 | 500 | |
501 | 501 | function setLastUser( $username, $store_new_user_to_db = true ) { |
502 | 502 | 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__ ); |
504 | 504 | $row = self::$db->fetchObject( $res ); |
505 | | - if ( $row==false ) { |
| 505 | + if ( $row == false ) { |
506 | 506 | 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' ); |
508 | 508 | $this->last_uid = self::$db->insertId(); |
509 | 509 | } else { |
510 | 510 | $this->last_uid = null; |
— | — | @@ -516,8 +516,8 @@ |
517 | 517 | } |
518 | 518 | |
519 | 519 | 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__ ); |
522 | 522 | $row = self::$db->fetchObject( $res ); |
523 | 523 | if ( $row != false ) { |
524 | 524 | return $row->name; |
— | — | @@ -552,9 +552,9 @@ |
553 | 553 | 'article_id=' . self::$db->addQuotes( $this->mArticleId ) . ' and ' . |
554 | 554 | 'poll_id=' . self::$db->addQuotes( $this->mPollId ) ); |
555 | 555 | $row = self::$db->fetchObject( $res ); |
556 | | - if ( $row==false ) { |
| 556 | + if ( $row == false ) { |
557 | 557 | 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 ), |
559 | 559 | __METHOD__ . ':update poll' ); |
560 | 560 | $this->pid = self::$db->insertId(); |
561 | 561 | } else { |
— | — | @@ -568,16 +568,16 @@ |
569 | 569 | if ( $this->mOrderId != $row->order_id || $this->dependsOn != $row->dependance ) { |
570 | 570 | $res = self::$db->replace( 'qp_poll_desc', |
571 | 571 | '', |
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 ), |
573 | 573 | __METHOD__ . ':poll attributes update' |
574 | 574 | ); |
575 | 575 | } |
576 | 576 | } |
577 | | - |
| 577 | + |
578 | 578 | private function setQuestionDesc() { |
579 | 579 | $insert = array(); |
580 | 580 | 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 ); |
582 | 582 | $ques->question_id = $qkey; |
583 | 583 | } |
584 | 584 | if ( count( $insert ) > 0 ) { |
— | — | @@ -593,7 +593,7 @@ |
594 | 594 | foreach ( $this->Questions as $qkey => &$ques ) { |
595 | 595 | $ques->packSpans(); |
596 | 596 | 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"] ); |
598 | 598 | } |
599 | 599 | $ques->restoreSpans(); |
600 | 600 | } |
— | — | @@ -608,8 +608,8 @@ |
609 | 609 | private function setProposals() { |
610 | 610 | $insert = Array(); |
611 | 611 | 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 ); |
614 | 614 | } |
615 | 615 | } |
616 | 616 | if ( count( $insert ) > 0 ) { |
— | — | @@ -624,16 +624,16 @@ |
625 | 625 | private function setAnswers() { |
626 | 626 | $insert = Array(); |
627 | 627 | 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 ] ); |
631 | 631 | } |
632 | 632 | } |
633 | 633 | } |
634 | 634 | # TODO: delete votes of all users, when the POST question header is incompatible with question header in DB ? |
635 | 635 | # delete previous vote to make sure previous header of this poll was not incompatible with current vote |
636 | 636 | self::$db->delete( 'qp_question_answers', |
637 | | - array( 'uid'=>$this->last_uid, 'pid'=>$this->pid ), |
| 637 | + array( 'uid' => $this->last_uid, 'pid' => $this->pid ), |
638 | 638 | __METHOD__ . ':delete previous answers of current user to the same poll' |
639 | 639 | ); |
640 | 640 | # vote |
— | — | @@ -645,7 +645,7 @@ |
646 | 646 | __METHOD__ ); |
647 | 647 | self::$db->replace( 'qp_users_polls', |
648 | 648 | '', |
649 | | - array( 'uid'=>$this->last_uid, 'pid'=>$this->pid ), |
| 649 | + array( 'uid' => $this->last_uid, 'pid' => $this->pid ), |
650 | 650 | __METHOD__ ); |
651 | 651 | } |
652 | 652 | ignore_user_abort( $old_user_abort ); |
— | — | @@ -653,7 +653,7 @@ |
654 | 654 | |
655 | 655 | # when the user votes and poll wasn't previousely voted yet, it also creates the poll in DB |
656 | 656 | function setUserVote() { |
657 | | - if ( $this->pid !==null && |
| 657 | + if ( $this->pid !== null && |
658 | 658 | $this->last_uid !== null && |
659 | 659 | $this->mCompletedPostData == "complete" && |
660 | 660 | is_array( $this->Questions ) && count( $this->Questions ) > 0 ) { |
Index: trunk/extensions/QPoll/qp_question.php |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Mutator of the question state |
59 | | - * |
| 59 | + * |
60 | 60 | * @protected |
61 | 61 | * @param $pState - state of the question |
62 | 62 | * @param $error_message - optional main_header_parsing error message |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Accessor of the question state. |
76 | | - * |
| 76 | + * |
77 | 77 | * @protected |
78 | 78 | */ |
79 | 79 | function getState() { |
— | — | @@ -99,8 +99,8 @@ |
100 | 100 | # @return string : type of the question, empty when not defined |
101 | 101 | function parseAttributes( $attr_str ) { |
102 | 102 | 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 ) { |
105 | 105 | preg_match( '`' . $key . '?="(.*?)"`u', $attr_str, $val ); |
106 | 106 | } |
107 | 107 | $type = $paramkeys[ 't[yi]p[eo]' ]; |
— | — | @@ -109,20 +109,20 @@ |
110 | 110 | $textwidth = $paramkeys[ 'textwidth' ]; |
111 | 111 | $showresults = $paramkeys[ 'showresults' ]; |
112 | 112 | 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; |
115 | 115 | } |
116 | 116 | # setup question layout parameters |
117 | 117 | if ( $this->transposed ) { |
118 | 118 | $this->spanType = 'rowspan'; |
119 | 119 | $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' ); |
121 | 121 | $this->proposalTextStyle = 'text-align:center; padding-left: 5px; padding-right: 5px; '; |
122 | 122 | $this->proposalTextStyle .= ( $this->proposalsFirst ) ? ' vertical-align: bottom;' : 'vertical-align:top;'; |
123 | 123 | } else { |
124 | 124 | $this->spanType = 'colspan'; |
125 | 125 | $this->categoriesStyle = ''; |
126 | | - $this->signClass = array( 'first'=>'signl', 'middle'=>'signc', 'last'=>'signr' ); |
| 126 | + $this->signClass = array( 'first' => 'signl', 'middle' => 'signc', 'last' => 'signr' ); |
127 | 127 | $this->proposalTextStyle = 'vertical-align:middle; '; |
128 | 128 | $this->proposalTextStyle .= ( $this->proposalsFirst ) ? 'padding-right: 10px;' : 'padding-left: 10px;'; |
129 | 129 | } |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | # use the value from the question |
139 | 139 | $this->showResults = qp_AbstractPoll::parse_ShowResults( $showresults[1] ); |
140 | 140 | # apply undefined attributes from the poll's showresults definition |
141 | | - foreach( $this->pollShowResults as $attr => $val ) { |
| 141 | + foreach ( $this->pollShowResults as $attr => $val ) { |
142 | 142 | if ( $attr != 'type' && !isset( $this->showResults[$attr] ) ) { |
143 | 143 | $this->showResults[$attr] = $val; |
144 | 144 | } |
— | — | @@ -151,7 +151,7 @@ |
152 | 152 | # if needed to setup templates depending on question type |
153 | 153 | # right now, cell templates depends only on input type and showresults type |
154 | 154 | if ( $this->showResults['type'] != 0 ) { |
155 | | - $this->{'cellTemplate' . $this->showResults['type']}(); |
| 155 | + $this-> { 'cellTemplate' . $this->showResults['type'] } (); |
156 | 156 | } |
157 | 157 | return $type; |
158 | 158 | } |
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | $this->Percents = $qdata->Percents; |
238 | 238 | } else { |
239 | 239 | # no percents - no stats |
240 | | - $this->showResults = Array( 'type'=>0 ); |
| 240 | + $this->showResults = Array( 'type' => 0 ); |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
— | — | @@ -257,14 +257,14 @@ |
258 | 258 | $row = Array(); |
259 | 259 | if ( $this->proposalsFirst ) { |
260 | 260 | // 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" ); |
262 | 262 | } |
263 | | - foreach( $this->mCategories as &$cat ) { |
| 263 | + foreach ( $this->mCategories as &$cat ) { |
264 | 264 | $row[] = $this->parser->recursiveTagParse( $cat['name'] ); |
265 | 265 | } |
266 | 266 | if ( !$this->proposalsFirst ) { |
267 | 267 | // 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" ); |
269 | 269 | } |
270 | 270 | return $row; |
271 | 271 | } |
— | — | @@ -275,14 +275,14 @@ |
276 | 276 | # real category spans have sense only for radiobuttons |
277 | 277 | if ( $this->proposalsFirst ) { |
278 | 278 | // 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" ); |
280 | 280 | } |
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'] ) ); |
283 | 283 | } |
284 | 284 | if ( !$this->proposalsFirst ) { |
285 | 285 | // 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" ); |
287 | 287 | } |
288 | 288 | } |
289 | 289 | return $row; |
— | — | @@ -300,18 +300,18 @@ |
301 | 301 | $this->categoriesStyle .= 'border:1px solid gray;'; |
302 | 302 | } |
303 | 303 | if ( $this->categoriesStyle != '' ) { |
304 | | - qp_Renderer::applyAttrsToRow( $spansRow, array( 'style'=>$this->categoriesStyle ) ); |
| 304 | + qp_Renderer::applyAttrsToRow( $spansRow, array( 'style' => $this->categoriesStyle ) ); |
305 | 305 | } |
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 ) ); |
307 | 307 | } |
308 | 308 | if ( $this->categoriesStyle != '' ) { |
309 | | - qp_Renderer::applyAttrsToRow( $catRow, array( 'style'=>$this->categoriesStyle ) ); |
| 309 | + qp_Renderer::applyAttrsToRow( $catRow, array( 'style' => $this->categoriesStyle ) ); |
310 | 310 | } |
311 | | - $this->addRow( $catRow, array( 'class'=>'categories'), 'th', array( 'name'=>0 ) ); |
| 311 | + $this->addRow( $catRow, array( 'class' => 'categories' ), 'th', array( 'name' => 0 ) ); |
312 | 312 | foreach ( $this->mProposalText as $proposalId => $text ) { |
313 | 313 | $row = Array(); |
314 | 314 | $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' ); |
316 | 316 | foreach ( $this->mCategories as $catId => $catDesc ) { |
317 | 317 | $row[ $catId ] = Array(); |
318 | 318 | $spanState->className = 'sign'; |
— | — | @@ -324,12 +324,12 @@ |
325 | 325 | $row[ $catId ][ 'class' ] = $spanState->className; |
326 | 326 | if ( $this->showResults['type'] != 0 ) { |
327 | 327 | # 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 ); |
329 | 329 | } else { |
330 | 330 | $row[ $catId ][ 0 ] = ''; |
331 | 331 | } |
332 | 332 | } |
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 ) ); |
334 | 334 | if ( $this->proposalsFirst ) { |
335 | 335 | # first element is proposaltext |
336 | 336 | array_unshift( $row, $text ); |
— | — | @@ -337,7 +337,7 @@ |
338 | 338 | # last element is proposaltext |
339 | 339 | $row[] = $text; |
340 | 340 | } |
341 | | - $this->addRow( $row, array( 'class'=>$rawClass ), 'td' ); |
| 341 | + $this->addRow( $row, array( 'class' => $rawClass ), 'td' ); |
342 | 342 | } |
343 | 343 | return qp_Renderer::renderHTMLobject( $this->mRenderTable ); |
344 | 344 | } |
— | — | @@ -346,14 +346,14 @@ |
347 | 347 | |
348 | 348 | # cell templates for the selected showresults |
349 | 349 | var $cellTemplate = Array(); |
350 | | - var $cellTemplateParam = Array( 'percents'=>'', 'bar1style'=>'', 'bar2style'=>'' ); |
| 350 | + var $cellTemplateParam = Array( 'percents' => '', 'bar1style' => '', 'bar2style' => '' ); |
351 | 351 | |
352 | 352 | # setup a template for showresults=1 |
353 | 353 | # showresults=1 cellTemplate has only one variant |
354 | 354 | function cellTemplate1() { |
355 | 355 | $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'] ) |
358 | 358 | ); |
359 | 359 | if ( isset( $this->showResults['color'] ) ) { |
360 | 360 | $this->cellTemplate[0]['style'] = 'color:' . $this->showResults['color'] . ';'; |
— | — | @@ -390,14 +390,14 @@ |
391 | 391 | } |
392 | 392 | # has one available template ('bar') |
393 | 393 | $this->cellTemplate = array( |
394 | | - 'bar'=>array( '__tag'=>'div', 'class'=>'stats2', |
395 | | - 0=>array( '__tag'=>'div', 'class'=>'bar1', 'style'=>&$this->cellTemplateParam['bar1style'], 0=>' ' ), |
396 | | - 1=>array( '__tag'=>'div', 'class'=>'bar2', 'style'=>&$this->cellTemplateParam['bar2style'], 0=>' ' ), |
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 => ' ' ), |
| 396 | + 1 => array( '__tag' => 'div', 'class' => 'bar2', 'style' => &$this->cellTemplateParam['bar2style'], 0 => ' ' ), |
| 397 | + 2 => array( '__tag' => 'div', 'class' => 'bar3', 'style' => $percentstyle, 0 => &$this->cellTemplateParam['percents'] ) |
398 | 398 | ), |
399 | 399 | # 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' => '' |
402 | 402 | ); |
403 | 403 | # dynamical styles, width: in percents will be added during rendering in addShowResults |
404 | 404 | if ( isset( $this->showResults['color'] ) ) { |
— | — | @@ -416,7 +416,7 @@ |
417 | 417 | # there is a stat in cell |
418 | 418 | $this->cellTemplateParam['percents'] = $percents . '%'; |
419 | 419 | $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' ]; |
421 | 421 | return qp_Renderer::renderHTMLobject( $this->cellTemplate['bar'] ); |
422 | 422 | } else { |
423 | 423 | return ''; |
— | — | @@ -449,7 +449,7 @@ |
450 | 450 | $this->Percents = $qdata->Percents; |
451 | 451 | } else { |
452 | 452 | # no percents - no stats |
453 | | - $this->showResults = Array( 'type'=>0 ); |
| 453 | + $this->showResults = Array( 'type' => 0 ); |
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
— | — | @@ -500,14 +500,14 @@ |
501 | 501 | function store( qp_PollStore &$pollStore ) { |
502 | 502 | if ( $pollStore->pid !== null ) { |
503 | 503 | $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 ) ); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
— | — | @@ -556,10 +556,10 @@ |
557 | 557 | function parseBodyHeader( $input ) { |
558 | 558 | $this->raws = preg_split( '`\n`su', $input, -1, PREG_SPLIT_NO_EMPTY ); |
559 | 559 | 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 ); |
561 | 561 | } |
562 | 562 | 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 ); |
564 | 564 | } |
565 | 565 | # parse the header - spans and categories |
566 | 566 | $catString = isset( $matches[1] ) ? $matches[1] : ''; |
— | — | @@ -571,14 +571,14 @@ |
572 | 572 | $this->categoriesStyle .= 'border:1px solid gray;'; |
573 | 573 | } |
574 | 574 | if ( $this->categoriesStyle != '' ) { |
575 | | - qp_Renderer::applyAttrsToRow( $spansRow, array( 'style'=>$this->categoriesStyle ) ); |
| 575 | + qp_Renderer::applyAttrsToRow( $spansRow, array( 'style' => $this->categoriesStyle ) ); |
576 | 576 | } |
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 ) ); |
578 | 578 | } |
579 | 579 | if ( $this->categoriesStyle != '' ) { |
580 | | - qp_Renderer::applyAttrsToRow( $catRow, array( 'style'=>$this->categoriesStyle ) ); |
| 580 | + qp_Renderer::applyAttrsToRow( $catRow, array( 'style' => $this->categoriesStyle ) ); |
581 | 581 | } |
582 | | - $this->addRow( $catRow, array( 'class'=>'categories'), 'th', array( 'name'=>0 ) ); |
| 582 | + $this->addRow( $catRow, array( 'class' => 'categories' ), 'th', array( 'name' => 0 ) ); |
583 | 583 | } |
584 | 584 | |
585 | 585 | function singleChoiceParseBody() { |
— | — | @@ -594,7 +594,7 @@ |
595 | 595 | function questionParseBody( $inputType ) { |
596 | 596 | # Parameters used in some special cases. |
597 | 597 | $proposalId = -1; |
598 | | - foreach( $this->raws as $raw ) { |
| 598 | + foreach ( $this->raws as $raw ) { |
599 | 599 | if ( !preg_match( $this->mProposalPattern, $raw, $matches ) ) { |
600 | 600 | continue; |
601 | 601 | } |
— | — | @@ -605,10 +605,10 @@ |
606 | 606 | $rawClass = 'proposal'; |
607 | 607 | $text = array_pop( $matches ); |
608 | 608 | $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' ); |
610 | 610 | foreach ( $this->mCategories as $catId => $catDesc ) { |
611 | 611 | $row[ $catId ] = Array(); |
612 | | - $inp = Array( '__tag'=>'input' ); |
| 612 | + $inp = Array( '__tag' => 'input' ); |
613 | 613 | $spanState->className = 'sign'; |
614 | 614 | # Determine the input's name and value. |
615 | 615 | switch( $this->mType ) { |
— | — | @@ -623,9 +623,9 @@ |
624 | 624 | $this->renderSpan( $name, $catDesc, $text, $rawClass, $spanState ); |
625 | 625 | if ( $spanState->cellsLeft <= 1 ) { |
626 | 626 | # end of new span |
627 | | - if ( $this->mBeingCorrected && |
| 627 | + if ( $this->mBeingCorrected && |
628 | 628 | !$spanState->wasChecked && |
629 | | - $this->mRequest->getVal($name) != $value ) { |
| 629 | + $this->mRequest->getVal( $name ) != $value ) { |
630 | 630 | # the span (a part of proposal) was submitted but unanswered |
631 | 631 | $text = $this->bodyErrorMessage( wfMsg( 'qp_error_unanswered_span' ), 'NA' ) . $text; |
632 | 632 | # highlight current span to indicate an error |
— | — | @@ -669,7 +669,7 @@ |
670 | 670 | if ( count( $this->mProposalText ) > count( $this->mCategories ) ) { |
671 | 671 | # if there was no previous errors, hightlight the whole row |
672 | 672 | if ( $this->getState() == '' ) { |
673 | | - foreach( $row as &$cell ) { |
| 673 | + foreach ( $row as &$cell ) { |
674 | 674 | $cell[ 'style' ] = QP_CSS_ERROR_STYLE; |
675 | 675 | } |
676 | 676 | } |
— | — | @@ -683,15 +683,15 @@ |
684 | 684 | $inp[ 'value' ] = $value; |
685 | 685 | if ( $this->showResults['type'] != 0 ) { |
686 | 686 | # 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 ); |
688 | 688 | } else { |
689 | 689 | $row[ $catId ][ 0 ] = $inp; |
690 | 690 | } |
691 | 691 | } |
692 | 692 | # If the proposal text is empty, the question has a syntax error. |
693 | | - if( trim( $text ) == '' ) { |
| 693 | + if ( trim( $text ) == '' ) { |
694 | 694 | $text = $this->bodyErrorMessage( wfMsg( 'qp_error_proposal_text_empty' ), 'error' ); |
695 | | - foreach( $row as &$cell ) { |
| 695 | + foreach ( $row as &$cell ) { |
696 | 696 | $cell[ 'style' ] = QP_CSS_ERROR_STYLE; |
697 | 697 | } |
698 | 698 | $rawClass = 'proposalerror'; |
— | — | @@ -700,7 +700,7 @@ |
701 | 701 | if ( $this->mBeingCorrected && !array_key_exists( $proposalId, $this->mProposalCategoryId ) ) { |
702 | 702 | # if there was no previous errors, hightlight the whole row |
703 | 703 | if ( $this->getState() == '' ) { |
704 | | - foreach( $row as &$cell ) { |
| 704 | + foreach ( $row as &$cell ) { |
705 | 705 | $cell[ 'style' ] = QP_CSS_ERROR_STYLE; |
706 | 706 | } |
707 | 707 | } |
— | — | @@ -708,7 +708,7 @@ |
709 | 709 | $rawClass = 'proposalerror'; |
710 | 710 | } |
711 | 711 | 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 ) ); |
713 | 713 | if ( $this->proposalsFirst ) { |
714 | 714 | # first element is proposaltext |
715 | 715 | array_unshift( $row, $text ); |
— | — | @@ -716,7 +716,7 @@ |
717 | 717 | # last element is proposaltext |
718 | 718 | $row[] = $text; |
719 | 719 | } |
720 | | - $this->addRow( $row, array( 'class'=>$rawClass ), 'td' ); |
| 720 | + $this->addRow( $row, array( 'class' => $rawClass ), 'td' ); |
721 | 721 | } |
722 | 722 | } |
723 | 723 | } |
— | — | @@ -729,7 +729,7 @@ |
730 | 730 | } |
731 | 731 | $this->mProposalPattern .= '(.*)`u'; |
732 | 732 | $proposalId = -1; |
733 | | - foreach( $this->raws as $raw ) { |
| 733 | + foreach ( $this->raws as $raw ) { |
734 | 734 | # empty proposal text and row |
735 | 735 | $text = null; |
736 | 736 | $row = Array(); |
— | — | @@ -754,7 +754,7 @@ |
755 | 755 | foreach ( $this->mCategories as $catId => $catDesc ) { |
756 | 756 | $typeId = $matches[ $catId ]; |
757 | 757 | $row[ $catId ] = Array(); |
758 | | - $inp = Array( '__tag'=>'input' ); |
| 758 | + $inp = Array( '__tag' => 'input' ); |
759 | 759 | # Determine the input's name and value. |
760 | 760 | switch ( $typeId ) { |
761 | 761 | case '<>': |
— | — | @@ -819,15 +819,15 @@ |
820 | 820 | } |
821 | 821 | if ( $this->showResults['type'] != 0 ) { |
822 | 822 | # 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 ); |
824 | 824 | } else { |
825 | 825 | $row[ $catId ][ 0 ] = $inp; |
826 | 826 | } |
827 | 827 | } |
828 | 828 | # If the proposal text is empty, the question has a syntax error. |
829 | | - if( trim( $text ) == '' ) { |
| 829 | + if ( trim( $text ) == '' ) { |
830 | 830 | $text = $this->bodyErrorMessage( wfMsg( "qp_error_proposal_text_empty" ), "error" ); |
831 | | - foreach( $row as &$cell ) { |
| 831 | + foreach ( $row as &$cell ) { |
832 | 832 | $cell[ 'style' ] = QP_CSS_ERROR_STYLE; |
833 | 833 | } |
834 | 834 | $rawClass = 'proposalerror'; |
— | — | @@ -836,14 +836,14 @@ |
837 | 837 | if ( $this->mBeingCorrected && !array_key_exists( $proposalId, $this->mProposalCategoryId ) ) { |
838 | 838 | # if there was no previous errors, hightlight the whole row |
839 | 839 | if ( $this->getState() == '' ) { |
840 | | - foreach( $row as &$cell ) { |
| 840 | + foreach ( $row as &$cell ) { |
841 | 841 | $cell[ 'style' ] = QP_CSS_ERROR_STYLE; |
842 | 842 | } |
843 | 843 | } |
844 | 844 | $text = $this->bodyErrorMessage( wfMsg( 'qp_error_no_answer' ), 'NA' ) . $text; |
845 | 845 | $rawClass = 'proposalerror'; |
846 | 846 | } |
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 ) ); |
848 | 848 | if ( $this->proposalsFirst ) { |
849 | 849 | # first element is proposaltext |
850 | 850 | array_unshift( $row, $text ); |
— | — | @@ -851,21 +851,21 @@ |
852 | 852 | # last element is proposaltext |
853 | 853 | $row[] = $text; |
854 | 854 | } |
855 | | - $this->addRow( $row, array( 'class'=>$rawClass ), 'td' ); |
| 855 | + $this->addRow( $row, array( 'class' => $rawClass ), 'td' ); |
856 | 856 | } |
857 | 857 | return qp_Renderer::renderHTMLobject( $this->mRenderTable ); |
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
861 | 861 | * build internal & visual representation of question categories |
862 | | - * |
| 862 | + * |
863 | 863 | * @param $input the raw source of categories |
864 | 864 | */ |
865 | 865 | function parseCategories( $input ) { |
866 | 866 | $row = Array(); |
867 | 867 | if ( $this->proposalsFirst ) { |
868 | 868 | // 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" ); |
870 | 870 | } |
871 | 871 | # build "raw" categories array |
872 | 872 | # split tokens |
— | — | @@ -873,8 +873,8 @@ |
874 | 874 | $matching_braces = Array(); |
875 | 875 | $curr_elem = ''; |
876 | 876 | $categories = Array(); |
877 | | - foreach( $cat_split as $part ) { |
878 | | - switch ($part) { |
| 877 | + foreach ( $cat_split as $part ) { |
| 878 | + switch ( $part ) { |
879 | 879 | case '|' : |
880 | 880 | if ( count( $matching_braces ) == 0 ) { |
881 | 881 | # delimeters are working only when braces are completely closed |
— | — | @@ -912,29 +912,29 @@ |
913 | 913 | if ( !array_key_exists( 1, $categories ) ) { |
914 | 914 | $categories[0] .= $this->bodyErrorMessage( wfMsg( "qp_error_too_few_categories" ), "error" ); |
915 | 915 | } |
916 | | - foreach( $categories as $catkey => $category ) { |
| 916 | + foreach ( $categories as $catkey => $category ) { |
917 | 917 | $category = trim( $category ); |
918 | 918 | # If a category name is empty, the question has a syntax error. |
919 | | - if( $category == "") { |
| 919 | + if ( $category == "" ) { |
920 | 920 | $category = $this->bodyErrorMessage( wfMsg( "qp_error_category_name_empty" ), "error" ); |
921 | 921 | } |
922 | 922 | $this->mCategories[ $catkey ]["name"] = $category; |
923 | 923 | $row[] = $this->parser->recursiveTagParse( $category ); |
924 | 924 | } |
925 | | - |
| 925 | + |
926 | 926 | # cut unused categories rows which are presented in DB but were removed from article |
927 | 927 | $this->mCategories = array_slice( $this->mCategories, 0, count( $categories ) ); |
928 | 928 | if ( !$this->proposalsFirst ) { |
929 | 929 | // 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" ); |
931 | 931 | } |
932 | 932 | return $row; |
933 | 933 | } |
934 | | - |
| 934 | + |
935 | 935 | /** |
936 | 936 | * build internal & visual representation of question category spans |
937 | 937 | * ( also known as metacategories or "category groups" ) |
938 | | - * |
| 938 | + * |
939 | 939 | * @param $input the raw source of category spans |
940 | 940 | */ |
941 | 941 | # warning: parseCategorySpans() should be called after parseCategories() |
— | — | @@ -952,7 +952,7 @@ |
953 | 953 | array_shift( $span_split ); |
954 | 954 | if ( isset( $span_split[0] ) && in_array( $span_split[0], array( '!', '|' ) ) ) { |
955 | 955 | $delim = $span_split[0]; |
956 | | - foreach( $span_split as $part ) { |
| 956 | + foreach ( $span_split as $part ) { |
957 | 957 | if ( $part == $delim ) { |
958 | 958 | if ( count( $matching_braces ) == 0 ) { |
959 | 959 | # delimeters are working only when braces are completely closed |
— | — | @@ -996,13 +996,13 @@ |
997 | 997 | } |
998 | 998 | # analyze previousely build "raw" spans array |
999 | 999 | # Less than one span is a syntax error. |
1000 | | - if(!array_key_exists(0, $spans)) { |
| 1000 | + if ( !array_key_exists( 0, $spans ) ) { |
1001 | 1001 | return $this->bodyErrorMessage( wfMsg( "qp_error_too_few_spans" ), "error" ); |
1002 | 1002 | } |
1003 | 1003 | # fill undefined spans with the last span value |
1004 | 1004 | $SpanCategDelta = count( $this->mCategories ) - count( $spans[0] ); |
1005 | 1005 | $lastDefinedSpanKey = array_pop( array_diff( array_keys( $spans[1] ), array_keys( $spans[1], "", true ) ) ); |
1006 | | - if ($lastDefinedSpanKey !== null) { |
| 1006 | + if ( $lastDefinedSpanKey !== null ) { |
1007 | 1007 | if ( $SpanCategDelta > 0 ) { |
1008 | 1008 | # increase the length of last defined span value to match total lenth of categories |
1009 | 1009 | $lastSpanType = $spans[0][$lastDefinedSpanKey]; |
— | — | @@ -1014,32 +1014,32 @@ |
1015 | 1015 | array_slice( $spans[1], $lastDefinedSpanKey ) ); |
1016 | 1016 | } elseif ( $SpanCategDelta < 0 ) { |
1017 | 1017 | # 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 ); |
1020 | 1020 | } |
1021 | 1021 | } else { |
1022 | 1022 | # 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' ); |
1024 | 1024 | } |
1025 | 1025 | # populate mCategorySpans and row |
1026 | 1026 | if ( $this->proposalsFirst ) { |
1027 | 1027 | // 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" ); |
1029 | 1029 | } |
1030 | 1030 | $colspanBase = ( $lastDefinedSpanKey == 0 ) ? 1 : 0; |
1031 | 1031 | $colspan = 1; |
1032 | 1032 | $categorySpanId = 0; |
1033 | | - foreach($spans[0] as $spanKey => $spanType) { |
| 1033 | + foreach ( $spans[0] as $spanKey => $spanType ) { |
1034 | 1034 | $spanCategory = trim( $spans[1][$spanKey] ); |
1035 | | - if ( $spanCategory=="" ) { |
| 1035 | + if ( $spanCategory == "" ) { |
1036 | 1036 | $colspan++; |
1037 | 1037 | } 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 |
1040 | 1040 | $this->mCategorySpans[ $categorySpanId ]['name'] = $spanCategory; |
1041 | 1041 | $this->mCategorySpans[ $categorySpanId ]['count'] = $colspan; |
1042 | 1042 | 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 ] ); |
1044 | 1044 | $i-- ) { |
1045 | 1045 | $this->mCategories[$i]['spanId'] = $categorySpanId; |
1046 | 1046 | } |
— | — | @@ -1050,14 +1050,14 @@ |
1051 | 1051 | } |
1052 | 1052 | if ( !$this->proposalsFirst ) { |
1053 | 1053 | // 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" ); |
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | return $row; |
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | function isUniqueProposalCategoryId( $proposalId, $catId ) { |
1061 | | - foreach( $this->mProposalCategoryId as $proposalCategoryId ) { |
| 1061 | + foreach ( $this->mProposalCategoryId as $proposalCategoryId ) { |
1062 | 1062 | if ( in_array( $catId, $proposalCategoryId ) ) { |
1063 | 1063 | return false; |
1064 | 1064 | } |
— | — | @@ -1069,15 +1069,15 @@ |
1070 | 1070 | |
1071 | 1071 | # cell templates for the selected showresults |
1072 | 1072 | var $cellTemplate = Array(); |
1073 | | - var $cellTemplateParam = Array( 'inp'=>'', 'percents'=>'', 'bar1style'=>'', 'bar2style'=>'' ); |
| 1073 | + var $cellTemplateParam = Array( 'inp' => '', 'percents' => '', 'bar1style' => '', 'bar2style' => '' ); |
1074 | 1074 | |
1075 | 1075 | # setup a template for showresults=1 |
1076 | 1076 | # showresults=1 cellTemplate has only one variant |
1077 | 1077 | function cellTemplate1() { |
1078 | 1078 | $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'] ) |
1082 | 1082 | ); |
1083 | 1083 | if ( isset( $this->showResults['color'] ) ) { |
1084 | 1084 | $this->cellTemplate[1]['style'] = 'color:' . $this->showResults['color'] . ';'; |
— | — | @@ -1114,34 +1114,34 @@ |
1115 | 1115 | $percentstyle .= 'background:' . $this->showResults['textbackground'] . ';'; |
1116 | 1116 | } |
1117 | 1117 | # 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=>' ' ), |
1121 | | - 2=>array( '__tag'=>'div', 'class'=>'bar2', 'style'=>&$this->cellTemplateParam['bar2style'], 0=>' ' ), |
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 => ' ' ), |
| 1121 | + 2 => array( '__tag' => 'div', 'class' => 'bar2', 'style' => &$this->cellTemplateParam['bar2style'], 0 => ' ' ), |
| 1122 | + 3 => array( '__tag' => 'div', 'class' => 'bar0', 'style' => $percentstyle, 0 => &$this->cellTemplateParam['percents'] ) |
1123 | 1123 | ); |
1124 | | - $bar2 = array( '__tag'=>'div', 'class'=>'stats1', |
1125 | | - 0=>array( '__tag'=>'div', 'class'=>'bar0', 0=>' ' ), |
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 => ' ' ), |
| 1126 | + 1 => &$bar[1], |
| 1127 | + 2 => &$bar[2], |
| 1128 | + 3 => &$bar[3] |
1129 | 1129 | ); |
1130 | 1130 | # has two available templates ('bar','textinput') |
1131 | 1131 | $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'] ), |
1136 | 1136 | ), |
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 |
1140 | 1140 | ) |
1141 | 1141 | ) |
1142 | 1142 | ), |
1143 | 1143 | # 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' => '' |
1146 | 1146 | ); |
1147 | 1147 | # dynamical styles, width: in percents will be added during rendering in addShowResults |
1148 | 1148 | if ( isset( $this->showResults['color'] ) ) { |
— | — | @@ -1161,7 +1161,7 @@ |
1162 | 1162 | # there is a stat in cell |
1163 | 1163 | $this->cellTemplateParam['percents'] = $percents . '%'; |
1164 | 1164 | $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' ]; |
1166 | 1166 | if ( $inp['type'] == 'text' ) { |
1167 | 1167 | return qp_Renderer::renderHTMLobject( $this->cellTemplate['textinput'] ); |
1168 | 1168 | } else { |