r109267 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109266‎ | r109267 | r109268 >
Date:00:44, 18 January 2012
Author:awjrichards
Status:ok
Tags:sopa 
Comment:
Fixed bad handling of empty zip param; first pass at adding error message display.
Modified paths:
  • /trunk/extensions/CongressLookup/CongressLookup.i18n.php (modified) (history)
  • /trunk/extensions/CongressLookup/SpecialCongressLookup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CongressLookup/CongressLookup.i18n.php
@@ -24,6 +24,7 @@
2525 'congresslookup-no-house-rep' => 'No House representative was found for your zip code.',
2626 'congresslookup-no-senators' => 'No senators were found for your zip code.',
2727 'congresslookup-report-errors' => 'Report an error',
 28+ 'congresslookup-zipcode-error' => 'Please enter your zipcode in the format "12345" or "12345-1234".',
2829 );
2930
3031 /** Message documentation (Message documentation)
@@ -42,4 +43,5 @@
4344 'congresslookup-no-house-rep' => 'Error message for when no House representative is found',
4445 'congresslookup-no-senators' => 'Error message for when no Senators are found',
4546 'congresslookup-report-errors' => 'Label for a link to the error reporting page',
 47+ 'congresslookup-zipcode-error' => 'Error message for when an invalid zip code is entered to the form.',
4648 );
Index: trunk/extensions/CongressLookup/SpecialCongressLookup.php
@@ -19,8 +19,9 @@
2020 global $wgRequest, $wgOut;
2121
2222 // Pull in query string parameters
23 - $this->setZip( $wgRequest->getVal( 'zip' ));
24 -
 23+ $zip = $wgRequest->getVal( 'zip' );
 24+ if ( !is_null( $zip )) $this->setZip( $zip );
 25+
2526 // Setup
2627 $wgOut->disable();
2728 $this->sendHeaders();
@@ -116,6 +117,7 @@
117118 margin-bottom: 1em;
118119 }
119120 p.error {
 121+ color: red;
120122 }
121123 </style>
122124 </head>
@@ -276,6 +278,11 @@
277279 $htmlOut = <<<HTML
278280 <h4>Contact your representatives</h4>
279281 <div class="sopaActionDiv">
 282+HTML;
 283+ if ( $isError ) {
 284+ $htmlOut .= Html::element( 'p', array( 'class' => 'error' ), wfMsg( 'congresslookup-zipcode-error' ));
 285+ }
 286+ $htmlOut .= <<<HTML
280287 <form action="" method="GET">
281288 <label for="zip">Your zip code:</label>
282289 <input type="text" maxlength="10" size="5" name="zip" id="zip"/>

Status & tagging log