r53026 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53025‎ | r53026 | r53027 >
Date:00:26, 10 July 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed some issues with's in a form and not. Also enforced 80char line breaks.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -78,8 +78,14 @@
7979
8080 if ( $wgUser->isAnon() ) {
8181 $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+ );
8490 return;
8591 }
8692
@@ -105,11 +111,6 @@
106112 private function showForm() {
107113 global $wgUser, $wgOut;
108114
109 - $wgOut->addHTML( Xml::openElement( 'form', array(
110 - 'method' => 'post',
111 - 'action' => $this->getTitle()->getLinkURL(),
112 - 'id' => 'optin-survey',
113 - ) ) );
114115 $opt = ( self::isOptedIn( $wgUser ) ? 'out' : 'in' );
115116 if ( $opt == 'out' ) {
116117 $wgOut->addWikiMsg( 'optin-survey-intro' );
@@ -117,13 +118,17 @@
118119 }
119120 else
120121 {
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+ );
123129 $this->showOptInButtons();
124130 $wgOut->addWikiMsg( 'optin-improvements' );
125131 }
126132 $wgOut->addHTML( Xml::hidden( 'opt', $opt ) );
127 - $wgOut->addHTML( Xml::closeElement( 'form' ) );
128133 }
129134
130135 function showOptInButtons() {
@@ -138,7 +143,13 @@
139144 Xml::tags( 'div', array(),
140145 Xml::tags( 'div', array(),
141146 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+ ),
143154 Xml::element( 'span',
144155 array( 'class' => 'optin-button-shorttext' ),
145156 wfMsg( 'optin-accept-short' )
@@ -159,7 +170,11 @@
160171 Xml::tags( 'div', array(),
161172 Xml::tags( 'div', array(),
162173 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+ ),
164179 Xml::element( 'span',
165180 array( 'class' => 'optin-button-shorttext' ),
166181 wfMsg( 'optin-deny-short' )
@@ -174,7 +189,11 @@
175190 )
176191 );
177192 }
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+ );
179198 }
180199
181200 private function showSurvey() {
@@ -185,7 +204,15 @@
186205 $wgOptInStyleVersion );
187206 UsabilityInitiativeHooks::addStyle( 'OptIn/OptIn.css',
188207 $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' );
190217 foreach ( $wgOptInSurvey as $id => $question ) {
191218 switch ( $question['type'] ) {
192219 case 'dropdown':
@@ -384,6 +411,7 @@
385412 Xml::submitButton( wfMsg( 'optin-submit-out' ) )
386413 );
387414 $retval .= Xml::closeElement( 'dl' );
 415+ $retval .= Xml::closeElement( 'form' );
388416 $wgOut->addHTML( $retval );
389417 }
390418
@@ -403,7 +431,8 @@
404432 $answer = $wgRequest->getVal( "survey-$id", '' );
405433 if ( $answer === 'other' ) {
406434 $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" );
408437 } else if ( $answer === '' ) {
409438 $insert['ois_answer'] = null;
410439 $insert['ois_answer_data'] = null;
@@ -413,12 +442,18 @@
414443 }
415444 break;
416445 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+ );
420454 break;
421455 case 'yesno':
422 - $insert['ois_answer'] = $wgRequest->getVal( "survey-$id", null );
 456+ $insert['ois_answer'] =
 457+ $wgRequest->getVal( "survey-$id", null );
423458 $data = '';
424459 if ( $insert['ois_answer'] == 'yes' )
425460 $data += $wgRequest->getVal( "survey-$id-ifyes", '' );

Status & tagging log