Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php |
— | — | @@ -78,8 +78,14 @@ |
79 | 79 | |
80 | 80 | if ( $wgUser->isAnon() ) { |
81 | 81 | $url = SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( |
82 | | - array( 'returnto' => $this->getTitle( $par )->getPrefixedUrl() ) ); |
83 | | - $wgOut->wrapWikiMsg( "<div class='plainlinks'>\n$1\n</div>", array( 'optin-needlogin', $url ) ); |
| 82 | + array( |
| 83 | + 'returnto' => $this->getTitle( $par )->getPrefixedUrl() |
| 84 | + ) |
| 85 | + ); |
| 86 | + $wgOut->wrapWikiMsg( |
| 87 | + "<div class='plainlinks'>\n$1\n</div>", |
| 88 | + array( 'optin-needlogin', $url ) |
| 89 | + ); |
84 | 90 | return; |
85 | 91 | } |
86 | 92 | |
— | — | @@ -105,11 +111,6 @@ |
106 | 112 | private function showForm() { |
107 | 113 | global $wgUser, $wgOut; |
108 | 114 | |
109 | | - $wgOut->addHTML( Xml::openElement( 'form', array( |
110 | | - 'method' => 'post', |
111 | | - 'action' => $this->getTitle()->getLinkURL(), |
112 | | - 'id' => 'optin-survey', |
113 | | - ) ) ); |
114 | 115 | $opt = ( self::isOptedIn( $wgUser ) ? 'out' : 'in' ); |
115 | 116 | if ( $opt == 'out' ) { |
116 | 117 | $wgOut->addWikiMsg( 'optin-survey-intro' ); |
— | — | @@ -117,13 +118,17 @@ |
118 | 119 | } |
119 | 120 | else |
120 | 121 | { |
121 | | - $wgOut->addHTML( Xml::tags( 'div', array( 'class' => 'optin-intro' ), |
122 | | - wfMsg( 'optin-intro' ) ) ); |
| 122 | + $wgOut->addHTML( |
| 123 | + Xml::tags( |
| 124 | + 'div', |
| 125 | + array( 'class' => 'optin-intro' ), |
| 126 | + wfMsg( 'optin-intro' ) |
| 127 | + ) |
| 128 | + ); |
123 | 129 | $this->showOptInButtons(); |
124 | 130 | $wgOut->addWikiMsg( 'optin-improvements' ); |
125 | 131 | } |
126 | 132 | $wgOut->addHTML( Xml::hidden( 'opt', $opt ) ); |
127 | | - $wgOut->addHTML( Xml::closeElement( 'form' ) ); |
128 | 133 | } |
129 | 134 | |
130 | 135 | function showOptInButtons() { |
— | — | @@ -138,7 +143,13 @@ |
139 | 144 | Xml::tags( 'div', array(), |
140 | 145 | Xml::tags( 'div', array(), |
141 | 146 | Xml::tags( 'div', array(), |
142 | | - Xml::tags( 'a', array( 'href' => $this->getTitle( $this->mOrigin )->getFullURL( 'opt=in' ) ), |
| 147 | + Xml::tags( |
| 148 | + 'a', |
| 149 | + array( |
| 150 | + 'href' => $this->getTitle( |
| 151 | + $this->mOrigin |
| 152 | + )->getFullURL( 'opt=in' ) |
| 153 | + ), |
143 | 154 | Xml::element( 'span', |
144 | 155 | array( 'class' => 'optin-button-shorttext' ), |
145 | 156 | wfMsg( 'optin-accept-short' ) |
— | — | @@ -159,7 +170,11 @@ |
160 | 171 | Xml::tags( 'div', array(), |
161 | 172 | Xml::tags( 'div', array(), |
162 | 173 | Xml::tags( 'div', array(), |
163 | | - Xml::tags( 'a', array( 'href' => $this->mOriginTitle->getFullURL() ), |
| 174 | + Xml::tags( |
| 175 | + 'a', |
| 176 | + array( |
| 177 | + 'href' => $this->mOriginTitle->getFullURL() |
| 178 | + ), |
164 | 179 | Xml::element( 'span', |
165 | 180 | array( 'class' => 'optin-button-shorttext' ), |
166 | 181 | wfMsg( 'optin-deny-short' ) |
— | — | @@ -174,7 +189,11 @@ |
175 | 190 | ) |
176 | 191 | ); |
177 | 192 | } |
178 | | - $wgOut->addHTML( Xml::element( 'div', array( 'style' => 'clear: both; ' ), '', false ) ); |
| 193 | + $wgOut->addHTML( |
| 194 | + Xml::element( |
| 195 | + 'div', array( 'style' => 'clear: both; ' ), '', false |
| 196 | + ) |
| 197 | + ); |
179 | 198 | } |
180 | 199 | |
181 | 200 | private function showSurvey() { |
— | — | @@ -185,7 +204,15 @@ |
186 | 205 | $wgOptInStyleVersion ); |
187 | 206 | UsabilityInitiativeHooks::addStyle( 'OptIn/OptIn.css', |
188 | 207 | $wgOptInStyleVersion ); |
189 | | - $retval = Xml::openElement( 'dl' ); |
| 208 | + |
| 209 | + $retval .= Xml::openElement( |
| 210 | + 'form', array( |
| 211 | + 'method' => 'post', |
| 212 | + 'action' => $this->getTitle()->getLinkURL(), |
| 213 | + 'id' => 'optin-survey', |
| 214 | + ) |
| 215 | + ); |
| 216 | + $retval .= Xml::openElement( 'dl' ); |
190 | 217 | foreach ( $wgOptInSurvey as $id => $question ) { |
191 | 218 | switch ( $question['type'] ) { |
192 | 219 | case 'dropdown': |
— | — | @@ -384,6 +411,7 @@ |
385 | 412 | Xml::submitButton( wfMsg( 'optin-submit-out' ) ) |
386 | 413 | ); |
387 | 414 | $retval .= Xml::closeElement( 'dl' ); |
| 415 | + $retval .= Xml::closeElement( 'form' ); |
388 | 416 | $wgOut->addHTML( $retval ); |
389 | 417 | } |
390 | 418 | |
— | — | @@ -403,7 +431,8 @@ |
404 | 432 | $answer = $wgRequest->getVal( "survey-$id", '' ); |
405 | 433 | if ( $answer === 'other' ) { |
406 | 434 | $insert['ois_answer'] = null; |
407 | | - $insert['ois_answer_data'] = $wgRequest->getVal( "survey-$id-other" ); |
| 435 | + $insert['ois_answer_data'] = |
| 436 | + $wgRequest->getVal( "survey-$id-other" ); |
408 | 437 | } else if ( $answer === '' ) { |
409 | 438 | $insert['ois_answer'] = null; |
410 | 439 | $insert['ois_answer_data'] = null; |
— | — | @@ -413,12 +442,18 @@ |
414 | 443 | } |
415 | 444 | break; |
416 | 445 | case 'checkboxes': |
417 | | - $checked = array_map( 'intval', $wgRequest->getArray( "survey-$id", array() ) ); |
418 | | - $insert['ois_answer'] = ( count( $checked ) ? implode( ',', $checked ) : null ); |
419 | | - $insert['ois_answer_data'] = ( in_array( 'other', $checked ) ? $wgRequest->getVal( "survey-$id-other" ) : null ); |
| 446 | + $checked = array_map( |
| 447 | + 'intval', $wgRequest->getArray( "survey-$id", array() ) |
| 448 | + ); |
| 449 | + $insert['ois_answer'] = |
| 450 | + ( count( $checked ) ? implode( ',', $checked ) : null ); |
| 451 | + $insert['ois_answer_data'] = ( in_array( 'other', $checked ) ? |
| 452 | + $wgRequest->getVal( "survey-$id-other" ) : null |
| 453 | + ); |
420 | 454 | break; |
421 | 455 | case 'yesno': |
422 | | - $insert['ois_answer'] = $wgRequest->getVal( "survey-$id", null ); |
| 456 | + $insert['ois_answer'] = |
| 457 | + $wgRequest->getVal( "survey-$id", null ); |
423 | 458 | $data = ''; |
424 | 459 | if ( $insert['ois_answer'] == 'yes' ) |
425 | 460 | $data += $wgRequest->getVal( "survey-$id-ifyes", '' ); |