r69992 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69991‎ | r69992 | r69993 >
Date:09:28, 27 July 2010
Author:reedy
Status:ok
Tags:
Comment:
Create instance of CentralNoticeDB in SpecialCentralNotice.php and SpecialNoticeText.php

Reuse, fix call of dynamic method as static
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialNoticeText.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -6,7 +6,7 @@
77 }
88
99 class CentralNotice extends SpecialPage {
10 -
 10+ var $centralNoticeDB;
1111 /* Functions */
1212
1313 function CentralNotice() {
@@ -15,6 +15,8 @@
1616
1717 // Internationalization
1818 wfLoadExtensionMessages( 'CentralNotice' );
 19+
 20+ $this->centralNoticeDB = new CentralNoticeDB();
1921 }
2022
2123 function execute( $sub ) {
@@ -95,7 +97,7 @@
9698 // Set since this is a single display
9799 if ( $method == 'listNoticeDetail' ) {
98100 $notice = $wgRequest->getVal ( 'notice' );
99 - CentralNoticeDB::updatePreferred( $notice, '1' );
 101+ $this->centralNoticeDB->updatePreferred( $notice, '1' );
100102 }
101103 else {
102104 // Build list of notices to unset
@@ -103,10 +105,10 @@
104106
105107 // Set flag accordingly
106108 foreach ( $preferredNotices as $notice ) {
107 - CentralNoticeDB::updatePreferred( $notice, '1' );
 109+ $this->centralNoticeDB->updatePreferred( $notice, '1' );
108110 }
109111 foreach ( $unsetNotices as $notice ) {
110 - CentralNoticeDB::updatePreferred( $notice, '0' );
 112+ $this->centralNoticeDB->updatePreferred( $notice, '0' );
111113 }
112114 }
113115 }
@@ -158,11 +160,11 @@
159161 if ( !isset( $preferredNotices ) && $method !== 'addNotice' ) {
160162 if ( $method == 'listNoticeDetail' ) {
161163 $notice = $wgRequest->getVal ( 'notice' );
162 - CentralNoticeDB::updatePreferred( $notice, 0 );
 164+ $this->centralNoticeDB->updatePreferred( $notice, 0 );
163165 } else {
164166 $allNotices = $this->getNoticesName();
165167 foreach ( $allNotices as $notice ) {
166 - CentralNoticeDB::updatePreferred( $notice, '0' );
 168+ $this->centralNoticeDB->updatePreferred( $notice, '0' );
167169 }
168170 }
169171 }
Index: trunk/extensions/CentralNotice/SpecialNoticeText.php
@@ -3,9 +3,12 @@
44 class SpecialNoticeText extends NoticePage {
55 var $project = 'wikipedia';
66 var $language = 'en';
 7+ var $centralNoticeDB;
78
89 function __construct() {
910 parent::__construct( "NoticeText" );
 11+
 12+ $this->centralNoticeDB = new CentralNoticeDB();
1013 }
1114
1215 /**
@@ -28,14 +31,14 @@
2932
3033 if ( $this->language == 'en' && $this->project != null ) {
3134 // See if we have any preferred notices for all of en
32 - $notices = CentralNoticeDB::getNotices( '', 'en', '', '', 1 );
 35+ $notices = $this->centralNoticeDB->getNotices( '', 'en', '', '', 1 );
3336
3437 if ( $notices ) {
3538 // Pull out values
3639 foreach ( $notices as $notice => $val ) {
3740 // Either match against ALL project or a specific project
3841 if ( $val['project'] == '' || $val['project'] == $this->project ) {
39 - $templates = CentralNoticeDB::selectTemplatesAssigned( $notice );
 42+ $templates = $this->centralNoticeDB->selectTemplatesAssigned( $notice );
4043 break;
4144 }
4245 }
@@ -43,10 +46,10 @@
4447 }
4548
4649 if ( !$templates && $this->project == 'wikipedia' ) {
47 - $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, '', '', 1 );
 50+ $notices = $this->centralNoticeDB->getNotices( 'wikipedia', $this->language, '', '', 1 );
4851 if ( $notices && is_array( $notices ) ) {
4952 foreach ( $notices as $notice => $val ) {
50 - $templates = CentralNoticeDB::selectTemplatesAssigned( $notice );
 53+ $templates = $this->centralNoticeDB->selectTemplatesAssigned( $notice );
5154 break;
5255 }
5356 }

Status & tagging log