r94140 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94139‎ | r94140 | r94141 >
Date:01:32, 10 August 2011
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
moving classes to separate files for hiphop support
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php (added) (history)
  • /trunk/extensions/CentralNotice/CentralNoticeLogPager.php (added) (history)
  • /trunk/extensions/CentralNotice/CentralNoticePager.php (added) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -1741,123 +1741,3 @@
17421742 }
17431743 }
17441744 }
1745 -
1746 -class CentralNoticePager extends TemplatePager {
1747 - var $viewPage, $special;
1748 - var $editable;
1749 -
1750 - function __construct( $special ) {
1751 - parent::__construct( $special );
1752 - }
1753 -
1754 - /**
1755 - * Pull banners from the database
1756 - */
1757 - function getQueryInfo() {
1758 - $notice = $this->mRequest->getVal( 'notice' );
1759 - $noticeId = CentralNotice::getNoticeId( $notice );
1760 - if ( $noticeId ) {
1761 - // Return all the banners not already assigned to the current campaign
1762 - return array(
1763 - 'tables' => array( 'cn_assignments', 'cn_templates' ),
1764 - 'fields' => array( 'cn_templates.tmp_name', 'cn_templates.tmp_id' ),
1765 - 'conds' => array( 'cn_assignments.tmp_id IS NULL' ),
1766 - 'join_conds' => array(
1767 - 'cn_assignments' => array(
1768 - 'LEFT JOIN',
1769 - "cn_assignments.tmp_id = cn_templates.tmp_id " .
1770 - "AND cn_assignments.not_id = $noticeId"
1771 - )
1772 - )
1773 - );
1774 - } else {
1775 - // Return all the banners in the database
1776 - return array(
1777 - 'tables' => 'cn_templates',
1778 - 'fields' => array( 'tmp_name', 'tmp_id' ),
1779 - );
1780 - }
1781 - }
1782 -
1783 - /**
1784 - * Generate the content of each table row (1 row = 1 banner)
1785 - */
1786 - function formatRow( $row ) {
1787 -
1788 - // Begin banner row
1789 - $htmlOut = Xml::openElement( 'tr' );
1790 -
1791 - if ( $this->editable ) {
1792 - // Add box
1793 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
1794 - Xml::check( 'addTemplates[]', '', array ( 'value' => $row->tmp_name ) )
1795 - );
1796 - // Weight select
1797 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
1798 - Xml::listDropDown( "weight[$row->tmp_id]",
1799 - CentralNotice::dropDownList(
1800 - wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 )
1801 - ) ,
1802 - '',
1803 - '25',
1804 - '',
1805 - '' )
1806 - );
1807 - }
1808 -
1809 - // Link and Preview
1810 - $render = new SpecialBannerLoader();
1811 - $render->siteName = 'Wikipedia';
1812 - $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
1813 - try {
1814 - $preview = $render->getHtmlNotice( $row->tmp_name );
1815 - } catch ( SpecialBannerLoaderException $e ) {
1816 - $preview = wfMsg( 'centralnotice-nopreview' );
1817 - }
1818 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
1819 - $this->getSkin()->makeLinkObj( $this->viewPage,
1820 - htmlspecialchars( $row->tmp_name ),
1821 - 'template=' . urlencode( $row->tmp_name ) ) .
1822 - Xml::fieldset( wfMsg( 'centralnotice-preview' ),
1823 - $preview,
1824 - array( 'class' => 'cn-bannerpreview')
1825 - )
1826 - );
1827 -
1828 - // End banner row
1829 - $htmlOut .= Xml::closeElement( 'tr' );
1830 -
1831 - return $htmlOut;
1832 - }
1833 -
1834 - /**
1835 - * Specify table headers
1836 - */
1837 - function getStartBody() {
1838 - $htmlOut = '';
1839 - $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) );
1840 - $htmlOut .= Xml::openElement( 'tr' );
1841 - if ( $this->editable ) {
1842 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ),
1843 - wfMsg ( "centralnotice-add" )
1844 - );
1845 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ),
1846 - wfMsg ( "centralnotice-weight" )
1847 - );
1848 - }
1849 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left' ),
1850 - wfMsg ( 'centralnotice-templates' )
1851 - );
1852 - $htmlOut .= Xml::closeElement( 'tr' );
1853 - return $htmlOut;
1854 - }
1855 -
1856 - /**
1857 - * Close table
1858 - */
1859 - function getEndBody() {
1860 - $htmlOut = '';
1861 - $htmlOut .= Xml::closeElement( 'table' );
1862 - return $htmlOut;
1863 - }
1864 -}
Index: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -781,7 +781,7 @@
782782 * @param $displayAccount integer flag for display to logged in users
783783 * @param $fundraising integer flag for fundraising banner (optional)
784784 * @param $landingPages string list of landing pages (optional)
785 - * @return boolean banner successfully added or not?
 785+ * @return true or false depending on whether banner was successfully added
