http://www.mediawiki.org/wiki/Special:Code/MediaWiki/93317

Revision: 93317
Author:   ashley
Date:     2011-07-27 21:31:36 +0000 (Wed, 27 Jul 2011)
Log Message:
-----------
SocialProfile: automagically register the new namespaces

Modified Paths:
--------------
    trunk/extensions/SocialProfile/SocialProfile.php

Added Paths:
-----------
    trunk/extensions/SocialProfile/SocialProfile.namespaces.php

Added: trunk/extensions/SocialProfile/SocialProfile.namespaces.php
===================================================================
--- trunk/extensions/SocialProfile/SocialProfile.namespaces.php                 
        (rev 0)
+++ trunk/extensions/SocialProfile/SocialProfile.namespaces.php 2011-07-27 
21:31:36 UTC (rev 93317)
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Translations of the namespaces introduced by SocialProfile.
+ *
+ * @file
+ */
+
+$namespaceNames = array();
+
+// For wikis where the SocialProfile extension is not installed.
+if( !defined( 'NS_USER_WIKI' ) ) {
+       define( 'NS_USER_WIKI', 200 );
+}
+
+if( !defined( 'NS_USER_WIKI_TALK' ) ) {
+       define( 'NS_USER_WIKI_TALK', 201 );
+}
+
+if( !defined( 'NS_USER_PROFILE' ) ) {
+       define( 'NS_USER_PROFILE', 202 );
+}
+
+if( !defined( 'NS_USER_PROFILE_TALK' ) ) {
+       define( 'NS_USER_PROFILE_TALK', 203 );
+}
+
+/** English */
+$namespaceNames['en'] = array(
+       NS_USER_WIKI => 'UserWiki',
+       NS_USER_WIKI_TALK => 'UserWiki_talk',
+       NS_USER_PROFILE => 'User_profile',
+       NS_USER_PROFILE_TALK => 'User_profile_talk',
+);
+
+/** Finnish (Suomi) */
+$namespaceNames['fi'] = array(
+       NS_USER_WIKI => 'Käyttäjäwiki',
+       NS_USER_WIKI_TALK => 'Keskustelu_käyttäjäwikistä',
+       NS_USER_PROFILE => 'Käyttäjäprofiili',
+       NS_USER_PROFILE_TALK => 'Keskustelu_käyttäjäprofiilista',
+);
\ No newline at end of file


Property changes on: trunk/extensions/SocialProfile/SocialProfile.namespaces.php
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/SocialProfile/SocialProfile.php
===================================================================
--- trunk/extensions/SocialProfile/SocialProfile.php    2011-07-27 21:26:44 UTC 
(rev 93316)
+++ trunk/extensions/SocialProfile/SocialProfile.php    2011-07-27 21:31:36 UTC 
(rev 93317)
@@ -21,6 +21,7 @@
 $wgExtensionMessagesFiles['SocialProfileUserStats'] = $dir . 
'UserStats/UserStats.i18n.php';
 $wgExtensionMessagesFiles['SocialProfileUserStatus'] = $dir . 
'UserStatus/UserStatus.i18n.php';
 
+$wgExtensionMessagesFiles['SocialProfileNamespaces'] = $dir . 
'SocialProfile.namespaces.php';
 $wgExtensionAliasesFiles['SocialProfile'] = $dir . 'SocialProfile.alias.php';
 
 // Classes to be autoloaded
@@ -222,8 +223,8 @@
 
 function efSocialProfileSchemaUpdates( $updater = null ) {
        $dir = dirname( __FILE__ );
-       $dbExt = "";
-       global $wgExtNewTables, $wgDBtype;
+       $dbExt = '';
+       global $wgDBtype;
 
        if ( $wgDBtype == 'postgres' ) {
                $dbExt = '.postgres';
@@ -287,4 +288,36 @@
        $renameUserSQL->tables['user_system_messages'] = array( 'um_user_name', 
'um_user_id' );
        return true;
 }
-*/
\ No newline at end of file
+*/
+
+if( !defined( 'NS_USER_WIKI' ) ) {
+       define( 'NS_USER_WIKI', 200 );
+}
+
+if( !defined( 'NS_USER_WIKI_TALK' ) ) {
+       define( 'NS_USER_WIKI_TALK', 201 );
+}
+
+if( !defined( 'NS_USER_PROFILE' ) ) {
+       define( 'NS_USER_PROFILE', 202 );
+}
+
+if( !defined( 'NS_USER_PROFILE_TALK' ) ) {
+       define( 'NS_USER_PROFILE_TALK', 203 );
+}
+
+$wgHooks['CanonicalNamespaces'][] = 
'wfSocialProfileRegisterCanonicalNamespaces';
+/**
+ * Register the canonical names for our custom namespaces and their talkspaces.
+ *
+ * @param $list Array: array of namespace numbers with corresponding
+ *                     canonical names
+ * @return Boolean: true
+ */
+function wfSocialProfileRegisterCanonicalNamespaces( &$list ) {
+       $list[NS_USER_WIKI] = 'UserWiki';
+       $list[NS_USER_WIKI_TALK] = 'UserWiki_talk';
+       $list[NS_USER_PROFILE] = 'User_profile';
+       $list[NS_USER_PROFILE_TALK] = 'User_profile_talk';
+       return true;
+}
\ No newline at end of file


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to