Index: trunk/extensions/QPoll/maintenance/qp_schemaupdater.php |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | * @param $tableset array list of DB tables in set |
125 | 125 | * @return array with names of non-existing tables in specified list |
126 | 126 | */ |
127 | | - private static function tablesExists( $tableset ) { |
| 127 | + private static function tablesExists( array $tableset ) { |
128 | 128 | $db = & wfGetDB( DB_MASTER ); |
129 | 129 | $tablesNotFound = array(); |
130 | 130 | foreach ( $tableset as &$table ) { |
Index: trunk/extensions/QPoll/model/cache/qp_pollcache.php |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | $this->updateFromPollStore(); |
286 | 286 | if ( count( $this->replace ) < 1 ) { |
287 | 287 | # this cannot happen here; however it can happen in ancestor classes |
288 | | - throw new Exception( "zero rows replace in " . __METHOD__ ); |
| 288 | + throw new MWException( "zero rows replace in " . __METHOD__ ); |
289 | 289 | } |
290 | 290 | $replaceRows = ( $curr_cache_rows = $wgMemc->get( $this->getMemcKey() ) ) === false || |
291 | 291 | serialize( $curr_cache_rows ) !== serialize( $this->memc_rows ); |
Index: trunk/extensions/QPoll/model/qp_questiondata.php |
— | — | @@ -64,14 +64,7 @@ |
65 | 65 | return; |
66 | 66 | } elseif ( $argv instanceof qp_StubQuestion ) { |
67 | 67 | # create question data from the already existing question |
68 | | - $this->question_id = $argv->mQuestionId; |
69 | | - $this->type = $argv->mType; |
70 | | - $this->CommonQuestion = $argv->mCommonQuestion; |
71 | | - $this->Categories = $argv->mCategories; |
72 | | - $this->CategorySpans = $argv->mCategorySpans; |
73 | | - $this->ProposalText = $argv->mProposalText; |
74 | | - $this->ProposalNames = $argv->mProposalNames; |
75 | | - $this->setQuestionAnswer( $argv ); |
| 68 | + $this->applyQuestion( $argv ); |
76 | 69 | return; |
77 | 70 | } |
78 | 71 | throw new MWException( "argv is neither an array nor instance of qp_QuestionData in " . __METHOD__ ); |
— | — | @@ -114,7 +107,7 @@ |
115 | 108 | * |
116 | 109 | * Used to reject previous vote in case the header is incompatble. |
117 | 110 | */ |
118 | | - function isCompatible( &$question ) { |
| 111 | + function isCompatible( qp_StubQuestion $question ) { |
119 | 112 | if ( $question->mType != $this->type ) { |
120 | 113 | return false; |
121 | 114 | } |
— | — | @@ -206,7 +199,14 @@ |
207 | 200 | return ( $name !== '' ) ? ":|{$name}|" : ''; |
208 | 201 | } |
209 | 202 | |
210 | | - public function setQuestionAnswer( qp_StubQuestion $question ) { |
| 203 | + public function applyQuestion( qp_StubQuestion $question ) { |
| 204 | + $this->question_id = $question->mQuestionId; |
| 205 | + $this->type = $question->mType; |
| 206 | + $this->CommonQuestion = $question->mCommonQuestion; |
| 207 | + $this->Categories = $question->mCategories; |
| 208 | + $this->CategorySpans = $question->mCategorySpans; |
| 209 | + $this->ProposalText = $question->mProposalText; |
| 210 | + $this->ProposalNames = $question->mProposalNames; |
211 | 211 | $this->ProposalCategoryId = $question->mProposalCategoryId; |
212 | 212 | $this->ProposalCategoryText = $question->mProposalCategoryText; |
213 | 213 | } |
Index: trunk/extensions/QPoll/model/qp_question_collection.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | * placed in $except. ($except must therefore be an array) |
67 | 67 | * function returns false if $except holds all values between $min and $max. |
68 | 68 | */ |
69 | | - function rand_except( $min, $max, $except ) { |
| 69 | + function rand_except( $min, $max, array $except ) { |
70 | 70 | # first sort array values |
71 | 71 | sort( $except, SORT_NUMERIC ); |
72 | 72 | # calculate average gap between except-values |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | |
114 | 114 | function setUsedQuestions( $randomQuestions ) { |
115 | 115 | if ( !is_array( $randomQuestions ) ) { |
116 | | - foreach ( $this->questions as $qidx => &$question ) { |
| 116 | + foreach ( $this->questions as $qidx => $question ) { |
117 | 117 | $question->usedId = $question->mQuestionId; |
118 | 118 | } |
119 | 119 | return; |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | $this->usedQuestions = array(); |
123 | 123 | # questions keys start from 1 |
124 | 124 | $usedId = 1; |
125 | | - foreach ( $this->questions as $qidx => &$question ) { |
| 125 | + foreach ( $this->questions as $qidx => $question ) { |
126 | 126 | if ( in_array( $qidx, $randomQuestions, true ) ) { |
127 | 127 | # usedQuestions keys start from 0 |
128 | 128 | $this->usedQuestions[] = $qidx; |
— | — | @@ -149,7 +149,7 @@ |
150 | 150 | |
151 | 151 | function usedCount() { |
152 | 152 | $used = 0; |
153 | | - foreach ( $this->questions as &$question ) { |
| 153 | + foreach ( $this->questions as $question ) { |
154 | 154 | if ( $question->usedId !== false ) { |
155 | 155 | $used++; |
156 | 156 | } |
Index: trunk/extensions/QPoll/model/qp_pollstore.php |
— | — | @@ -86,38 +86,39 @@ |
87 | 87 | * @param $argv['from'] indicates type of construction, other elements of $argv |
88 | 88 | * vary according to the value of 'from' |
89 | 89 | */ |
90 | | - function __construct( $argv = null ) { |
| 90 | + function __construct( array $argv ) { |
91 | 91 | $this->interpResult = new qp_InterpResult(); |
92 | 92 | # set poll store of poll descriptions cache and all it's ancestors |
93 | 93 | qp_PollCache::setStore( $this ); |
94 | | - if ( is_array( $argv ) && array_key_exists( "from", $argv ) ) { |
| 94 | + $from = 'null'; |
| 95 | + if ( array_key_exists( 'from', $argv ) ) { |
| 96 | + $from = $argv['from']; |
95 | 97 | $this->Questions = array(); |
96 | 98 | $this->mCompletedPostData = 'NA'; |
97 | 99 | $this->pid = null; |
98 | 100 | $is_post = false; |
99 | | - switch ( $argv[ 'from' ] ) { |
100 | | - case 'poll_post' : |
101 | | - $is_post = true; |
102 | | - case 'poll_get' : |
103 | | - $this->createFromTagData( $argv, $is_post ); |
104 | | - break; |
105 | | - case 'pid' : |
106 | | - if ( array_key_exists( 'pid', $argv ) ) { |
107 | | - $pid = intval( $argv[ 'pid' ] ); |
108 | | - $this->createFromPid( $pid ); |
109 | | - } |
110 | | - break; |
111 | | - default : |
112 | | - throw new MWException( 'Unknown value of "from" parameter: ' . $argv[ 'from' ] . ' in ' . __METHOD__ ); |
| 101 | + switch ( $from ) { |
| 102 | + case 'poll_post' : |
| 103 | + $is_post = true; |
| 104 | + case 'poll_get' : |
| 105 | + $this->createFromTagData( $argv, $is_post ); |
| 106 | + return; |
| 107 | + case 'pid' : |
| 108 | + if ( array_key_exists( 'pid', $argv ) ) { |
| 109 | + $pid = intval( $argv[ 'pid' ] ); |
| 110 | + $this->createFromPid( $pid ); |
| 111 | + } |
| 112 | + return; |
113 | 113 | } |
114 | 114 | } |
| 115 | + throw new MWException( 'Unknown value of "from" parameter: ' . $from . ' in ' . __METHOD__ ); |
115 | 116 | } |
116 | 117 | |
117 | 118 | /** |
118 | 119 | * Creates new poll from data available in qpoll tag attributes. |
119 | 120 | * Usually that is HTTP GET / POST operation. |
120 | 121 | */ |
121 | | - function createFromTagData( &$argv, $is_post ) { |
| 122 | + function createFromTagData( array &$argv, $is_post ) { |
122 | 123 | global $wgParser; |
123 | 124 | if ( array_key_exists( 'title', $argv ) ) { |
124 | 125 | $title = $argv[ 'title' ]; |
— | — | @@ -824,7 +825,7 @@ |
825 | 826 | * Get username by uid |
826 | 827 | * @param $uid integer qpoll user id |
827 | 828 | */ |
828 | | - function getUserName( $uid ) { |
| 829 | + static function getUserName( $uid ) { |
829 | 830 | $db = wfGetDB( DB_MASTER ); |
830 | 831 | if ( $uid !== null ) { |
831 | 832 | $res = $db->select( |
— | — | @@ -908,13 +909,14 @@ |
909 | 910 | * @param $question qp_StubQuestion |
910 | 911 | * instance of question which has current user vote |
911 | 912 | */ |
912 | | - public function setQuestionAnswer( qp_StubQuestion $question ) { |
| 913 | + public function setQuestion( qp_StubQuestion $question ) { |
913 | 914 | if ( $this->questionExists( $question->mQuestionId ) ) { |
914 | 915 | # question data already exists, poll structure was stored during previous |
915 | 916 | # submission. |
916 | 917 | # question, category and proposal descriptions are already loaded into |
917 | 918 | # $this->Questions[$question->mQuestionId] by $this->loadQuestions() |
918 | | - $this->Questions[$question->mQuestionId]->setQuestionAnswer( $question ); |
| 919 | + # but might have pending update, if the source of the poll was modified |
| 920 | + $this->Questions[$question->mQuestionId]->applyQuestion( $question ); |
919 | 921 | } else { |
920 | 922 | # create new question data from scratch (first submission) |
921 | 923 | $this->Questions[$question->mQuestionId] = qp_QuestionData::factory( $question ); |
Index: trunk/extensions/QPoll/specials/qp_special.php |
— | — | @@ -51,7 +51,12 @@ |
52 | 52 | parent::__construct( $name, $restriction, $listed, $function, $file, $includable ); |
53 | 53 | } |
54 | 54 | |
55 | | - function qpLink( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) { |
| 55 | + function qpLink( |
| 56 | + $target, |
| 57 | + $text = null, |
| 58 | + array $customAttribs = array(), |
| 59 | + array $query = array(), |
| 60 | + array $options = array() ) { |
56 | 61 | return self::$linker->link( $target, $text, $customAttribs, $query, $options ); |
57 | 62 | } |
58 | 63 | |
Index: trunk/extensions/QPoll/specials/qp_results.php |
— | — | @@ -203,7 +203,7 @@ |
204 | 204 | return ''; |
205 | 205 | } |
206 | 206 | $pollStore->loadQuestions(); |
207 | | - $userName = $pollStore->getUserName( $uid ); |
| 207 | + $userName = qp_PollStore::getUserName( $uid ); |
208 | 208 | if ( $userName === false ) { |
209 | 209 | return ''; |
210 | 210 | } |
— | — | @@ -221,7 +221,7 @@ |
222 | 222 | $headerTags = $this->getAnswerHeader( $pollStore ); |
223 | 223 | $output .= qp_Renderer::renderTagArray( $headerTags ); |
224 | 224 | unset( $headerTags ); |
225 | | - foreach ( $pollStore->Questions as &$qdata ) { |
| 225 | + foreach ( $pollStore->Questions as $qdata ) { |
226 | 226 | if ( $pollStore->isUsedQuestion( $qdata->question_id ) ) { |
227 | 227 | $output .= "<br />\n<b>" . $qdata->question_id . ".</b> " . qp_Setup::entities( $qdata->CommonQuestion ) . "<br />\n"; |
228 | 228 | $qview = $qdata->getView(); |
— | — | @@ -251,7 +251,7 @@ |
252 | 252 | $output .= $this->qpLink( $this->getTitle(), wfMsg( 'qp_export_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'stats_xls', 'id' => $pid ) ) . "<br />\n"; |
253 | 253 | $output .= $this->qpLink( $this->getTitle(), wfMsg( 'qp_voices_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'voices_xls', 'id' => $pid ) ) . "<br />\n"; |
254 | 254 | $output .= $this->qpLink( $this->getTitle(), wfMsg( 'qp_interpretation_results_to_xls' ), array( "style" => "font-weight:bold;" ), array( 'action' => 'interpretation_xls', 'id' => $pid ) ) . "<br />\n"; |
255 | | - foreach ( $pollStore->Questions as &$qdata ) { |
| 255 | + foreach ( $pollStore->Questions as $qdata ) { |
256 | 256 | $qview = $qdata->getView(); |
257 | 257 | $output .= $qview->displayQuestionStats( $this, $pid ); |
258 | 258 | } |
— | — | @@ -415,9 +415,7 @@ |
416 | 416 | |
417 | 417 | function getPageHeader() { |
418 | 418 | global $wgLang, $wgContLang; |
419 | | - # fake pollStore to get username by uid: avoid to use this trick as much as possible |
420 | | - $pollStore = new qp_PollStore(); |
421 | | - $userName = $pollStore->getUserName( $this->uid ); |
| 419 | + $userName = qp_PollStore::getUserName( $this->uid ); |
422 | 420 | $db = wfGetDB( DB_SLAVE ); |
423 | 421 | $res = $db->select( |
424 | 422 | 'qp_users_polls', |
— | — | @@ -654,24 +652,24 @@ |
655 | 653 | # 'parentheses' are unavailable in MW 1.14.x |
656 | 654 | $head[] = wfMsg( 'qp_parentheses', $goto_link ) . '<br />'; |
657 | 655 | $ques_found = false; |
658 | | - foreach ( $pollStore->Questions as &$ques ) { |
659 | | - if ( $ques->question_id == $this->question_id ) { |
| 656 | + foreach ( $pollStore->Questions as $qdata ) { |
| 657 | + if ( $qdata->question_id == $this->question_id ) { |
660 | 658 | $ques_found = true; |
661 | 659 | break; |
662 | 660 | } |
663 | 661 | } |
664 | 662 | if ( $ques_found ) { |
665 | | - $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $ques->CommonQuestion ) ); |
666 | | - if ( array_key_exists( $this->cat_id, $ques->Categories ) ) { |
667 | | - $categ = &$ques->Categories[ $this->cat_id ]; |
668 | | - $proptext = $ques->ProposalText[ $this->proposal_id ]; |
| 663 | + $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $qdata->CommonQuestion ) ); |
| 664 | + if ( array_key_exists( $this->cat_id, $qdata->Categories ) ) { |
| 665 | + $categ = &$qdata->Categories[ $this->cat_id ]; |
| 666 | + $proptext = $qdata->ProposalText[ $this->proposal_id ]; |
669 | 667 | $cat_name = $categ['name']; |
670 | 668 | if ( array_key_exists( 'spanId', $categ ) ) { |
671 | | - $cat_name = wfMsg( 'qp_full_category_name', $cat_name, $ques->CategorySpans[ $categ['spanId'] ]['name'] ); |
| 669 | + $cat_name = wfMsg( 'qp_full_category_name', $cat_name, $qdata->CategorySpans[ $categ['spanId'] ]['name'] ); |
672 | 670 | } |
673 | 671 | $qpa = wfMsg( 'qp_header_line_qucl', |
674 | 672 | $this->question_id, |
675 | | - qp_Setup::entities( $ques->CommonQuestion ), |
| 673 | + qp_Setup::entities( $qdata->CommonQuestion ), |
676 | 674 | qp_Setup::entities( $proptext ), |
677 | 675 | qp_Setup::entities( $cat_name ) ) . '<br />'; |
678 | 676 | $head[] = array( '__tag' => 'div', 'class' => 'head', 'style' => 'padding-left:2em;', 0 => $qpa ); |
Index: trunk/extensions/QPoll/ctrl/poll/qp_abstractpoll.php |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | * |
101 | 101 | * @public |
102 | 102 | */ |
103 | | - function __construct( $argv, qp_AbstractPollView $view ) { |
| 103 | + function __construct( array $argv, qp_AbstractPollView $view ) { |
104 | 104 | global $wgLanguageCode; |
105 | 105 | $this->mResponse = qp_Setup::$request->response(); |
106 | 106 | # Determine which messages will be used, according to the language. |
— | — | @@ -250,7 +250,7 @@ |
251 | 251 | * @modifies $paramkeys array key is attribute regexp, value is the value of attribute |
252 | 252 | * @return string the value of question's type attribute |
253 | 253 | */ |
254 | | - function getQuestionAttributes( $attr_str, &$paramkeys ) { |
| 254 | + function getQuestionAttributes( $attr_str, array &$paramkeys ) { |
255 | 255 | $paramkeys = qp_Setup::getXmlLikeAttributes( $attr_str, $this->questionAttributeKeys ); |
256 | 256 | # apply default questions attributes from poll definition, if there is any |
257 | 257 | foreach ( $this->defaultQuestionAttributes as $attr => $val ) { |
Index: trunk/extensions/QPoll/ctrl/poll/qp_pollstats.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | */ |
44 | 44 | class qp_PollStats extends qp_AbstractPoll { |
45 | 45 | |
46 | | - function __construct( $argv, qp_PollStatsView $view ) { |
| 46 | + function __construct( array $argv, qp_PollStatsView $view ) { |
47 | 47 | parent::__construct( $argv, $view ); |
48 | 48 | $this->pollAddr = trim( $argv['address'] ); |
49 | 49 | } |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | array_unshift( $unparsedAttributes, null ); |
101 | 101 | unset( $unparsedAttributes[0] ); |
102 | 102 | # first pass: parse the headers |
103 | | - foreach ( $this->pollStore->Questions as &$qdata ) { |
| 103 | + foreach ( $this->pollStore->Questions as $qdata ) { |
104 | 104 | $question = new qp_QuestionStats( |
105 | 105 | $this, |
106 | 106 | qp_QuestionStatsView::newFromBaseView( $this->view ), |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | |
150 | 150 | # populate the question with data and build it's HTML representation |
151 | 151 | # returns HTML representation of the question |
152 | | - function parseStats( qp_QuestionStats &$question ) { |
| 152 | + function parseStats( qp_QuestionStats $question ) { |
153 | 153 | # parse the question body |
154 | 154 | if ( $question->getQuestionAnswer( $this->pollStore ) ) { |
155 | 155 | $question->statsParseBody(); |
Index: trunk/extensions/QPoll/ctrl/poll/qp_poll.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | # maximal count of attepts of answer submission ( < 1 for infinite ) |
56 | 56 | var $maxAttempts = 0; |
57 | 57 | |
58 | | - function __construct( $argv, qp_PollView $view ) { |
| 58 | + function __construct( array $argv, qp_PollView $view ) { |
59 | 59 | parent::__construct( $argv, $view ); |
60 | 60 | # dependance attr |
61 | 61 | if ( array_key_exists( 'dependance', $argv ) ) { |
— | — | @@ -374,8 +374,9 @@ |
375 | 375 | /** |
376 | 376 | * Parse question main header (common question and XML attributes) |
377 | 377 | * initializes common question and question type/subtype |
378 | | - * @param $input the question's header in QPoll syntax |
379 | | - * @return an instance of question that matches the header attributes |
| 378 | + * @param $header string |
| 379 | + * the question's header in QPoll syntax |
| 380 | + * @return instance of question that matches the header attributes |
380 | 381 | */ |
381 | 382 | function parseMainHeader( $header ) { |
382 | 383 | # split common question and question attributes from the header |
— | — | @@ -473,7 +474,7 @@ |
474 | 475 | if ( $this->mBeingCorrected ) { |
475 | 476 | if ( $question->getState() == '' ) { |
476 | 477 | # question is OK, store it into pollStore |
477 | | - $this->pollStore->setQuestionAnswer( $question ); |
| 478 | + $this->pollStore->setQuestion( $question ); |
478 | 479 | } else { |
479 | 480 | # http post: not every proposals were answered: do not update DB |
480 | 481 | $this->pollStore->stateIncomplete(); |
Index: trunk/extensions/QPoll/ctrl/qp_interpresult.php |
— | — | @@ -139,13 +139,16 @@ |
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Build a projection of associative array tree to 2nd dimensional array |
143 | | - * @modifies $strucTable array destination 2nd dimensional array |
144 | | - * (see description in $this->getStructuredAnswerTable); |
145 | | - * @param $structured array current node of associative array tree |
146 | | - * @param $level_header string current "folder-like" prefix of |
147 | | - * structured answer nested key (levels are separated with " / ") |
| 143 | + * @modifies $strucTable array |
| 144 | + * destination 2nd dimensional array; |
| 145 | + * see description in $this->getStructuredAnswerTable(); |
| 146 | + * @param $structured mixed |
| 147 | + * array / scalar current node of associative array tree |
| 148 | + * @param $level_header string |
| 149 | + * current "folder-like" prefix of structured answer nested key |
| 150 | + * (levels are separated with " / ") |
148 | 151 | */ |
149 | | - function buildStructuredTable( &$strucTable, &$structured, $level_header = '' ) { |
| 152 | + function buildStructuredTable( array &$strucTable, &$structured, $level_header = '' ) { |
150 | 153 | $keys = array(); |
151 | 154 | $vals = array(); |
152 | 155 | if ( is_array( $structured ) ) { |
Index: trunk/extensions/QPoll/ctrl/question/qp_abstractquestion.php |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | * @param $attr_str - source text with question attributes |
87 | 87 | * @return string : type of the question, empty when not defined |
88 | 88 | */ |
89 | | - function applyAttributes( $paramkeys ) { |
| 89 | + function applyAttributes( array $paramkeys ) { |
90 | 90 | $this->view->setLayout( $paramkeys[ 'layout' ], $paramkeys[ 'textwidth' ] ); |
91 | 91 | $this->view->setShowResults( $paramkeys[ 'showresults' ] ); |
92 | 92 | $this->view->setPropWidth( $paramkeys[ 'propwidth' ] ); |
Index: trunk/extensions/QPoll/ctrl/question/qp_textquestion.php |
— | — | @@ -252,11 +252,10 @@ |
253 | 253 | /** |
254 | 254 | * Applies previousely parsed attributes from main header into question's view |
255 | 255 | * (all attributes but type) |
256 | | - * |
257 | | - * @param $attr_str - source text with question attributes |
258 | | - * @return string : type of the question, empty when not defined |
| 256 | + * @param $paramkeys array |
| 257 | + * key is attribute name regexp match, value is the value of attribute |
259 | 258 | */ |
260 | | - function applyAttributes( $paramkeys ) { |
| 259 | + function applyAttributes( array $paramkeys ) { |
261 | 260 | parent::applyAttributes( $paramkeys ); |
262 | 261 | if ( $this->mSubType === 'requireAllCategories' ) { |
263 | 262 | # radio button prevents from filling all categories, disable it |
Index: trunk/extensions/QPoll/ctrl/question/qp_stubquestion.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | # load some question fields from qp_QuestionData given |
35 | 35 | # (usually qp_QuestionData is an array property of qp_PollStore instance) |
36 | 36 | # @param $qdata - an instance of qp_QuestionData |
37 | | - function loadAnswer( qp_QuestionData &$qdata ) { |
| 37 | + function loadAnswer( qp_QuestionData $qdata ) { |
38 | 38 | $this->alreadyVoted = $qdata->alreadyVoted; |
39 | 39 | $this->mPrevProposalCategoryId = $qdata->ProposalCategoryId; |
40 | 40 | $this->mPrevProposalCategoryText = $qdata->ProposalCategoryText; |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | |
49 | 49 | # populates an instance of qp_Question with data from qp_QuestionData |
50 | 50 | # @param the object of type qp_Question |
51 | | - function getQuestionAnswer( qp_PollStore &$pollStore ) { |
| 51 | + function getQuestionAnswer( qp_PollStore $pollStore ) { |
52 | 52 | if ( $pollStore->pid !== null ) { |
53 | 53 | if ( $pollStore->questionExists( $this->mQuestionId ) ) { |
54 | 54 | $qdata = $pollStore->Questions[ $this->mQuestionId ]; |
— | — | @@ -95,12 +95,13 @@ |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | | - * @return associative array of script-generated interpretation error |
100 | | - * messages for current question proposals (and optionally categories) |
101 | | - * false, when there are no script-generated error messages |
| 99 | + * @return mixed |
| 100 | + * array (associative) of script-generated interpretation error messages |
| 101 | + * for current question proposals (and optionally categories); |
| 102 | + * boolean false, when there are no script-generated error messages; |
102 | 103 | */ |
103 | 104 | function getInterpErrors() { |
104 | | - $interpResult = &$this->poll->pollStore->interpResult; |
| 105 | + $interpResult = $this->poll->pollStore->interpResult; |
105 | 106 | if ( !is_array( $interpResult->qpcErrors ) || |
106 | 107 | !isset( $interpResult->qpcErrors[$this->mQuestionId] ) ) { |
107 | 108 | return false; |
Index: trunk/extensions/QPoll/ctrl/question/qp_questionstats.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | # load some question fields from qp_QuestionData given |
27 | 27 | # (usually qp_QuestionData is a property of qp_PollStore instance) |
28 | 28 | # @param $qdata - an instance of qp_QuestionData |
29 | | - function loadAnswer( qp_QuestionData &$qdata ) { |
| 29 | + function loadAnswer( qp_QuestionData $qdata ) { |
30 | 30 | $this->alreadyVoted = $qdata->alreadyVoted; |
31 | 31 | $this->mCommonQuestion = $qdata->CommonQuestion; |
32 | 32 | $this->mProposalText = $qdata->ProposalText; |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | |
43 | 43 | # populates an instance of qp_Question with data from qp_QuestionData |
44 | 44 | # input: the object of type qp_Question |
45 | | - function getQuestionAnswer( qp_PollStore &$pollStore ) { |
| 45 | + function getQuestionAnswer( qp_PollStore $pollStore ) { |
46 | 46 | if ( $pollStore->pid !== null ) { |
47 | 47 | if ( $pollStore->questionExists( $this->mQuestionId ) ) { |
48 | 48 | $qdata = $pollStore->Questions[ $this->mQuestionId ]; |
Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -299,7 +299,7 @@ |
300 | 300 | /** |
301 | 301 | * Autoload classes from the map provided |
302 | 302 | */ |
303 | | - static function autoLoad( $map ) { |
| 303 | + static function autoLoad( array $map ) { |
304 | 304 | global $wgAutoloadClasses; |
305 | 305 | foreach ( $map as $path => &$classes ) { |
306 | 306 | if ( is_array( $classes ) ) { |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | * @return array key is attribute regexp |
519 | 519 | * value is the value of attribute or null |
520 | 520 | */ |
521 | | - static function getXmlLikeAttributes( $attr_str, $attr_list ) { |
| 521 | + static function getXmlLikeAttributes( $attr_str, array $attr_list ) { |
522 | 522 | $attr_vals = array(); |
523 | 523 | $match = array(); |
524 | 524 | foreach ( $attr_list as $attr_name ) { |
— | — | @@ -551,8 +551,9 @@ |
552 | 552 | } |
553 | 553 | |
554 | 554 | static function onLanguageGetMagic( &$magicWords, $langCode ) { |
555 | | - foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans ) |
556 | | - $magicWords [$word ] = $trans; |
| 555 | + foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans ) { |
| 556 | + $magicWords[$word] = $trans; |
| 557 | + } |
557 | 558 | return true; |
558 | 559 | } |
559 | 560 | |
Index: trunk/extensions/QPoll/includes/qp_functionshook.php |
— | — | @@ -50,9 +50,9 @@ |
51 | 51 | |
52 | 52 | var $error_message = 'no_such_poll'; |
53 | 53 | |
54 | | - function qpuserchoice( &$parser, $frame, $args ) { |
| 54 | + function qpuserchoice( Parser &$parser, PPFrame $frame, array $args ) { |
55 | 55 | qp_Setup::onLoadAllMessages(); |
56 | | - $this->frame = &$frame; |
| 56 | + $this->frame = $frame; |
57 | 57 | $this->args = &$args; |
58 | 58 | if ( isset( $args[ 0 ] ) ) { |
59 | 59 | # args[0] is a poll address |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | |
105 | | - function qpuserchoiceValidResult( $qdata ) { |
| 105 | + function qpuserchoiceValidResult( qp_QuestionData $qdata ) { |
106 | 106 | $result = ''; |
107 | 107 | if ( array_key_exists( $this->proposal_id, $qdata->ProposalCategoryId ) ) { |
108 | 108 | foreach ( $qdata->ProposalCategoryId[ $this->proposal_id ] as $id_key => $cat_id ) { |
Index: trunk/extensions/QPoll/includes/qp_xlswriter.php |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | * for cell formatting; we store these instances in self::$format array |
94 | 94 | * and then address these by passing array keys (strings with format "name"). |
95 | 95 | */ |
96 | | - function addFormats( $formats ) { |
| 96 | + function addFormats( array $formats ) { |
97 | 97 | foreach ( $formats as $fkey => $fdef ) { |
98 | 98 | self::$fdef[$fkey] = $fdef; |
99 | 99 | self::$format[$fkey] = self::$wb->addformat( $fdef ); |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | /** |
178 | 178 | * Write 2d-table of data into selected column of the current row. |
179 | 179 | */ |
180 | | - function writeFormattedTable( $colnum, &$table, $fkey = 'null' ) { |
| 180 | + function writeFormattedTable( $colnum, array &$table, $fkey = 'null' ) { |
181 | 181 | $ws = self::$ws; |
182 | 182 | foreach ( $table as $rnum => &$row ) { |
183 | 183 | foreach ( $row as $cnum => &$cell ) { |
Index: trunk/extensions/QPoll/includes/qp_renderer.php |
— | — | @@ -52,11 +52,13 @@ |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Renders nested tag array into string |
56 | | - * @param $tag multidimensional array of xml/html tags |
| 56 | + * @param $tag mixed |
| 57 | + * array (multidimensional) of xml/html tags; |
| 58 | + * string single text node; |
57 | 59 | * @return string representation of xml/html |
58 | 60 | * |
59 | 61 | * the stucture of $tag is like this: |
60 | | - * array( "__tag"=>"td", "class"=>"myclass", 0=>"text before li", 1=>array( "__tag"=>"li", 0=>"text inside li" ), 2=>"text after li" ) |
| 62 | + * array( '__tag'=>'td', 'class'=>'myclass', 0=>'text before li', 1=>array( '__tag'=>'li', 0=>'text inside li' ), 2=>'text after li' ) |
61 | 63 | * |
62 | 64 | * both tagged and tagless lists are supported |
63 | 65 | */ |
— | — | @@ -127,7 +129,7 @@ |
128 | 130 | /** |
129 | 131 | * add one or more CSS class name to tag class attribute |
130 | 132 | */ |
131 | | - static function addClass( &$tag, $className ) { |
| 133 | + static function addClass( array &$tag, $className ) { |
132 | 134 | if ( !isset( $tag['class'] ) ) { |
133 | 135 | $tag['class'] = $className; |
134 | 136 | return; |
— | — | @@ -152,8 +154,11 @@ |
153 | 155 | * each element of resulting tagarray |
154 | 156 | * @return array tagarray |
155 | 157 | */ |
156 | | - static function tagList( $row, $destinationAttr = 0, $rowattrs = array( '__tag' => 'td' ) ) { |
157 | | - if ( count( $row ) <= 0 ) { |
| 158 | + static function tagList( |
| 159 | + array $row, |
| 160 | + $destinationAttr = 0, |
| 161 | + array $rowattrs = array( '__tag' => 'td' ) ) { |
| 162 | + if ( count( $row ) < 1 ) { |
158 | 163 | return ''; |
159 | 164 | } |
160 | 165 | $result = array(); |
— | — | @@ -174,7 +179,11 @@ |
175 | 180 | * destination cell xml attributes ("name"=>0, "count"=>colspan" ) |
176 | 181 | * @return array of destination cells |
177 | 182 | */ |
178 | | - static function newRow( $row, $rowattrs = "", $celltag = "td", $attribute_maps = null ) { |
| 183 | + static function newRow( |
| 184 | + array $row, |
| 185 | + array $rowattrs = array(), |
| 186 | + $celltag = "td", |
| 187 | + array $attribute_maps = array() ) { |
179 | 188 | $result = ""; |
180 | 189 | if ( count( $row ) > 0 ) { |
181 | 190 | foreach ( $row as &$cell ) { |
— | — | @@ -183,21 +192,18 @@ |
184 | 193 | } |
185 | 194 | $cell['__tag'] = $celltag; |
186 | 195 | $cell['__end'] = "\n"; |
187 | | - if ( is_array( $attribute_maps ) ) { |
188 | | - # converts ("count"=>3) to ("colspan"=>3) in table headers - don't use frequently |
189 | | - foreach ( $attribute_maps as $key => $val ) { |
190 | | - if ( array_key_exists( $key, $cell ) ) { |
191 | | - $cell[ $val ] = $cell[ $key ]; |
192 | | - unset( $cell[ $key ] ); |
193 | | - } |
| 196 | + # converts ("count"=>3) to ("colspan"=>3) in table headers |
| 197 | + # please don't use frequently, because it's inefficient |
| 198 | + foreach ( $attribute_maps as $key => $val ) { |
| 199 | + if ( array_key_exists( $key, $cell ) ) { |
| 200 | + $cell[ $val ] = $cell[ $key ]; |
| 201 | + unset( $cell[ $key ] ); |
194 | 202 | } |
195 | 203 | } |
196 | 204 | } |
197 | 205 | $result = array( '__tag' => 'tr', 0 => $row, '__end' => "\n" ); |
198 | | - if ( is_array( $rowattrs ) ) { |
| 206 | + if ( count( $rowattrs ) > 0 ) { |
199 | 207 | $result = array_merge( $rowattrs, $result ); |
200 | | - } elseif ( $rowattrs !== "" ) { |
201 | | - $result[0][] = __METHOD__ . ':invalid rowattrs supplied'; |
202 | 208 | } |
203 | 209 | } |
204 | 210 | return $result; |
— | — | @@ -207,7 +213,12 @@ |
208 | 214 | * Add row to the table |
209 | 215 | * todo: document |
210 | 216 | */ |
211 | | - static function addRow( &$table, $row, $rowattrs = "", $celltag = "td", $attribute_maps = null ) { |
| 217 | + static function addRow( |
| 218 | + array &$table, |
| 219 | + array $row, |
| 220 | + array $rowattrs = array(), |
| 221 | + $celltag = "td", |
| 222 | + array $attribute_maps = array() ) { |
212 | 223 | $table[] = self::newRow( $row, $rowattrs, $celltag, $attribute_maps ); |
213 | 224 | } |
214 | 225 | |
— | — | @@ -215,7 +226,12 @@ |
216 | 227 | * Add column to the table |
217 | 228 | * todo: document |
218 | 229 | */ |
219 | | - static function addColumn( &$table, $column, $rowattrs = "", $celltag = "td", $attribute_maps = null ) { |
| 230 | + static function addColumn( |
| 231 | + array &$table, |
| 232 | + array $column, |
| 233 | + array $rowattrs = array(), |
| 234 | + $celltag = "td", |
| 235 | + array $attribute_maps = array() ) { |
220 | 236 | if ( count( $column ) > 0 ) { |
221 | 237 | $row = 0; |
222 | 238 | foreach ( $column as &$cell ) { |
— | — | @@ -224,19 +240,15 @@ |
225 | 241 | } |
226 | 242 | $cell[ '__tag' ] = $celltag; |
227 | 243 | $cell[ '__end' ] = "\n"; |
228 | | - if ( is_array( $attribute_maps ) ) { |
229 | | - # converts ("count"=>3) to ("rowspan"=>3) in table headers - don't use frequently |
230 | | - foreach ( $attribute_maps as $key => $val ) { |
231 | | - if ( array_key_exists( $key, $cell ) ) { |
232 | | - $cell[ $val ] = $cell[ $key ]; |
233 | | - unset( $cell[ $key ] ); |
234 | | - } |
| 244 | + # converts ("count"=>3) to ("rowspan"=>3) in table headers - don't use frequently |
| 245 | + foreach ( $attribute_maps as $key => $val ) { |
| 246 | + if ( array_key_exists( $key, $cell ) ) { |
| 247 | + $cell[ $val ] = $cell[ $key ]; |
| 248 | + unset( $cell[ $key ] ); |
235 | 249 | } |
236 | 250 | } |
237 | | - if ( is_array( $rowattrs ) ) { |
| 251 | + if ( count( $rowattrs ) > 0 ) { |
238 | 252 | $cell = array_merge( $rowattrs, $cell ); |
239 | | - } elseif ( $rowattrs !== "" ) { |
240 | | - $cell[ 0 ] = __METHOD__ . ':invalid rowattrs supplied'; |
241 | 253 | } |
242 | 254 | if ( !array_key_exists( $row, $table ) ) { |
243 | 255 | $table[ $row ] = array( '__tag' => 'tr', '__end' => "\n" ); |
— | — | @@ -252,7 +264,11 @@ |
253 | 265 | } |
254 | 266 | } |
255 | 267 | |
256 | | - static function displayRow( $row, $rowattrs = "", $celltag = "td", $attribute_maps = null ) { |
| 268 | + static function displayRow( |
| 269 | + array $row, |
| 270 | + array $rowattrs = array(), |
| 271 | + $celltag = "td", |
| 272 | + array $attribute_maps = array() ) { |
257 | 273 | # temporary var $tagsrow used to avoid warning in E_STRICT mode |
258 | 274 | $tagsrow = self::newRow( $row, $rowattrs, $celltag, $attribute_maps ); |
259 | 275 | return self::renderTagArray( $tagsrow ); |
— | — | @@ -262,8 +278,8 @@ |
263 | 279 | * use newRow() or addColumn() to add resulting row/column to the table |
264 | 280 | * if you want to use the resulting row with renderTagArray(), don't forget to apply attrs=array('__tag'=>'td') |
265 | 281 | */ |
266 | | - static function applyAttrsToRow( &$row, $attrs ) { |
267 | | - if ( is_array( $attrs ) && count( $attrs > 0 ) ) { |
| 282 | + static function applyAttrsToRow( array &$row, array $attrs ) { |
| 283 | + if ( count( $attrs > 0 ) ) { |
268 | 284 | foreach ( $row as &$cell ) { |
269 | 285 | if ( !is_array( $cell ) ) { |
270 | 286 | $cell = array_merge( $attrs, array( $cell ) ); |
Index: trunk/extensions/QPoll/interpretation/qp_interpret.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | * or false, when the poll questions were not randomized |
70 | 70 | * @return instance of qp_InterpResult class (interpretation result) |
71 | 71 | */ |
72 | | - static function getResult( $interpArticle, $injectVars ) { |
| 72 | + static function getResult( Article $interpArticle, array $injectVars ) { |
73 | 73 | global $wgParser, $wgContLang; |
74 | 74 | $matches = array(); |
75 | 75 | # extract <qpinterpret> tags from the article content |
Index: trunk/extensions/QPoll/interpretation/qp_eval.php |
— | — | @@ -224,9 +224,10 @@ |
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Calls php interpreter to lint interpretation script code |
228 | | - * @param $code string with php code |
229 | | - * @return bool true, when code has no syntax errors; |
230 | | - * string error message from php lint |
| 228 | + * @param $code string with php code |
| 229 | + * @return mixed |
| 230 | + * boolean true, when code has no syntax errors; |
| 231 | + * string error message from php lint; |
231 | 232 | */ |
232 | 233 | static function lint( $code ) { |
233 | 234 | $pipes = array(); |
— | — | @@ -312,9 +313,13 @@ |
313 | 314 | /** |
314 | 315 | * Checks the submitted eval code for errors |
315 | 316 | * In case of success returns transformed code, which is safer for eval |
316 | | - * @param $sourceCode submitted code which has to be eval'ed (no php tags) |
317 | | - * @param $destinationCode transformed code (in case of success) (no php tags) |
318 | | - * @return boolean true in case of success, string with error message on failure |
| 317 | + * @param $sourceCode string |
| 318 | + * submitted code which has to be eval'ed (no php tags) |
| 319 | + * @param $destinationCode string |
| 320 | + * transformed code (in case of success) (no php tags) |
| 321 | + * @return mixed |
| 322 | + * boolean true in case of success; |
| 323 | + * string error message on failure; |
319 | 324 | */ |
320 | 325 | static function checkAndTransformCode( $sourceCode, &$destinationCode ) { |
321 | 326 | |
— | — | @@ -382,18 +387,22 @@ |
383 | 388 | |
384 | 389 | /** |
385 | 390 | * Interpretates the answer with selected script |
386 | | - * @param $interpretScript string source code of interpretation script |
387 | | - * @param $injectVars array of PHP data to inject into interpretation script; |
388 | | - * key of element will become variable name |
389 | | - * in the interpretation script; |
390 | | - * value of element will become variable value |
391 | | - * in the interpretation script; |
392 | | - * @param $interpResult instance of qp_InterpResult class |
| 391 | + * @param $interpretScript |
| 392 | + * string source code of interpretation script |
| 393 | + * @param $injectVars |
| 394 | + * array of PHP data to inject into interpretation script; |
| 395 | + * key of element will become variable name in the interpretation script; |
| 396 | + * value of element will become variable value in the interpretation script; |
| 397 | + * @param $interpResult qp_InterpResult |
393 | 398 | * @modifies $interpResult |
394 | | - * @return array script result to check, or |
395 | | - * qp_InterpResult $interpResult (in case of error) |
| 399 | + * @return mixed |
| 400 | + * array script result to check |
| 401 | + * qp_InterpResult $interpResult (in case of error) |
396 | 402 | */ |
397 | | - static function interpretAnswer( $interpretScript, $injectVars, qp_InterpResult $interpResult ) { |
| 403 | + static function interpretAnswer( |
| 404 | + $interpretScript, |
| 405 | + array $injectVars, |
| 406 | + qp_InterpResult $interpResult ) { |
398 | 407 | # template page evaluation |
399 | 408 | if ( ( $check = self::selfCheck() ) !== true ) { |
400 | 409 | # self-check error |
Index: trunk/extensions/QPoll/view/proposal/qp_tabularquestionproposalview.php |
— | — | @@ -185,7 +185,7 @@ |
186 | 186 | * @return boolean true when at least one category was found in the list |
187 | 187 | * false otherwise |
188 | 188 | */ |
189 | | - function applyInterpErrors( $prop_desc ) { |
| 189 | + function applyInterpErrors( array $prop_desc ) { |
190 | 190 | $foundCats = false; |
191 | 191 | # scan the category views row to highlight erroneous categories |
192 | 192 | foreach ( $this->row as $cat_id => &$cat_tag ) { |
Index: trunk/extensions/QPoll/view/proposal/qp_textquestionproposalview.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | * @return boolean true when at least one category was found in the list |
128 | 128 | * false otherwise |
129 | 129 | */ |
130 | | - function applyInterpErrors( $prop_desc ) { |
| 130 | + function applyInterpErrors( array $prop_desc ) { |
131 | 131 | $foundCats = false; |
132 | 132 | $cat_id = -1; |
133 | 133 | foreach ( $this->viewtokens as &$token ) { |
Index: trunk/extensions/QPoll/view/qp_interpresultview.php |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | /** |
55 | 55 | * Add interpretation results to tagarray of poll view |
56 | 56 | */ |
57 | | - function showInterpResults( &$tagarray, qp_InterpResult $ctrl, $showDescriptions = false ) { |
| 57 | + function showInterpResults( array &$tagarray, qp_InterpResult $ctrl, $showDescriptions = false ) { |
58 | 58 | if ( $ctrl->hasVisibleProperties() ) { |
59 | 59 | return; |
60 | 60 | } |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | foreach ( $strucTable as &$line ) { |
94 | 94 | if ( isset( $line['keys'] ) ) { |
95 | 95 | # current node is associative array |
96 | | - qp_Renderer::addRow( $rows, $line['keys'], '', 'th' ); |
| 96 | + qp_Renderer::addRow( $rows, $line['keys'], array(), 'th' ); |
97 | 97 | qp_Renderer::addRow( $rows, $line['vals'] ); |
98 | 98 | } else { |
99 | 99 | # current node is scalar value |
Index: trunk/extensions/QPoll/view/results/qp_questiondataresults.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | $this->ctrl = $ctrl; |
24 | 24 | } |
25 | 25 | |
26 | | - protected function categoryentities( $cat ) { |
| 26 | + protected function categoryentities( array $cat ) { |
27 | 27 | $cat['name'] = qp_Setup::entities( $cat['name'] ); |
28 | 28 | return $cat; |
29 | 29 | } |
— | — | @@ -33,8 +33,18 @@ |
34 | 34 | function displayUserQuestionVote() { |
35 | 35 | $ctrl = $this->ctrl; |
36 | 36 | $output = "<div class=\"qpoll\">\n" . "<table class=\"qdata\">\n"; |
37 | | - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ), array( 'class' => 'spans' ), 'th', array( 'count' => 'colspan', 'name' => 0 ) ); |
38 | | - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->Categories ), '', 'th', array( 'name' => 0 ) ); |
| 37 | + $output .= qp_Renderer::displayRow( |
| 38 | + array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ), |
| 39 | + array( 'class' => 'spans' ), |
| 40 | + 'th', |
| 41 | + array( 'count' => 'colspan', 'name' => 0 ) |
| 42 | + ); |
| 43 | + $output .= qp_Renderer::displayRow( |
| 44 | + array_map( array( $this, 'categoryentities' ), $ctrl->Categories ), |
| 45 | + array(), |
| 46 | + 'th', |
| 47 | + array( 'name' => 0 ) |
| 48 | + ); |
39 | 49 | # multiple choice polls doesn't use real spans, instead, every column is like "span" |
40 | 50 | $spansUsed = count( $ctrl->CategorySpans ) > 0 || $ctrl->type == "multipleChoice"; |
41 | 51 | foreach ( $ctrl->ProposalText as $propkey => &$proposal_text ) { |
— | — | @@ -80,8 +90,18 @@ |
81 | 91 | $current_title = $page->getTitle(); |
82 | 92 | $output = "<br />\n<b>" . $ctrl->question_id . ".</b> " . qp_Setup::entities( $ctrl->CommonQuestion ) . "<br />\n"; |
83 | 93 | $output .= "<div class=\"qpoll\">\n" . "<table class=\"qdata\">\n"; |
84 | | - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ), array( 'class' => 'spans' ), 'th', array( 'count' => 'colspan', 'name' => 0 ) ); |
85 | | - $output .= qp_Renderer::displayRow( array_map( array( $this, 'categoryentities' ), $ctrl->Categories ), '', 'th', array( 'name' => 0 ) ); |
| 94 | + $output .= qp_Renderer::displayRow( |
| 95 | + array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ), |
| 96 | + array( 'class' => 'spans' ), |
| 97 | + 'th', |
| 98 | + array( 'count' => 'colspan', 'name' => 0 ) |
| 99 | + ); |
| 100 | + $output .= qp_Renderer::displayRow( |
| 101 | + array_map( array( $this, 'categoryentities' ), $ctrl->Categories ), |
| 102 | + array(), |
| 103 | + 'th', |
| 104 | + array( 'name' => 0 ) |
| 105 | + ); |
86 | 106 | # multiple choice polls doesn't use real spans, instead, every column is like "span" |
87 | 107 | $spansUsed = count( $ctrl->CategorySpans ) > 0 || $ctrl->type == "multipleChoice"; |
88 | 108 | foreach ( $ctrl->ProposalText as $propkey => &$proposal_text ) { |
Index: trunk/extensions/QPoll/view/results/qp_textquestiondataresults.php |
— | — | @@ -100,7 +100,10 @@ |
101 | 101 | throw new MWException( 'DB token has invalid type (' . gettype( $token ) . ') in ' . __METHOD__ ); |
102 | 102 | } |
103 | 103 | } |
104 | | - $output .= qp_Renderer::displayRow( array( $row ), array( 'class' => 'qdatatext' ) ); |
| 104 | + $output .= qp_Renderer::displayRow( |
| 105 | + array( $row ), |
| 106 | + array( 'class' => 'qdatatext' ) |
| 107 | + ); |
105 | 108 | } |
106 | 109 | $output .= "</table>\n" . "</div>\n"; |
107 | 110 | return $output; |
Index: trunk/extensions/QPoll/view/qp_abstractview.php |
— | — | @@ -60,9 +60,9 @@ |
61 | 61 | * @param $parser instance of parser for current tag hook |
62 | 62 | * @param $ppframe instance of ppframe for current tag hook |
63 | 63 | */ |
64 | | - function __construct( &$parser, &$frame ) { |
65 | | - $this->parser = &$parser; |
66 | | - $this->ppframe = &$frame; |
| 64 | + function __construct( Parser $parser, PPFrame $frame ) { |
| 65 | + $this->parser = $parser; |
| 66 | + $this->ppframe = $frame; |
67 | 67 | $this->linker = new Linker(); |
68 | 68 | } |
69 | 69 | |
— | — | @@ -84,7 +84,12 @@ |
85 | 85 | $this->ctrl = $ctrl; |
86 | 86 | } |
87 | 87 | |
88 | | - function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) { |
| 88 | + function link( |
| 89 | + $target, |
| 90 | + $text = null, |
| 91 | + array $customAttribs = array(), |
| 92 | + array $query = array(), |
| 93 | + array $options = array() ) { |
89 | 94 | return $this->linker->link( $target, $text, $customAttribs, $query, $options ); |
90 | 95 | } |
91 | 96 | |
Index: trunk/extensions/QPoll/view/xls/qp_xlstabularquestion.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | $this->writeRowLn( 0, $row ); |
33 | 33 | } |
34 | 34 | |
35 | | - function writeQuestionVoice( $pvoices ) { |
| 35 | + function writeQuestionVoice( array $pvoices ) { |
36 | 36 | $qdata = $this->qdata; |
37 | 37 | # create square table of proposal / category answers for each uid in uvoices array |
38 | 38 | $voicesTable = array(); |
Index: trunk/extensions/QPoll/view/xls/qp_xlspoll.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | function voicesToXls( qp_PollStore $pollStore ) { |
70 | 70 | $pollStore->loadQuestions(); |
71 | 71 | $first_question = true; |
72 | | - foreach ( $pollStore->Questions as $qkey => &$qdata ) { |
| 72 | + foreach ( $pollStore->Questions as $qkey => $qdata ) { |
73 | 73 | $xlsq = ( $qdata->type === 'textQuestion' ) ? $this->text_writer : $this->tabular_writer; |
74 | 74 | $xlsq->setQuestionData( $qdata ); |
75 | 75 | if ( $first_question ) { |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | $pollStore->loadTotals(); |
117 | 117 | $pollStore->calculateStatistics(); |
118 | 118 | $first_question = true; |
119 | | - foreach ( $pollStore->Questions as $qkey => &$qdata ) { |
| 119 | + foreach ( $pollStore->Questions as $qkey => $qdata ) { |
120 | 120 | $xlsq = ( $qdata->type === 'textQuestion' ) ? $this->text_writer : $this->tabular_writer; |
121 | 121 | $xlsq->setQuestionData( $qdata ); |
122 | 122 | if ( $first_question ) { |
Index: trunk/extensions/QPoll/view/xls/qp_xlstextquestion.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | ) ); |
13 | 13 | } |
14 | 14 | |
15 | | - function writeQuestionVoice( $pvoices ) { |
| 15 | + function writeQuestionVoice( array $pvoices ) { |
16 | 16 | $qdata = $this->qdata; |
17 | 17 | foreach ( $qdata->ProposalText as $propkey => &$serialized_tokens ) { |
18 | 18 | # Create 2D-table of proposal / category answers for each uid in uvoices array |
Index: trunk/extensions/QPoll/view/question/qp_tabularquestionview.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | * @param $frame |
70 | 70 | * @param $showResults poll's showResults (may be overriden in the question) |
71 | 71 | */ |
72 | | - function __construct( &$parser, &$frame, $showResults ) { |
| 72 | + function __construct( Parser $parser, PPFrame $frame, $showResults ) { |
73 | 73 | parent::__construct( $parser, $frame ); |
74 | 74 | $this->pollShowResults = $showResults; |
75 | 75 | } |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | * Builds tagarray of categories |
145 | 145 | * @param $categories "raw" categories |
146 | 146 | */ |
147 | | - function buildCategoriesRow( $categories ) { |
| 147 | + function buildCategoriesRow( array $categories ) { |
148 | 148 | $row = array(); |
149 | 149 | if ( $this->proposalsFirst ) { |
150 | 150 | // add empty <th> at the begin of row to "compensate" proposal text |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | * Builds tagarray of category spans |
165 | 165 | * @param $categorySpans "raw" spans |
166 | 166 | */ |
167 | | - function buildSpansRow( $categorySpans ) { |
| 167 | + function buildSpansRow( array $categorySpans ) { |
168 | 168 | $row = array(); |
169 | 169 | if ( $this->proposalsFirst ) { |
170 | 170 | // add empty <th> at the begin of row to "compensate" proposal text |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | } |
240 | 240 | if ( isset( $this->pviews[$prop_id] ) ) { |
241 | 241 | # the whole proposal line has errors |
242 | | - $propview = &$this->pviews[$prop_id]; |
| 242 | + $propview = $this->pviews[$prop_id]; |
243 | 243 | if ( !is_array( $prop_desc ) ) { |
244 | 244 | if ( !is_string( $prop_desc ) ) { |
245 | 245 | $prop_desc = wfMsg( 'qp_interpetation_wrong_answer' ); |
— | — | @@ -267,11 +267,11 @@ |
268 | 268 | $questionTable = array(); |
269 | 269 | # add header views to $questionTable |
270 | 270 | foreach ( $this->hviews as $header ) { |
271 | | - $rowattrs = ''; |
272 | | - $attribute_maps = null; |
| 271 | + $rowattrs = array(); |
| 272 | + $attribute_maps = array(); |
273 | 273 | if ( is_object( $header ) ) { |
274 | 274 | $row = &$header->row; |
275 | | - $rowattrs = array( 'class' => $header->className ); |
| 275 | + $rowattrs['class'] = $header->className; |
276 | 276 | $attribute_maps = &$header->attribute_maps; |
277 | 277 | } else { |
278 | 278 | $row = &$header; |
Index: trunk/extensions/QPoll/view/question/qp_stubquestionview.php |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | * @param $parser |
63 | 63 | * @param $frame |
64 | 64 | */ |
65 | | - function __construct( &$parser, &$frame ) { |
| 65 | + function __construct( Parser $parser, PPFrame $frame ) { |
66 | 66 | parent::__construct( $parser, $frame ); |
67 | 67 | } |
68 | 68 | |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | * @param $className CSS class name of row |
106 | 106 | * @param $attribute_maps translation of source attributes into html attributes (see qp_Renderer class) |
107 | 107 | */ |
108 | | - function addHeaderRow( $row, $className, $attribute_maps = null ) { |
| 108 | + function addHeaderRow( $row, $className, array $attribute_maps = array() ) { |
109 | 109 | $this->hviews[] = (object) array( |
110 | 110 | 'row' => $row, |
111 | 111 | 'className' => $className, |
— | — | @@ -126,11 +126,11 @@ |
127 | 127 | $questionTable = array(); |
128 | 128 | # add header views to $questionTable |
129 | 129 | foreach ( $this->hviews as $header ) { |
130 | | - $rowattrs = ''; |
131 | | - $attribute_maps = null; |
| 130 | + $rowattrs = array(); |
| 131 | + $attribute_maps = array(); |
132 | 132 | if ( is_object( $header ) ) { |
133 | 133 | $row = &$header->row; |
134 | | - $rowattrs = array( 'class' => $header->className ); |
| 134 | + $rowattrs['class'] = $header->className; |
135 | 135 | $attribute_maps = &$header->attribute_maps; |
136 | 136 | } else { |
137 | 137 | $row = &$header; |
Index: trunk/extensions/QPoll/view/question/qp_textquestionview.php |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | /** |
81 | 81 | * Add proposal error tagarray |
82 | 82 | */ |
83 | | - function addError( $elem ) { |
| 83 | + function addError( stdClass $elem ) { |
84 | 84 | $this->cell[] = array( |
85 | 85 | '__tag' => 'span', |
86 | 86 | 'class' => 'proposalerror', |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | /** |
92 | 92 | * Add category as input type text / checkbox / radio / textarea tagarray |
93 | 93 | */ |
94 | | - function addInput( $elem, $className ) { |
| 94 | + function addInput( stdClass $elem, $className ) { |
95 | 95 | $tagName = ( $elem->type === 'text' && $elem->attributes['height'] !== 0 ) ? 'textarea' : 'input'; |
96 | 96 | $lines_count = 1; |
97 | 97 | # get category value |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | /** |
155 | 155 | * Add category as select / option list tagarray |
156 | 156 | */ |
157 | | - function addSelect( $elem, $className ) { |
| 157 | + function addSelect( stdClass $elem, $className ) { |
158 | 158 | if ( $elem->options[0] !== '' ) { |
159 | 159 | # default element in select/option set always must be an empty option |
160 | 160 | array_unshift( $elem->options, '' ); |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | /** |
211 | 211 | * Add tagarray representation of proposal part |
212 | 212 | */ |
213 | | - function addProposalPart( $elem ) { |
| 213 | + function addProposalPart( /* string */ $elem ) { |
214 | 214 | $this->cell[] = array( |
215 | 215 | '__tag' => 'span', |
216 | 216 | 'class' => 'prop_part', |
— | — | @@ -268,7 +268,7 @@ |
269 | 269 | * @param $frame |
270 | 270 | * @param $showResults poll's showResults (may be overriden in the question) |
271 | 271 | */ |
272 | | - function __construct( &$parser, &$frame, $showResults ) { |
| 272 | + function __construct( Parser $parser, PPFrame $frame, $showResults ) { |
273 | 273 | parent::__construct( $parser, $frame ); |
274 | 274 | $this->vr = new qp_TextQuestionViewRow( $this ); |
275 | 275 | /* todo: implement showResults */ |
— | — | @@ -319,7 +319,7 @@ |
320 | 320 | } |
321 | 321 | if ( isset( $this->pviews[$prop_id] ) ) { |
322 | 322 | # the whole proposal line has errors |
323 | | - $propview = &$this->pviews[$prop_id]; |
| 323 | + $propview = $this->pviews[$prop_id]; |
324 | 324 | if ( !is_array( $prop_desc ) ) { |
325 | 325 | if ( !is_string( $prop_desc ) ) { |
326 | 326 | $prop_desc = wfMsg( 'qp_interpetation_wrong_answer' ); |
— | — | @@ -350,7 +350,7 @@ |
351 | 351 | * @param $viewtokens array of viewtokens |
352 | 352 | * @return tagarray |
353 | 353 | */ |
354 | | - function renderParsedProposal( $pkey, &$viewtokens ) { |
| 354 | + function renderParsedProposal( $pkey, array &$viewtokens ) { |
355 | 355 | $vr = $this->vr; |
356 | 356 | # proposal prefix for category tag id generation |
357 | 357 | $vr->reset( "tx{$this->ctrl->poll->mOrderId}q{$this->ctrl->mQuestionId}p{$pkey}" ); |
— | — | @@ -411,18 +411,18 @@ |
412 | 412 | $questionTable = array(); |
413 | 413 | # add header views to $questionTable |
414 | 414 | foreach ( $this->hviews as $header ) { |
415 | | - $rowattrs = ''; |
416 | | - $attribute_maps = null; |
| 415 | + $rowattrs = array(); |
| 416 | + $attribute_maps = array(); |
417 | 417 | if ( is_object( $header ) ) { |
418 | 418 | $row = &$header->row; |
419 | | - $rowattrs = array( 'class' => $header->className ); |
| 419 | + $rowattrs['class'] = $header->className; |
420 | 420 | $attribute_maps = &$header->attribute_maps; |
421 | 421 | } else { |
422 | 422 | $row = &$header; |
423 | 423 | } |
424 | 424 | qp_Renderer::addRow( $questionTable, $row, $rowattrs, 'th', $attribute_maps ); |
425 | 425 | } |
426 | | - foreach ( $this->pviews as $pkey => &$propview ) { |
| 426 | + foreach ( $this->pviews as $pkey => $propview ) { |
427 | 427 | $prop = $this->renderParsedProposal( $pkey, $propview->viewtokens ); |
428 | 428 | $rowattrs = array( 'class' => $propview->rowClass ); |
429 | 429 | if ( $this->transposed ) { |