https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111514

Revision: 111514
Author:   jeroendedauw
Date:     2012-02-15 00:10:16 +0000 (Wed, 15 Feb 2012)
Log Message:
-----------
address bug 34383

Modified Paths:
--------------
    trunk/extensions/SemanticForms/SemanticForms.php
    trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
    trunk/extensions/SemanticForms/includes/SF_Utils.php
    trunk/extensions/SemanticForms/languages/SF_Language.php
    trunk/extensions/SemanticForms/specials/SF_CreateCategory.php

Added Paths:
-----------
    trunk/extensions/SemanticForms/languages/SF_Namespaces.php

Modified: trunk/extensions/SemanticForms/SemanticForms.php
===================================================================
--- trunk/extensions/SemanticForms/SemanticForms.php    2012-02-15 00:02:08 UTC 
(rev 111513)
+++ trunk/extensions/SemanticForms/SemanticForms.php    2012-02-15 00:10:16 UTC 
(rev 111514)
@@ -91,6 +91,7 @@
 $wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables';
 $wgHooks['PageSchemasRegisterHandlers'][] = 'SFPageSchemas::registerClass';
 $wgHooks['EditPage::importFormData'][] = 'SFUtils::showFormPreview';
+$wgHooks['CanonicalNamespaces'][] = 'SFUtils::onCanonicalNamespaces';
 
 $wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI';
 $wgAPIModules['sfautoedit'] = 'SFAutoeditAPI';
@@ -172,6 +173,8 @@
 $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . 
'/languages/SF_Messages.php';
 $wgExtensionMessagesFiles['SemanticFormsAlias'] = $sfgIP . 
'/languages/SF_Aliases.php';
 $wgExtensionMessagesFiles['SemanticFormsMagic'] = $sfgIP . 
'/languages/SF_Magic.php';
+$wgExtensionMessagesFiles['SemanticFormsNS'] = $sfgIP . 
'/languages/SF_Namespaces.php';
+
 // Allow for popup windows for file upload
 $wgEditPageFrameOptions = 'SAMEORIGIN';
 

Modified: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php      
2012-02-15 00:02:08 UTC (rev 111513)
+++ trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php      
2012-02-15 00:10:16 UTC (rev 111514)
@@ -30,15 +30,10 @@
  * greater or equal to 100.
  */
 function sffInitNamespaces() {
-       global $wgExtraNamespaces, $wgNamespaceAliases, 
$wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang;
+       global $wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang;
 
        sffInitContentLanguage( $wgLanguageCode );
 
-       // Register namespace identifiers
-       if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); }
-       $wgExtraNamespaces = $wgExtraNamespaces + $sfgContLang->getNamespaces();
-       $wgNamespaceAliases = $wgNamespaceAliases + 
$sfgContLang->getNamespaceAliases();
-
        // Support subpages only for talk pages by default
        $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array(
                SF_NS_FORM_TALK => true

Modified: trunk/extensions/SemanticForms/includes/SF_Utils.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_Utils.php        2012-02-15 
00:02:08 UTC (rev 111513)
+++ trunk/extensions/SemanticForms/includes/SF_Utils.php        2012-02-15 
00:10:16 UTC (rev 111514)
@@ -417,8 +417,8 @@
 
        public static function formDropdownHTML() {
                // create a dropdown of possible form names
-               global $sfgContLang;
-               $namespace_labels = $sfgContLang->getNamespaces();
+               global $wgContLang;
+               $namespace_labels = $wgContLang->getNamespaces();
                $form_label = $namespace_labels[SF_NS_FORM];
                $form_names = SFUtils::getAllForms();
                $select_body = "\n";
@@ -1082,4 +1082,21 @@
        }
 
 
+       /**
+        * For extensions adding their own namespaces or altering the defaults.
+        * @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces
+        *
+        * @since 2.4.1
+        *
+        * @param array $list
+        *
+        * @return true
+        */
+       public static function onCanonicalNamespaces( array &$list ) {
+               $list[SF_NS_FORM] = 'Form';
+               $list[SF_NS_FORM_TALK] = 'Form_talk';
+
+               return true;
+       }
+
 }

Modified: trunk/extensions/SemanticForms/languages/SF_Language.php
===================================================================
--- trunk/extensions/SemanticForms/languages/SF_Language.php    2012-02-15 
00:02:08 UTC (rev 111513)
+++ trunk/extensions/SemanticForms/languages/SF_Language.php    2012-02-15 
00:10:16 UTC (rev 111514)
@@ -15,7 +15,6 @@
        // arrays for the names of special properties and namespaces -
        // all messages are stored in SF_Messages.php
        protected $m_SpecialProperties;
-       protected $m_Namespaces;
 
        // By default, every language has English-language aliases for
        // special properties and namespaces
@@ -25,26 +24,7 @@
                'Creates pages with form'       => 
SF_SP_CREATES_PAGES_WITH_FORM,
        );
 
-       protected $m_NamespaceAliases = array(
-               'Form'          => SF_NS_FORM,
-               'Form_talk'     => SF_NS_FORM_TALK
-       );
-
        /**
-        * Function that returns an array of namespace identifiers.
-        */
-       function getNamespaces() {
-               return $this->m_Namespaces;
-       }
-
-       /**
-        * Function that returns an array of namespace aliases, if any.
-        */
-       function getNamespaceAliases() {
-               return $this->m_NamespaceAliases;
-       }
-
-       /**
         * Function that returns the labels for the special properties.
         */
        function getPropertyLabels() {

Added: trunk/extensions/SemanticForms/languages/SF_Namespaces.php
===================================================================
--- trunk/extensions/SemanticForms/languages/SF_Namespaces.php                  
        (rev 0)
+++ trunk/extensions/SemanticForms/languages/SF_Namespaces.php  2012-02-15 
00:10:16 UTC (rev 111514)
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Namespace internationalizationfor the Semantic Forms extension.
+ *
+ * @since 0.1
+ *
+ * @file SF_Namespaces.php
+ * @ingroup SemanticForms
+ *
+ * @licence GNU GPL v3+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+
+$namespaceNames = array();
+
+$namespaceNames['en'] = array(
+       SF_NS_FORM       => 'Form',
+       SF_NS_FORM_TALK  => 'Form_talk',
+);

Modified: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php
===================================================================
--- trunk/extensions/SemanticForms/specials/SF_CreateCategory.php       
2012-02-15 00:02:08 UTC (rev 111513)
+++ trunk/extensions/SemanticForms/specials/SF_CreateCategory.php       
2012-02-15 00:10:16 UTC (rev 111514)
@@ -30,12 +30,14 @@
                        $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] . 
"::$default_form]]";
                        $text = wfMsgForContent( 'sf_category_hasdefaultform', 
$form_tag );
                }
+
                if ( $parent_category !== '' ) {
                        global $wgContLang;
                        $namespace_labels = $wgContLang->getNamespaces();
                        $category_namespace = $namespace_labels[NS_CATEGORY];
                        $text .= "\n\n[[$category_namespace:$parent_category]]";
                }
+
                return $text;
        }
 


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

Reply via email to