r93293 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93292‎ | r93293 | r93294 >
Date:18:15, 27 July 2011
Author:ashley
Status:deferred (Comments)
Tags:
Comment:
DPLforum: automagically register the new namespace + its talkspace
Modified paths:
  • /trunk/extensions/DPLforum/DPLforum.namespaces.php (added) (history)
  • /trunk/extensions/DPLforum/DPLforum.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DPLforum/DPLforum.namespaces.php
@@ -0,0 +1,29 @@
 2+<?php
 3+/**
 4+ * Translations of the Forum namespace.
 5+ *
 6+ * @file
 7+ */
 8+
 9+$namespaceNames = array();
 10+
 11+// For wikis where the DPLforum extension is not installed.
 12+if( !defined( 'NS_FORUM' ) ) {
 13+ define( 'NS_FORUM', 110 );
 14+}
 15+
 16+if( !defined( 'NS_FORUM_TALK' ) ) {
 17+ define( 'NS_FORUM_TALK', 111 );
 18+}
 19+
 20+/** English */
 21+$namespaceNames['en'] = array(
 22+ NS_FORUM => 'Forum',
 23+ NS_FORUM_TALK => 'Forum_talk',
 24+);
 25+
 26+/** Finnish (Suomi) */
 27+$namespaceNames['fi'] = array(
 28+ NS_FORUM => 'Foorumi',
 29+ NS_FORUM_TALK => 'Keskustelu_foorumista',
 30+);
\ No newline at end of file
Property changes on: trunk/extensions/DPLforum/DPLforum.namespaces.php
___________________________________________________________________
Added: svn:eol-style
131 + native
Index: trunk/extensions/DPLforum/DPLforum.php
@@ -1,7 +1,7 @@
22 <?php
33 /**
44
5 - DPLforum v3.3.1 -- DynamicPageList-based forum extension
 5+ DPLforum v3.3.3 -- DynamicPageList-based forum extension
66
77 Author: Ross McClure
88 http://www.mediawiki.org/wiki/User:Algorithm
@@ -26,7 +26,7 @@
2727 http://www.gnu.org/copyleft/gpl.html
2828
2929 To install, add following to LocalSettings.php
30 - require_once("extensions/DPLforum/DPLforum.php");
 30+ require_once("$IP/extensions/DPLforum/DPLforum.php");
3131
3232 */
3333
@@ -35,19 +35,29 @@
3636 die( 1 );
3737 }
3838
39 -$wgHooks['ParserFirstCallInit'][] = 'wfDPLinit';
40 -$wgHooks['LanguageGetMagic'][] = 'wfDPLmagic';
 39+// Extension credits that will show up on Special:Version
4140 $wgExtensionCredits['parserhook'][] = array(
4241 'path' => __FILE__,
4342 'name' => 'DPLforum',
4443 'author' => 'Ross McClure',
45 - 'version' => '3.3.2',
 44+ 'version' => '3.3.3',
4645 'url' => 'http://www.mediawiki.org/wiki/Extension:DPLforum',
4746 'descriptionmsg' => 'dplforum-desc',
4847 );
4948
 49+// Define the namespace constants
 50+define( 'NS_FORUM', 110 );
 51+define( 'NS_FORUM_TALK', 111 );
 52+
 53+// Hooked functions
 54+$wgHooks['ParserFirstCallInit'][] = 'wfDPLinit';
 55+$wgHooks['LanguageGetMagic'][] = 'wfDPLmagic';
 56+$wgHooks['CanonicalNamespaces'][] = 'wfDPLforumCanonicalNamespaces';
 57+
 58+// Set up i18n and autoload the main class
5059 $dir = dirname( __FILE__ ) . '/';
5160 $wgExtensionMessagesFiles['DPLforum'] = $dir . 'DPLforum.i18n.php';
 61+$wgExtensionMessagesFiles['DPLforumNamespaces'] = $dir . 'DPLforum.namespaces.php';
5262 $wgAutoloadClasses['DPLForum'] = $dir . 'DPLforum_body.php';
5363
5464 function wfDPLinit( &$parser ) {
@@ -68,3 +78,16 @@
6979 $f = new DPLForum();
7080 return $f->parse( $input, $parser );
7181 }
 82+
 83+/**
 84+ * Register the canonical names for our namespace and its talkspace.
 85+ *
 86+ * @param $list Array: array of namespace numbers with corresponding
 87+ * canonical names
 88+ * @return Boolean: true
 89+ */
 90+function wfDPLforumCanonicalNamespaces( &$list ) {
 91+ $list[NS_FORUM] = 'Forum';
 92+ $list[NS_FORUM_TALK] = 'Forum_talk';
 93+ return true;
 94+}
\ No newline at end of file

Comments

#Comment by Siebrand (talk | contribs)   18:37, 27 July 2011

Even though extension:Translate does not yet support translation of namespace names for extensions, it might be wise to keep the namespaces.php as clean as possible by putting the define()s in the init file. IIRC that's how other extensions like LiquidThreads do it.

#Comment by Jack Phoenix (talk | contribs)   18:43, 27 July 2011

The defines are (also) in the main setup file and as a matter of fact, LiquidThreads also has those define()s in the NS file — see http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/LiquidThreads/i18n/Lqt.namespaces.php?view=markup . I don't exactly get why they are there, but safe than sorry. :-)

#Comment by Siebrand (talk | contribs)   18:45, 27 July 2011

My bad. Guess we'll fix it whenever it needs fixing. Thanks for the reply.

Status & tagging log