r71690 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71689‎ | r71690 | r71691 >
Date:02:58, 26 August 2010
Author:kaldari
Status:ok
Tags:
Comment:
adding state preservation for campaign start date and time in 'Add a campaign' interface
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -293,7 +293,7 @@
294294
295295 // Normalize timestamp format. If no timestamp passed, defaults to now.
296296 $ts = wfTimestamp( TS_MW, $timestamp );
297 -
 297+
298298 $fields = array(
299299 array( "month", "centralnotice-month", $months, substr( $ts, 4, 2 ) ),
300300 array( "day", "centralnotice-day", $days, substr( $ts, 6, 2 ) ),
@@ -511,6 +511,19 @@
512512
513513 if ( $this->editable ) {
514514
 515+ // If there was an error, we'll need to restore the state of the start date and time select lists
 516+ if ( $wgRequest->wasPosted() ) {
 517+ $startArray = $wgRequest->getArray( 'start' );
 518+ $timestamp = $startArray['year'] .
 519+ $startArray['month'] .
 520+ $startArray['day'] .
 521+ $startArray['hour'] .
 522+ $startArray['min'] . '00'
 523+ ;
 524+ } else {
 525+ $timestamp = null;
 526+ }
 527+
515528 // Begin Add a campaign fieldset
516529 $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
517530
@@ -530,12 +543,12 @@
531544 // Start Date
532545 $htmlOut .= Xml::openElement( 'tr' );
533546 $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-start-date' ) );
534 - $htmlOut .= Xml::tags( 'td', array(), $this->dateSelector( 'start' ) );
 547+ $htmlOut .= Xml::tags( 'td', array(), $this->dateSelector( 'start', $timestamp ) );
535548 $htmlOut .= Xml::closeElement( 'tr' );
536549 // Start Time
537550 $htmlOut .= Xml::openElement( 'tr' );
538551 $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-start-hour' ) );
539 - $htmlOut .= Xml::tags( 'td', array(), $this->timeSelector( 'start' ) );
 552+ $htmlOut .= Xml::tags( 'td', array(), $this->timeSelector( 'start', $timestamp ) );
540553 $htmlOut .= Xml::closeElement( 'tr' );
541554 // Project
542555 $htmlOut .= Xml::openElement( 'tr' );
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -223,16 +223,16 @@
224224 $htmlOut .= Xml::openElement( 'p', null );
225225 $htmlOut .= wfMsg( 'centralnotice-banner-display' );
226226 if ( $wgRequest->wasPosted() ) {
227 - $displayAnon = $wgRequest->getCheck( 'displayAnon' );
 227+ $displayAnon = $wgRequest->getCheck( 'displayAnon' ); // Restore checkbox state in event of error
228228 } else {
229 - $displayAnon = true;
 229+ $displayAnon = true; // Default is checked
230230 }
231231 $htmlOut .= Xml::check( 'displayAnon', $displayAnon, array( 'id' => 'displayAnon' ) );
232232 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' );
233233 if ( $wgRequest->wasPosted() ) {
234 - $displayAccount = $wgRequest->getCheck( 'displayAccount' );
 234+ $displayAccount = $wgRequest->getCheck( 'displayAccount' ); // Restore checkbox state in event of error
235235 } else {
236 - $displayAccount = true;
 236+ $displayAccount = true; // Default is checked
237237 }
238238 $htmlOut .= Xml::check( 'displayAccount', $displayAccount, array( 'id' => 'displayAccount' ) );
239239 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' );
@@ -468,16 +468,16 @@
469469 $htmlOut .= Xml::openElement( 'p', null );
470470 $htmlOut .= wfMsg( 'centralnotice-banner-display' );
471471 if ( $wgRequest->wasPosted() ) {
472 - $displayAnon = $wgRequest->getCheck( 'displayAnon' );
 472+ $displayAnon = $wgRequest->getCheck( 'displayAnon' ); // Restore checkbox state in event of error
473473 } else {
474 - $displayAnon = ( $row->tmp_display_anon == 1 );
 474+ $displayAnon = ( $row->tmp_display_anon == 1 ); // Default to saved state
475475 }
476476 $htmlOut .= Xml::check( 'displayAnon', $displayAnon, wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) );
477477 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' );
478478 if ( $wgRequest->wasPosted() ) {
479 - $displayAccount = $wgRequest->getCheck( 'displayAccount' );
 479+ $displayAccount = $wgRequest->getCheck( 'displayAccount' ); // Restore checkbox state in event of error
480480 } else {
481 - $displayAccount = ( $row->tmp_display_account == 1 );
 481+ $displayAccount = ( $row->tmp_display_account == 1 ); // Default to saved state
482482 }
483483 $htmlOut .= Xml::check( 'displayAccount', $displayAccount, wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) );
484484 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' );

Status & tagging log