r39151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39150‎ | r39151 | r39152 >
Date:14:48, 11 August 2008
Author:siebrand
Status:old
Tags:
Comment:
Some updates:
* exit if outside MEDIAWIKI context before setting globals, also exit in special page class file
* update extension credits, add descriptionmsg, update documentation URL
* add wgExtensionAliasesFiles to support special page name localisation
* split off hook code into an own class
* delay message loading
* i18n file resorted and author credits added to language blocks to support Translate localisation
* bumped version to 2.0, as this probably is no longer compatible back to MediaWiki 1.8
* EOL whitespace removed
Modified paths:
  • /trunk/extensions/NewsChannel/NewsChannel.alias.php (added) (history)
  • /trunk/extensions/NewsChannel/NewsChannel.class.php (added) (history)
  • /trunk/extensions/NewsChannel/NewsChannel.class.php (added) (history)
  • /trunk/extensions/NewsChannel/NewsChannel.i18n.php (modified) (history)
  • /trunk/extensions/NewsChannel/NewsChannel.php (modified) (history)
  • /trunk/extensions/NewsChannel/NewsChannel_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewsChannel/NewsChannel.class.php
@@ -0,0 +1,22 @@
 2+<?php
 3+if (!defined('MEDIAWIKI')) die();
 4+
 5+class LinkNewsChannel {
 6+ static function ExtensionFeeds() {
 7+ global $wgOut, $wgNewsChannelTitle;
 8+
 9+ $title = Title::newFromText( 'NewsChannel', NS_SPECIAL );
 10+ $wgOut->addLink( array(
 11+ 'rel' => 'alternate',
 12+ 'type' => 'application/rss+xml',
 13+ 'title' => $wgNewsChannelTitle . ' - RSS 2.0',
 14+ 'href' => $title->getLocalURL( 'format=rss20' ) ) );
 15+ $wgOut->addLink( array(
 16+ 'rel' => 'alternate',
 17+ 'type' => 'application/atom+xml',
 18+ 'title' => $wgNewsChannelTitle . ' - Atom 1.0',
 19+ 'href' => $title->getLocalURL( 'format=atom10' ) ) );
 20+
 21+ return true;
 22+ }
 23+}
\ No newline at end of file
Property changes on: trunk/extensions/NewsChannel/NewsChannel.class.php
___________________________________________________________________
Added: svn:mergeinfo
Added: svn:eol-style
124 + native
Added: svn:keywords
225 + Id
Index: trunk/extensions/NewsChannel/NewsChannel.alias.php
@@ -0,0 +1,14 @@
 2+<?php
 3+/**
 4+ * Aliases for special pages
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$aliases = array();
 11+
 12+/** English */
 13+$aliases['en'] = array(
 14+ 'NewsChannel' => array( 'NewsChannel' ),
 15+);
Property changes on: trunk/extensions/NewsChannel/NewsChannel.alias.php
___________________________________________________________________
Added: svn:eol-style
116 + native
Added: svn:keywords
217 + Id
Index: trunk/extensions/NewsChannel/NewsChannel_body.php
@@ -1,4 +1,5 @@
22 <?php
 3+if (!defined('MEDIAWIKI')) die();
