r112493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112492‎ | r112493 | r112494 >
Date:17:33, 27 February 2012
Author:yaron
Status:resolved (Comments)
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_Language.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_Namespaces.php (added) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -91,6 +91,7 @@
9292 $wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables';
9393 $wgHooks['PageSchemasRegisterHandlers'][] = 'SFPageSchemas::registerClass';
9494 $wgHooks['EditPage::importFormData'][] = 'SFUtils::showFormPreview';
 95+$wgHooks['CanonicalNamespaces'][] = 'SFUtils::registerNamespaces';
9596
9697 $wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI';
9798 $wgAPIModules['sfautoedit'] = 'SFAutoeditAPI';
@@ -172,6 +173,8 @@
173174 $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php';
174175 $wgExtensionMessagesFiles['SemanticFormsAlias'] = $sfgIP . '/languages/SF_Aliases.php';
175176 $wgExtensionMessagesFiles['SemanticFormsMagic'] = $sfgIP . '/languages/SF_Magic.php';
 177+$wgExtensionMessagesFiles['SemanticFormsNS'] = $sfgIP . '/languages/SF_Namespaces.php';
 178+
176179 // Allow for popup windows for file upload
177180 $wgEditPageFrameOptions = 'SAMEORIGIN';
178181
@@ -242,7 +245,7 @@
243246 // load global functions
244247 require_once( 'includes/SF_GlobalFunctions.php' );
245248
246 -sffInitNamespaces();
 249+sffInitContentLanguage( $wgLanguageCode );
247250
248251 # ##
249252 # The number of allowed values per autocomplete - too many might
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
@@ -21,31 +21,6 @@
2222 }
2323
2424 /**********************************************/
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 -/**********************************************/
5025 /***** language settings *****/
5126 /**********************************************/
5227
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -327,10 +327,12 @@
328328 return $form_names;
329329 }
330330
 331+ /**
 332+ * Creates a dropdown of possible form names.
 333+ */
331334 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();
335337 $form_label = $namespace_labels[SF_NS_FORM];
336338 $form_names = SFUtils::getAllForms();
337339 $select_body = "\n";
@@ -945,5 +947,28 @@
946948 return $merged;
947949 }
948950
 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;
949963
 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+
950975 }
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 @@
77 */
88
99 /**
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+ *
1212 * @ingroup SFLanguage
1313 */
1414 abstract class SF_Language {
1515
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.
1818 protected $m_SpecialProperties;
19 - protected $m_Namespaces;
2019
2120 // By default, every language has English-language aliases for
22 - // special properties and namespaces
 21+ // special properties.
2322 protected $m_SpecialPropertyAliases = array(
2423 'Has default form' => SF_SP_HAS_DEFAULT_FORM,
2524 'Has alternate form' => SF_SP_HAS_ALTERNATE_FORM,
2625 'Creates pages with form' => SF_SP_CREATES_PAGES_WITH_FORM,
2726 );
2827
29 - protected $m_NamespaceAliases = array(
30 - 'Form' => SF_NS_FORM,
31 - 'Form_talk' => SF_NS_FORM_TALK
32 - );
33 -
3428 /**
35 - * Function that returns an array of namespace identifiers.
 29+ * Returns the labels for the special properties.
3630 */
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 - */
5131 function getPropertyLabels() {
5232 return $this->m_SpecialProperties;
5333 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r112620Follow-up to r112493 - moved namespace names from individual language files i...yaron18:11, 28 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111514address bug 34383jeroendedauw00:10, 15 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   06:52, 28 February 2012

But still breaks translated namespaces.

#Comment by Yaron Koren (talk | contribs)   18:21, 28 February 2012

Thanks for pointing that out - I believe I just fixed the problem, in SVN.

Status & tagging log