Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -293,7 +293,7 @@ |
294 | 294 | |
295 | 295 | // Normalize timestamp format. If no timestamp passed, defaults to now. |
296 | 296 | $ts = wfTimestamp( TS_MW, $timestamp ); |
297 | | - |
| 297 | + |
298 | 298 | $fields = array( |
299 | 299 | array( "month", "centralnotice-month", $months, substr( $ts, 4, 2 ) ), |
300 | 300 | array( "day", "centralnotice-day", $days, substr( $ts, 6, 2 ) ), |
— | — | @@ -511,6 +511,19 @@ |
512 | 512 | |
513 | 513 | if ( $this->editable ) { |
514 | 514 | |
| 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 | + |
515 | 528 | // Begin Add a campaign fieldset |
516 | 529 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
517 | 530 | |
— | — | @@ -530,12 +543,12 @@ |
531 | 544 | // Start Date |
532 | 545 | $htmlOut .= Xml::openElement( 'tr' ); |
533 | 546 | $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 ) ); |
535 | 548 | $htmlOut .= Xml::closeElement( 'tr' ); |
536 | 549 | // Start Time |
537 | 550 | $htmlOut .= Xml::openElement( 'tr' ); |
538 | 551 | $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 ) ); |
540 | 553 | $htmlOut .= Xml::closeElement( 'tr' ); |
541 | 554 | // Project |
542 | 555 | $htmlOut .= Xml::openElement( 'tr' ); |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -223,16 +223,16 @@ |
224 | 224 | $htmlOut .= Xml::openElement( 'p', null ); |
225 | 225 | $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
226 | 226 | if ( $wgRequest->wasPosted() ) { |
227 | | - $displayAnon = $wgRequest->getCheck( 'displayAnon' ); |
| 227 | + $displayAnon = $wgRequest->getCheck( 'displayAnon' ); // Restore checkbox state in event of error |
228 | 228 | } else { |
229 | | - $displayAnon = true; |
| 229 | + $displayAnon = true; // Default is checked |
230 | 230 | } |
231 | 231 | $htmlOut .= Xml::check( 'displayAnon', $displayAnon, array( 'id' => 'displayAnon' ) ); |
232 | 232 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
233 | 233 | if ( $wgRequest->wasPosted() ) { |
234 | | - $displayAccount = $wgRequest->getCheck( 'displayAccount' ); |
| 234 | + $displayAccount = $wgRequest->getCheck( 'displayAccount' ); // Restore checkbox state in event of error |
235 | 235 | } else { |
236 | | - $displayAccount = true; |
| 236 | + $displayAccount = true; // Default is checked |
237 | 237 | } |
238 | 238 | $htmlOut .= Xml::check( 'displayAccount', $displayAccount, array( 'id' => 'displayAccount' ) ); |
239 | 239 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
— | — | @@ -468,16 +468,16 @@ |
469 | 469 | $htmlOut .= Xml::openElement( 'p', null ); |
470 | 470 | $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
471 | 471 | if ( $wgRequest->wasPosted() ) { |
472 | | - $displayAnon = $wgRequest->getCheck( 'displayAnon' ); |
| 472 | + $displayAnon = $wgRequest->getCheck( 'displayAnon' ); // Restore checkbox state in event of error |
473 | 473 | } else { |
474 | | - $displayAnon = ( $row->tmp_display_anon == 1 ); |
| 474 | + $displayAnon = ( $row->tmp_display_anon == 1 ); // Default to saved state |
475 | 475 | } |
476 | 476 | $htmlOut .= Xml::check( 'displayAnon', $displayAnon, wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) ); |
477 | 477 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
478 | 478 | if ( $wgRequest->wasPosted() ) { |
479 | | - $displayAccount = $wgRequest->getCheck( 'displayAccount' ); |
| 479 | + $displayAccount = $wgRequest->getCheck( 'displayAccount' ); // Restore checkbox state in event of error |
480 | 480 | } else { |
481 | | - $displayAccount = ( $row->tmp_display_account == 1 ); |
| 481 | + $displayAccount = ( $row->tmp_display_account == 1 ); // Default to saved state |
482 | 482 | } |
483 | 483 | $htmlOut .= Xml::check( 'displayAccount', $displayAccount, wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) ); |
484 | 484 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |