http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94140
Revision: 94140
Author: kaldari
Date: 2011-08-10 01:32:56 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
moving classes to separate files for hiphop support
Modified Paths:
--------------
trunk/extensions/CentralNotice/CentralNotice.php
trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
Added Paths:
-----------
trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php
trunk/extensions/CentralNotice/CentralNoticeLogPager.php
trunk/extensions/CentralNotice/CentralNoticePager.php
Modified: trunk/extensions/CentralNotice/CentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.php 2011-08-09 23:37:26 UTC
(rev 94139)
+++ trunk/extensions/CentralNotice/CentralNotice.php 2011-08-10 01:32:56 UTC
(rev 94140)
@@ -110,7 +110,6 @@
$wgAutoloadClasses['CentralNotice'] = $specialDir .
'SpecialCentralNotice.php';
$wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php';
- $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php';
if ( $wgNoticeInfrastructure ) {
$wgSpecialPages['CentralNotice'] = 'CentralNotice';
@@ -124,6 +123,11 @@
$wgSpecialPages['CentralNoticeLogs'] =
'SpecialCentralNoticeLogs';
$wgAutoloadClasses['SpecialCentralNoticeLogs'] = $specialDir .
'SpecialCentralNoticeLogs.php';
+
+ $wgAutoloadClasses['TemplatePager'] = $dir .
'TemplatePager.php';
+ $wgAutoloadClasses['CentralNoticePager'] = $dir .
'CentralNoticePager.php';
+ $wgAutoloadClasses['CentralNoticeLogPager'] = $dir .
'CentralNoticeLogPager.php';
+ $wgAutoloadClasses['CentralNoticeBannerLogPager'] = $dir .
'CentralNoticeBannerLogPager.php';
}
}
Added: trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php
(rev 0)
+++ trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php
2011-08-10 01:32:56 UTC (rev 94140)
@@ -0,0 +1,215 @@
+<?php
+
+class CentralNoticeBannerLogPager extends CentralNoticeLogPager {
+ var $viewPage, $special;
+
+ function __construct( $special ) {
+ $this->special = $special;
+ parent::__construct($special);
+
+ $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate',
'view' );
+ }
+
+ /**
+ * Sort the log list by timestamp
+ */
+ function getIndexField() {
+ return 'tmplog_timestamp';
+ }
+
+ /**
+ * Pull log entries from the database
+ */
+ function getQueryInfo() {
+ return array(
+ 'tables' => array( 'cn_template_log' ),
+ 'fields' => '*',
+ );
+ }
+
+ /**
+ * Generate the content of each table row (1 row = 1 log entry)
+ */
+ function formatRow( $row ) {
+ global $wgLang, $wgExtensionAssetsPath;
+
+ // Create a user object so we can pull the name, user page, etc.
+ $loggedUser = User::newFromId( $row->tmplog_user_id );
+ // Create the user page link
+ $userLink = $this->getSkin()->makeLinkObj(
$loggedUser->getUserPage(),
+ $loggedUser->getName() );
+ $userTalkLink = $this->getSkin()->makeLinkObj(
$loggedUser->getTalkPage(),
+ wfMsg ( 'centralnotice-talk-link' ) );
+
+ // Create the banner link
+ $bannerLink = $this->getSkin()->makeLinkObj( $this->viewPage,
+ htmlspecialchars( $row->tmplog_template_name ),
+ 'template=' . urlencode( $row->tmplog_template_name ) );
+
+ // Begin log entry primary row
+ $htmlOut = Xml::openElement( 'tr' );
+
+ $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' )
);
+ if ( $row->tmplog_action !== 'removed' ) {
+ $htmlOut .= '<a
href="javascript:toggleDisplay(\''.$row->tmplog_id.'\')">'.
+ '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png"
id="cn-collapsed-'.$row->tmplog_id.'"
style="display:block;vertical-align:baseline;"/>'.
+ '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png"
id="cn-uncollapsed-'.$row->tmplog_id.'"
style="display:none;vertical-align:baseline;"/>'.
+ '</a>';
+ }
+ $htmlOut .= Xml::closeElement( 'td' );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ $wgLang->date( $row->tmplog_timestamp ) . ' ' .
$wgLang->time( $row->tmplog_timestamp )
+ );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ wfMsg ( 'centralnotice-user-links', $userLink,
$userTalkLink )
+ );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ $row->tmplog_action
+ );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ $bannerLink
+ );
+ $htmlOut .= Xml::tags( 'td', array(),
+ ' '
+ );
+
+ // End log entry primary row
+ $htmlOut .= Xml::closeElement( 'tr' );
+
+ if ( $row->tmplog_action !== 'removed' ) {
+ // Begin log entry secondary row
+ $htmlOut .= Xml::openElement( 'tr', array( 'id' =>
'cn-log-details-'.$row->tmplog_id, 'style' => 'display:none;' ) );
+
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
+ ' ' // force a table cell in older browsers
+ );
+ $htmlOut .= Xml::openElement( 'td', array( 'valign' =>
'top', 'colspan' => '5' ) );
+ if ( $row->tmplog_action == 'created' ) {
+ $htmlOut .= $this->showInitialSettings( $row );
+ } else if ( $row->tmplog_action == 'modified' ) {
+ $htmlOut .= $this->showChanges( $row );
+ }
+ $htmlOut .= Xml::closeElement( 'td' );
+
+ // End log entry primary row
+ $htmlOut .= Xml::closeElement( 'tr' );
+ }
+
+ return $htmlOut;
+ }
+
+ function getStartBody() {
+ $htmlOut = '';
+ $htmlOut .= Xml::openElement( 'table', array( 'id' =>
'cn-campaign-logs', 'cellpadding' => 3 ) );
+ $htmlOut .= Xml::openElement( 'tr' );
+ $htmlOut .= Xml::element( 'th', array( 'style' => 'width:
20px;' ) );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 130px;' ),
+ wfMsg ( 'centralnotice-timestamp' )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
+ wfMsg ( 'centralnotice-user' )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 100px;' ),
+ wfMsg ( 'centralnotice-action' )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
+ wfMsg ( 'centralnotice-banner' )
+ );
+ $htmlOut .= Xml::tags( 'td', array(),
+ ' '
+ );
+ $htmlOut .= Xml::closeElement( 'tr' );
+ return $htmlOut;
+ }
+
+ /**
+ * Close table
+ */
+ function getEndBody() {
+ $htmlOut = '';
+ $htmlOut .= Xml::closeElement( 'table' );
+ return $htmlOut;
+ }
+
+ function showInitialSettings( $row ) {
+ global $wgLang;
+ $details = '';
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-anon' ),
+ ($row->tmplog_end_anon ? 'on' : 'off')
+ )."<br/>";
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-account' ),
+ ($row->tmplog_end_account ? 'on' : 'off')
+ )."<br/>";
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-fundraising' ),
+ ($row->tmplog_end_fundraising ? 'on' : 'off')
+ )."<br/>";
+ if ( $row->tmplog_end_landingpages ) {
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-landingpages' ),
+ $row->tmplog_end_landingpages
+ )."<br/>";
+ }
+ return $details;
+ }
+
+ function showChanges( $row ) {
+ global $wgLang;
+ $details = '';
+ $details .= $this->testBooleanChange( 'anon', $row );
+ $details .= $this->testBooleanChange( 'account', $row );
+ $details .= $this->testBooleanChange( 'fundraising', $row );
+ $details .= $this->testTextChange( 'landingpages', $row );
+ if ( $row->tmplog_content_change ) {
+ // Show changes to banner content
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-banner-content' ),
+ wfMsg ( 'centralnotice-banner-content-changed' )
+ )."<br/>";
+ }
+ return $details;
+ }
+
+ private function testBooleanChange( $param, $row ) {
+ $result = '';
+ $beginField = 'tmplog_begin_'.$param;
+ $endField = 'tmplog_end_'.$param;
+ if ( $row->$beginField !== $row->$endField ) {
+ $result .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-'.$param ),
+ wfMsg (
+ 'centralnotice-changed',
+ ( $row->$beginField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
+ ( $row->$endField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
+ )
+ )."<br/>";
+ }
+ return $result;
+ }
+
+ private function testTextChange( $param, $row ) {
+ $result = '';
+ $beginField = 'tmplog_begin_'.$param;
+ $endField = 'tmplog_end_'.$param;
+ if ( $row->$beginField !== $row->$endField ) {
+ $result .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-'.$param ),
+ wfMsg (
+ 'centralnotice-changed',
+ $row->$beginField,
+ $row->$endField
+ )
+ )."<br/>";
+ }
+ return $result;
+ }
+}
Added: trunk/extensions/CentralNotice/CentralNoticeLogPager.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNoticeLogPager.php
(rev 0)
+++ trunk/extensions/CentralNotice/CentralNoticeLogPager.php 2011-08-10
01:32:56 UTC (rev 94140)
@@ -0,0 +1,306 @@
+<?php
+
+class CentralNoticeLogPager extends ReverseChronologicalPager {
+ var $viewPage, $special;
+
+ function __construct( $special ) {
+ $this->special = $special;
+ parent::__construct();
+
+ // Override paging defaults
+ list( $this->mLimit, /* $offset */ ) =
$this->mRequest->getLimitOffset( 20, '' );
+ $this->mLimitsShown = array( 20, 50, 100 );
+
+ $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' );
+ }
+
+ /**
+ * Sort the log list by timestamp
+ */
+ function getIndexField() {
+ return 'notlog_timestamp';
+ }
+
+ /**
+ * Pull log entries from the database
+ */
+ function getQueryInfo() {
+ return array(
+ 'tables' => array( 'cn_notice_log' ),
+ 'fields' => '*',
+ );
+ }
+
+ /**
+ * Generate the content of each table row (1 row = 1 log entry)
+ */
+ function formatRow( $row ) {
+ global $wgLang, $wgExtensionAssetsPath;
+
+ // Create a user object so we can pull the name, user page, etc.
+ $loggedUser = User::newFromId( $row->notlog_user_id );
+ // Create the user page link
+ $userLink = $this->getSkin()->makeLinkObj(
$loggedUser->getUserPage(),
+ $loggedUser->getName() );
+ $userTalkLink = $this->getSkin()->makeLinkObj(
$loggedUser->getTalkPage(),
+ wfMsg ( 'centralnotice-talk-link' ) );
+
+ // Create the campaign link
+ $campaignLink = $this->getSkin()->makeLinkObj( $this->viewPage,
+ htmlspecialchars( $row->notlog_not_name ),
+ 'method=listNoticeDetail¬ice=' . urlencode(
$row->notlog_not_name ) );
+
+ // Begin log entry primary row
+ $htmlOut = Xml::openElement( 'tr' );
+
+ $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' )
);
+ if ( $row->notlog_action !== 'removed' ) {
+ $htmlOut .= '<a
href="javascript:toggleDisplay(\''.$row->notlog_id.'\')">'.
+ '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png"
id="cn-collapsed-'.$row->notlog_id.'"
style="display:block;vertical-align:baseline;"/>'.
+ '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png"
id="cn-uncollapsed-'.$row->notlog_id.'"
style="display:none;vertical-align:baseline;"/>'.
+ '</a>';
+ }
+ $htmlOut .= Xml::closeElement( 'td' );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ $wgLang->date( $row->notlog_timestamp ) . ' ' .
$wgLang->time( $row->notlog_timestamp )
+ );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ wfMsg ( 'centralnotice-user-links', $userLink,
$userTalkLink )
+ );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ $row->notlog_action
+ );
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
+ $campaignLink
+ );
+ $htmlOut .= Xml::tags( 'td', array(),
+ ' '
+ );
+
+ // End log entry primary row
+ $htmlOut .= Xml::closeElement( 'tr' );
+
+ if ( $row->notlog_action !== 'removed' ) {
+ // Begin log entry secondary row
+ $htmlOut .= Xml::openElement( 'tr', array( 'id' =>
'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) );
+
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
+ ' ' // force a table cell in older browsers
+ );
+ $htmlOut .= Xml::openElement( 'td', array( 'valign' =>
'top', 'colspan' => '5' ) );
+ if ( $row->notlog_action == 'created' ) {
+ $htmlOut .= $this->showInitialSettings( $row );
+ } else if ( $row->notlog_action == 'modified' ) {
+ $htmlOut .= $this->showChanges( $row );
+ }
+ $htmlOut .= Xml::closeElement( 'td' );
+
+ // End log entry primary row
+ $htmlOut .= Xml::closeElement( 'tr' );
+ }
+
+ return $htmlOut;
+ }
+
+ function showInitialSettings( $row ) {
+ global $wgLang;
+ $details = '';
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-start-date' ),
+ $wgLang->date( $row->notlog_end_start ).'
'.$wgLang->time( $row->notlog_end_start )
+ )."<br/>";
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-end-date' ),
+ $wgLang->date( $row->notlog_end_end ).'
'.$wgLang->time( $row->notlog_end_end )
+ )."<br/>";
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-projects' ),
+ $row->notlog_end_projects
+ )."<br/>";
+ $language_count = count( explode ( ', ',
$row->notlog_end_languages ) );
+ $languageList = '';
+ if ( $language_count > 15 ) {
+ $languageList = wfMsg (
'centralnotice-multiple-languages', $language_count );
+ } elseif ( $language_count > 0 ) {
+ $languageList = $row->notlog_end_languages;
+ }
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-languages' ),
+ $languageList
+ )."<br/>";
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-geo' ),
+ ($row->notlog_end_geo ? 'on' : 'off')
+ )."<br/>";
+ if ( $row->notlog_end_geo ) {
+ $country_count = count( explode ( ', ',
$row->notlog_end_countries ) );
+ $countryList = '';
+ if ( $country_count > 20 ) {
+ $countryList = wfMsg (
'centralnotice-multiple-countries', $country_count );
+ } elseif ( $country_count > 0 ) {
+ $countryList = $row->notlog_end_countries;
+ }
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-countries' ),
+ $countryList
+ )."<br/>";
+ }
+ return $details;
+ }
+
+ function showChanges( $row ) {
+ global $wgLang;
+ $details = '';
+ if ( $row->notlog_begin_start !== $row->notlog_end_start ) {
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-start-date' ),
+ wfMsg (
+ 'centralnotice-changed',
+ $wgLang->date( $row->notlog_begin_start
).' '.$wgLang->time( $row->notlog_begin_start ),
+ $wgLang->date( $row->notlog_end_start
).' '.$wgLang->time( $row->notlog_end_start )
+ )
+ )."<br/>";
+ }
+ if ( $row->notlog_begin_end !== $row->notlog_end_end ) {
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-end-date' ),
+ wfMsg (
+ 'centralnotice-changed',
+ $wgLang->date( $row->notlog_begin_end
).' '.$wgLang->time( $row->notlog_begin_end ),
+ $wgLang->date( $row->notlog_end_end ).'
'.$wgLang->time( $row->notlog_end_end )
+ )
+ )."<br/>";
+ }
+ $details .= $this->testBooleanChange( 'enabled', $row );
+ $details .= $this->testBooleanChange( 'preferred', $row );
+ $details .= $this->testBooleanChange( 'locked', $row );
+ $details .= $this->testBooleanChange( 'geo', $row );
+ $details .= $this->testSetChange( 'projects', $row );
+ $details .= $this->testSetChange( 'languages', $row );
+ $details .= $this->testSetChange( 'countries', $row );
+ if ( $row->notlog_begin_banners !== $row->notlog_end_banners ) {
+ // Show changes to banner weights and assignment
+ $beginBannersObject = json_decode(
$row->notlog_begin_banners );
+ $endBannersObject = json_decode(
$row->notlog_end_banners );
+ $beginBanners = array();
+ $endBanners = array();
+ foreach( $beginBannersObject as $key => $weight ) {
+ $beginBanners[$key] = $key.' ('.$weight.')';
+ }
+ foreach( $endBannersObject as $key => $weight ) {
+ $endBanners[$key] = $key.' ('.$weight.')';
+ }
+ if ( $beginBanners ) {
+ $before = implode( ', ', $beginBanners );
+ } else {
+ $before = wfMsg (
'centralnotice-no-assignments' );
+ }
+ if ( $endBanners ) {
+ $after = implode( ', ', $endBanners );
+ } else {
+ $after = wfMsg ( 'centralnotice-no-assignments'
);
+ }
+ $details .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-templates' ),
+ wfMsg ( 'centralnotice-changed', $before,
$after)
+ )."<br/>";
+ }
+ return $details;
+ }
+
+ private function testBooleanChange( $param, $row ) {
+ $result = '';
+ $beginField = 'notlog_begin_'.$param;
+ $endField = 'notlog_end_'.$param;
+ if ( $row->$beginField !== $row->$endField ) {
+ $result .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-'.$param ),
+ wfMsg (
+ 'centralnotice-changed',
+ ( $row->$beginField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
+ ( $row->$endField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
+ )
+ )."<br/>";
+ }
+ return $result;
+ }
+
+ private function testSetChange( $param, $row ) {
+ $result = '';
+ $beginField = 'notlog_begin_'.$param;
+ $endField = 'notlog_end_'.$param;
+ if ( $row->$beginField !== $row->$endField ) {
+ $beginSet = array();
+ $endSet = array();
+ if ( $row->$beginField ) {
+ $beginSet = explode( ', ', $row->$beginField );
+ }
+ if ( $row->$endField ) {
+ $endSet = explode( ', ', $row->$endField );
+ }
+ $added = array_diff( $endSet, $beginSet );
+ $removed = array_diff( $beginSet, $endSet );
+ $differences = '';
+ if ( $added ) {
+ $differences .= wfMsg ( 'centralnotice-added',
implode( ', ', $added ) );
+ if ( $removed ) $differences .= '; ';
+ }
+ if ( $removed ) {
+ $differences .= wfMsg (
'centralnotice-removed', implode( ', ', $removed ) );
+ }
+ $result .= wfMsg (
+ 'centralnotice-log-label',
+ wfMsg ( 'centralnotice-'.$param ),
+ $differences
+ )."<br/>";
+ }
+ return $result;
+ }
+
+ /**
+ * Specify table headers
+ */
+ function getStartBody() {
+ $htmlOut = '';
+ $htmlOut .= Xml::openElement( 'table', array( 'id' =>
'cn-campaign-logs', 'cellpadding' => 3 ) );
+ $htmlOut .= Xml::openElement( 'tr' );
+ $htmlOut .= Xml::element( 'th', array( 'style' => 'width:
20px;' ) );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 130px;' ),
+ wfMsg ( 'centralnotice-timestamp' )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
+ wfMsg ( 'centralnotice-user' )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 100px;' ),
+ wfMsg ( 'centralnotice-action' )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
+ wfMsg ( 'centralnotice-notice' )
+ );
+ $htmlOut .= Xml::tags( 'td', array(),
+ ' '
+ );
+ $htmlOut .= Xml::closeElement( 'tr' );
+ return $htmlOut;
+ }
+
+ /**
+ * Close table
+ */
+ function getEndBody() {
+ $htmlOut = '';
+ $htmlOut .= Xml::closeElement( 'table' );
+ return $htmlOut;
+ }
+
+}
Added: trunk/extensions/CentralNotice/CentralNoticePager.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNoticePager.php
(rev 0)
+++ trunk/extensions/CentralNotice/CentralNoticePager.php 2011-08-10
01:32:56 UTC (rev 94140)
@@ -0,0 +1,121 @@
+<?php
+
+class CentralNoticePager extends TemplatePager {
+ var $viewPage, $special;
+ var $editable;
+
+ function __construct( $special ) {
+ parent::__construct( $special );
+ }
+
+ /**
+ * Pull banners from the database
+ */
+ function getQueryInfo() {
+ $notice = $this->mRequest->getVal( 'notice' );
+ $noticeId = CentralNotice::getNoticeId( $notice );
+ if ( $noticeId ) {
+ // Return all the banners not already assigned to the
current campaign
+ return array(
+ 'tables' => array( 'cn_assignments',
'cn_templates' ),
+ 'fields' => array( 'cn_templates.tmp_name',
'cn_templates.tmp_id' ),
+ 'conds' => array( 'cn_assignments.tmp_id IS
NULL' ),
+ 'join_conds' => array(
+ 'cn_assignments' => array(
+ 'LEFT JOIN',
+ "cn_assignments.tmp_id =
cn_templates.tmp_id " .
+ "AND cn_assignments.not_id =
$noticeId"
+ )
+ )
+ );
+ } else {
+ // Return all the banners in the database
+ return array(
+ 'tables' => 'cn_templates',
+ 'fields' => array( 'tmp_name', 'tmp_id' ),
+ );
+ }
+ }
+
+ /**
+ * Generate the content of each table row (1 row = 1 banner)
+ */
+ function formatRow( $row ) {
+
+ // Begin banner row
+ $htmlOut = Xml::openElement( 'tr' );
+
+ if ( $this->editable ) {
+ // Add box
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
+ Xml::check( 'addTemplates[]', '', array (
'value' => $row->tmp_name ) )
+ );
+ // Weight select
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
+ Xml::listDropDown( "weight[$row->tmp_id]",
+ CentralNotice::dropDownList(
+ wfMsg( 'centralnotice-weight'
), range ( 0, 100, 5 )
+ ) ,
+ '',
+ '25',
+ '',
+ '' )
+ );
+ }
+
+ // Link and Preview
+ $render = new SpecialBannerLoader();
+ $render->siteName = 'Wikipedia';
+ $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
+ try {
+ $preview = $render->getHtmlNotice( $row->tmp_name );
+ } catch ( SpecialBannerLoaderException $e ) {
+ $preview = wfMsg( 'centralnotice-nopreview' );
+ }
+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
+ $this->getSkin()->makeLinkObj( $this->viewPage,
+ htmlspecialchars( $row->tmp_name ),
+ 'template=' . urlencode( $row->tmp_name ) ) .
+ Xml::fieldset( wfMsg( 'centralnotice-preview' ),
+ $preview,
+ array( 'class' => 'cn-bannerpreview')
+ )
+ );
+
+ // End banner row
+ $htmlOut .= Xml::closeElement( 'tr' );
+
+ return $htmlOut;
+ }
+
+ /**
+ * Specify table headers
+ */
+ function getStartBody() {
+ $htmlOut = '';
+ $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' =>
9 ) );
+ $htmlOut .= Xml::openElement( 'tr' );
+ if ( $this->editable ) {
+ $htmlOut .= Xml::element( 'th', array( 'align' =>
'left', 'width' => '5%' ),
+ wfMsg ( "centralnotice-add" )
+ );
+ $htmlOut .= Xml::element( 'th', array( 'align' =>
'left', 'width' => '5%' ),
+ wfMsg ( "centralnotice-weight" )
+ );
+ }
+ $htmlOut .= Xml::element( 'th', array( 'align' => 'left' ),
+ wfMsg ( 'centralnotice-templates' )
+ );
+ $htmlOut .= Xml::closeElement( 'tr' );
+ return $htmlOut;
+ }
+
+ /**
+ * Close table
+ */
+ function getEndBody() {
+ $htmlOut = '';
+ $htmlOut .= Xml::closeElement( 'table' );
+ return $htmlOut;
+ }
+}
Modified: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
2011-08-09 23:37:26 UTC (rev 94139)
+++ trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
2011-08-10 01:32:56 UTC (rev 94140)
@@ -1741,123 +1741,3 @@
}
}
}
-
-class CentralNoticePager extends TemplatePager {
- var $viewPage, $special;
- var $editable;
-
- function __construct( $special ) {
- parent::__construct( $special );
- }
-
- /**
- * Pull banners from the database
- */
- function getQueryInfo() {
- $notice = $this->mRequest->getVal( 'notice' );
- $noticeId = CentralNotice::getNoticeId( $notice );
- if ( $noticeId ) {
- // Return all the banners not already assigned to the
current campaign
- return array(
- 'tables' => array( 'cn_assignments',
'cn_templates' ),
- 'fields' => array( 'cn_templates.tmp_name',
'cn_templates.tmp_id' ),
- 'conds' => array( 'cn_assignments.tmp_id IS
NULL' ),
- 'join_conds' => array(
- 'cn_assignments' => array(
- 'LEFT JOIN',
- "cn_assignments.tmp_id =
cn_templates.tmp_id " .
- "AND cn_assignments.not_id =
$noticeId"
- )
- )
- );
- } else {
- // Return all the banners in the database
- return array(
- 'tables' => 'cn_templates',
- 'fields' => array( 'tmp_name', 'tmp_id' ),
- );
- }
- }
-
- /**
- * Generate the content of each table row (1 row = 1 banner)
- */
- function formatRow( $row ) {
-
- // Begin banner row
- $htmlOut = Xml::openElement( 'tr' );
-
- if ( $this->editable ) {
- // Add box
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
- Xml::check( 'addTemplates[]', '', array (
'value' => $row->tmp_name ) )
- );
- // Weight select
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
- Xml::listDropDown( "weight[$row->tmp_id]",
- CentralNotice::dropDownList(
- wfMsg( 'centralnotice-weight'
), range ( 0, 100, 5 )
- ) ,
- '',
- '25',
- '',
- '' )
- );
- }
-
- // Link and Preview
- $render = new SpecialBannerLoader();
- $render->siteName = 'Wikipedia';
- $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
- try {
- $preview = $render->getHtmlNotice( $row->tmp_name );
- } catch ( SpecialBannerLoaderException $e ) {
- $preview = wfMsg( 'centralnotice-nopreview' );
- }
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
- $this->getSkin()->makeLinkObj( $this->viewPage,
- htmlspecialchars( $row->tmp_name ),
- 'template=' . urlencode( $row->tmp_name ) ) .
- Xml::fieldset( wfMsg( 'centralnotice-preview' ),
- $preview,
- array( 'class' => 'cn-bannerpreview')
- )
- );
-
- // End banner row
- $htmlOut .= Xml::closeElement( 'tr' );
-
- return $htmlOut;
- }
-
- /**
- * Specify table headers
- */
- function getStartBody() {
- $htmlOut = '';
- $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' =>
9 ) );
- $htmlOut .= Xml::openElement( 'tr' );
- if ( $this->editable ) {
- $htmlOut .= Xml::element( 'th', array( 'align' =>
'left', 'width' => '5%' ),
- wfMsg ( "centralnotice-add" )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' =>
'left', 'width' => '5%' ),
- wfMsg ( "centralnotice-weight" )
- );
- }
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left' ),
- wfMsg ( 'centralnotice-templates' )
- );
- $htmlOut .= Xml::closeElement( 'tr' );
- return $htmlOut;
- }
-
- /**
- * Close table
- */
- function getEndBody() {
- $htmlOut = '';
- $htmlOut .= Xml::closeElement( 'table' );
- return $htmlOut;
- }
-}
Modified: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
===================================================================
--- trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
2011-08-09 23:37:26 UTC (rev 94139)
+++ trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
2011-08-10 01:32:56 UTC (rev 94140)
@@ -117,522 +117,3 @@
}
}
-
-class CentralNoticeLogPager extends ReverseChronologicalPager {
- var $viewPage, $special;
-
- function __construct( $special ) {
- $this->special = $special;
- parent::__construct();
-
- // Override paging defaults
- list( $this->mLimit, /* $offset */ ) =
$this->mRequest->getLimitOffset( 20, '' );
- $this->mLimitsShown = array( 20, 50, 100 );
-
- $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' );
- }
-
- /**
- * Sort the log list by timestamp
- */
- function getIndexField() {
- return 'notlog_timestamp';
- }
-
- /**
- * Pull log entries from the database
- */
- function getQueryInfo() {
- return array(
- 'tables' => array( 'cn_notice_log' ),
- 'fields' => '*',
- );
- }
-
- /**
- * Generate the content of each table row (1 row = 1 log entry)
- */
- function formatRow( $row ) {
- global $wgLang, $wgExtensionAssetsPath;
-
- // Create a user object so we can pull the name, user page, etc.
- $loggedUser = User::newFromId( $row->notlog_user_id );
- // Create the user page link
- $userLink = $this->getSkin()->makeLinkObj(
$loggedUser->getUserPage(),
- $loggedUser->getName() );
- $userTalkLink = $this->getSkin()->makeLinkObj(
$loggedUser->getTalkPage(),
- wfMsg ( 'centralnotice-talk-link' ) );
-
- // Create the campaign link
- $campaignLink = $this->getSkin()->makeLinkObj( $this->viewPage,
- htmlspecialchars( $row->notlog_not_name ),
- 'method=listNoticeDetail¬ice=' . urlencode(
$row->notlog_not_name ) );
-
- // Begin log entry primary row
- $htmlOut = Xml::openElement( 'tr' );
-
- $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' )
);
- if ( $row->notlog_action !== 'removed' ) {
- $htmlOut .= '<a
href="javascript:toggleDisplay(\''.$row->notlog_id.'\')">'.
- '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png"
id="cn-collapsed-'.$row->notlog_id.'"
style="display:block;vertical-align:baseline;"/>'.
- '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png"
id="cn-uncollapsed-'.$row->notlog_id.'"
style="display:none;vertical-align:baseline;"/>'.
- '</a>';
- }
- $htmlOut .= Xml::closeElement( 'td' );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- $wgLang->date( $row->notlog_timestamp ) . ' ' .
$wgLang->time( $row->notlog_timestamp )
- );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- wfMsg ( 'centralnotice-user-links', $userLink,
$userTalkLink )
- );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- $row->notlog_action
- );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- $campaignLink
- );
- $htmlOut .= Xml::tags( 'td', array(),
- ' '
- );
-
- // End log entry primary row
- $htmlOut .= Xml::closeElement( 'tr' );
-
- if ( $row->notlog_action !== 'removed' ) {
- // Begin log entry secondary row
- $htmlOut .= Xml::openElement( 'tr', array( 'id' =>
'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) );
-
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
- ' ' // force a table cell in older browsers
- );
- $htmlOut .= Xml::openElement( 'td', array( 'valign' =>
'top', 'colspan' => '5' ) );
- if ( $row->notlog_action == 'created' ) {
- $htmlOut .= $this->showInitialSettings( $row );
- } else if ( $row->notlog_action == 'modified' ) {
- $htmlOut .= $this->showChanges( $row );
- }
- $htmlOut .= Xml::closeElement( 'td' );
-
- // End log entry primary row
- $htmlOut .= Xml::closeElement( 'tr' );
- }
-
- return $htmlOut;
- }
-
- function showInitialSettings( $row ) {
- global $wgLang;
- $details = '';
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-start-date' ),
- $wgLang->date( $row->notlog_end_start ).'
'.$wgLang->time( $row->notlog_end_start )
- )."<br/>";
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-end-date' ),
- $wgLang->date( $row->notlog_end_end ).'
'.$wgLang->time( $row->notlog_end_end )
- )."<br/>";
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-projects' ),
- $row->notlog_end_projects
- )."<br/>";
- $language_count = count( explode ( ', ',
$row->notlog_end_languages ) );
- $languageList = '';
- if ( $language_count > 15 ) {
- $languageList = wfMsg (
'centralnotice-multiple-languages', $language_count );
- } elseif ( $language_count > 0 ) {
- $languageList = $row->notlog_end_languages;
- }
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-languages' ),
- $languageList
- )."<br/>";
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-geo' ),
- ($row->notlog_end_geo ? 'on' : 'off')
- )."<br/>";
- if ( $row->notlog_end_geo ) {
- $country_count = count( explode ( ', ',
$row->notlog_end_countries ) );
- $countryList = '';
- if ( $country_count > 20 ) {
- $countryList = wfMsg (
'centralnotice-multiple-countries', $country_count );
- } elseif ( $country_count > 0 ) {
- $countryList = $row->notlog_end_countries;
- }
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-countries' ),
- $countryList
- )."<br/>";
- }
- return $details;
- }
-
- function showChanges( $row ) {
- global $wgLang;
- $details = '';
- if ( $row->notlog_begin_start !== $row->notlog_end_start ) {
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-start-date' ),
- wfMsg (
- 'centralnotice-changed',
- $wgLang->date( $row->notlog_begin_start
).' '.$wgLang->time( $row->notlog_begin_start ),
- $wgLang->date( $row->notlog_end_start
).' '.$wgLang->time( $row->notlog_end_start )
- )
- )."<br/>";
- }
- if ( $row->notlog_begin_end !== $row->notlog_end_end ) {
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-end-date' ),
- wfMsg (
- 'centralnotice-changed',
- $wgLang->date( $row->notlog_begin_end
).' '.$wgLang->time( $row->notlog_begin_end ),
- $wgLang->date( $row->notlog_end_end ).'
'.$wgLang->time( $row->notlog_end_end )
- )
- )."<br/>";
- }
- $details .= $this->testBooleanChange( 'enabled', $row );
- $details .= $this->testBooleanChange( 'preferred', $row );
- $details .= $this->testBooleanChange( 'locked', $row );
- $details .= $this->testBooleanChange( 'geo', $row );
- $details .= $this->testSetChange( 'projects', $row );
- $details .= $this->testSetChange( 'languages', $row );
- $details .= $this->testSetChange( 'countries', $row );
- if ( $row->notlog_begin_banners !== $row->notlog_end_banners ) {
- // Show changes to banner weights and assignment
- $beginBannersObject = json_decode(
$row->notlog_begin_banners );
- $endBannersObject = json_decode(
$row->notlog_end_banners );
- $beginBanners = array();
- $endBanners = array();
- foreach( $beginBannersObject as $key => $weight ) {
- $beginBanners[$key] = $key.' ('.$weight.')';
- }
- foreach( $endBannersObject as $key => $weight ) {
- $endBanners[$key] = $key.' ('.$weight.')';
- }
- if ( $beginBanners ) {
- $before = implode( ', ', $beginBanners );
- } else {
- $before = wfMsg (
'centralnotice-no-assignments' );
- }
- if ( $endBanners ) {
- $after = implode( ', ', $endBanners );
- } else {
- $after = wfMsg ( 'centralnotice-no-assignments'
);
- }
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-templates' ),
- wfMsg ( 'centralnotice-changed', $before,
$after)
- )."<br/>";
- }
- return $details;
- }
-
- private function testBooleanChange( $param, $row ) {
- $result = '';
- $beginField = 'notlog_begin_'.$param;
- $endField = 'notlog_end_'.$param;
- if ( $row->$beginField !== $row->$endField ) {
- $result .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-'.$param ),
- wfMsg (
- 'centralnotice-changed',
- ( $row->$beginField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
- ( $row->$endField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
- )
- )."<br/>";
- }
- return $result;
- }
-
- private function testSetChange( $param, $row ) {
- $result = '';
- $beginField = 'notlog_begin_'.$param;
- $endField = 'notlog_end_'.$param;
- if ( $row->$beginField !== $row->$endField ) {
- $beginSet = array();
- $endSet = array();
- if ( $row->$beginField ) {
- $beginSet = explode( ', ', $row->$beginField );
- }
- if ( $row->$endField ) {
- $endSet = explode( ', ', $row->$endField );
- }
- $added = array_diff( $endSet, $beginSet );
- $removed = array_diff( $beginSet, $endSet );
- $differences = '';
- if ( $added ) {
- $differences .= wfMsg ( 'centralnotice-added',
implode( ', ', $added ) );
- if ( $removed ) $differences .= '; ';
- }
- if ( $removed ) {
- $differences .= wfMsg (
'centralnotice-removed', implode( ', ', $removed ) );
- }
- $result .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-'.$param ),
- $differences
- )."<br/>";
- }
- return $result;
- }
-
- /**
- * Specify table headers
- */
- function getStartBody() {
- $htmlOut = '';
- $htmlOut .= Xml::openElement( 'table', array( 'id' =>
'cn-campaign-logs', 'cellpadding' => 3 ) );
- $htmlOut .= Xml::openElement( 'tr' );
- $htmlOut .= Xml::element( 'th', array( 'style' => 'width:
20px;' ) );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 130px;' ),
- wfMsg ( 'centralnotice-timestamp' )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
- wfMsg ( 'centralnotice-user' )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 100px;' ),
- wfMsg ( 'centralnotice-action' )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
- wfMsg ( 'centralnotice-notice' )
- );
- $htmlOut .= Xml::tags( 'td', array(),
- ' '
- );
- $htmlOut .= Xml::closeElement( 'tr' );
- return $htmlOut;
- }
-
- /**
- * Close table
- */
- function getEndBody() {
- $htmlOut = '';
- $htmlOut .= Xml::closeElement( 'table' );
- return $htmlOut;
- }
-
-}
-
-class CentralNoticeBannerLogPager extends CentralNoticeLogPager {
- var $viewPage, $special;
-
- function __construct( $special ) {
- $this->special = $special;
- parent::__construct($special);
-
- $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate',
'view' );
- }
-
- /**
- * Sort the log list by timestamp
- */
- function getIndexField() {
- return 'tmplog_timestamp';
- }
-
- /**
- * Pull log entries from the database
- */
- function getQueryInfo() {
- return array(
- 'tables' => array( 'cn_template_log' ),
- 'fields' => '*',
- );
- }
-
- /**
- * Generate the content of each table row (1 row = 1 log entry)
- */
- function formatRow( $row ) {
- global $wgLang, $wgExtensionAssetsPath;
-
- // Create a user object so we can pull the name, user page, etc.
- $loggedUser = User::newFromId( $row->tmplog_user_id );
- // Create the user page link
- $userLink = $this->getSkin()->makeLinkObj(
$loggedUser->getUserPage(),
- $loggedUser->getName() );
- $userTalkLink = $this->getSkin()->makeLinkObj(
$loggedUser->getTalkPage(),
- wfMsg ( 'centralnotice-talk-link' ) );
-
- // Create the banner link
- $bannerLink = $this->getSkin()->makeLinkObj( $this->viewPage,
- htmlspecialchars( $row->tmplog_template_name ),
- 'template=' . urlencode( $row->tmplog_template_name ) );
-
- // Begin log entry primary row
- $htmlOut = Xml::openElement( 'tr' );
-
- $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' )
);
- if ( $row->tmplog_action !== 'removed' ) {
- $htmlOut .= '<a
href="javascript:toggleDisplay(\''.$row->tmplog_id.'\')">'.
- '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png"
id="cn-collapsed-'.$row->tmplog_id.'"
style="display:block;vertical-align:baseline;"/>'.
- '<img
src="'.$wgExtensionAssetsPath.'/CentralNotice/uncollapsed.png"
id="cn-uncollapsed-'.$row->tmplog_id.'"
style="display:none;vertical-align:baseline;"/>'.
- '</a>';
- }
- $htmlOut .= Xml::closeElement( 'td' );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- $wgLang->date( $row->tmplog_timestamp ) . ' ' .
$wgLang->time( $row->tmplog_timestamp )
- );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- wfMsg ( 'centralnotice-user-links', $userLink,
$userTalkLink )
- );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- $row->tmplog_action
- );
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class'
=> 'primary' ),
- $bannerLink
- );
- $htmlOut .= Xml::tags( 'td', array(),
- ' '
- );
-
- // End log entry primary row
- $htmlOut .= Xml::closeElement( 'tr' );
-
- if ( $row->tmplog_action !== 'removed' ) {
- // Begin log entry secondary row
- $htmlOut .= Xml::openElement( 'tr', array( 'id' =>
'cn-log-details-'.$row->tmplog_id, 'style' => 'display:none;' ) );
-
- $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
- ' ' // force a table cell in older browsers
- );
- $htmlOut .= Xml::openElement( 'td', array( 'valign' =>
'top', 'colspan' => '5' ) );
- if ( $row->tmplog_action == 'created' ) {
- $htmlOut .= $this->showInitialSettings( $row );
- } else if ( $row->tmplog_action == 'modified' ) {
- $htmlOut .= $this->showChanges( $row );
- }
- $htmlOut .= Xml::closeElement( 'td' );
-
- // End log entry primary row
- $htmlOut .= Xml::closeElement( 'tr' );
- }
-
- return $htmlOut;
- }
-
- function getStartBody() {
- $htmlOut = '';
- $htmlOut .= Xml::openElement( 'table', array( 'id' =>
'cn-campaign-logs', 'cellpadding' => 3 ) );
- $htmlOut .= Xml::openElement( 'tr' );
- $htmlOut .= Xml::element( 'th', array( 'style' => 'width:
20px;' ) );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 130px;' ),
- wfMsg ( 'centralnotice-timestamp' )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
- wfMsg ( 'centralnotice-user' )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 100px;' ),
- wfMsg ( 'centralnotice-action' )
- );
- $htmlOut .= Xml::element( 'th', array( 'align' => 'left',
'style' => 'width: 160px;' ),
- wfMsg ( 'centralnotice-banner' )
- );
- $htmlOut .= Xml::tags( 'td', array(),
- ' '
- );
- $htmlOut .= Xml::closeElement( 'tr' );
- return $htmlOut;
- }
-
- /**
- * Close table
- */
- function getEndBody() {
- $htmlOut = '';
- $htmlOut .= Xml::closeElement( 'table' );
- return $htmlOut;
- }
-
- function showInitialSettings( $row ) {
- global $wgLang;
- $details = '';
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-anon' ),
- ($row->tmplog_end_anon ? 'on' : 'off')
- )."<br/>";
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-account' ),
- ($row->tmplog_end_account ? 'on' : 'off')
- )."<br/>";
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-fundraising' ),
- ($row->tmplog_end_fundraising ? 'on' : 'off')
- )."<br/>";
- if ( $row->tmplog_end_landingpages ) {
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-landingpages' ),
- $row->tmplog_end_landingpages
- )."<br/>";
- }
- return $details;
- }
-
- function showChanges( $row ) {
- global $wgLang;
- $details = '';
- $details .= $this->testBooleanChange( 'anon', $row );
- $details .= $this->testBooleanChange( 'account', $row );
- $details .= $this->testBooleanChange( 'fundraising', $row );
- $details .= $this->testTextChange( 'landingpages', $row );
- if ( $row->tmplog_content_change ) {
- // Show changes to banner content
- $details .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-banner-content' ),
- wfMsg ( 'centralnotice-banner-content-changed' )
- )."<br/>";
- }
- return $details;
- }
-
- private function testBooleanChange( $param, $row ) {
- $result = '';
- $beginField = 'tmplog_begin_'.$param;
- $endField = 'tmplog_end_'.$param;
- if ( $row->$beginField !== $row->$endField ) {
- $result .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-'.$param ),
- wfMsg (
- 'centralnotice-changed',
- ( $row->$beginField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) ),
- ( $row->$endField ? wfMsg (
'centralnotice-on' ) : wfMsg ( 'centralnotice-off' ) )
- )
- )."<br/>";
- }
- return $result;
- }
-
- private function testTextChange( $param, $row ) {
- $result = '';
- $beginField = 'tmplog_begin_'.$param;
- $endField = 'tmplog_end_'.$param;
- if ( $row->$beginField !== $row->$endField ) {
- $result .= wfMsg (
- 'centralnotice-log-label',
- wfMsg ( 'centralnotice-'.$param ),
- wfMsg (
- 'centralnotice-changed',
- $row->$beginField,
- $row->$endField
- )
- )."<br/>";
- }
- return $result;
- }
-}
Modified: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
===================================================================
--- trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
2011-08-09 23:37:26 UTC (rev 94139)
+++ trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
2011-08-10 01:32:56 UTC (rev 94140)
@@ -781,7 +781,7 @@
* @param $displayAccount integer flag for display to logged in users
* @param $fundraising integer flag for fundraising banner (optional)
* @param $landingPages string list of landing pages (optional)
- * @return boolean banner successfully added or not?
+ * @return true or false depending on whether banner was successfully
added
*/
public function addTemplate( $name, $body, $displayAnon,
$displayAccount, $fundraising = 0,
$landingPages = '' ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs