Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | } |
195 | 195 | } |
196 | 196 | } 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' ); |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | $project_name = $wgRequest->getVal( 'project_name' ); |
206 | 206 | $project_languages = $wgRequest->getArray( 'project_languages' ); |
207 | 207 | 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' ); |
209 | 209 | } else { |
210 | 210 | $this->addNotice( $noticeName, '0', $start, $project_name, $project_languages ); |
211 | 211 | } |
— | — | @@ -598,6 +598,7 @@ |
599 | 599 | |
600 | 600 | function listNoticeDetail( $notice ) { |
601 | 601 | global $wgOut, $wgRequest, $wgUser; |
| 602 | + |
602 | 603 | if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) { |
603 | 604 | |
604 | 605 | // Handle removing of banners from the campaign |
— | — | @@ -632,29 +633,31 @@ |
633 | 634 | $wgOut->redirect( $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$notice" ) ); |
634 | 635 | return; |
635 | 636 | } |
636 | | - |
637 | | - $htmlOut = ''; |
638 | 637 | |
639 | | - // Begin Campaign detail fieldset |
640 | | - $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
| 638 | + $noticeId = $this->getNoticeId( $notice ); |
641 | 639 | |
642 | | - if ( $this->editable ) { |
643 | | - $htmlOut .= Xml::openElement( 'form', |
644 | | - array( |
645 | | - 'method' => 'post', |
646 | | - 'action' => $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$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' ); |
658 | 643 | } 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¬ice=$notice" ) |
| 654 | + ) |
| 655 | + ); |
| 656 | + } |
| 657 | + |
| 658 | + $output_detail = $this->noticeDetailForm( $notice ); |
| 659 | + $output_assigned = $this->assignedTemplatesForm( $notice ); |
| 660 | + $output_templates = $this->addTemplatesForm( $notice ); |
| 661 | + |
659 | 662 | $htmlOut .= $output_detail; |
660 | 663 | |
661 | 664 | // Catch for no banners so that we don't double message |
— | — | @@ -687,13 +690,13 @@ |
688 | 691 | Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) |
689 | 692 | ); |
690 | 693 | } |
| 694 | + |
| 695 | + if ( $this->editable ) { |
| 696 | + $htmlOut .= Xml::closeElement( 'form' ); |
| 697 | + } |
| 698 | + $htmlOut .= Xml::closeElement( 'fieldset' ); |
| 699 | + $wgOut->addHTML( $htmlOut ); |
691 | 700 | } |
692 | | - |
693 | | - if ( $this->editable ) { |
694 | | - $htmlOut .= Xml::closeElement( 'form' ); |
695 | | - } |
696 | | - $htmlOut .= Xml::closeElement( 'fieldset' ); |
697 | | - $wgOut->addHTML( $htmlOut ); |
698 | 701 | } |
699 | 702 | |
700 | 703 | /** |
— | — | @@ -972,10 +975,10 @@ |
973 | 976 | $dbr = wfGetDB( DB_SLAVE ); |
974 | 977 | $res = $dbr->select( 'cn_notices', 'not_name', array( 'not_name' => $noticeName ) ); |
975 | 978 | 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' ); |
977 | 980 | return; |
978 | 981 | } 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' ); |
980 | 983 | return; |
981 | 984 | } else { |
982 | 985 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -1025,12 +1028,12 @@ |
1026 | 1029 | array( 'not_name' => $noticeName ) |
1027 | 1030 | ); |
1028 | 1031 | 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' ); |
1030 | 1033 | return; |
1031 | 1034 | } |
1032 | 1035 | $row = $dbr->fetchObject( $res ); |
1033 | 1036 | 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' ); |
1035 | 1038 | return; |
1036 | 1039 | } else { |
1037 | 1040 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -1059,7 +1062,7 @@ |
1060 | 1063 | ) |
1061 | 1064 | ); |
1062 | 1065 | 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' ); |
1064 | 1067 | } else { |
1065 | 1068 | $dbw = wfGetDB( DB_MASTER ); |
1066 | 1069 | $dbw->begin(); |
— | — | @@ -1135,14 +1138,14 @@ |
1136 | 1139 | |
1137 | 1140 | // Start/end don't line up |
1138 | 1141 | 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' ); |
1140 | 1143 | return; |
1141 | 1144 | } |
1142 | 1145 | |
1143 | 1146 | // Invalid campaign name |
1144 | 1147 | $res = $dbr->select( 'cn_notices', 'not_name', array( 'not_name' => $noticeName ) ); |
1145 | 1148 | 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' ); |
1147 | 1150 | } |
1148 | 1151 | |
1149 | 1152 | // Overlap over a date within the same project and language |
— | — | @@ -1169,7 +1172,7 @@ |
1170 | 1173 | array( 'not_name' => $noticeName ) |
1171 | 1174 | ); |
1172 | 1175 | 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' ); |
1174 | 1177 | } else { |
1175 | 1178 | $dbw = wfGetDB( DB_MASTER ); |
1176 | 1179 | $dbw->begin(); |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -562,7 +562,7 @@ |
563 | 563 | $res = $dbr->select( 'cn_assignments', 'asn_id', array( 'tmp_id' => $id ), __METHOD__ ); |
564 | 564 | |
565 | 565 | 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' ); |
567 | 567 | return; |
568 | 568 | } else { |
569 | 569 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -587,7 +587,7 @@ |
588 | 588 | global $wgOut; |
589 | 589 | |
590 | 590 | 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' ); |
592 | 592 | return; |
593 | 593 | } |
594 | 594 | |
— | — | @@ -603,7 +603,7 @@ |
604 | 604 | ); |
605 | 605 | |
606 | 606 | 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' ); |
608 | 608 | return false; |
609 | 609 | } else { |
610 | 610 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -634,7 +634,7 @@ |
635 | 635 | global $wgOut; |
636 | 636 | |
637 | 637 | 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' ); |
639 | 639 | return; |
640 | 640 | } |
641 | 641 | |