786786 */
787787 public function addTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising = 0,
788788 $landingPages = '' ) {
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
@@ -117,522 +117,3 @@
118118 }
119119
120120 }
121 -
122 -class CentralNoticeLogPager extends ReverseChronologicalPager {
123 - var $viewPage, $special;
124 -
125 - function __construct( $special ) {
126 - $this->special = $special;
127 - parent::__construct();
128 -
129 - // Override paging defaults
130 - list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' );
131 - $this->mLimitsShown = array( 20, 50, 100 );
132 -
133 - $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' );
134 - }
135 -
136 - /**
137 - * Sort the log list by timestamp
138 - */
139 - function getIndexField() {
140 - return 'notlog_timestamp';
141 - }
142 -
143 - /**
144 - * Pull log entries from the database
145 - */
146 - function getQueryInfo() {
147 - return array(
148 - 'tables' => array( 'cn_notice_log' ),
149 - 'fields' => '*',
150 - );
151 - }
152 -
153 - /**
154 - * Generate the content of each table row (1 row = 1 log entry)
155 - */
156 - function formatRow( $row ) {
157 - global $wgLang, $wgExtensionAssetsPath;
158 -
159 - // Create a user object so we can pull the name, user page, etc.
160 - $loggedUser = User::newFromId( $row->notlog_user_id );
161 - // Create the user page link
162 - $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(),
163 - $loggedUser->getName() );
164 - $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(),
165 - wfMsg ( 'centralnotice-talk-link' ) );
166 -
167 - // Create the campaign link
168 - $campaignLink = $this->getSkin()->makeLinkObj( $this->viewPage,
169 - htmlspecialchars( $row->notlog_not_name ),
170 - 'method=listNoticeDetail&notice=' . urlencode( $row->notlog_not_name ) );
171 -
172 - // Begin log entry primary row
173 - $htmlOut = Xml::openElement( 'tr' );
174 -
175 - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) );
176 - if ( $row->notlog_action !== 'removed' ) {
177 - $htmlOut .= '<a href="javascript:toggleDisplay(\''.$row->notlog_id.'\')">'.
178 - '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->notlog_id.'" style="display:block;vertical-align:baseline;"/>'.
179 - '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->notlog_id.'" style="display:none;vertical-align:baseline;"/>'.
180 - '</a>';
181 - }
182 - $htmlOut .= Xml::closeElement( 'td' );
183 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
184 - $wgLang->date( $row->notlog_timestamp ) . ' ' . $wgLang->time( $row->notlog_timestamp )
185 - );
186 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
187 - wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink )
188 - );
189 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
190 - $row->notlog_action
191 - );
192 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
193 - $campaignLink
194 - );
195 - $htmlOut .= Xml::tags( 'td', array(),
196 - '&nbsp;'
197 - );
198 -
199 - // End log entry primary row
200 - $htmlOut .= Xml::closeElement( 'tr' );
201 -
202 - if ( $row->notlog_action !== 'removed' ) {
203 - // Begin log entry secondary row
204 - $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) );
205 -
206 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
207 - '&nbsp;' // force a table cell in older browsers
208 - );
209 - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) );
210 - if ( $row->notlog_action == 'created' ) {
211 - $htmlOut .= $this->showInitialSettings( $row );
212 - } else if ( $row->notlog_action == 'modified' ) {
213 - $htmlOut .= $this->showChanges( $row );
214 - }
215 - $htmlOut .= Xml::closeElement( 'td' );
216 -
217 - // End log entry primary row
218 - $htmlOut .= Xml::closeElement( 'tr' );
219 - }
220 -
221 - return $htmlOut;
222 - }
223 -
224 - function showInitialSettings( $row ) {
225 - global $wgLang;
226 - $details = '';
227 - $details .= wfMsg (
228 - 'centralnotice-log-label',
229 - wfMsg ( 'centralnotice-start-date' ),
230 - $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start )
231 - )."<br/>";
232 - $details .= wfMsg (
233 - 'centralnotice-log-label',
234 - wfMsg ( 'centralnotice-end-date' ),
235 - $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end )
236 - )."<br/>";
237 - $details .= wfMsg (
238 - 'centralnotice-log-label',
239 - wfMsg ( 'centralnotice-projects' ),
240 - $row->notlog_end_projects
241 - )."<br/>";
242 - $language_count = count( explode ( ', ', $row->notlog_end_languages ) );
243 - $languageList = '';
244 - if ( $language_count > 15 ) {
245 - $languageList = wfMsg ( 'centralnotice-multiple-languages', $language_count );
246 - } elseif ( $language_count > 0 ) {
247 - $languageList = $row->notlog_end_languages;
248 - }
249 - $details .= wfMsg (
250 - 'centralnotice-log-label',
251 - wfMsg ( 'centralnotice-languages' ),
252 - $languageList
253 - )."<br/>";
254 - $details .= wfMsg (
255 - 'centralnotice-log-label',
256 - wfMsg ( 'centralnotice-geo' ),
257 - ($row->notlog_end_geo ? 'on' : 'off')
258 - )."<br/>";
259 - if ( $row->notlog_end_geo ) {
260 - $country_count = count( explode ( ', ', $row->notlog_end_countries ) );
261 - $countryList = '';
262 - if ( $country_count > 20 ) {
263 - $countryList = wfMsg ( 'centralnotice-multiple-countries', $country_count );
264 - } elseif ( $country_count > 0 ) {
265 - $countryList = $row->notlog_end_countries;
266 - }
267 - $details .= wfMsg (
268 - 'centralnotice-log-label',
269 - wfMsg ( 'centralnotice-countries' ),
270 - $countryList
271 - )."<br/>";
272 - }
273 - return $details;
274 - }
275 -
276 - function showChanges( $row ) {
277 - global $wgLang;
278 - $details = '';
279 - if ( $row->notlog_begin_start !== $row->notlog_end_start ) {
280 - $details .= wfMsg (
281 - 'centralnotice-log-label',
282 - wfMsg ( 'centralnotice-start-date' ),
283 - wfMsg (
284 - 'centralnotice-changed',
285 - $wgLang->date( $row->notlog_begin_start ).' '.$wgLang->time( $row->notlog_begin_start ),
286 - $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start )
287 - )
288 - )."<br/>";
289 - }
290 - if ( $row->notlog_begin_end !== $row->notlog_end_end ) {
291 - $details .= wfMsg (
292 - 'centralnotice-log-label',
293 - wfMsg ( 'centralnotice-end-date' ),
294 - wfMsg (
295 - 'centralnotice-changed',
296 - $wgLang->date( $row->notlog_begin_end ).' '.$wgLang->time( $row->notlog_begin_end ),
297 - $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end )
298 - )
299 - )."<br/>";
300 - }
301 - $details .= $this->testBooleanChange( 'enabled', $row );
302 - $details .= $this->testBooleanChange( 'preferred', $row );
303 - $details .= $this->testBooleanChange( 'locked', $row );
304 - $details .= $this->testBooleanChange( 'geo', $row );
305 - $details .= $this->testSetChange( 'projects', $row );
306 - $details .= $this->testSetChange( 'languages', $row );
307 - $details .= $this->testSetChange( 'countries', $row );
308 - if ( $row->notlog_begin_banners !== $row->notlog_end_banners ) {
309 - // Show changes to banner weights and assignment
310 - $beginBannersObject = json_decode( $row->notlog_begin_banners );
311 - $endBannersObject = json_decode( $row->notlog_end_banners );
312 - $beginBanners = array();
313 - $endBanners = array();
314 - foreach( $beginBannersObject as $key => $weight ) {
315 - $beginBanners[$key] = $key.' ('.$weight.')';
316 - }
317 - foreach( $endBannersObject as $key => $weight ) {
318 - $endBanners[$key] = $key.' ('.$weight.')';
319 - }
320 - if ( $beginBanners ) {
321 - $before = implode( ', ', $beginBanners );
322 - } else {
323 - $before = wfMsg ( 'centralnotice-no-assignments' );
324 - }
325 - if ( $endBanners ) {
326 - $after = implode( ', ', $endBanners );
327 - } else {
328 - $after = wfMsg ( 'centralnotice-no-assignments' );
329 - }
330 - $details .= wfMsg (
331 - 'centralnotice-log-label',
332 - wfMsg ( 'centralnotice-templates' ),
333 - wfMsg ( 'centralnotice-changed', $before, $after)
334 - )."<br/>";
335 - }
336 - return $details;
337 - }
338 -
339 - private function testBooleanChange( $param, $row ) {
340 - $result = '';
341 - $beginField = 'notlog_begin_'.$param;
342 - $endField = 'notlog_end_'.$param;
343 - if ( $row->$beginField !== $row->$endField ) {
344 - $result .= wfMsg (
345 - 'centralnotice-log-label',
346 - wfMsg ( 'centralnotice-'.$param ),
347 - wfMsg (
348 - 'centralnotice-changed',
349 - ( $row->$beginField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
350 - ( $row->$endField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
351 - )
352 - )."<br/>";
353 - }
354 - return $result;
355 - }
356 -
357 - private function testSetChange( $param, $row ) {
358 - $result = '';
359 - $beginField = 'notlog_begin_'.$param;
360 - $endField = 'notlog_end_'.$param;
361 - if ( $row->$beginField !== $row->$endField ) {
362 - $beginSet = array();
363 - $endSet = array();
364 - if ( $row->$beginField ) {
365 - $beginSet = explode( ', ', $row->$beginField );
366 - }
367 - if ( $row->$endField ) {
368 - $endSet = explode( ', ', $row->$endField );
369 - }
370 - $added = array_diff( $endSet, $beginSet );
371 - $removed = array_diff( $beginSet, $endSet );
372 - $differences = '';
373 - if ( $added ) {
374 - $differences .= wfMsg ( 'centralnotice-added', implode( ', ', $added ) );
375 - if ( $removed ) $differences .= '; ';
376 - }
377 - if ( $removed ) {
378 - $differences .= wfMsg ( 'centralnotice-removed', implode( ', ', $removed ) );
379 - }
380 - $result .= wfMsg (
381 - 'centralnotice-log-label',
382 - wfMsg ( 'centralnotice-'.$param ),
383 - $differences
384 - )."<br/>";
385 - }
386 - return $result;
387 - }
388 -
389 - /**
390 - * Specify table headers
391 - */
392 - function getStartBody() {
393 - $htmlOut = '';
394 - $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) );
395 - $htmlOut .= Xml::openElement( 'tr' );
396 - $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) );
397 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ),
398 - wfMsg ( 'centralnotice-timestamp' )
399 - );
400 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
401 - wfMsg ( 'centralnotice-user' )
402 - );
403 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ),
404 - wfMsg ( 'centralnotice-action' )
405 - );
406 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
407 - wfMsg ( 'centralnotice-notice' )
408 - );
409 - $htmlOut .= Xml::tags( 'td', array(),
410 - '&nbsp;'
411 - );
412 - $htmlOut .= Xml::closeElement( 'tr' );
413 - return $htmlOut;
414 - }
415 -
416 - /**
417 - * Close table
418 - */
419 - function getEndBody() {
420 - $htmlOut = '';
421 - $htmlOut .= Xml::closeElement( 'table' );
422 - return $htmlOut;
423 - }
424 -
425 -}
426 -
427 -class CentralNoticeBannerLogPager extends CentralNoticeLogPager {
428 - var $viewPage, $special;
429 -
430 - function __construct( $special ) {
431 - $this->special = $special;
432 - parent::__construct($special);
433 -
434 - $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
435 - }
436 -
437 - /**
438 - * Sort the log list by timestamp
439 - */
440 - function getIndexField() {
441 - return 'tmplog_timestamp';
442 - }
443 -
444 - /**
445 - * Pull log entries from the database
446 - */
447 - function getQueryInfo() {
448 - return array(
449 - 'tables' => array( 'cn_template_log' ),
450 - 'fields' => '*',
451 - );
452 - }
453 -
454 - /**
455 - * Generate the content of each table row (1 row = 1 log entry)
456 - */
457 - function formatRow( $row ) {
458 - global $wgLang, $wgExtensionAssetsPath;
459 -
460 - // Create a user object so we can pull the name, user page, etc.
461 - $loggedUser = User::newFromId( $row->tmplog_user_id );
462 - // Create the user page link
463 - $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(),
464 - $loggedUser->getName() );
465 - $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(),
466 - wfMsg ( 'centralnotice-talk-link' ) );
467 -
468 - // Create the banner link
469 - $bannerLink = $this->getSkin()->makeLinkObj( $this->viewPage,
470 - htmlspecialchars( $row->tmplog_template_name ),
471 - 'template=' . urlencode( $row->tmplog_template_name ) );
472 -
473 - // Begin log entry primary row
474 - $htmlOut = Xml::openElement( 'tr' );
475 -
476 - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) );
477 - if ( $row->tmplog_action !== 'removed' ) {
478 - $htmlOut .= '<a href="javascript:toggleDisplay(\''.$row->tmplog_id.'\')">'.
479 - '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->tmplog_id.'" style="display:block;vertical-align:baseline;"/>'.
480 - '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->tmplog_id.'" style="display:none;vertical-align:baseline;"/>'.
481 - '</a>';
482 - }
483 - $htmlOut .= Xml::closeElement( 'td' );
484 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
485 - $wgLang->date( $row->tmplog_timestamp ) . ' ' . $wgLang->time( $row->tmplog_timestamp )
486 - );
487 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
488 - wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink )
489 - );
490 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
491 - $row->tmplog_action
492 - );
493 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
494 - $bannerLink
495 - );
496 - $htmlOut .= Xml::tags( 'td', array(),
497 - '&nbsp;'
498 - );
499 -
500 - // End log entry primary row
501 - $htmlOut .= Xml::closeElement( 'tr' );
502 -
503 - if ( $row->tmplog_action !== 'removed' ) {
504 - // Begin log entry secondary row
505 - $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->tmplog_id, 'style' => 'display:none;' ) );
506 -
507 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
508 - '&nbsp;' // force a table cell in older browsers
509 - );
510 - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) );
511 - if ( $row->tmplog_action == 'created' ) {
512 - $htmlOut .= $this->showInitialSettings( $row );
513 - } else if ( $row->tmplog_action == 'modified' ) {
514 - $htmlOut .= $this->showChanges( $row );
515 - }
516 - $htmlOut .= Xml::closeElement( 'td' );
517 -
518 - // End log entry primary row
519 - $htmlOut .= Xml::closeElement( 'tr' );
520 - }
521 -
522 - return $htmlOut;
523 - }
524 -
525 - function getStartBody() {
526 - $htmlOut = '';
527 - $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) );
528 - $htmlOut .= Xml::openElement( 'tr' );
529 - $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) );
530 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ),
531 - wfMsg ( 'centralnotice-timestamp' )
532 - );
533 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
534 - wfMsg ( 'centralnotice-user' )
535 - );
536 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ),
537 - wfMsg ( 'centralnotice-action' )
538 - );
539 - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
540 - wfMsg ( 'centralnotice-banner' )
541 - );
542 - $htmlOut .= Xml::tags( 'td', array(),
543 - '&nbsp;'
544 - );
545 - $htmlOut .= Xml::closeElement( 'tr' );
546 - return $htmlOut;
547 - }
548 -
549 - /**
550 - * Close table
551 - */
552 - function getEndBody() {
553 - $htmlOut = '';
554 - $htmlOut .= Xml::closeElement( 'table' );
555 - return $htmlOut;
556 - }
557 -
558 - function showInitialSettings( $row ) {
559 - global $wgLang;
560 - $details = '';
561 - $details .= wfMsg (
562 - 'centralnotice-log-label',
563 - wfMsg ( 'centralnotice-anon' ),
564 - ($row->tmplog_end_anon ? 'on' : 'off')
565 - )."<br/>";
566 - $details .= wfMsg (
567 - 'centralnotice-log-label',
568 - wfMsg ( 'centralnotice-account' ),
569 - ($row->tmplog_end_account ? 'on' : 'off')
570 - )."<br/>";
571 - $details .= wfMsg (
572 - 'centralnotice-log-label',
573 - wfMsg ( 'centralnotice-fundraising' ),
574 - ($row->tmplog_end_fundraising ? 'on' : 'off')
575 - )."<br/>";
576 - if ( $row->tmplog_end_landingpages ) {
577 - $details .= wfMsg (
578 - 'centralnotice-log-label',
579 - wfMsg ( 'centralnotice-landingpages' ),
580 - $row->tmplog_end_landingpages
581 - )."<br/>";
582 - }
583 - return $details;
584 - }
585 -
586 - function showChanges( $row ) {
587 - global $wgLang;
588 - $details = '';
589 - $details .= $this->testBooleanChange( 'anon', $row );
590 - $details .= $this->testBooleanChange( 'account', $row );
591 - $details .= $this->testBooleanChange( 'fundraising', $row );
592 - $details .= $this->testTextChange( 'landingpages', $row );
593 - if ( $row->tmplog_content_change ) {
594 - // Show changes to banner content
595 - $details .= wfMsg (
596 - 'centralnotice-log-label',
597 - wfMsg ( 'centralnotice-banner-content' ),
598 - wfMsg ( 'centralnotice-banner-content-changed' )
599 - )."<br/>";
600 - }
601 - return $details;
602 - }
603 -
604 - private function testBooleanChange( $param, $row ) {
605 - $result = '';
606 - $beginField = 'tmplog_begin_'.$param;
607 - $endField = 'tmplog_end_'.$param;
608 - if ( $row->$beginField !== $row->$endField ) {
609 - $result .= wfMsg (
610 - 'centralnotice-log-label',
611 - wfMsg ( 'centralnotice-'.$param ),
612 - wfMsg (
613 - 'centralnotice-changed',
614 - ( $row->$beginField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
615 - ( $row->$endField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
616 - )
617 - )."<br/>";
618 - }
619 - return $result;
620 - }
621 -
622 - private function testTextChange( $param, $row ) {
623 - $result = '';
624 - $beginField = 'tmplog_begin_'.$param;
625 - $endField = 'tmplog_end_'.$param;
626 - if ( $row->$beginField !== $row->$endField ) {
627 - $result .= wfMsg (
628 - 'centralnotice-log-label',
629 - wfMsg ( 'centralnotice-'.$param ),
630 - wfMsg (
631 - 'centralnotice-changed',
632 - $row->$beginField,
633 - $row->$endField
634 - )
635 - )."<br/>";
636 - }
637 - return $result;
638 - }
639 -}
Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -110,7 +110,6 @@
111111
112112 $wgAutoloadClasses['CentralNotice'] = $specialDir . 'SpecialCentralNotice.php';
113113 $wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php';
114 - $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php';
115114
116115 if ( $wgNoticeInfrastructure ) {
117116 $wgSpecialPages['CentralNotice'] = 'CentralNotice';
@@ -124,6 +123,11 @@
125124
126125 $wgSpecialPages['CentralNoticeLogs'] = 'SpecialCentralNoticeLogs';
127126 $wgAutoloadClasses['SpecialCentralNoticeLogs'] = $specialDir . 'SpecialCentralNoticeLogs.php';
 127+
 128+ $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php';
 129+ $wgAutoloadClasses['CentralNoticePager'] = $dir . 'CentralNoticePager.php';
 130+ $wgAutoloadClasses['CentralNoticeLogPager'] = $dir . 'CentralNoticeLogPager.php';
 131+ $wgAutoloadClasses['CentralNoticeBannerLogPager'] = $dir . 'CentralNoticeBannerLogPager.php';
128132 }
129133 }
130134
Index: trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php
@@ -0,0 +1,215 @@
 2+<?php
 3+
 4+class CentralNoticeBannerLogPager extends CentralNoticeLogPager {
 5+ var $viewPage, $special;
 6+
 7+ function __construct( $special ) {
 8+ $this->special = $special;
 9+ parent::__construct($special);
 10+
 11+ $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
 12+ }
 13+
 14+ /**
 15+ * Sort the log list by timestamp
 16+ */
 17+ function getIndexField() {
 18+ return 'tmplog_timestamp';
 19+ }
 20+
 21+ /**
 22+ * Pull log entries from the database
 23+ */
 24+ function getQueryInfo() {
 25+ return array(
 26+ 'tables' => array( 'cn_template_log' ),
 27+ 'fields' => '*',
 28+ );
 29+ }
 30+
 31+ /**
 32+ * Generate the content of each table row (1 row = 1 log entry)
 33+ */
 34+ function formatRow( $row ) {
 35+ global $wgLang, $wgExtensionAssetsPath;
 36+
 37+ // Create a user object so we can pull the name, user page, etc.
 38+ $loggedUser = User::newFromId( $row->tmplog_user_id );
 39+ // Create the user page link
 40+ $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(),
 41+ $loggedUser->getName() );
 42+ $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(),
 43+ wfMsg ( 'centralnotice-talk-link' ) );
 44+
 45+ // Create the banner link
 46+ $bannerLink = $this->getSkin()->makeLinkObj( $this->viewPage,
 47+ htmlspecialchars( $row->tmplog_template_name ),
 48+ 'template=' . urlencode( $row->tmplog_template_name ) );
 49+
 50+ // Begin log entry primary row
 51+ $htmlOut = Xml::openElement( 'tr' );
 52+
 53+ $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) );
 54+ if ( $row->tmplog_action !== 'removed' ) {
 55+ $htmlOut .= '<a href="javascript:toggleDisplay(\''.$row->tmplog_id.'\')">'.
 56+ '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->tmplog_id.'" style="display:block;vertical-align:baseline;"/>'.
 57+ '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->tmplog_id.'" style="display:none;vertical-align:baseline;"/>'.
 58+ '</a>';
 59+ }
 60+ $htmlOut .= Xml::closeElement( 'td' );
 61+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 62+ $wgLang->date( $row->tmplog_timestamp ) . ' ' . $wgLang->time( $row->tmplog_timestamp )
 63+ );
 64+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 65+ wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink )
 66+ );
 67+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 68+ $row->tmplog_action
 69+ );
 70+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 71+ $bannerLink
 72+ );
 73+ $htmlOut .= Xml::tags( 'td', array(),
 74+ '&nbsp;'
 75+ );
 76+
 77+ // End log entry primary row
 78+ $htmlOut .= Xml::closeElement( 'tr' );
 79+
 80+ if ( $row->tmplog_action !== 'removed' ) {
 81+ // Begin log entry secondary row
 82+ $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->tmplog_id, 'style' => 'display:none;' ) );
 83+
 84+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
 85+ '&nbsp;' // force a table cell in older browsers
 86+ );
 87+ $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) );
 88+ if ( $row->tmplog_action == 'created' ) {
 89+ $htmlOut .= $this->showInitialSettings( $row );
 90+ } else if ( $row->tmplog_action == 'modified' ) {
 91+ $htmlOut .= $this->showChanges( $row );
 92+ }
 93+ $htmlOut .= Xml::closeElement( 'td' );
 94+
 95+ // End log entry primary row
 96+ $htmlOut .= Xml::closeElement( 'tr' );
 97+ }
 98+
 99+ return $htmlOut;
 100+ }
 101+
 102+ function getStartBody() {
 103+ $htmlOut = '';
 104+ $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) );
 105+ $htmlOut .= Xml::openElement( 'tr' );
 106+ $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) );
 107+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ),
 108+ wfMsg ( 'centralnotice-timestamp' )
 109+ );
 110+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
 111+ wfMsg ( 'centralnotice-user' )
 112+ );
 113+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ),
 114+ wfMsg ( 'centralnotice-action' )
 115+ );
 116+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
 117+ wfMsg ( 'centralnotice-banner' )
 118+ );
 119+ $htmlOut .= Xml::tags( 'td', array(),
 120+ '&nbsp;'
 121+ );
 122+ $htmlOut .= Xml::closeElement( 'tr' );
 123+ return $htmlOut;
 124+ }
 125+
 126+ /**
 127+ * Close table
 128+ */
 129+ function getEndBody() {
 130+ $htmlOut = '';
 131+ $htmlOut .= Xml::closeElement( 'table' );
 132+ return $htmlOut;
 133+ }
 134+
 135+ function showInitialSettings( $row ) {
 136+ global $wgLang;
 137+ $details = '';
 138+ $details .= wfMsg (
 139+ 'centralnotice-log-label',
 140+ wfMsg ( 'centralnotice-anon' ),
 141+ ($row->tmplog_end_anon ? 'on' : 'off')
 142+ )."<br/>";
 143+ $details .= wfMsg (
 144+ 'centralnotice-log-label',
 145+ wfMsg ( 'centralnotice-account' ),
 146+ ($row->tmplog_end_account ? 'on' : 'off')
 147+ )."<br/>";
 148+ $details .= wfMsg (
 149+ 'centralnotice-log-label',
 150+ wfMsg ( 'centralnotice-fundraising' ),
 151+ ($row->tmplog_end_fundraising ? 'on' : 'off')
 152+ )."<br/>";
 153+ if ( $row->tmplog_end_landingpages ) {
 154+ $details .= wfMsg (
 155+ 'centralnotice-log-label',
 156+ wfMsg ( 'centralnotice-landingpages' ),
 157+ $row->tmplog_end_landingpages
 158+ )."<br/>";
 159+ }
 160+ return $details;
 161+ }
 162+
 163+ function showChanges( $row ) {
 164+ global $wgLang;
 165+ $details = '';
 166+ $details .= $this->testBooleanChange( 'anon', $row );
 167+ $details .= $this->testBooleanChange( 'account', $row );
 168+ $details .= $this->testBooleanChange( 'fundraising', $row );
 169+ $details .= $this->testTextChange( 'landingpages', $row );
 170+ if ( $row->tmplog_content_change ) {
 171+ // Show changes to banner content
 172+ $details .= wfMsg (
 173+ 'centralnotice-log-label',
 174+ wfMsg ( 'centralnotice-banner-content' ),
 175+ wfMsg ( 'centralnotice-banner-content-changed' )
 176+ )."<br/>";
 177+ }
 178+ return $details;
 179+ }
 180+
 181+ private function testBooleanChange( $param, $row ) {
 182+ $result = '';
 183+ $beginField = 'tmplog_begin_'.$param;
 184+ $endField = 'tmplog_end_'.$param;
 185+ if ( $row->$beginField !== $row->$endField ) {
 186+ $result .= wfMsg (
 187+ 'centralnotice-log-label',
 188+ wfMsg ( 'centralnotice-'.$param ),
 189+ wfMsg (
 190+ 'centralnotice-changed',
 191+ ( $row->$beginField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
 192+ ( $row->$endField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
 193+ )
 194+ )."<br/>";
 195+ }
 196+ return $result;
 197+ }
 198+
 199+ private function testTextChange( $param, $row ) {
 200+ $result = '';
 201+ $beginField = 'tmplog_begin_'.$param;
 202+ $endField = 'tmplog_end_'.$param;
 203+ if ( $row->$beginField !== $row->$endField ) {
 204+ $result .= wfMsg (
 205+ 'centralnotice-log-label',
 206+ wfMsg ( 'centralnotice-'.$param ),
 207+ wfMsg (
 208+ 'centralnotice-changed',
 209+ $row->$beginField,
 210+ $row->$endField
 211+ )
 212+ )."<br/>";
 213+ }
 214+ return $result;
 215+ }
 216+}
Index: trunk/extensions/CentralNotice/CentralNoticePager.php
@@ -0,0 +1,121 @@
 2+<?php
 3+
 4+class CentralNoticePager extends TemplatePager {
 5+ var $viewPage, $special;
 6+ var $editable;
 7+
 8+ function __construct( $special ) {
 9+ parent::__construct( $special );
 10+ }
 11+
 12+ /**
 13+ * Pull banners from the database
 14+ */
 15+ function getQueryInfo() {
 16+ $notice = $this->mRequest->getVal( 'notice' );
 17+ $noticeId = CentralNotice::getNoticeId( $notice );
 18+ if ( $noticeId ) {
 19+ // Return all the banners not already assigned to the current campaign
 20+ return array(
 21+ 'tables' => array( 'cn_assignments', 'cn_templates' ),
 22+ 'fields' => array( 'cn_templates.tmp_name', 'cn_templates.tmp_id' ),
 23+ 'conds' => array( 'cn_assignments.tmp_id IS NULL' ),
 24+ 'join_conds' => array(
 25+ 'cn_assignments' => array(
 26+ 'LEFT JOIN',
 27+ "cn_assignments.tmp_id = cn_templates.tmp_id " .
 28+ "AND cn_assignments.not_id = $noticeId"
 29+ )
 30+ )
 31+ );
 32+ } else {
 33+ // Return all the banners in the database
 34+ return array(
 35+ 'tables' => 'cn_templates',
 36+ 'fields' => array( 'tmp_name', 'tmp_id' ),
 37+ );
 38+ }
 39+ }
 40+
 41+ /**
 42+ * Generate the content of each table row (1 row = 1 banner)
 43+ */
 44+ function formatRow( $row ) {
 45+
 46+ // Begin banner row
 47+ $htmlOut = Xml::openElement( 'tr' );
 48+
 49+ if ( $this->editable ) {
 50+ // Add box
 51+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
 52+ Xml::check( 'addTemplates[]', '', array ( 'value' => $row->tmp_name ) )
 53+ );
 54+ // Weight select
 55+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
 56+ Xml::listDropDown( "weight[$row->tmp_id]",
 57+ CentralNotice::dropDownList(
 58+ wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 )
 59+ ) ,
 60+ '',
 61+ '25',
 62+ '',
 63+ '' )
 64+ );
 65+ }
 66+
 67+ // Link and Preview
 68+ $render = new SpecialBannerLoader();
 69+ $render->siteName = 'Wikipedia';
 70+ $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
 71+ try {
 72+ $preview = $render->getHtmlNotice( $row->tmp_name );
 73+ } catch ( SpecialBannerLoaderException $e ) {
 74+ $preview = wfMsg( 'centralnotice-nopreview' );
 75+ }
 76+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
 77+ $this->getSkin()->makeLinkObj( $this->viewPage,
 78+ htmlspecialchars( $row->tmp_name ),
 79+ 'template=' . urlencode( $row->tmp_name ) ) .
 80+ Xml::fieldset( wfMsg( 'centralnotice-preview' ),
 81+ $preview,
 82+ array( 'class' => 'cn-bannerpreview')
 83+ )
 84+ );
 85+
 86+ // End banner row
 87+ $htmlOut .= Xml::closeElement( 'tr' );
 88+
 89+ return $htmlOut;
 90+ }
 91+
 92+ /**
 93+ * Specify table headers
 94+ */
 95+ function getStartBody() {
 96+ $htmlOut = '';
 97+ $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) );
 98+ $htmlOut .= Xml::openElement( 'tr' );
 99+ if ( $this->editable ) {
 100+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ),
 101+ wfMsg ( "centralnotice-add" )
 102+ );
 103+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ),
 104+ wfMsg ( "centralnotice-weight" )
 105+ );
 106+ }
 107+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left' ),
 108+ wfMsg ( 'centralnotice-templates' )
 109+ );
 110+ $htmlOut .= Xml::closeElement( 'tr' );
 111+ return $htmlOut;
 112+ }
 113+
 114+ /**
 115+ * Close table
 116+ */
 117+ function getEndBody() {
 118+ $htmlOut = '';
 119+ $htmlOut .= Xml::closeElement( 'table' );
 120+ return $htmlOut;
 121+ }
 122+}
