Index: trunk/extensions/SemanticForms/SemanticForms.php |
— | — | @@ -91,6 +91,7 @@ |
92 | 92 | $wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables'; |
93 | 93 | $wgHooks['PageSchemasRegisterHandlers'][] = 'SFPageSchemas::registerClass'; |
94 | 94 | $wgHooks['EditPage::importFormData'][] = 'SFUtils::showFormPreview'; |
| 95 | +$wgHooks['CanonicalNamespaces'][] = 'SFUtils::registerNamespaces'; |
95 | 96 | |
96 | 97 | $wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI'; |
97 | 98 | $wgAPIModules['sfautoedit'] = 'SFAutoeditAPI'; |
— | — | @@ -172,6 +173,8 @@ |
173 | 174 | $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php'; |
174 | 175 | $wgExtensionMessagesFiles['SemanticFormsAlias'] = $sfgIP . '/languages/SF_Aliases.php'; |
175 | 176 | $wgExtensionMessagesFiles['SemanticFormsMagic'] = $sfgIP . '/languages/SF_Magic.php'; |
| 177 | +$wgExtensionMessagesFiles['SemanticFormsNS'] = $sfgIP . '/languages/SF_Namespaces.php'; |
| 178 | + |
176 | 179 | // Allow for popup windows for file upload |
177 | 180 | $wgEditPageFrameOptions = 'SAMEORIGIN'; |
178 | 181 | |
— | — | @@ -242,7 +245,7 @@ |
243 | 246 | // load global functions |
244 | 247 | require_once( 'includes/SF_GlobalFunctions.php' ); |
245 | 248 | |
246 | | -sffInitNamespaces(); |
| 249 | +sffInitContentLanguage( $wgLanguageCode ); |
247 | 250 | |
248 | 251 | # ## |
249 | 252 | # The number of allowed values per autocomplete - too many might |
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -21,31 +21,6 @@ |
22 | 22 | } |
23 | 23 | |
24 | 24 | /**********************************************/ |
25 | | -/***** namespace settings *****/ |
26 | | -/**********************************************/ |
27 | | - |
28 | | -/** |
29 | | - * Init the additional namespaces used by Semantic Forms. The |
30 | | - * parameter denotes the least unused even namespace ID that is |
31 | | - * greater or equal to 100. |
32 | | - */ |
33 | | -function sffInitNamespaces() { |
34 | | - global $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang; |
35 | | - |
36 | | - sffInitContentLanguage( $wgLanguageCode ); |
37 | | - |
38 | | - // Register namespace identifiers |
39 | | - if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); } |
40 | | - $wgExtraNamespaces = $wgExtraNamespaces + $sfgContLang->getNamespaces(); |
41 | | - $wgNamespaceAliases = $wgNamespaceAliases + $sfgContLang->getNamespaceAliases(); |
42 | | - |
43 | | - // Support subpages only for talk pages by default |
44 | | - $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array( |
45 | | - SF_NS_FORM_TALK => true |
46 | | - ); |
47 | | -} |
48 | | - |
49 | | -/**********************************************/ |
50 | 25 | /***** language settings *****/ |
51 | 26 | /**********************************************/ |
52 | 27 | |
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php |
— | — | @@ -327,10 +327,12 @@ |
328 | 328 | return $form_names; |
329 | 329 | } |
330 | 330 | |
| 331 | + /** |
| 332 | + * Creates a dropdown of possible form names. |
| 333 | + */ |
331 | 334 | public static function formDropdownHTML() { |
332 | | - // create a dropdown of possible form names |
333 | | - global $sfgContLang; |
334 | | - $namespace_labels = $sfgContLang->getNamespaces(); |
| 335 | + global $wgContLang; |
| 336 | + $namespace_labels = $wgContLang->getNamespaces(); |
335 | 337 | $form_label = $namespace_labels[SF_NS_FORM]; |
336 | 338 | $form_names = SFUtils::getAllForms(); |
337 | 339 | $select_body = "\n"; |
— | — | @@ -945,5 +947,28 @@ |
946 | 948 | return $merged; |
947 | 949 | } |
948 | 950 | |
| 951 | + /** |
| 952 | + * Register the namespaces for Semantic Forms. |
| 953 | + * @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces |
| 954 | + * |
| 955 | + * @since 2.4.1 |
| 956 | + * |
| 957 | + * @param array $list |
| 958 | + * |
| 959 | + * @return true |
| 960 | + */ |
| 961 | + public static function registerNamespaces( array &$list ) { |
| 962 | + global $wgNamespacesWithSubpages; |
949 | 963 | |
| 964 | + $list[SF_NS_FORM] = 'Form'; |
| 965 | + $list[SF_NS_FORM_TALK] = 'Form_talk'; |
| 966 | + |
| 967 | + // Support subpages only for talk pages by default |
| 968 | + $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array( |
| 969 | + SF_NS_FORM_TALK => true |
| 970 | + ); |
| 971 | + |
| 972 | + return true; |
| 973 | + } |
| 974 | + |
950 | 975 | } |
Index: trunk/extensions/SemanticForms/languages/SF_Namespaces.php |
— | — | @@ -0,0 +1,20 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Namespace internationalization for the Semantic Forms extension. |
| 6 | + * |
| 7 | + * @since 2.4.1 |
| 8 | + * |
| 9 | + * @file SF_Namespaces.php |
| 10 | + * @ingroup SemanticForms |
| 11 | + * |
| 12 | + * @licence GNU GPL v2+ |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | + |
| 16 | +$namespaceNames = array(); |
| 17 | + |
| 18 | +$namespaceNames['en'] = array( |
| 19 | + SF_NS_FORM => 'Form', |
| 20 | + SF_NS_FORM_TALK => 'Form_talk', |
| 21 | +); |
Index: trunk/extensions/SemanticForms/languages/SF_Language.php |
— | — | @@ -6,47 +6,27 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * Base class for all language classes - a truncated version of Semantic |
11 | | - * MediaWiki's 'SMW_Language' class |
| 10 | + * Base class for all language classes. |
| 11 | + * |
12 | 12 | * @ingroup SFLanguage |
13 | 13 | */ |
14 | 14 | abstract class SF_Language { |
15 | 15 | |
16 | | - // arrays for the names of special properties and namespaces - |
17 | | - // all messages are stored in SF_Messages.php |
| 16 | + // Array for the names of special properties - all messages are |
| 17 | + // stored in SF_Messages.php. |
18 | 18 | protected $m_SpecialProperties; |
19 | | - protected $m_Namespaces; |
20 | 19 | |
21 | 20 | // By default, every language has English-language aliases for |
22 | | - // special properties and namespaces |
| 21 | + // special properties. |
23 | 22 | protected $m_SpecialPropertyAliases = array( |
24 | 23 | 'Has default form' => SF_SP_HAS_DEFAULT_FORM, |
25 | 24 | 'Has alternate form' => SF_SP_HAS_ALTERNATE_FORM, |
26 | 25 | 'Creates pages with form' => SF_SP_CREATES_PAGES_WITH_FORM, |
27 | 26 | ); |
28 | 27 | |
29 | | - protected $m_NamespaceAliases = array( |
30 | | - 'Form' => SF_NS_FORM, |
31 | | - 'Form_talk' => SF_NS_FORM_TALK |
32 | | - ); |
33 | | - |
34 | 28 | /** |
35 | | - * Function that returns an array of namespace identifiers. |
| 29 | + * Returns the labels for the special properties. |
36 | 30 | */ |
37 | | - function getNamespaces() { |
38 | | - return $this->m_Namespaces; |
39 | | - } |
40 | | - |
41 | | - /** |
42 | | - * Function that returns an array of namespace aliases, if any. |
43 | | - */ |
44 | | - function getNamespaceAliases() { |
45 | | - return $this->m_NamespaceAliases; |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * Function that returns the labels for the special properties. |
50 | | - */ |
51 | 31 | function getPropertyLabels() { |
52 | 32 | return $this->m_SpecialProperties; |
53 | 33 | } |