r71643 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71642‎ | r71643 | r71644 >
Date:18:41, 25 August 2010
Author:kaldari
Status:ok
Tags:
Comment:
fixing error messages per comment at r71613
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -193,7 +193,7 @@
194194 }
195195 }
196196 } else {
197 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'sessionfailure' ) ) );
 197+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'sessionfailure' );
198198 }
199199 }
200200
@@ -204,7 +204,7 @@
205205 $project_name = $wgRequest->getVal( 'project_name' );
206206 $project_languages = $wgRequest->getArray( 'project_languages' );
207207 if ( $noticeName == '' ) {
208 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-null-string' ) ) );
 208+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-null-string' );
209209 } else {
210210 $this->addNotice( $noticeName, '0', $start, $project_name, $project_languages );
211211 }
@@ -598,6 +598,7 @@
599599
600600 function listNoticeDetail( $notice ) {
601601 global $wgOut, $wgRequest, $wgUser;
 602+
602603 if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) {
603604
604605 // Handle removing of banners from the campaign
@@ -632,29 +633,31 @@
633634 $wgOut->redirect( $this->getTitle()->getLocalUrl( "method=listNoticeDetail&notice=$notice" ) );
634635 return;
635636 }
636 -
637 - $htmlOut = '';
638637
639 - // Begin Campaign detail fieldset
640 - $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
 638+ $noticeId = $this->getNoticeId( $notice );
641639
642 - if ( $this->editable ) {
643 - $htmlOut .= Xml::openElement( 'form',
644 - array(
645 - 'method' => 'post',
646 - 'action' => $this->getTitle()->getLocalUrl( "method=listNoticeDetail&notice=$notice" )
647 - )
648 - );
649 - }
650 -
651 - $output_detail = $this->noticeDetailForm( $notice );
652 - $output_assigned = $this->assignedTemplatesForm( $notice );
653 - $output_templates = $this->addTemplatesForm( $notice );
654 -
655 - if ( $output_detail == '' ) {
656 - // Campaign not found
657 - $htmlOut .= Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-notice-doesnt-exist' ) );
 640+ // Make sure notice exists
 641+ if ( !$noticeId ) {
 642+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-notice-doesnt-exist' );
658643 } else {
 644+ $htmlOut = '';
 645+
 646+ // Begin Campaign detail fieldset
 647+ $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
 648+
 649+ if ( $this->editable ) {
 650+ $htmlOut .= Xml::openElement( 'form',
 651+ array(
 652+ 'method' => 'post',
 653+ 'action' => $this->getTitle()->getLocalUrl( "method=listNoticeDetail&notice=$notice" )
 654+ )
 655+ );
 656+ }
 657+
 658+ $output_detail = $this->noticeDetailForm( $notice );
 659+ $output_assigned = $this->assignedTemplatesForm( $notice );
 660+ $output_templates = $this->addTemplatesForm( $notice );
 661+
659662 $htmlOut .= $output_detail;
660663
661664 // Catch for no banners so that we don't double message
@@ -687,13 +690,13 @@
688691 Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
689692 );
690693 }
 694+
 695+ if ( $this->editable ) {
 696+ $htmlOut .= Xml::closeElement( 'form' );
 697+ }
 698+ $htmlOut .= Xml::closeElement( 'fieldset' );
 699+ $wgOut->addHTML( $htmlOut );
691700 }
692 -
693 - if ( $this->editable ) {
694 - $htmlOut .= Xml::closeElement( 'form' );
695 - }
696 - $htmlOut .= Xml::closeElement( 'fieldset' );
697 - $wgOut->addHTML( $htmlOut );
698701 }
699702
700703 /**
@@ -972,10 +975,10 @@
973976 $dbr = wfGetDB( DB_SLAVE );
974977 $res = $dbr->select( 'cn_notices', 'not_name', array( 'not_name' => $noticeName ) );
975978 if ( $dbr->numRows( $res ) > 0 ) {
976 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-notice-exists' ) ) );
 979+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-notice-exists' );
977980 return;
978981 } elseif ( empty( $project_languages ) ) {
979 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-no-language' ) ) );
 982+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-no-language' );
980983 return;
981984 } else {
982985 $dbw = wfGetDB( DB_MASTER );
@@ -1025,12 +1028,12 @@
10261029 array( 'not_name' => $noticeName )
10271030 );
10281031 if ( $dbr->numRows( $res ) < 1 ) {
1029 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-remove-notice-doesnt-exist' ) ) );
 1032+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-remove-notice-doesnt-exist' );
10301033 return;
10311034 }
10321035 $row = $dbr->fetchObject( $res );
10331036 if ( $row->not_locked == '1' ) {
1034 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-notice-is-locked' ) ) );
 1037+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-notice-is-locked' );
10351038 return;
10361039 } else {
10371040 $dbw = wfGetDB( DB_MASTER );
@@ -1059,7 +1062,7 @@
10601063 )
10611064 );
10621065 if ( $dbr->numRows( $res ) > 0 ) {
1063 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-template-already-exists' ) ) );
 1066+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-template-already-exists' );
10641067 } else {
10651068 $dbw = wfGetDB( DB_MASTER );
10661069 $dbw->begin();
@@ -1135,14 +1138,14 @@
11361139
11371140 // Start/end don't line up
11381141 if ( $start > $end || $end < $start ) {
1139 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-invalid-date-range3' ) ) );
 1142+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-invalid-date-range3' );
11401143 return;
11411144 }
11421145
11431146 // Invalid campaign name
11441147 $res = $dbr->select( 'cn_notices', 'not_name', array( 'not_name' => $noticeName ) );
11451148 if ( $dbr->numRows( $res ) < 1 ) {
1146 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-notice-doesnt-exist' ) ) );
 1149+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-notice-doesnt-exist' );
11471150 }
11481151
11491152 // Overlap over a date within the same project and language
@@ -1169,7 +1172,7 @@
11701173 array( 'not_name' => $noticeName )
11711174 );
11721175 if ( $dbr->numRows( $res ) < 1 ) {
1173 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-doesnt-exist' ) ) );
 1176+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-doesnt-exist' );
11741177 } else {
11751178 $dbw = wfGetDB( DB_MASTER );
11761179 $dbw->begin();
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -562,7 +562,7 @@
563563 $res = $dbr->select( 'cn_assignments', 'asn_id', array( 'tmp_id' => $id ), __METHOD__ );
564564
565565 if ( $dbr->numRows( $res ) > 0 ) {
566 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-template-still-bound' ) ) );
 566+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-template-still-bound' );
567567 return;
568568 } else {
569569 $dbw = wfGetDB( DB_MASTER );
@@ -587,7 +587,7 @@
588588 global $wgOut;
589589
590590 if ( $body == '' || $name == '' ) {
591 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-null-string' ) ) );
 591+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-null-string' );
592592 return;
593593 }
594594
@@ -603,7 +603,7 @@
604604 );
605605
606606 if ( $dbr->numRows( $res ) > 0 ) {
607 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-template-exists' ) ) );
 607+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-template-exists' );
608608 return false;
609609 } else {
610610 $dbw = wfGetDB( DB_MASTER );
@@ -634,7 +634,7 @@
635635 global $wgOut;
636636
637637 if ( $body == '' || $name == '' ) {
638 - $wgOut->addHTML( Xml::element( 'div', array( 'class' => 'cn-error' ), wfMsg( 'centralnotice-null-string' ) ) );
 638+ $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-null-string' );
639639 return;
640640 }
641641

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71613cleaning up form tags, fixing error message, removing unneeded name check in ...kaldari01:41, 25 August 2010

Status & tagging log