Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | } |
8 | 8 | |
9 | 9 | class CentralNotice extends SpecialPage { |
10 | | - |
| 10 | + var $centralNoticeDB; |
11 | 11 | /* Functions */ |
12 | 12 | |
13 | 13 | function CentralNotice() { |
— | — | @@ -15,6 +15,8 @@ |
16 | 16 | |
17 | 17 | // Internationalization |
18 | 18 | wfLoadExtensionMessages( 'CentralNotice' ); |
| 19 | + |
| 20 | + $this->centralNoticeDB = new CentralNoticeDB(); |
19 | 21 | } |
20 | 22 | |
21 | 23 | function execute( $sub ) { |
— | — | @@ -95,7 +97,7 @@ |
96 | 98 | // Set since this is a single display |
97 | 99 | if ( $method == 'listNoticeDetail' ) { |
98 | 100 | $notice = $wgRequest->getVal ( 'notice' ); |
99 | | - CentralNoticeDB::updatePreferred( $notice, '1' ); |
| 101 | + $this->centralNoticeDB->updatePreferred( $notice, '1' ); |
100 | 102 | } |
101 | 103 | else { |
102 | 104 | // Build list of notices to unset |
— | — | @@ -103,10 +105,10 @@ |
104 | 106 | |
105 | 107 | // Set flag accordingly |
106 | 108 | foreach ( $preferredNotices as $notice ) { |
107 | | - CentralNoticeDB::updatePreferred( $notice, '1' ); |
| 109 | + $this->centralNoticeDB->updatePreferred( $notice, '1' ); |
108 | 110 | } |
109 | 111 | foreach ( $unsetNotices as $notice ) { |
110 | | - CentralNoticeDB::updatePreferred( $notice, '0' ); |
| 112 | + $this->centralNoticeDB->updatePreferred( $notice, '0' ); |
111 | 113 | } |
112 | 114 | } |
113 | 115 | } |
— | — | @@ -158,11 +160,11 @@ |
159 | 161 | if ( !isset( $preferredNotices ) && $method !== 'addNotice' ) { |
160 | 162 | if ( $method == 'listNoticeDetail' ) { |
161 | 163 | $notice = $wgRequest->getVal ( 'notice' ); |
162 | | - CentralNoticeDB::updatePreferred( $notice, 0 ); |
| 164 | + $this->centralNoticeDB->updatePreferred( $notice, 0 ); |
163 | 165 | } else { |
164 | 166 | $allNotices = $this->getNoticesName(); |
165 | 167 | foreach ( $allNotices as $notice ) { |
166 | | - CentralNoticeDB::updatePreferred( $notice, '0' ); |
| 168 | + $this->centralNoticeDB->updatePreferred( $notice, '0' ); |
167 | 169 | } |
168 | 170 | } |
169 | 171 | } |
Index: trunk/extensions/CentralNotice/SpecialNoticeText.php |
— | — | @@ -3,9 +3,12 @@ |
4 | 4 | class SpecialNoticeText extends NoticePage { |
5 | 5 | var $project = 'wikipedia'; |
6 | 6 | var $language = 'en'; |
| 7 | + var $centralNoticeDB; |
7 | 8 | |
8 | 9 | function __construct() { |
9 | 10 | parent::__construct( "NoticeText" ); |
| 11 | + |
| 12 | + $this->centralNoticeDB = new CentralNoticeDB(); |
10 | 13 | } |
11 | 14 | |
12 | 15 | /** |
— | — | @@ -28,14 +31,14 @@ |
29 | 32 | |
30 | 33 | if ( $this->language == 'en' && $this->project != null ) { |
31 | 34 | // See if we have any preferred notices for all of en |
32 | | - $notices = CentralNoticeDB::getNotices( '', 'en', '', '', 1 ); |
| 35 | + $notices = $this->centralNoticeDB->getNotices( '', 'en', '', '', 1 ); |
33 | 36 | |
34 | 37 | if ( $notices ) { |
35 | 38 | // Pull out values |
36 | 39 | foreach ( $notices as $notice => $val ) { |
37 | 40 | // Either match against ALL project or a specific project |
38 | 41 | if ( $val['project'] == '' || $val['project'] == $this->project ) { |
39 | | - $templates = CentralNoticeDB::selectTemplatesAssigned( $notice ); |
| 42 | + $templates = $this->centralNoticeDB->selectTemplatesAssigned( $notice ); |
40 | 43 | break; |
41 | 44 | } |
42 | 45 | } |
— | — | @@ -43,10 +46,10 @@ |
44 | 47 | } |
45 | 48 | |
46 | 49 | if ( !$templates && $this->project == 'wikipedia' ) { |
47 | | - $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, '', '', 1 ); |
| 50 | + $notices = $this->centralNoticeDB->getNotices( 'wikipedia', $this->language, '', '', 1 ); |
48 | 51 | if ( $notices && is_array( $notices ) ) { |
49 | 52 | foreach ( $notices as $notice => $val ) { |
50 | | - $templates = CentralNoticeDB::selectTemplatesAssigned( $notice ); |
| 53 | + $templates = $this->centralNoticeDB->selectTemplatesAssigned( $notice ); |
51 | 54 | break; |
52 | 55 | } |
53 | 56 | } |