34 /**
45 * News Channel extension 1.6
56 * This MediaWiki extension represents a RSS 2.0/Atom 1.0 news channel for wiki project.
@@ -25,8 +26,6 @@
2627 * Constructor is used to initialize class member variables and load extension messages.
2728 */
2829 function NewsChannel() {
29 -
30 - wfLoadExtensionMessages( 'NewsChannel' );
3130 SpecialPage::SpecialPage( 'NewsChannel' );
3231 }
3332
@@ -39,6 +38,8 @@
4039 function execute( $par ) {
4140 global $wgRequest, $wgVersion, $wgOut, $wgNewsChannelCategory, $wgNewsChannelDefaultItems;
4241
 42+ wfLoadExtensionMessages( 'NewsChannel' );
 43+
4344 if( version_compare( $wgVersion, '1.8', '<' ) === true ) {
4445 $wgOut->showErrorPage( "Error: Upgrade required", "The News Channel extension can't work " .
4546 "on MediaWiki older than 1.8. Please, upgrade." );
@@ -141,7 +142,7 @@
142143 $exCatSqlQueryStr = '';
143144
144145 if ( $subquerySupport == false ) {
145 - $sqlQueryStr =
 146+ $sqlQueryStr =
146147 "SELECT {$catlinksTableName}.cl_from, " .
147148 "MIN({$catlinksTableName}.cl_timestamp) AS timestamp, COUNT(*) AS match_count, " .
148149 "{$pageTableName}.page_namespace AS ns, {$pageTableName}.page_title AS title, " .
@@ -240,8 +241,8 @@
241242 function formatFeedHeader() {
242243 global $wgRequest, $wgServer, $wgContLanguageCode, $wgOut;
243244 global $wgNewsChannelTitle, $wgNewsChannelDescription, $wgNewsChannelCopyright,
244 - $wgNewsChannelLanguage, $wgNewsChannelLogoImage, $wgNewsChannelUpdateInterval,
245 - $wgNewsChannelEditorName, $wgNewsChannelEditorAddress, $wgNewsChannelWebMasterName,
 245+ $wgNewsChannelLanguage, $wgNewsChannelLogoImage, $wgNewsChannelUpdateInterval,
 246+ $wgNewsChannelEditorName, $wgNewsChannelEditorAddress, $wgNewsChannelWebMasterName,
246247 $wgNewsChannelWebMasterAddress;
247248
248249 if( empty( $wgNewsChannelLanguage ) )
@@ -429,4 +430,3 @@
430431 </form>' . "\n" );
431432 }
432433 }
433 -?>
\ No newline at end of file
Index: trunk/extensions/NewsChannel/NewsChannel.i18n.php
@@ -10,17 +10,16 @@
1111 * Extension's home page: http://www.mediawiki.org/wiki/Extension:News_Channel
1212 *
1313 * Distributed under GNU General Public License 2.0 or later (http://www.gnu.org/copyleft/gpl.html)
14 -* Authors:
15 -* English messages: Iaroslav Vassiliev
16 -* Russian messages: Iaroslav Vassiliev
17 -* German messages: Cornelius Sicker
18 -* French messages: Mauro Bornet
1914 */
2015
2116 $messages = array();
2217
23 -$messages['en'] = array(
 18+/** English
 19+ * @author Iaroslav Vassiliev
 20+ */
 21+$messages['en'] = array(
2422 'newschannel' => 'News channel',
 23+ 'newschannel-desc' => 'Implements a news channel as a dynamic [[Special:NewsChannel|special page]]',
2524 'newschannel_format' => 'Format:',
2625 'newschannel_limit' => 'Limit:',
2726 'newschannel_include_category' => 'Additional category:',
@@ -28,16 +27,10 @@
2928 'newschannel_submit_button' => 'Create feed',
3029 );
3130
32 -$messages['ru'] = array(
33 - 'newschannel' => 'Канал новостей',
34 - 'newschannel_format' => 'Формат новостей:',
35 - 'newschannel_limit' => 'Кол-во последних новостей:',
36 - 'newschannel_include_category' => 'Дополнительная категория:',
37 - 'newschannel_exclude_category' => 'Исключить категорию:',
38 - 'newschannel_submit_button' => 'Вывести',
39 -);
40 -
41 -$messages['de'] = array(
 31+/** German (Deutsch)
 32+ * @author Cornelius Sicker
 33+ */
 34+$messages['de'] = array(
4235 'newschannel' => 'Nachrichten',
4336 'newschannel_format' => 'Format:',
4437 'newschannel_limit' => 'Limit:',
@@ -46,7 +39,10 @@
4740 'newschannel_submit_button' => 'Feed erstellen',
4841 );
4942
50 -$messages['fr'] = array(
 43+/** French (Français)
 44+ * @author Mauro Bornet
 45+ */
 46+$messages['fr'] = array(
5147 'newschannel' => 'Chaîne d\'information',
5248 'newschannel_format' => 'Format:',
5349 'newschannel_limit' => 'Limite:',
@@ -54,4 +50,15 @@
5551 'newschannel_exclude_category' => 'Catégorie(s) exclue(s):',
5652 'newschannel_submit_button' => 'Créer le flux',
5753 );
58 -?>
\ No newline at end of file
 54+
 55+/** Russian (Русский)
 56+ * @author Iaroslav Vassiliev
 57+ */
 58+$messages['ru'] = array(
 59+ 'newschannel' => 'Канал новостей',
 60+ 'newschannel_format' => 'Формат новостей:',
 61+ 'newschannel_limit' => 'Кол-во последних новостей:',
 62+ 'newschannel_include_category' => 'Дополнительная категория:',
 63+ 'newschannel_exclude_category' => 'Исключить категорию:',
 64+ 'newschannel_submit_button' => 'Вывести',
 65+);
Index: trunk/extensions/NewsChannel/NewsChannel.php
@@ -13,6 +13,14 @@
1414 * Distributed under GNU General Public License 2.0 or later (http://www.gnu.org/copyleft/gpl.html)
1515 */
1616
 17+if ( !defined( 'MEDIAWIKI' ) ) {
 18+ echo <<<EOT
 19+To install this extension, put the following line in LocalSettings.php:
 20+require_once( "\$IP/extensions/NewsChannel/NewsChannel.php" );
 21+EOT;
 22+ exit( 1 );
 23+}
 24+
1725 // Set up general channel info here
1826
1927 /** Channel title. */
@@ -21,7 +29,7 @@
2230 $wgNewsChannelDescription = 'The most hot IT news on MyWikiSite.com.';
2331 /**
2432 * Channel's language code and optional country subcode, e. g. 'en-US'.
25 -* Default is language, specified in $wgLanguageCode variable in LocalSettings.php file.
 33+* Default is language, specified in $wgLanguageCode variable in LocalSettings.php file.
2634 */
2735 $wgNewsChannelLanguage = '';
2836 /** Copyright text. */
@@ -66,44 +74,20 @@
6775
6876 // End of configuration settings
6977
70 -if ( !defined( 'MEDIAWIKI' ) ) {
71 - echo <<<EOT
72 -To install this extension, put the following line in LocalSettings.php:
73 -require_once( "\$IP/extensions/NewsChannel/NewsChannel.php" );
74 -EOT;
75 - exit( 1 );
76 -}
77 -
7878 $wgExtensionCredits['specialpage'][] = array(
79 - 'name' => 'News Channel',
80 - 'version' => 1.6,
81 - 'author' => 'Iaroslav Vassiliev <codedriller@gmail.com>',
82 - 'description' => 'This MediaWiki extension represents a news channel for wiki project. ' .
 79+ 'name' => 'News Channel',
 80+ 'version' => '2.0',
 81+ 'author' => '[mailto:codedriller@gmail.com Iaroslav Vassiliev]',
 82+ 'description' => 'This MediaWiki extension represents a news channel for wiki project. ' .
8383 'The channel is implemented as a dynamic [[Special:NewsChannel|special page]].',
84 - 'url' => 'http://www.mediawiki.org/wiki/Extension:News_Channel'
 84+ 'descriptionmsg' => 'newschannel-desc',
 85+ 'url' => 'http://www.mediawiki.org/wiki/Extension:News_Channel',
8586 );
8687
87 -//$wgExtensionFunctions[] = 'wfSetupNewsChannelExtension';
88 -$wgAutoloadClasses['NewsChannel'] = dirname( __FILE__ ) . '/NewsChannel_body.php';
89 -$wgExtensionMessagesFiles['NewsChannel'] = dirname( __FILE__ ) . '/NewsChannel.i18n.php';
 88+$dir = dirname(__FILE__) . '/';
 89+$wgAutoloadClasses['NewsChannel'] = $dir . 'NewsChannel_body.php';
 90+$wgAutoloadClasses['LinkNewsChannel'] = $dir . 'NewsChannel.class.php';
 91+$wgExtensionMessagesFiles['NewsChannel'] = $dir . 'NewsChannel.i18n.php';
 92+$wgExtensionAliasesFiles['NewsChannel'] = $dir . 'NewsChannel.alias.php';
9093 $wgSpecialPages['NewsChannel'] = 'NewsChannel';
91 -$wgHooks['BeforePageDisplay'][] = 'wfLinkNewsChannelExtensionFeeds';
92 -
93 -function wfLinkNewsChannelExtensionFeeds() {
94 - global $wgOut, $wgNewsChannelTitle;
95 -
96 - $title = Title::newFromText( 'NewsChannel', NS_SPECIAL );
97 - $wgOut->addLink( array(
98 - 'rel' => 'alternate',
99 - 'type' => 'application/rss+xml',
100 - 'title' => $wgNewsChannelTitle . ' - RSS 2.0',
101 - 'href' => $title->getLocalURL( 'format=rss20' ) ) );
102 - $wgOut->addLink( array(
103 - 'rel' => 'alternate',
104 - 'type' => 'application/atom+xml',
105 - 'title' => $wgNewsChannelTitle . ' - Atom 1.0',
106 - 'href' => $title->getLocalURL( 'format=atom10' ) ) );
107 -
108 - return true;
109 -}
110 -?>
\ No newline at end of file
 94+$wgHooks['BeforePageDisplay'][] = 'LinkNewsChannel::ExtensionFeeds';

Status & tagging log