r111514 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111513‎ | r111514 | r111515 >
Date:00:10, 15 February 2012
Author:jeroendedauw
Status:reverted (Comments)
Tags:
Comment:
address bug 34383
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)
  • /trunk/extensions/SemanticForms/specials/SF_CreateCategory.php (modified) (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::onCanonicalNamespaces';
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
Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php
@@ -30,12 +30,14 @@
3131 $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] . "::$default_form]]";
3232 $text = wfMsgForContent( 'sf_category_hasdefaultform', $form_tag );
3333 }
 34+
3435 if ( $parent_category !== '' ) {
3536 global $wgContLang;
3637 $namespace_labels = $wgContLang->getNamespaces();
3738 $category_namespace = $namespace_labels[NS_CATEGORY];
3839 $text .= "\n\n[[$category_namespace:$parent_category]]";
3940 }
 41+
4042 return $text;
4143 }
4244
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
@@ -30,15 +30,10 @@
3131 * greater or equal to 100.
3232 */
3333 function sffInitNamespaces() {
34 - global $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang;
 34+ global $wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang;
3535
3636 sffInitContentLanguage( $wgLanguageCode );
3737
38 - // Register namespace identifiers
39 - if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); }
40 - $wgExtraNamespaces = $wgExtraNamespaces + $sfgContLang->getNamespaces();
41 - $wgNamespaceAliases = $wgNamespaceAliases + $sfgContLang->getNamespaceAliases();
42 -
4338 // Support subpages only for talk pages by default
4439 $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array(
4540 SF_NS_FORM_TALK => true
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -417,8 +417,8 @@
418418
419419 public static function formDropdownHTML() {
420420 // create a dropdown of possible form names
421 - global $sfgContLang;
422 - $namespace_labels = $sfgContLang->getNamespaces();
 421+ global $wgContLang;
 422+ $namespace_labels = $wgContLang->getNamespaces();
423423 $form_label = $namespace_labels[SF_NS_FORM];
424424 $form_names = SFUtils::getAllForms();
425425 $select_body = "\n";
@@ -1082,4 +1082,21 @@
10831083 }
10841084
10851085
 1086+ /**
 1087+ * For extensions adding their own namespaces or altering the defaults.
 1088+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces
 1089+ *
 1090+ * @since 2.4.1
 1091+ *
 1092+ * @param array $list
 1093+ *
 1094+ * @return true
 1095+ */
 1096+ public static function onCanonicalNamespaces( array &$list ) {
 1097+ $list[SF_NS_FORM] = 'Form';
 1098+ $list[SF_NS_FORM_TALK] = 'Form_talk';
 1099+
 1100+ return true;
 1101+ }
 1102+
10861103 }
Index: trunk/extensions/SemanticForms/languages/SF_Namespaces.php
@@ -0,0 +1,20 @@
 2+<?php
 3+
 4+/**
 5+ * Namespace internationalizationfor the Semantic Forms extension.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file SF_Namespaces.php
 10+ * @ingroup SemanticForms
 11+ *
 12+ * @licence GNU GPL v3+
 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
@@ -15,7 +15,6 @@
1616 // arrays for the names of special properties and namespaces -
1717 // all messages are stored in SF_Messages.php
1818 protected $m_SpecialProperties;
19 - protected $m_Namespaces;
2019
2120 // By default, every language has English-language aliases for
2221 // special properties and namespaces
@@ -25,26 +24,7 @@
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.
36 - */
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 - /**
4929 * Function that returns the labels for the special properties.
5030 */
5131 function getPropertyLabels() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r111532follow up to r111514, fix typojeroendedauw13:28, 15 February 2012
r111653revert r111514 - this breaks compat with 1.16jeroendedauw17:32, 16 February 2012
r112493Re-did changes in r111514 by jeroendedauw, with slight modifications - now th...yaron17:33, 27 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111507address bug 34383jeroendedauw23:24, 14 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:08, 15 February 2012

Typo: internationalizationfor

License?

#Comment by Nikerabbit (talk | contribs)   12:38, 16 February 2012

This breaks all existing namespace localisations!

Status & tagging log