r73240 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73239‎ | r73240 | r73241 >
Date:18:54, 17 September 2010
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
beginning support for viewing banner allocation
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.i18n.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialBannerAllocation.php (added) (history)
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -104,6 +104,9 @@
105105 $wgSpecialPages['NoticeTemplate'] = 'SpecialNoticeTemplate';
106106 $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 'SpecialNoticeTemplate.php';
107107
 108+ $wgSpecialPages['BannerAllocation'] = 'SpecialBannerAllocation';
 109+ $wgAutoloadClasses['SpecialBannerAllocation'] = $dir . 'SpecialBannerAllocation.php';
 110+
108111 $wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php';
109112 $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php';
110113 }
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -179,7 +179,8 @@
180180
181181 $pages = array(
182182 'CentralNotice' => wfMsg( 'centralnotice-notices' ),
183 - 'NoticeTemplate' => wfMsg ( 'centralnotice-templates' )
 183+ 'NoticeTemplate' => wfMsg ( 'centralnotice-templates' ),
 184+ 'BannerAllocation' => wfMsg ( 'centralnotice-allocation' )
184185 );
185186 $htmlOut = Xml::openElement( 'ul', array( 'id' => 'preftoc' ) );
186187 foreach ( $pages as $page => $msg ) {
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php
@@ -11,7 +11,8 @@
1212
1313 $messages['en'] = array(
1414 'centralnotice' => 'Central notice admin',
15 - 'noticetemplate' => 'Central notice banner',
 15+ 'noticetemplate' => 'Central notice banners',
 16+ 'bannerallocation' => 'Central notice banner allocation',
1617 'centralnotice-desc' => 'Adds a central sitenotice',
1718 'centralnotice-summary' => 'This module allows you to edit your currently setup central notices.
1819 It can also be used to add or remove old notices.',
@@ -122,6 +123,7 @@
123124 'centralnotice-banner-collapsible' => 'Collapsible',
124125 'centralnotice-geotargeted' => 'Geotargeted',
125126 'centralnotice-countries' => 'Countries',
 127+ 'centralnotice-allocation' => 'Allocation',
126128
127129 'right-centralnotice-admin' => 'Manage central notices',
128130 'right-centralnotice-translate' => 'Translate central notices',
Index: trunk/extensions/CentralNotice/SpecialBannerAllocation.php
@@ -0,0 +1,88 @@
 2+<?php
 3+
 4+if ( !defined( 'MEDIAWIKI' ) ) {
 5+ echo "CentralNotice extension\n";
 6+ exit( 1 );
 7+}
 8+
 9+class SpecialBannerAllocation extends UnlistedSpecialPage {
 10+ var $centralNoticeError;
 11+
 12+ function __construct() {
 13+ // Register special page
 14+ parent::__construct( "BannerAllocation" );
 15+
 16+ // Internationalization
 17+ wfLoadExtensionMessages( 'CentralNotice' );
 18+ }
 19+
 20+ /**
 21+ * Handle different types of page requests
 22+ */
 23+ function execute( $sub ) {
 24+ global $wgOut, $wgUser, $wgRequest, $wgScriptPath;
 25+
 26+ // Begin output
 27+ $this->setHeaders();
 28+
 29+ // Add style file to the output headers
 30+ $wgOut->addExtensionStyle( "$wgScriptPath/extensions/CentralNotice/centralnotice.css" );
 31+
 32+ // Add script file to the output headers
 33+ $wgOut->addScriptFile( "$wgScriptPath/extensions/CentralNotice/centralnotice.js" );
 34+
 35+ // Initialize error variable
 36+ $this->centralNoticeError = false;
 37+
 38+ // Show summary
 39+ $wgOut->addWikiMsg( 'centralnotice-summary' );
 40+
 41+ // Show header
 42+ CentralNotice::printHeader();
 43+
 44+ // Begin Banners tab content
 45+ $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'preferences' ) ) );
 46+
 47+ $htmlOut = '';
 48+
 49+ // Begin Allocation selection fieldset
 50+ $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
 51+
 52+ $htmlOut .= 'Coming soon!';
 53+
 54+ // End Allocation selection fieldset
 55+ $htmlOut .= Xml::closeElement( 'fieldset' );
 56+
 57+ $wgOut->addHTML( $htmlOut );
 58+
 59+ // Handle form submissions
 60+ if ( $wgRequest->wasPosted() ) {
 61+
 62+ // Show list of banners by default
 63+ $this->showList();
 64+
 65+ }
 66+
 67+ // End Banners tab content
 68+ $wgOut->addHTML( Xml::closeElement( 'div' ) );
 69+ }
 70+
 71+ /**
 72+ * Show a list of banners with allocation. Newer banners are shown first.
 73+ */
 74+ function showList() {
 75+ // Begin building HTML
 76+ $htmlOut = '';
 77+
 78+ // Begin Allocation list fieldset
 79+ $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
 80+
 81+ $htmlOut .= "List goes here";
 82+
 83+ // End Allocation list fieldset
 84+ $htmlOut .= Xml::closeElement( 'fieldset' );
 85+
 86+ $wgOut->addHTML( $htmlOut );
 87+ }
 88+
 89+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r73821no longer needed per comment at r73240kaldari19:10, 27 September 2010
r75567using wgExtensionAssetsPath per Tim's suggestion at r73240kaldari19:35, 27 October 2010

Comments

#Comment by Catrope (talk | contribs)   18:44, 27 September 2010
+		wfLoadExtensionMessages( 'CentralNotice' );

This function is a no-op as of 1.16.

#Comment by Kaldari (talk | contribs)   19:11, 27 September 2010

fixed in r73821.

#Comment by Tim Starling (talk | contribs)   18:57, 27 October 2010
+		// Add style file to the output headers
+		$wgOut->addExtensionStyle( "$wgScriptPath/extensions/CentralNotice/centralnotice.css" );
+		
+		// Add script file to the output headers
+		$wgOut->addScriptFile( "$wgScriptPath/extensions/CentralNotice/centralnotice.js" );

This should use $wgExtensionAssetsPath not $wgScriptPath/extensions.

#Comment by Kaldari (talk | contribs)   19:35, 27 October 2010

Thanks. Fixed in r75567.

Status & tagging log