https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112493
Revision: 112493 Author: yaron Date: 2012-02-27 17:33:19 +0000 (Mon, 27 Feb 2012) Log Message: ----------- Re-did changes in r111514 by jeroendedauw, with slight modifications - now that MW 1.16 is no longer supported, this updated namespace-registration code can go back in 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 Added Paths: ----------- trunk/extensions/SemanticForms/languages/SF_Namespaces.php Modified: trunk/extensions/SemanticForms/SemanticForms.php =================================================================== --- trunk/extensions/SemanticForms/SemanticForms.php 2012-02-27 17:30:43 UTC (rev 112492) +++ trunk/extensions/SemanticForms/SemanticForms.php 2012-02-27 17:33:19 UTC (rev 112493) @@ -91,6 +91,7 @@ $wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables'; $wgHooks['PageSchemasRegisterHandlers'][] = 'SFPageSchemas::registerClass'; $wgHooks['EditPage::importFormData'][] = 'SFUtils::showFormPreview'; +$wgHooks['CanonicalNamespaces'][] = 'SFUtils::registerNamespaces'; $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'; @@ -242,7 +245,7 @@ // load global functions require_once( 'includes/SF_GlobalFunctions.php' ); -sffInitNamespaces(); +sffInitContentLanguage( $wgLanguageCode ); # ## # The number of allowed values per autocomplete - too many might Modified: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php =================================================================== --- trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php 2012-02-27 17:30:43 UTC (rev 112492) +++ trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php 2012-02-27 17:33:19 UTC (rev 112493) @@ -21,31 +21,6 @@ } /**********************************************/ -/***** namespace settings *****/ -/**********************************************/ - -/** - * Init the additional namespaces used by Semantic Forms. The - * parameter denotes the least unused even namespace ID that is - * greater or equal to 100. - */ -function sffInitNamespaces() { - global $wgExtraNamespaces, $wgNamespaceAliases, $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 - ); -} - -/**********************************************/ /***** language settings *****/ /**********************************************/ Modified: trunk/extensions/SemanticForms/includes/SF_Utils.php =================================================================== --- trunk/extensions/SemanticForms/includes/SF_Utils.php 2012-02-27 17:30:43 UTC (rev 112492) +++ trunk/extensions/SemanticForms/includes/SF_Utils.php 2012-02-27 17:33:19 UTC (rev 112493) @@ -327,10 +327,12 @@ return $form_names; } + /** + * Creates a dropdown of possible form names. + */ 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"; @@ -945,5 +947,28 @@ return $merged; } + /** + * Register the namespaces for Semantic Forms. + * @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces + * + * @since 2.4.1 + * + * @param array $list + * + * @return true + */ + public static function registerNamespaces( array &$list ) { + global $wgNamespacesWithSubpages; + $list[SF_NS_FORM] = 'Form'; + $list[SF_NS_FORM_TALK] = 'Form_talk'; + + // Support subpages only for talk pages by default + $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array( + SF_NS_FORM_TALK => true + ); + + return true; + } + } Modified: trunk/extensions/SemanticForms/languages/SF_Language.php =================================================================== --- trunk/extensions/SemanticForms/languages/SF_Language.php 2012-02-27 17:30:43 UTC (rev 112492) +++ trunk/extensions/SemanticForms/languages/SF_Language.php 2012-02-27 17:33:19 UTC (rev 112493) @@ -6,47 +6,27 @@ */ /** - * Base class for all language classes - a truncated version of Semantic - * MediaWiki's 'SMW_Language' class + * Base class for all language classes. + * * @ingroup SFLanguage */ abstract class SF_Language { - // arrays for the names of special properties and namespaces - - // all messages are stored in SF_Messages.php + // Array for the names of special properties - 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 + // special properties. protected $m_SpecialPropertyAliases = array( 'Has default form' => SF_SP_HAS_DEFAULT_FORM, 'Has alternate form' => SF_SP_HAS_ALTERNATE_FORM, '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. + * Returns the labels for the special properties. */ - 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() { return $this->m_SpecialProperties; } 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-27 17:33:19 UTC (rev 112493) @@ -0,0 +1,20 @@ +<?php + +/** + * Namespace internationalization for the Semantic Forms extension. + * + * @since 2.4.1 + * + * @file SF_Namespaces.php + * @ingroup SemanticForms + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ + +$namespaceNames = array(); + +$namespaceNames['en'] = array( + SF_NS_FORM => 'Form', + SF_NS_FORM_TALK => 'Form_talk', +); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs