r71716 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71715‎ | r71716 | r71717 >
Date:17:36, 26 August 2010
Author:kaldari
Status:ok
Tags:
Comment:
restore form state for project name and languages on error
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -511,7 +511,7 @@
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
 515+ // If there was an error, we'll need to restore the state of the form
516516 if ( $wgRequest->wasPosted() ) {
517517 $startArray = $wgRequest->getArray( 'start' );
518518 $timestamp = $startArray['year'] .
@@ -520,8 +520,12 @@
521521 $startArray['hour'] .
522522 $startArray['min'] . '00'
523523 ;
 524+ $projectSelected = $wgRequest->getVal( 'project_name' );
 525+ $noticeLanguages = $wgRequest->getArray( 'project_languages' );
524526 } else {
525527 $timestamp = null;
 528+ $projectSelected = '';
 529+ $noticeLanguages = array();
526530 }
527531
528532 // Begin Add a campaign fieldset
@@ -553,12 +557,12 @@
554558 // Project
555559 $htmlOut .= Xml::openElement( 'tr' );
556560 $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-project-name' ) );
557 - $htmlOut .= Xml::tags( 'td', array(), $this->projectDropDownList() );
 561+ $htmlOut .= Xml::tags( 'td', array(), $this->projectDropDownList( $projectSelected ) );
558562 $htmlOut .= Xml::closeElement( 'tr' );
559563 // Languages
560564 $htmlOut .= Xml::openElement( 'tr' );
561565 $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) );
562 - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector() );
 566+ $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) );
563567 $htmlOut .= Xml::closeElement( 'tr' );
564568 $htmlOut .= Xml::closeElement( 'table' );
565569 $htmlOut .= Xml::hidden( 'change', 'weight' );
@@ -731,7 +735,7 @@
732736
733737 if ( $row ) {
734738
735 - // If there was an error, we'll need to restore the state of the start date and time select lists
 739+ // If there was an error, we'll need to restore the state of the form
736740 if ( $wgRequest->wasPosted() ) {
737741 $startArray = $wgRequest->getArray( 'start' );
738742 $timestamp = $startArray['year'] .
@@ -740,12 +744,13 @@
741745 $startArray['hour'] .
742746 $startArray['min'] . '00'
743747 ;
 748+ $projectSelected = $wgRequest->getVal( 'project_name' );
 749+ $noticeLanguages = $wgRequest->getArray( 'project_languages' );
744750 } else {
745751 $timestamp = $row->not_start;
 752+ $projectSelected = $row->not_project;
 753+ $noticeLanguages = $this->getNoticeLanguages( $notice );
746754 }
747 -
748 - // Get all languages associated with the campaign
749 - $noticeLanguages = $this->getNoticeLanguages( $notice );
750755
751756 // Build Html
752757 $htmlOut = '';
@@ -766,12 +771,12 @@
767772 // End Date
768773 $htmlOut .= Xml::openElement( 'tr' );
769774 $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-end-date' ) );
770 - $htmlOut .= Xml::tags( 'td', array(), $this->dateSelector( 'end', $row->not_end, "[$row->not_name]" ) );
 775+ $htmlOut .= Xml::tags( 'td', array(), $this->dateSelector( 'end', $row->not_end ) );
771776 $htmlOut .= Xml::closeElement( 'tr' );
772777 // Project
773778 $htmlOut .= Xml::openElement( 'tr' );
774779 $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-project-name' ) );
775 - $htmlOut .= Xml::tags( 'td', array(), $this->projectDropDownList( $row->not_project ) );
 780+ $htmlOut .= Xml::tags( 'td', array(), $this->projectDropDownList( $projectSelected ) );
776781 $htmlOut .= Xml::closeElement( 'tr' );
777782 // Languages
778783 $htmlOut .= Xml::openElement( 'tr' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r71720correctly handle state restore of languages (even if no languages were select...kaldari18:11, 26 August 2010

Status & tagging log