Index: trunk/extensions/CentralNotice/CentralNoticeLogPager.php
@@ -0,0 +1,306 @@
 2+<?php
 3+
 4+class CentralNoticeLogPager extends ReverseChronologicalPager {
 5+ var $viewPage, $special;
 6+
 7+ function __construct( $special ) {
 8+ $this->special = $special;
 9+ parent::__construct();
 10+
 11+ // Override paging defaults
 12+ list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' );
 13+ $this->mLimitsShown = array( 20, 50, 100 );
 14+
 15+ $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' );
 16+ }
 17+
 18+ /**
 19+ * Sort the log list by timestamp
 20+ */
 21+ function getIndexField() {
 22+ return 'notlog_timestamp';
 23+ }
 24+
 25+ /**
 26+ * Pull log entries from the database
 27+ */
 28+ function getQueryInfo() {
 29+ return array(
 30+ 'tables' => array( 'cn_notice_log' ),
 31+ 'fields' => '*',
 32+ );
 33+ }
 34+
 35+ /**
 36+ * Generate the content of each table row (1 row = 1 log entry)
 37+ */
 38+ function formatRow( $row ) {
 39+ global $wgLang, $wgExtensionAssetsPath;
 40+
 41+ // Create a user object so we can pull the name, user page, etc.
 42+ $loggedUser = User::newFromId( $row->notlog_user_id );
 43+ // Create the user page link
 44+ $userLink = $this->getSkin()->makeLinkObj( $loggedUser->getUserPage(),
 45+ $loggedUser->getName() );
 46+ $userTalkLink = $this->getSkin()->makeLinkObj( $loggedUser->getTalkPage(),
 47+ wfMsg ( 'centralnotice-talk-link' ) );
 48+
 49+ // Create the campaign link
 50+ $campaignLink = $this->getSkin()->makeLinkObj( $this->viewPage,
 51+ htmlspecialchars( $row->notlog_not_name ),
 52+ 'method=listNoticeDetail&notice=' . urlencode( $row->notlog_not_name ) );
 53+
 54+ // Begin log entry primary row
 55+ $htmlOut = Xml::openElement( 'tr' );
 56+
 57+ $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) );
 58+ if ( $row->notlog_action !== 'removed' ) {
 59+ $htmlOut .= '<a href="javascript:toggleDisplay(\''.$row->notlog_id.'\')">'.
 60+ '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-'.$row->notlog_id.'" style="display:block;vertical-align:baseline;"/>'.
 61+ '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png" id="cn-uncollapsed-'.$row->notlog_id.'" style="display:none;vertical-align:baseline;"/>'.
 62+ '</a>';
 63+ }
 64+ $htmlOut .= Xml::closeElement( 'td' );
 65+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 66+ $wgLang->date( $row->notlog_timestamp ) . ' ' . $wgLang->time( $row->notlog_timestamp )
 67+ );
 68+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 69+ wfMsg ( 'centralnotice-user-links', $userLink, $userTalkLink )
 70+ );
 71+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 72+ $row->notlog_action
 73+ );
 74+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ),
 75+ $campaignLink
 76+ );
 77+ $htmlOut .= Xml::tags( 'td', array(),
 78+ '&nbsp;'
 79+ );
 80+
 81+ // End log entry primary row
 82+ $htmlOut .= Xml::closeElement( 'tr' );
 83+
 84+ if ( $row->notlog_action !== 'removed' ) {
 85+ // Begin log entry secondary row
 86+ $htmlOut .= Xml::openElement( 'tr', array( 'id' => 'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) );
 87+
 88+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
 89+ '&nbsp;' // force a table cell in older browsers
 90+ );
 91+ $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) );
 92+ if ( $row->notlog_action == 'created' ) {
 93+ $htmlOut .= $this->showInitialSettings( $row );
 94+ } else if ( $row->notlog_action == 'modified' ) {
 95+ $htmlOut .= $this->showChanges( $row );
 96+ }
 97+ $htmlOut .= Xml::closeElement( 'td' );
 98+
 99+ // End log entry primary row
 100+ $htmlOut .= Xml::closeElement( 'tr' );
 101+ }
 102+
 103+ return $htmlOut;
 104+ }
 105+
 106+ function showInitialSettings( $row ) {
 107+ global $wgLang;
 108+ $details = '';
 109+ $details .= wfMsg (
 110+ 'centralnotice-log-label',
 111+ wfMsg ( 'centralnotice-start-date' ),
 112+ $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start )
 113+ )."<br/>";
 114+ $details .= wfMsg (
 115+ 'centralnotice-log-label',
 116+ wfMsg ( 'centralnotice-end-date' ),
 117+ $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end )
 118+ )."<br/>";
 119+ $details .= wfMsg (
 120+ 'centralnotice-log-label',
 121+ wfMsg ( 'centralnotice-projects' ),
 122+ $row->notlog_end_projects
 123+ )."<br/>";
 124+ $language_count = count( explode ( ', ', $row->notlog_end_languages ) );
 125+ $languageList = '';
 126+ if ( $language_count > 15 ) {
 127+ $languageList = wfMsg ( 'centralnotice-multiple-languages', $language_count );
 128+ } elseif ( $language_count > 0 ) {
 129+ $languageList = $row->notlog_end_languages;
 130+ }
 131+ $details .= wfMsg (
 132+ 'centralnotice-log-label',
 133+ wfMsg ( 'centralnotice-languages' ),
 134+ $languageList
 135+ )."<br/>";
 136+ $details .= wfMsg (
 137+ 'centralnotice-log-label',
 138+ wfMsg ( 'centralnotice-geo' ),
 139+ ($row->notlog_end_geo ? 'on' : 'off')
 140+ )."<br/>";
 141+ if ( $row->notlog_end_geo ) {
 142+ $country_count = count( explode ( ', ', $row->notlog_end_countries ) );
 143+ $countryList = '';
 144+ if ( $country_count > 20 ) {
 145+ $countryList = wfMsg ( 'centralnotice-multiple-countries', $country_count );
 146+ } elseif ( $country_count > 0 ) {
 147+ $countryList = $row->notlog_end_countries;
 148+ }
 149+ $details .= wfMsg (
 150+ 'centralnotice-log-label',
 151+ wfMsg ( 'centralnotice-countries' ),
 152+ $countryList
 153+ )."<br/>";
 154+ }
 155+ return $details;
 156+ }
 157+
 158+ function showChanges( $row ) {
 159+ global $wgLang;
 160+ $details = '';
 161+ if ( $row->notlog_begin_start !== $row->notlog_end_start ) {
 162+ $details .= wfMsg (
 163+ 'centralnotice-log-label',
 164+ wfMsg ( 'centralnotice-start-date' ),
 165+ wfMsg (
 166+ 'centralnotice-changed',
 167+ $wgLang->date( $row->notlog_begin_start ).' '.$wgLang->time( $row->notlog_begin_start ),
 168+ $wgLang->date( $row->notlog_end_start ).' '.$wgLang->time( $row->notlog_end_start )
 169+ )
 170+ )."<br/>";
 171+ }
 172+ if ( $row->notlog_begin_end !== $row->notlog_end_end ) {
 173+ $details .= wfMsg (
 174+ 'centralnotice-log-label',
 175+ wfMsg ( 'centralnotice-end-date' ),
 176+ wfMsg (
 177+ 'centralnotice-changed',
 178+ $wgLang->date( $row->notlog_begin_end ).' '.$wgLang->time( $row->notlog_begin_end ),
 179+ $wgLang->date( $row->notlog_end_end ).' '.$wgLang->time( $row->notlog_end_end )
 180+ )
 181+ )."<br/>";
 182+ }
 183+ $details .= $this->testBooleanChange( 'enabled', $row );
 184+ $details .= $this->testBooleanChange( 'preferred', $row );
 185+ $details .= $this->testBooleanChange( 'locked', $row );
 186+ $details .= $this->testBooleanChange( 'geo', $row );
 187+ $details .= $this->testSetChange( 'projects', $row );
 188+ $details .= $this->testSetChange( 'languages', $row );
 189+ $details .= $this->testSetChange( 'countries', $row );
 190+ if ( $row->notlog_begin_banners !== $row->notlog_end_banners ) {
 191+ // Show changes to banner weights and assignment
 192+ $beginBannersObject = json_decode( $row->notlog_begin_banners );
 193+ $endBannersObject = json_decode( $row->notlog_end_banners );
 194+ $beginBanners = array();
 195+ $endBanners = array();
 196+ foreach( $beginBannersObject as $key => $weight ) {
 197+ $beginBanners[$key] = $key.' ('.$weight.')';
 198+ }
 199+ foreach( $endBannersObject as $key => $weight ) {
 200+ $endBanners[$key] = $key.' ('.$weight.')';
 201+ }
 202+ if ( $beginBanners ) {
 203+ $before = implode( ', ', $beginBanners );
 204+ } else {
 205+ $before = wfMsg ( 'centralnotice-no-assignments' );
 206+ }
 207+ if ( $endBanners ) {
 208+ $after = implode( ', ', $endBanners );
 209+ } else {
 210+ $after = wfMsg ( 'centralnotice-no-assignments' );
 211+ }
 212+ $details .= wfMsg (
 213+ 'centralnotice-log-label',
 214+ wfMsg ( 'centralnotice-templates' ),
 215+ wfMsg ( 'centralnotice-changed', $before, $after)
 216+ )."<br/>";
 217+ }
 218+ return $details;
 219+ }
 220+
 221+ private function testBooleanChange( $param, $row ) {
 222+ $result = '';
 223+ $beginField = 'notlog_begin_'.$param;
 224+ $endField = 'notlog_end_'.$param;
 225+ if ( $row->$beginField !== $row->$endField ) {
 226+ $result .= wfMsg (
 227+ 'centralnotice-log-label',
 228+ wfMsg ( 'centralnotice-'.$param ),
 229+ wfMsg (
 230+ 'centralnotice-changed',
 231+ ( $row->$beginField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
 232+ ( $row->$endField ? wfMsg ( 'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
 233+ )
 234+ )."<br/>";
 235+ }
 236+ return $result;
 237+ }
 238+
 239+ private function testSetChange( $param, $row ) {
 240+ $result = '';
 241+ $beginField = 'notlog_begin_'.$param;
 242+ $endField = 'notlog_end_'.$param;
 243+ if ( $row->$beginField !== $row->$endField ) {
 244+ $beginSet = array();
 245+ $endSet = array();
 246+ if ( $row->$beginField ) {
 247+ $beginSet = explode( ', ', $row->$beginField );
 248+ }
 249+ if ( $row->$endField ) {
 250+ $endSet = explode( ', ', $row->$endField );
 251+ }
 252+ $added = array_diff( $endSet, $beginSet );
 253+ $removed = array_diff( $beginSet, $endSet );
 254+ $differences = '';
 255+ if ( $added ) {
 256+ $differences .= wfMsg ( 'centralnotice-added', implode( ', ', $added ) );
 257+ if ( $removed ) $differences .= '; ';
 258+ }
 259+ if ( $removed ) {
 260+ $differences .= wfMsg ( 'centralnotice-removed', implode( ', ', $removed ) );
 261+ }
 262+ $result .= wfMsg (
 263+ 'centralnotice-log-label',
 264+ wfMsg ( 'centralnotice-'.$param ),
 265+ $differences
 266+ )."<br/>";
 267+ }
 268+ return $result;
 269+ }
 270+
 271+ /**
 272+ * Specify table headers
 273+ */
 274+ function getStartBody() {
 275+ $htmlOut = '';
 276+ $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) );
 277+ $htmlOut .= Xml::openElement( 'tr' );
 278+ $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) );
 279+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ),
 280+ wfMsg ( 'centralnotice-timestamp' )
 281+ );
 282+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
 283+ wfMsg ( 'centralnotice-user' )
 284+ );
 285+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ),
 286+ wfMsg ( 'centralnotice-action' )
 287+ );
 288+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ),
 289+ wfMsg ( 'centralnotice-notice' )
 290+ );
 291+ $htmlOut .= Xml::tags( 'td', array(),
 292+ '&nbsp;'
 293+ );
 294+ $htmlOut .= Xml::closeElement( 'tr' );
 295+ return $htmlOut;
 296+ }
 297+
 298+ /**
 299+ * Close table
 300+ */
 301+ function getEndBody() {
 302+ $htmlOut = '';
 303+ $htmlOut .= Xml::closeElement( 'table' );
 304+ return $htmlOut;
 305+ }
 306+
 307+}

Comments

#Comment by 😂 (talk | contribs)   02:47, 10 August 2011

Classes don't have to necessarily be in their own separate files for hiphop support (otherwise even core wouldn't work). What bit of documentation made you think they did?

#Comment by Kaldari (talk | contribs)   02:50, 10 August 2011

That's what I heard at Wikimania. Maybe it was just a rumor :)

Status & tagging log