Index: trunk/extensions/CentralNotice/CentralNoticeLogPager.php |
— | — | @@ -1,356 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class CentralNoticeLogPager extends ReverseChronologicalPager { |
5 | | - var $viewPage, $special; |
6 | | - |
7 | | - function __construct( $special ) { |
8 | | - global $wgRequest; |
9 | | - $this->special = $special; |
10 | | - parent::__construct(); |
11 | | - |
12 | | - // Override paging defaults |
13 | | - list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' ); |
14 | | - $this->mLimitsShown = array( 20, 50, 100 ); |
15 | | - |
16 | | - $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' ); |
17 | | - } |
18 | | - |
19 | | - /** |
20 | | - * Sort the log list by timestamp |
21 | | - */ |
22 | | - function getIndexField() { |
23 | | - return 'notlog_timestamp'; |
24 | | - } |
25 | | - |
26 | | - /** |
27 | | - * Pull log entries from the database |
28 | | - */ |
29 | | - function getQueryInfo() { |
30 | | - global $wgRequest; |
31 | | - |
32 | | - $filterStartDate = 0; |
33 | | - $filterEndDate = 0; |
34 | | - $startYear = $wgRequest->getVal( 'start_year' ); |
35 | | - if ( $startYear === 'other' ) $startYear = null; |
36 | | - $startMonth = $wgRequest->getVal( 'start_month' ); |
37 | | - if ( $startMonth === 'other' ) $startMonth = null; |
38 | | - $startDay = $wgRequest->getVal( 'start_day' ); |
39 | | - if ( $startDay === 'other' ) $startDay = null; |
40 | | - $endYear = $wgRequest->getVal( 'end_year' ); |
41 | | - if ( $endYear === 'other' ) $endYear = null; |
42 | | - $endMonth = $wgRequest->getVal( 'end_month' ); |
43 | | - if ( $endMonth === 'other' ) $endMonth = null; |
44 | | - $endDay = $wgRequest->getVal( 'end_day' ); |
45 | | - if ( $endDay === 'other' ) $endDay = null; |
46 | | - |
47 | | - if ( $startYear && $startMonth && $startDay ) { |
48 | | - $filterStartDate = $startYear . $startMonth . $startDay; |
49 | | - } |
50 | | - if ( $endYear && $endMonth && $endDay ) { |
51 | | - $filterEndDate = $endYear . $endMonth . $endDay; |
52 | | - } |
53 | | - $filterCampaign = $wgRequest->getVal( 'campaign' ); |
54 | | - $filterUser = $wgRequest->getVal( 'user' ); |
55 | | - $reset = $wgRequest->getVal( 'centralnoticelogreset' ); |
56 | | - |
57 | | - $info = array( |
58 | | - 'tables' => array( 'cn_notice_log' ), |
59 | | - 'fields' => '*', |
60 | | - 'conds' => array() |
61 | | - ); |
62 | | - |
63 | | - if ( !$reset ) { |
64 | | - if ( $filterStartDate > 0 ) { |
65 | | - $filterStartDate = intval( $filterStartDate.'000000' ); |
66 | | - $info['conds'][] = "notlog_timestamp >= $filterStartDate"; |
67 | | - } |
68 | | - if ( $filterEndDate > 0 ) { |
69 | | - $filterEndDate = intval( $filterEndDate.'000000' ); |
70 | | - $info['conds'][] = "notlog_timestamp < $filterEndDate"; |
71 | | - } |
72 | | - if ( $filterCampaign ) { |
73 | | - $info['conds'][] = "notlog_not_name LIKE '$filterCampaign'"; |
74 | | - } |
75 | | - if ( $filterUser ) { |
76 | | - $user = User::newFromName( $filterUser ); |
77 | | - $userId = $user->getId(); |
78 | | - $info['conds'][] = "notlog_user_id = $userId"; |
79 | | - } |
80 | | - } |
81 | | - |
82 | | - return $info; |
83 | | - } |
84 | | - |
85 | | - /** |
86 | | - * Generate the content of each table row (1 row = 1 log entry) |
87 | | - */ |
88 | | - function formatRow( $row ) { |
89 | | - global $wgLang, $wgExtensionAssetsPath; |
90 | | - |
91 | | - // Create a user object so we can pull the name, user page, etc. |
92 | | - $loggedUser = User::newFromId( $row->notlog_user_id ); |
93 | | - // Create the user page link |
94 | | - $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(), |
95 | | - $loggedUser->getName() ); |
96 | | - $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(), |
97 | | - wfMsg ( 'centralnotice-talk-link' ) ); |
98 | | - |
99 | | - // Create the campaign link |
100 | | - $campaignLink = $this->getSkin()->makeLinkObj( $this->viewPage, |
101 | | - htmlspecialchars( $row->notlog_not_name ), |
102 | | - 'method=listNoticeDetail¬ice=' . urlencode( $row->notlog_not_name ) ); |
103 | | - |
104 | | - // Begin log entry primary row |
105 | | - $htmlOut = Xml::openElement( 'tr' ); |
106 | | - |
107 | | - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
108 | | - if ( $row->notlog_action !== 'removed' ) { |
109 | | - $htmlOut .= '<a href="javascript:toggleLogDisplay(\''.$row->notlog_id.'\')">'. |
110 | | - '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->notlog_id.'" style="display:block;"/>'. |
111 | | - '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->notlog_id.'" style="display:none;"/>'. |
112 | | - '</a>'; |
113 | | - } |
114 | | - $htmlOut .= Xml::closeElement( 'td' ); |
115 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
116 | | - $wgLang->date( $row->notlog_timestamp ) . ' ' . $wgLang->time( $row->notlog_timestamp ) |
117 | | - ); |
118 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
119 | | - wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink ) |
120 | | - ); |
121 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
122 | | - $row->notlog_action |
123 | | - ); |
124 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
125 | | - $campaignLink |
126 | | - ); |
127 | | - $htmlOut .= Xml::tags( 'td', array(), |
128 | | - ' ' |
129 | | - ); |
130 | | - |
131 | | - // End log entry primary row |
132 | | - $htmlOut .= Xml::closeElement( 'tr' ); |
133 | | - |
134 | | - if ( $row->notlog_action !== 'removed' ) { |
135 | | - // Begin log entry secondary row |
136 | | - $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) ); |
137 | | - |
138 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
139 | | - ' ' // force a table cell in older browsers |
140 | | - ); |
141 | | - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) ); |
142 | | - if ( $row->notlog_action == 'created' ) { |
143 | | - $htmlOut .= $this->showInitialSettings( $row ); |
144 | | - } else if ( $row->notlog_action == 'modified' ) { |
145 | | - $htmlOut .= $this->showChanges( $row ); |
146 | | - } |
147 | | - $htmlOut .= Xml::closeElement( 'td' ); |
148 | | - |
149 | | - // End log entry primary row |
150 | | - $htmlOut .= Xml::closeElement( 'tr' ); |
151 | | - } |
152 | | - |
153 | | - return $htmlOut; |
154 | | - } |
155 | | - |
156 | | - function showInitialSettings( $row ) { |
157 | | - global $wgLang; |
158 | | - $details = ''; |
159 | | - $details .= wfMsg ( |
160 | | - 'centralnotice-log-label', |
161 | | - wfMsg ( 'centralnotice-start-date' ), |
162 | | - $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start ) |
163 | | - )."<br/>"; |
164 | | - $details .= wfMsg ( |
165 | | - 'centralnotice-log-label', |
166 | | - wfMsg ( 'centralnotice-end-date' ), |
167 | | - $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end ) |
168 | | - )."<br/>"; |
169 | | - $details .= wfMsg ( |
170 | | - 'centralnotice-log-label', |
171 | | - wfMsg ( 'centralnotice-projects' ), |
172 | | - $row->notlog_end_projects |
173 | | - )."<br/>"; |
174 | | - $language_count = count( explode ( ', ', $row->notlog_end_languages ) ); |
175 | | - $languageList = ''; |
176 | | - if ( $language_count > 15 ) { |
177 | | - $languageList = wfMsg ( 'centralnotice-multiple-languages', $language_count ); |
178 | | - } elseif ( $language_count > 0 ) { |
179 | | - $languageList = $row->notlog_end_languages; |
180 | | - } |
181 | | - $details .= wfMsg ( |
182 | | - 'centralnotice-log-label', |
183 | | - wfMsg ( 'centralnotice-languages' ), |
184 | | - $languageList |
185 | | - )."<br/>"; |
186 | | - $details .= wfMsg ( |
187 | | - 'centralnotice-log-label', |
188 | | - wfMsg ( 'centralnotice-geo' ), |
189 | | - ($row->notlog_end_geo ? 'on' : 'off') |
190 | | - )."<br/>"; |
191 | | - if ( $row->notlog_end_geo ) { |
192 | | - $country_count = count( explode ( ', ', $row->notlog_end_countries ) ); |
193 | | - $countryList = ''; |
194 | | - if ( $country_count > 20 ) { |
195 | | - $countryList = wfMsg ( 'centralnotice-multiple-countries', $country_count ); |
196 | | - } elseif ( $country_count > 0 ) { |
197 | | - $countryList = $row->notlog_end_countries; |
198 | | - } |
199 | | - $details .= wfMsg ( |
200 | | - 'centralnotice-log-label', |
201 | | - wfMsg ( 'centralnotice-countries' ), |
202 | | - $countryList |
203 | | - )."<br/>"; |
204 | | - } |
205 | | - return $details; |
206 | | - } |
207 | | - |
208 | | - function showChanges( $row ) { |
209 | | - global $wgLang; |
210 | | - $details = ''; |
211 | | - if ( $row->notlog_begin_start !== $row->notlog_end_start ) { |
212 | | - $details .= wfMsg ( |
213 | | - 'centralnotice-log-label', |
214 | | - wfMsg ( 'centralnotice-start-date' ), |
215 | | - wfMsg ( |
216 | | - 'centralnotice-changed', |
217 | | - $wgLang->date( $row->notlog_begin_start ).' '.$wgLang->time( $row->notlog_begin_start ), |
218 | | - $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start ) |
219 | | - ) |
220 | | - )."<br/>"; |
221 | | - } |
222 | | - if ( $row->notlog_begin_end !== $row->notlog_end_end ) { |
223 | | - $details .= wfMsg ( |
224 | | - 'centralnotice-log-label', |
225 | | - wfMsg ( 'centralnotice-end-date' ), |
226 | | - wfMsg ( |
227 | | - 'centralnotice-changed', |
228 | | - $wgLang->date( $row->notlog_begin_end ).' '.$wgLang->time( $row->notlog_begin_end ), |
229 | | - $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end ) |
230 | | - ) |
231 | | - )."<br/>"; |
232 | | - } |
233 | | - $details .= $this->testBooleanChange( 'enabled', $row ); |
234 | | - $details .= $this->testBooleanChange( 'preferred', $row ); |
235 | | - $details .= $this->testBooleanChange( 'locked', $row ); |
236 | | - $details .= $this->testBooleanChange( 'geo', $row ); |
237 | | - $details .= $this->testSetChange( 'projects', $row ); |
238 | | - $details .= $this->testSetChange( 'languages', $row ); |
239 | | - $details .= $this->testSetChange( 'countries', $row ); |
240 | | - if ( $row->notlog_begin_banners !== $row->notlog_end_banners ) { |
241 | | - // Show changes to banner weights and assignment |
242 | | - $beginBannersObject = json_decode( $row->notlog_begin_banners ); |
243 | | - $endBannersObject = json_decode( $row->notlog_end_banners ); |
244 | | - $beginBanners = array(); |
245 | | - $endBanners = array(); |
246 | | - foreach( $beginBannersObject as $key => $weight ) { |
247 | | - $beginBanners[$key] = $key.' ('.$weight.')'; |
248 | | - } |
249 | | - foreach( $endBannersObject as $key => $weight ) { |
250 | | - $endBanners[$key] = $key.' ('.$weight.')'; |
251 | | - } |
252 | | - if ( $beginBanners ) { |
253 | | - $before = implode( ', ', $beginBanners ); |
254 | | - } else { |
255 | | - $before = wfMsg ( 'centralnotice-no-assignments' ); |
256 | | - } |
257 | | - if ( $endBanners ) { |
258 | | - $after = implode( ', ', $endBanners ); |
259 | | - } else { |
260 | | - $after = wfMsg ( 'centralnotice-no-assignments' ); |
261 | | - } |
262 | | - $details .= wfMsg ( |
263 | | - 'centralnotice-log-label', |
264 | | - wfMsg ( 'centralnotice-templates' ), |
265 | | - wfMsg ( 'centralnotice-changed', $before, $after) |
266 | | - )."<br/>"; |
267 | | - } |
268 | | - return $details; |
269 | | - } |
270 | | - |
271 | | - private function testBooleanChange( $param, $row ) { |
272 | | - $result = ''; |
273 | | - $beginField = 'notlog_begin_'.$param; |
274 | | - $endField = 'notlog_end_'.$param; |
275 | | - if ( $row->$beginField !== $row->$endField ) { |
276 | | - $result .= wfMsg ( |
277 | | - 'centralnotice-log-label', |
278 | | - wfMsg ( 'centralnotice-'.$param ), |
279 | | - wfMsg ( |
280 | | - 'centralnotice-changed', |
281 | | - ( $row->$beginField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ), |
282 | | - ( $row->$endField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ) |
283 | | - ) |
284 | | - )."<br/>"; |
285 | | - } |
286 | | - return $result; |
287 | | - } |
288 | | - |
289 | | - private function testSetChange( $param, $row ) { |
290 | | - $result = ''; |
291 | | - $beginField = 'notlog_begin_'.$param; |
292 | | - $endField = 'notlog_end_'.$param; |
293 | | - if ( $row->$beginField !== $row->$endField ) { |
294 | | - $beginSet = array(); |
295 | | - $endSet = array(); |
296 | | - if ( $row->$beginField ) { |
297 | | - $beginSet = explode( ', ', $row->$beginField ); |
298 | | - } |
299 | | - if ( $row->$endField ) { |
300 | | - $endSet = explode( ', ', $row->$endField ); |
301 | | - } |
302 | | - $added = array_diff( $endSet, $beginSet ); |
303 | | - $removed = array_diff( $beginSet, $endSet ); |
304 | | - $differences = ''; |
305 | | - if ( $added ) { |
306 | | - $differences .= wfMsg ( 'centralnotice-added', implode( ', ', $added ) ); |
307 | | - if ( $removed ) $differences .= '; '; |
308 | | - } |
309 | | - if ( $removed ) { |
310 | | - $differences .= wfMsg ( 'centralnotice-removed', implode( ', ', $removed ) ); |
311 | | - } |
312 | | - $result .= wfMsg ( |
313 | | - 'centralnotice-log-label', |
314 | | - wfMsg ( 'centralnotice-'.$param ), |
315 | | - $differences |
316 | | - )."<br/>"; |
317 | | - } |
318 | | - return $result; |
319 | | - } |
320 | | - |
321 | | - /** |
322 | | - * Specify table headers |
323 | | - */ |
324 | | - function getStartBody() { |
325 | | - $htmlOut = ''; |
326 | | - $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); |
327 | | - $htmlOut .= Xml::openElement( 'tr' ); |
328 | | - $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); |
329 | | - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), |
330 | | - wfMsg ( 'centralnotice-timestamp' ) |
331 | | - ); |
332 | | - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
333 | | - wfMsg ( 'centralnotice-user' ) |
334 | | - ); |
335 | | - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), |
336 | | - wfMsg ( 'centralnotice-action' ) |
337 | | - ); |
338 | | - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
339 | | - wfMsg ( 'centralnotice-notice' ) |
340 | | - ); |
341 | | - $htmlOut .= Xml::tags( 'td', array(), |
342 | | - ' ' |
343 | | - ); |
344 | | - $htmlOut .= Xml::closeElement( 'tr' ); |
345 | | - return $htmlOut; |
346 | | - } |
347 | | - |
348 | | - /** |
349 | | - * Close table |
350 | | - */ |
351 | | - function getEndBody() { |
352 | | - $htmlOut = ''; |
353 | | - $htmlOut .= Xml::closeElement( 'table' ); |
354 | | - return $htmlOut; |
355 | | - } |
356 | | - |
357 | | -} |
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
— | — | @@ -55,22 +55,16 @@ |
56 | 56 | $title = SpecialPage::getTitleFor( 'CentralNoticeLogs' ); |
57 | 57 | $fullUrl = wfExpandUrl( $title->getFullUrl(), PROTO_CURRENT ); |
58 | 58 | |
59 | | - $htmlOut .= Xml::radio( |
60 | | - 'log_type', |
61 | | - 'campaign', |
62 | | - ( $this->logType == 'campaignsettings' ? true : false ), |
63 | | - array( 'onclick' => "switchLogs( '".$fullUrl."', 'campaignsettings' )" ) |
64 | | - ); |
65 | | - $htmlOut .= Xml::label( wfMsg( 'centralnotice-campaign-settings' ), 'campaign' ); |
| 59 | + // Build the radio buttons for switching the log type |
| 60 | + $htmlOut .= $this->getLogSwitcher( 'campaignsettings', 'campaignSettings', |
| 61 | + 'centralnotice-campaign-settings', $fullUrl ); |
| 62 | + $htmlOut .= $this->getLogSwitcher( 'bannersettings', 'bannerSettings', |
| 63 | + 'centralnotice-banner-settings', $fullUrl ); |
| 64 | + $htmlOut .= $this->getLogSwitcher( 'bannercontent', 'bannerContent', |
| 65 | + 'centralnotice-banner-content', $fullUrl ); |
| 66 | + $htmlOut .= $this->getLogSwitcher( 'bannermessages', 'bannerMessages', |
| 67 | + 'centralnotice-banner-messages', $fullUrl ); |
66 | 68 | |
67 | | - $htmlOut .= Xml::radio( |
68 | | - 'log_type', |
69 | | - 'banner', |
70 | | - ( $this->logType == 'bannersettings' ? true : false ), |
71 | | - array( 'onclick' => "switchLogs( '".$fullUrl."', 'bannersettings' )" ) |
72 | | - ); |
73 | | - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-settings' ), 'banner' ); |
74 | | - |
75 | 69 | $htmlOut .= Xml::closeElement( 'div' ); |
76 | 70 | |
77 | 71 | if ( $this->logType == 'campaignsettings' ) { |
— | — | @@ -221,10 +215,16 @@ |
222 | 216 | function showLog( $logType ) { |
223 | 217 | global $wgOut; |
224 | 218 | |
225 | | - if ( $logType == 'bannersettings' ) { |
226 | | - $pager = new CentralNoticeBannerLogPager( $this ); |
227 | | - } else { |
228 | | - $pager = new CentralNoticeLogPager( $this ); |
| 219 | + switch ( $logType ) { |
| 220 | + case 'bannersettings': |
| 221 | + $pager = new CentralNoticeBannerLogPager( $this ); |
| 222 | + break; |
| 223 | + case 'bannercontent': |
| 224 | + case 'bannermessages': |
| 225 | + $pager = new CentralNoticePageLogPager( $this, $logType ); |
| 226 | + break; |
| 227 | + default: |
| 228 | + $pager = new CentralNoticeCampaignLogPager( $this ); |
229 | 229 | } |
230 | 230 | |
231 | 231 | $htmlOut = ''; |
— | — | @@ -247,11 +247,26 @@ |
248 | 248 | $wgOut->addHTML( $htmlOut ); |
249 | 249 | } |
250 | 250 | |
251 | | - private function getDateValue( $type ) { |
| 251 | + static function getDateValue( $type ) { |
252 | 252 | global $wgRequest; |
253 | 253 | $value = $wgRequest->getVal( $type ); |
254 | 254 | if ( $value === 'other' ) $value = null; |
255 | 255 | return $value; |
256 | 256 | } |
| 257 | + |
| 258 | + /** |
| 259 | + * Build a radio button that switches the log type when you click it |
| 260 | + */ |
| 261 | + private function getLogSwitcher( $type, $id, $message, $fullUrl ) { |
| 262 | + $htmlOut = ''; |
| 263 | + $htmlOut .= Xml::radio( |
| 264 | + 'log_type', |
| 265 | + $id, |
| 266 | + ( $this->logType == $type ? true : false ), |
| 267 | + array( 'onclick' => "switchLogs( '".$fullUrl."', '".$type."' )" ) |
| 268 | + ); |
| 269 | + $htmlOut .= Xml::label( wfMsg( $message ), $id ); |
| 270 | + return $htmlOut; |
| 271 | + } |
257 | 272 | |
258 | 273 | } |
Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -110,6 +110,7 @@ |
111 | 111 | |
112 | 112 | $wgAutoloadClasses['CentralNotice'] = $specialDir . 'SpecialCentralNotice.php'; |
113 | 113 | $wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php'; |
| 114 | + $wgAutoloadClasses['CentralNoticeMessageChanges'] = $dir . 'CentralNoticeMessageChanges.php'; |
114 | 115 | |
115 | 116 | if ( $wgNoticeInfrastructure ) { |
116 | 117 | $wgSpecialPages['CentralNotice'] = 'CentralNotice'; |
— | — | @@ -126,8 +127,9 @@ |
127 | 128 | |
128 | 129 | $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php'; |
129 | 130 | $wgAutoloadClasses['CentralNoticePager'] = $dir . 'CentralNoticePager.php'; |
130 | | - $wgAutoloadClasses['CentralNoticeLogPager'] = $dir . 'CentralNoticeLogPager.php'; |
| 131 | + $wgAutoloadClasses['CentralNoticeCampaignLogPager'] = $dir . 'CentralNoticeCampaignLogPager.php'; |
131 | 132 | $wgAutoloadClasses['CentralNoticeBannerLogPager'] = $dir . 'CentralNoticeBannerLogPager.php'; |
| 133 | + $wgAutoloadClasses['CentralNoticePageLogPager'] = $dir . 'CentralNoticePageLogPager.php'; |
132 | 134 | } |
133 | 135 | } |
134 | 136 | |
Index: trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class CentralNoticeBannerLogPager extends CentralNoticeLogPager { |
| 4 | +class CentralNoticeBannerLogPager extends CentralNoticeCampaignLogPager { |
5 | 5 | var $viewPage, $special; |
6 | 6 | |
7 | 7 | function __construct( $special ) { |
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php |
— | — | @@ -139,6 +139,7 @@ |
140 | 140 | 'centralnotice-view-allocation' => 'View banner allocation', |
141 | 141 | 'centralnotice-allocation-instructions' => 'Choose the environment you would like to view banner allocation for:', |
142 | 142 | 'centralnotice-languages' => 'Languages', |
| 143 | + 'centralnotice-language' => 'Language', |
143 | 144 | 'centralnotice-projects' => 'Projects', |
144 | 145 | 'centralnotice-country' => 'Country', |
145 | 146 | 'centralnotice-no-allocation' => 'No banners allocated.', |
— | — | @@ -172,6 +173,7 @@ |
173 | 174 | 'centralnotice-date' => 'Date', |
174 | 175 | 'centralnotice-apply-filters' => 'Apply filters', |
175 | 176 | 'centralnotice-clear-filters' => 'Clear filters', |
| 177 | + 'centralnotice-banner-messages' => 'Banner messages', |
176 | 178 | ); |
177 | 179 | |
178 | 180 | /** Message documentation (Message documentation) |
Index: trunk/extensions/CentralNotice/CentralNoticePageLogPager.php |
— | — | @@ -0,0 +1,207 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This class generates a paginated log of recent changes to banner messages (the parts that get |
| 6 | + * translated). We use the rencentchanges table since it is lightweight, however, this means that |
| 7 | + * the log only goes back 30 days. |
| 8 | + */ |
| 9 | +class CentralNoticePageLogPager extends ReverseChronologicalPager { |
| 10 | + var $viewPage, $special, $logType; |
| 11 | + |
| 12 | + /** |
| 13 | + * Construct instance of class. |
| 14 | + * @param $special object calling object |
| 15 | + * @param $type string type of log - 'bannercontent' or 'bannermessages' (optional) |
| 16 | + */ |
| 17 | + function __construct( $special, $type = 'bannercontent' ) { |
| 18 | + $this->special = $special; |
| 19 | + parent::__construct( $special ); |
| 20 | + |
| 21 | + $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); |
| 22 | + $this->logType = $type; |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Sort the log list by timestamp |
| 27 | + */ |
| 28 | + function getIndexField() { |
| 29 | + return 'rc_timestamp'; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Pull log entries from the database |
| 34 | + */ |
| 35 | + function getQueryInfo() { |
| 36 | + $conds = array( |
| 37 | + 'rc_bot' => 1, // include bot edits (all edits made by CentralNotice are bot edits) |
| 38 | + 'rc_namespace' => 8, // only MediaWiki pages |
| 39 | + ); |
| 40 | + if ( $this->logType == 'bannercontent' ) { |
| 41 | + // Add query contitions for banner content log |
| 42 | + $conds += array( |
| 43 | + "rc_title LIKE 'Centralnotice-template-%'", // get banner content |
| 44 | + ); |
| 45 | + } else { |
| 46 | + // Add query contitions for banner messages log |
| 47 | + $conds += array( |
| 48 | + "rc_title LIKE 'Centralnotice-%'", // get banner messages |
| 49 | + "rc_title NOT LIKE 'Centralnotice-template-%'", // exclude normal banner content |
| 50 | + ); |
| 51 | + } |
| 52 | + return array( |
| 53 | + 'tables' => array( 'recentchanges' ), |
| 54 | + 'fields' => '*', |
| 55 | + 'conds' => $conds, // WHERE conditions |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Generate the content of each table row (1 row = 1 log entry) |
| 61 | + */ |
| 62 | + function formatRow( $row ) { |
| 63 | + global $wgLang, $wgExtensionAssetsPath; |
| 64 | + |
| 65 | + // Create a user object so we can pull the name, user page, etc. |
| 66 | + $loggedUser = User::newFromId( $row->rc_user ); |
| 67 | + // Create the user page link |
| 68 | + $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(), |
| 69 | + $loggedUser->getName() ); |
| 70 | + $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(), |
| 71 | + wfMsg ( 'centralnotice-talk-link' ) ); |
| 72 | + |
| 73 | + $language = 'en'; // English is the default for CentralNotice messages |
| 74 | + |
| 75 | + if ( $this->logType == 'bannercontent' ) { |
| 76 | + // Extract the banner name from the title |
| 77 | + $pattern = '/Centralnotice-template-(.*)/'; |
| 78 | + preg_match( $pattern, $row->rc_title, $matches ); |
| 79 | + $banner = $matches[1]; |
| 80 | + } else if ( $this->logType == 'bannermessages' ) { |
| 81 | + // Split the title into banner, message, and language |
| 82 | + $titlePieces = explode( "/", $row->rc_title, 2 ); |
| 83 | + $titleBase = $titlePieces[0]; |
| 84 | + if ( array_key_exists( 1, $titlePieces ) ) $language = $titlePieces[1]; |
| 85 | + $pattern = '/Centralnotice-([^-]*)-(.*)/'; |
| 86 | + preg_match( $pattern, $titleBase, $matches ); |
| 87 | + $banner = $matches[1]; |
| 88 | + $message = $matches[2]; |
| 89 | + } |
| 90 | + |
| 91 | + // Create banner link |
| 92 | + $bannerLink = $this->getSkin()->makeLinkObj( $this->viewPage, |
| 93 | + htmlspecialchars( $banner ), |
| 94 | + 'template=' . urlencode( $banner ) ); |
| 95 | + |
| 96 | + // Create title object |
| 97 | + $title = Title::newFromText( "MediaWiki:{$row->rc_title}" ); |
| 98 | + |
| 99 | + if ( $this->logType == 'bannercontent' ) { |
| 100 | + // If the banner was just created, show a link to the banner. If the banner was |
| 101 | + // edited, show a link to the banner and a link to the diff. |
| 102 | + if ( $row->rc_new ) { |
| 103 | + $bannerCell = $bannerLink; |
| 104 | + } else { |
| 105 | + $querydiff = array( |
| 106 | + 'curid' => $row->rc_cur_id, |
| 107 | + 'diff' => $row->rc_this_oldid, |
| 108 | + 'oldid' => $row->rc_last_oldid |
| 109 | + ); |
| 110 | + $diffUrl = htmlspecialchars( $title->getLinkUrl( $querydiff ) ); |
| 111 | + // Should "diff" be localized? It appears not to be elsewhere in the interface. |
| 112 | + // See ChangesList->preCacheMessages() for example. |
| 113 | + $bannerCell = $bannerLink . " (<a href=\"$diffUrl\">diff</a>)"; |
| 114 | + } |
| 115 | + } else if ( $this->logType == 'bannermessages' ) { |
| 116 | + $bannerCell = $bannerLink; |
| 117 | + |
| 118 | + // Create the message link |
| 119 | + $messageLink = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $message ) ); |
| 120 | + |
| 121 | + // If the message was just created, show a link to the message. If the message was |
| 122 | + // edited, show a link to the message and a link to the diff. |
| 123 | + if ( $row->rc_new ) { |
| 124 | + $messageCell = $messageLink; |
| 125 | + } else { |
| 126 | + $querydiff = array( |
| 127 | + 'curid' => $row->rc_cur_id, |
| 128 | + 'diff' => $row->rc_this_oldid, |
| 129 | + 'oldid' => $row->rc_last_oldid |
| 130 | + ); |
| 131 | + $diffUrl = htmlspecialchars( $title->getLinkUrl( $querydiff ) ); |
| 132 | + // Should "diff" be localized? It appears not to be elsewhere in the interface. |
| 133 | + // See ChangesList->preCacheMessages() for example. |
| 134 | + $messageCell = $messageLink . " (<a href=\"$diffUrl\">diff</a>)"; |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + // Begin log entry primary row |
| 139 | + $htmlOut = Xml::openElement( 'tr' ); |
| 140 | + |
| 141 | + $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 142 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 143 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 144 | + $wgLang->date( $row->rc_timestamp ) . ' ' . $wgLang->time( $row->rc_timestamp ) |
| 145 | + ); |
| 146 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 147 | + wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink ) |
| 148 | + ); |
| 149 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 150 | + $bannerCell |
| 151 | + ); |
| 152 | + if ( $this->logType == 'bannermessages' ) { |
| 153 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 154 | + $messageCell |
| 155 | + ); |
| 156 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 157 | + $language |
| 158 | + ); |
| 159 | + } |
| 160 | + $htmlOut .= Xml::tags( 'td', array(), |
| 161 | + ' ' |
| 162 | + ); |
| 163 | + |
| 164 | + // End log entry primary row |
| 165 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 166 | + |
| 167 | + return $htmlOut; |
| 168 | + } |
| 169 | + |
| 170 | + function getStartBody() { |
| 171 | + $htmlOut = ''; |
| 172 | + $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); |
| 173 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 174 | + $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); |
| 175 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), |
| 176 | + wfMsg ( 'centralnotice-timestamp' ) |
| 177 | + ); |
| 178 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 179 | + wfMsg ( 'centralnotice-user' ) |
| 180 | + ); |
| 181 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 182 | + wfMsg ( 'centralnotice-banner' ) |
| 183 | + ); |
| 184 | + if ( $this->logType == 'bannermessages' ) { |
| 185 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 186 | + wfMsg ( 'centralnotice-message' ) |
| 187 | + ); |
| 188 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), |
| 189 | + wfMsg ( 'centralnotice-language' ) |
| 190 | + ); |
| 191 | + } |
| 192 | + $htmlOut .= Xml::tags( 'td', array(), |
| 193 | + ' ' |
| 194 | + ); |
| 195 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 196 | + return $htmlOut; |
| 197 | + } |
| 198 | + |
| 199 | + /** |
| 200 | + * Close table |
| 201 | + */ |
| 202 | + function getEndBody() { |
| 203 | + $htmlOut = ''; |
| 204 | + $htmlOut .= Xml::closeElement( 'table' ); |
| 205 | + return $htmlOut; |
| 206 | + } |
| 207 | + |
| 208 | +} |
Index: trunk/extensions/CentralNotice/CentralNoticeCampaignLogPager.php |
— | — | @@ -0,0 +1,356 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class CentralNoticeCampaignLogPager extends ReverseChronologicalPager { |
| 5 | + var $viewPage, $special; |
| 6 | + |
| 7 | + function __construct( $special ) { |
| 8 | + global $wgRequest; |
| 9 | + $this->special = $special; |
| 10 | + parent::__construct(); |
| 11 | + |
| 12 | + // Override paging defaults |
| 13 | + list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' ); |
| 14 | + $this->mLimitsShown = array( 20, 50, 100 ); |
| 15 | + |
| 16 | + $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' ); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Sort the log list by timestamp |
| 21 | + */ |
| 22 | + function getIndexField() { |
| 23 | + return 'notlog_timestamp'; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Pull log entries from the database |
| 28 | + */ |
| 29 | + function getQueryInfo() { |
| 30 | + global $wgRequest; |
| 31 | + |
| 32 | + $filterStartDate = 0; |
| 33 | + $filterEndDate = 0; |
| 34 | + $startYear = $wgRequest->getVal( 'start_year' ); |
| 35 | + if ( $startYear === 'other' ) $startYear = null; |
| 36 | + $startMonth = $wgRequest->getVal( 'start_month' ); |
| 37 | + if ( $startMonth === 'other' ) $startMonth = null; |
| 38 | + $startDay = $wgRequest->getVal( 'start_day' ); |
| 39 | + if ( $startDay === 'other' ) $startDay = null; |
| 40 | + $endYear = $wgRequest->getVal( 'end_year' ); |
| 41 | + if ( $endYear === 'other' ) $endYear = null; |
| 42 | + $endMonth = $wgRequest->getVal( 'end_month' ); |
| 43 | + if ( $endMonth === 'other' ) $endMonth = null; |
| 44 | + $endDay = $wgRequest->getVal( 'end_day' ); |
| 45 | + if ( $endDay === 'other' ) $endDay = null; |
| 46 | + |
| 47 | + if ( $startYear && $startMonth && $startDay ) { |
| 48 | + $filterStartDate = $startYear . $startMonth . $startDay; |
| 49 | + } |
| 50 | + if ( $endYear && $endMonth && $endDay ) { |
| 51 | + $filterEndDate = $endYear . $endMonth . $endDay; |
| 52 | + } |
| 53 | + $filterCampaign = $wgRequest->getVal( 'campaign' ); |
| 54 | + $filterUser = $wgRequest->getVal( 'user' ); |
| 55 | + $reset = $wgRequest->getVal( 'centralnoticelogreset' ); |
| 56 | + |
| 57 | + $info = array( |
| 58 | + 'tables' => array( 'cn_notice_log' ), |
| 59 | + 'fields' => '*', |
| 60 | + 'conds' => array() |
| 61 | + ); |
| 62 | + |
| 63 | + if ( !$reset ) { |
| 64 | + if ( $filterStartDate > 0 ) { |
| 65 | + $filterStartDate = intval( $filterStartDate.'000000' ); |
| 66 | + $info['conds'][] = "notlog_timestamp >= $filterStartDate"; |
| 67 | + } |
| 68 | + if ( $filterEndDate > 0 ) { |
| 69 | + $filterEndDate = intval( $filterEndDate.'000000' ); |
| 70 | + $info['conds'][] = "notlog_timestamp < $filterEndDate"; |
| 71 | + } |
| 72 | + if ( $filterCampaign ) { |
| 73 | + $info['conds'][] = "notlog_not_name LIKE '$filterCampaign'"; |
| 74 | + } |
| 75 | + if ( $filterUser ) { |
| 76 | + $user = User::newFromName( $filterUser ); |
| 77 | + $userId = $user->getId(); |
| 78 | + $info['conds'][] = "notlog_user_id = $userId"; |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + return $info; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Generate the content of each table row (1 row = 1 log entry) |
| 87 | + */ |
| 88 | + function formatRow( $row ) { |
| 89 | + global $wgLang, $wgExtensionAssetsPath; |
| 90 | + |
| 91 | + // Create a user object so we can pull the name, user page, etc. |
| 92 | + $loggedUser = User::newFromId( $row->notlog_user_id ); |
| 93 | + // Create the user page link |
| 94 | + $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(), |
| 95 | + $loggedUser->getName() ); |
| 96 | + $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(), |
| 97 | + wfMsg ( 'centralnotice-talk-link' ) ); |
| 98 | + |
| 99 | + // Create the campaign link |
| 100 | + $campaignLink = $this->getSkin()->makeLinkObj( $this->viewPage, |
| 101 | + htmlspecialchars( $row->notlog_not_name ), |
| 102 | + 'method=listNoticeDetail¬ice=' . urlencode( $row->notlog_not_name ) ); |
| 103 | + |
| 104 | + // Begin log entry primary row |
| 105 | + $htmlOut = Xml::openElement( 'tr' ); |
| 106 | + |
| 107 | + $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); |
| 108 | + if ( $row->notlog_action !== 'removed' ) { |
| 109 | + $htmlOut .= '<a href="javascript:toggleLogDisplay(\''.$row->notlog_id.'\')">'. |
| 110 | + '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->notlog_id.'" style="display:block;"/>'. |
| 111 | + '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->notlog_id.'" style="display:none;"/>'. |
| 112 | + '</a>'; |
| 113 | + } |
| 114 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 115 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 116 | + $wgLang->date( $row->notlog_timestamp ) . ' ' . $wgLang->time( $row->notlog_timestamp ) |
| 117 | + ); |
| 118 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 119 | + wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink ) |
| 120 | + ); |
| 121 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 122 | + $row->notlog_action |
| 123 | + ); |
| 124 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), |
| 125 | + $campaignLink |
| 126 | + ); |
| 127 | + $htmlOut .= Xml::tags( 'td', array(), |
| 128 | + ' ' |
| 129 | + ); |
| 130 | + |
| 131 | + // End log entry primary row |
| 132 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 133 | + |
| 134 | + if ( $row->notlog_action !== 'removed' ) { |
| 135 | + // Begin log entry secondary row |
| 136 | + $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) ); |
| 137 | + |
| 138 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 139 | + ' ' // force a table cell in older browsers |
| 140 | + ); |
| 141 | + $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) ); |
| 142 | + if ( $row->notlog_action == 'created' ) { |
| 143 | + $htmlOut .= $this->showInitialSettings( $row ); |
| 144 | + } else if ( $row->notlog_action == 'modified' ) { |
| 145 | + $htmlOut .= $this->showChanges( $row ); |
| 146 | + } |
| 147 | + $htmlOut .= Xml::closeElement( 'td' ); |
| 148 | + |
| 149 | + // End log entry primary row |
| 150 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 151 | + } |
| 152 | + |
| 153 | + return $htmlOut; |
| 154 | + } |
| 155 | + |
| 156 | + function showInitialSettings( $row ) { |
| 157 | + global $wgLang; |
| 158 | + $details = ''; |
| 159 | + $details .= wfMsg ( |
| 160 | + 'centralnotice-log-label', |
| 161 | + wfMsg ( 'centralnotice-start-date' ), |
| 162 | + $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start ) |
| 163 | + )."<br/>"; |
| 164 | + $details .= wfMsg ( |
| 165 | + 'centralnotice-log-label', |
| 166 | + wfMsg ( 'centralnotice-end-date' ), |
| 167 | + $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end ) |
| 168 | + )."<br/>"; |
| 169 | + $details .= wfMsg ( |
| 170 | + 'centralnotice-log-label', |
| 171 | + wfMsg ( 'centralnotice-projects' ), |
| 172 | + $row->notlog_end_projects |
| 173 | + )."<br/>"; |
| 174 | + $language_count = count( explode ( ', ', $row->notlog_end_languages ) ); |
| 175 | + $languageList = ''; |
| 176 | + if ( $language_count > 15 ) { |
| 177 | + $languageList = wfMsg ( 'centralnotice-multiple-languages', $language_count ); |
| 178 | + } elseif ( $language_count > 0 ) { |
| 179 | + $languageList = $row->notlog_end_languages; |
| 180 | + } |
| 181 | + $details .= wfMsg ( |
| 182 | + 'centralnotice-log-label', |
| 183 | + wfMsg ( 'centralnotice-languages' ), |
| 184 | + $languageList |
| 185 | + )."<br/>"; |
| 186 | + $details .= wfMsg ( |
| 187 | + 'centralnotice-log-label', |
| 188 | + wfMsg ( 'centralnotice-geo' ), |
| 189 | + ($row->notlog_end_geo ? 'on' : 'off') |
| 190 | + )."<br/>"; |
| 191 | + if ( $row->notlog_end_geo ) { |
| 192 | + $country_count = count( explode ( ', ', $row->notlog_end_countries ) ); |
| 193 | + $countryList = ''; |
| 194 | + if ( $country_count > 20 ) { |
| 195 | + $countryList = wfMsg ( 'centralnotice-multiple-countries', $country_count ); |
| 196 | + } elseif ( $country_count > 0 ) { |
| 197 | + $countryList = $row->notlog_end_countries; |
| 198 | + } |
| 199 | + $details .= wfMsg ( |
| 200 | + 'centralnotice-log-label', |
| 201 | + wfMsg ( 'centralnotice-countries' ), |
| 202 | + $countryList |
| 203 | + )."<br/>"; |
| 204 | + } |
| 205 | + return $details; |
| 206 | + } |
| 207 | + |
| 208 | + function showChanges( $row ) { |
| 209 | + global $wgLang; |
| 210 | + $details = ''; |
| 211 | + if ( $row->notlog_begin_start !== $row->notlog_end_start ) { |
| 212 | + $details .= wfMsg ( |
| 213 | + 'centralnotice-log-label', |
| 214 | + wfMsg ( 'centralnotice-start-date' ), |
| 215 | + wfMsg ( |
| 216 | + 'centralnotice-changed', |
| 217 | + $wgLang->date( $row->notlog_begin_start ).' '.$wgLang->time( $row->notlog_begin_start ), |
| 218 | + $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start ) |
| 219 | + ) |
| 220 | + )."<br/>"; |
| 221 | + } |
| 222 | + if ( $row->notlog_begin_end !== $row->notlog_end_end ) { |
| 223 | + $details .= wfMsg ( |
| 224 | + 'centralnotice-log-label', |
| 225 | + wfMsg ( 'centralnotice-end-date' ), |
| 226 | + wfMsg ( |
| 227 | + 'centralnotice-changed', |
| 228 | + $wgLang->date( $row->notlog_begin_end ).' '.$wgLang->time( $row->notlog_begin_end ), |
| 229 | + $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end ) |
| 230 | + ) |
| 231 | + )."<br/>"; |
| 232 | + } |
| 233 | + $details .= $this->testBooleanChange( 'enabled', $row ); |
| 234 | + $details .= $this->testBooleanChange( 'preferred', $row ); |
| 235 | + $details .= $this->testBooleanChange( 'locked', $row ); |
| 236 | + $details .= $this->testBooleanChange( 'geo', $row ); |
| 237 | + $details .= $this->testSetChange( 'projects', $row ); |
| 238 | + $details .= $this->testSetChange( 'languages', $row ); |
| 239 | + $details .= $this->testSetChange( 'countries', $row ); |
| 240 | + if ( $row->notlog_begin_banners !== $row->notlog_end_banners ) { |
| 241 | + // Show changes to banner weights and assignment |
| 242 | + $beginBannersObject = json_decode( $row->notlog_begin_banners ); |
| 243 | + $endBannersObject = json_decode( $row->notlog_end_banners ); |
| 244 | + $beginBanners = array(); |
| 245 | + $endBanners = array(); |
| 246 | + foreach( $beginBannersObject as $key => $weight ) { |
| 247 | + $beginBanners[$key] = $key.' ('.$weight.')'; |
| 248 | + } |
| 249 | + foreach( $endBannersObject as $key => $weight ) { |
| 250 | + $endBanners[$key] = $key.' ('.$weight.')'; |
| 251 | + } |
| 252 | + if ( $beginBanners ) { |
| 253 | + $before = implode( ', ', $beginBanners ); |
| 254 | + } else { |
| 255 | + $before = wfMsg ( 'centralnotice-no-assignments' ); |
| 256 | + } |
| 257 | + if ( $endBanners ) { |
| 258 | + $after = implode( ', ', $endBanners ); |
| 259 | + } else { |
| 260 | + $after = wfMsg ( 'centralnotice-no-assignments' ); |
| 261 | + } |
| 262 | + $details .= wfMsg ( |
| 263 | + 'centralnotice-log-label', |
| 264 | + wfMsg ( 'centralnotice-templates' ), |
| 265 | + wfMsg ( 'centralnotice-changed', $before, $after) |
| 266 | + )."<br/>"; |
| 267 | + } |
| 268 | + return $details; |
| 269 | + } |
| 270 | + |
| 271 | + private function testBooleanChange( $param, $row ) { |
| 272 | + $result = ''; |
| 273 | + $beginField = 'notlog_begin_'.$param; |
| 274 | + $endField = 'notlog_end_'.$param; |
| 275 | + if ( $row->$beginField !== $row->$endField ) { |
| 276 | + $result .= wfMsg ( |
| 277 | + 'centralnotice-log-label', |
| 278 | + wfMsg ( 'centralnotice-'.$param ), |
| 279 | + wfMsg ( |
| 280 | + 'centralnotice-changed', |
| 281 | + ( $row->$beginField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ), |
| 282 | + ( $row->$endField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ) |
| 283 | + ) |
| 284 | + )."<br/>"; |
| 285 | + } |
| 286 | + return $result; |
| 287 | + } |
| 288 | + |
| 289 | + private function testSetChange( $param, $row ) { |
| 290 | + $result = ''; |
| 291 | + $beginField = 'notlog_begin_'.$param; |
| 292 | + $endField = 'notlog_end_'.$param; |
| 293 | + if ( $row->$beginField !== $row->$endField ) { |
| 294 | + $beginSet = array(); |
| 295 | + $endSet = array(); |
| 296 | + if ( $row->$beginField ) { |
| 297 | + $beginSet = explode( ', ', $row->$beginField ); |
| 298 | + } |
| 299 | + if ( $row->$endField ) { |
| 300 | + $endSet = explode( ', ', $row->$endField ); |
| 301 | + } |
| 302 | + $added = array_diff( $endSet, $beginSet ); |
| 303 | + $removed = array_diff( $beginSet, $endSet ); |
| 304 | + $differences = ''; |
| 305 | + if ( $added ) { |
| 306 | + $differences .= wfMsg ( 'centralnotice-added', implode( ', ', $added ) ); |
| 307 | + if ( $removed ) $differences .= '; '; |
| 308 | + } |
| 309 | + if ( $removed ) { |
| 310 | + $differences .= wfMsg ( 'centralnotice-removed', implode( ', ', $removed ) ); |
| 311 | + } |
| 312 | + $result .= wfMsg ( |
| 313 | + 'centralnotice-log-label', |
| 314 | + wfMsg ( 'centralnotice-'.$param ), |
| 315 | + $differences |
| 316 | + )."<br/>"; |
| 317 | + } |
| 318 | + return $result; |
| 319 | + } |
| 320 | + |
| 321 | + /** |
| 322 | + * Specify table headers |
| 323 | + */ |
| 324 | + function getStartBody() { |
| 325 | + $htmlOut = ''; |
| 326 | + $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); |
| 327 | + $htmlOut .= Xml::openElement( 'tr' ); |
| 328 | + $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); |
| 329 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), |
| 330 | + wfMsg ( 'centralnotice-timestamp' ) |
| 331 | + ); |
| 332 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 333 | + wfMsg ( 'centralnotice-user' ) |
| 334 | + ); |
| 335 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), |
| 336 | + wfMsg ( 'centralnotice-action' ) |
| 337 | + ); |
| 338 | + $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), |
| 339 | + wfMsg ( 'centralnotice-notice' ) |
| 340 | + ); |
| 341 | + $htmlOut .= Xml::tags( 'td', array(), |
| 342 | + ' ' |
| 343 | + ); |
| 344 | + $htmlOut .= Xml::closeElement( 'tr' ); |
| 345 | + return $htmlOut; |
| 346 | + } |
| 347 | + |
| 348 | + /** |
| 349 | + * Close table |
| 350 | + */ |
| 351 | + function getEndBody() { |
| 352 | + $htmlOut = ''; |
| 353 | + $htmlOut .= Xml::closeElement( 'table' ); |
| 354 | + return $htmlOut; |
| 355 | + } |
| 356 | + |
| 357 | +} |
Property changes on: trunk/extensions/CentralNotice/CentralNoticeCampaignLogPager.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 358 | + native |