Index: trunk/extensions/QPoll/ctrl/question/qp_stubquestion.php |
— | — | @@ -75,10 +75,15 @@ |
76 | 76 | return array_search( $proposalName, $this->mProposalNames, true ); |
77 | 77 | } |
78 | 78 | |
| 79 | + /** |
| 80 | + * Replace lines of alone '\' character to empty lines. |
| 81 | + * Trims first and last empty line, left from raws split regexp, |
| 82 | + * when available. |
| 83 | + */ |
79 | 84 | private function substBackslashNL( &$s ) { |
80 | 85 | # warning: in single quoted regexp replace '\\\' translates into '\'; |
81 | | - # without trim(), regexp match in qp_PropAttrs::getFromSource() will fail. |
82 | | - $s = preg_replace( '/^(\s*\\\??\s*)$/mu', '', trim( $s ) ); |
| 86 | + # wikitext always uses '\n' as line separator (unix style) |
| 87 | + $s = preg_replace( '/^(\s*\\\??\s*)$|(\A\n)|(\n\Z)/mu', '', $s ); |
83 | 88 | } |
84 | 89 | |
85 | 90 | /** |
— | — | @@ -87,13 +92,12 @@ |
88 | 93 | */ |
89 | 94 | function splitRawProposals( $input ) { |
90 | 95 | # detect type of raw proposals |
91 | | - # originally was: preg_match( '/(?:^|\n)\s*\\??\s*(?:$|\n)/', $input ) |
92 | 96 | # multiline raw proposals have empty lines and also optionally have lines |
93 | 97 | # containing only '\' character. |
94 | 98 | if ( preg_match( '/^\s*\\??\s*$/mu', $input ) ) { |
95 | 99 | # multiline raw proposals |
96 | 100 | # warning: in single quoted regexp split '\\' translates into '\' |
97 | | - $this->raws = preg_split( '/^(\s*\\??\s*)$/mu', $input, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); |
| 101 | + $this->raws = preg_split( '/((?:^\s*$)+)/mu', $input, -1, PREG_SPLIT_NO_EMPTY ); |
98 | 102 | array_walk( $this->raws, array( __CLASS__, 'substBackslashNL' ) ); |
99 | 103 | } else { |
100 | 104 | # single line raw proposals |
— | — | @@ -101,9 +105,10 @@ |
102 | 106 | } |
103 | 107 | } |
104 | 108 | |
105 | | - # load some question fields from qp_QuestionData given |
106 | | - # (usually qp_QuestionData is an array property of qp_PollStore instance) |
107 | | - # @param $qdata - an instance of qp_QuestionData |
| 109 | + /** |
| 110 | + * Load answer-related question fields from qp_QuestionData instance given. |
| 111 | + * @param $qdata instance of qp_QuestionData |
| 112 | + */ |
108 | 113 | function loadAnswer( qp_QuestionData $qdata ) { |
109 | 114 | $this->alreadyVoted = $qdata->alreadyVoted; |
110 | 115 | $this->mPrevProposalCategoryId = $qdata->ProposalCategoryId; |
— | — | @@ -116,8 +121,10 @@ |
117 | 122 | } |
118 | 123 | } |
119 | 124 | |
120 | | - # populates an instance of qp_Question with data from qp_QuestionData |
121 | | - # @param the object of type qp_Question |
| 125 | + /** |
| 126 | + * Populates current instance of question with data from pollstore. |
| 127 | + * @param $pollStore instance of qp_PollStore |
| 128 | + */ |
122 | 129 | function getQuestionAnswer( qp_PollStore $pollStore ) { |
123 | 130 | if ( $pollStore->pid !== null ) { |
124 | 131 | if ( $pollStore->questionExists( $this->mQuestionId ) ) { |
— | — | @@ -131,9 +138,13 @@ |
132 | 139 | return false; |
133 | 140 | } |
134 | 141 | |
135 | | - # checks, whether user had previousely selected the category of the proposal of this question |
136 | | - # returns true/false for 'checkbox' and 'radio' inputTypes |
137 | | - # text string/false for 'text' inputType |
| 142 | + /** |
| 143 | + * Check, whether current user previousely selected the particular category of |
| 144 | + * the proposal of this question. |
| 145 | + * @return mixed |
| 146 | + * boolean true / boolean false for 'checkbox' and 'radio' inputTypes |
| 147 | + * string / boolean false for 'text' inputType |
| 148 | + */ |
138 | 149 | function answerExists( $inputType, $proposalId, $catId ) { |
139 | 150 | if ( $this->alreadyVoted ) { |
140 | 151 | if ( array_key_exists( $proposalId, $this->mPrevProposalCategoryId ) ) { |
Index: trunk/extensions/QPoll/view/poll/qp_pollview.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | $write_col[] = array( '__tag' => 'td', 'valign' => 'top', 0 => $question->view->renderQuestion(), '__end' => "\n" ); |
65 | 65 | if ( $this->currCol == 1 ) { |
66 | 66 | $write_row[] = array( '__tag' => 'tr', 0 => $write_col, '__end' => "\n" ); |
67 | | - $write_col = Array(); |
| 67 | + $write_col = array(); |
68 | 68 | } |
69 | 69 | if ( --$this->currCol < 1 ) { |
70 | 70 | $this->currCol = $this->perRow; |
— | — | @@ -131,22 +131,22 @@ |
132 | 132 | } |
133 | 133 | } else { |
134 | 134 | if ( $pollStore->getState() == "error" ) { |
135 | | - $submitBtn[ 'disabled' ] = 'disabled'; |
| 135 | + $submitBtn['disabled'] = 'disabled'; |
136 | 136 | } |
137 | 137 | } |
138 | 138 | $atLeft = $this->ctrl->attemptsLeft(); |
139 | 139 | if ( $atLeft === false ) { |
140 | | - $submitBtn[ 'disabled' ] = 'disabled'; |
| 140 | + $submitBtn['disabled'] = 'disabled'; |
141 | 141 | } |
142 | 142 | # disable submit button in preview mode & printable version |
143 | 143 | if ( qp_Setup::$request->getVal( 'action' ) == 'parse' || |
144 | 144 | qp_Setup::$output->isPrintable() ) { |
145 | | - $submitBtn[ 'disabled' ] = 'disabled'; |
| 145 | + $submitBtn['disabled'] = 'disabled'; |
146 | 146 | } |
147 | | - $submitBtn[ 'value' ] = wfMsgHtml( $submitMsg ); |
| 147 | + $submitBtn['value'] = wfMsgHtml( $submitMsg ); |
148 | 148 | $p = array( '__tag' => 'p' ); |
149 | 149 | $p[] = $submitBtn; |
150 | | - # output no more attempts message, when applicable |
| 150 | + # output "no more attempts" message, when applicable |
151 | 151 | if ( $atLeft === false ) { |
152 | 152 | $p[] = array( '__tag' => 'span', 'class' => 'attempts_counter', qp_Setup::specialchars( wfMsg( 'qp_error_no_more_attempts' ) ) ); |
153 | 153 | } elseif ( $atLeft !== true ) { |