r96960 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96959‎ | r96960 | r96961 >
Date:13:23, 13 September 2011
Author:ialex
Status:deferred
Tags:
Comment:
* Moved messages to a file linked from $wgExtensionMessagesFiles to use the common way to define messages and not the no-more existing $wgMessageCache
* Removed now useless parts from WOMLanguage
* Use descriptionmsg in $wgExtensionCredits with a message instead of description
* Moved away all that was possible away from the extension function
* Removed some code duplication
Modified paths:
  • /trunk/extensions/WikiObjectModel/includes/WOM_Initialize.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/WOM_Setup.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/languages/Messages.php (added) (history)
  • /trunk/extensions/WikiObjectModel/languages/WOMLanguage.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/languages/WOMLanguageEn.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiObjectModel/includes/WOM_Setup.php
@@ -2,6 +2,8 @@
33
44 global $wgOMIP, $wgAutoloadClasses;
55
 6+$wgAutoloadClasses['WOMProcessor'] = $wgOMIP . '/includes/WOM_Processor.php';
 7+
68 // POM Type
79 $wgAutoloadClasses['WikiObjectModelFactory'] = $wgOMIP . '/includes/models/WOMFactory.php';
810 $wgAutoloadClasses['WikiObjectModel'] = $wgOMIP . '/includes/models/WikiObjectModel.php';
Index: trunk/extensions/WikiObjectModel/includes/WOM_Initialize.php
@@ -8,83 +8,47 @@
99
1010 define( 'WOM_VERSION', '1.0' );
1111
 12+$wgExtensionCredits['parserhook'][] = array(
 13+ 'path' => __FILE__,
 14+ 'name' => 'Wiki ObjectModel Extension',
 15+ 'version' => WOM_VERSION,
 16+ 'author' => "Ning Hu, Justin Zhang, [http://smwforum.ontoprise.com/smwforum/index.php/Jesse_Wang Jesse Wang], sponsored by [http://projecthalo.com Project Halo], [http://www.vulcan.com Vulcan Inc.]",
 17+ 'url' => 'http://wiking.vulcan.com/dev',
 18+ 'descriptionmsg' => 'wom-desc'
 19+);
 20+
1221 $wgOMIP = $IP . '/extensions/WikiObjectModel';
1322 $wgOMScriptPath = $wgScriptPath . '/extensions/WikiObjectModel';
1423
15 -global $wgExtensionFunctions;
16 -$wgExtensionFunctions[] = 'wgOMSetupExtension';
 24+$wgExtensionFunctions[] = 'smwfOMInitLanguage';
 25+$wgExtensionMessagesFiles['WikiObjectModel'] = $wgOMIP . '/languages/Messages.php';
1726
1827 require_once( $wgOMIP . '/includes/WOM_Setup.php' );
1928
 29+function smwfOMInitLanguageObject( $langcode, $fallback = null ) {
 30+ global $wgOMIP;
2031
21 -function smwfOMInitContentLanguage( $langcode ) {
22 - global $wgOMIP, $wgOMContLang;
23 - if ( !empty( $wgOMContLang ) ) { return; }
 32+ $langClass = 'WOMLanguage' . str_replace( '-', '_', ucfirst( $langcode ) );
2433
25 - $mwContLangClass = 'WOMLanguage' . str_replace( '-', '_', ucfirst( $langcode ) );
26 -
27 - if ( file_exists( $wgOMIP . '/languages/' . $mwContLangClass . '.php' ) ) {
28 - include_once( $wgOMIP . '/languages/' . $mwContLangClass . '.php' );
 34+ if ( file_exists( $wgOMIP . '/languages/' . $langClass . '.php' ) ) {
 35+ include_once( $wgOMIP . '/languages/' . $langClass . '.php' );
2936 }
3037
3138 // fallback if language not supported
32 - if ( !class_exists( $mwContLangClass ) ) {
 39+ if ( !class_exists( $langClass ) ) {
 40+ if ( $fallback ) {
 41+ return $fallback;
 42+ }
3343 include_once( $wgOMIP . '/languages/WOMLanguageEn.php' );
34 - $mwContLangClass = 'WOMLanguageEn';
 44+ $langClass = 'WOMLanguageEn';
3545 }
36 - $wgOMContLang = new $mwContLangClass();
 46+ return new $langClass();
3747 }
3848
39 -function smwfOMInitMessages() {
40 - global $wgOMMessagesInitialized;
41 - if ( isset( $wgOMMessagesInitialized ) ) return; // prevent double init
 49+function smwfOMInitLanguage() {
 50+ global $wgLanguageCode, $wgLang;
 51+ global $wgOMContLang, $wgOMLang;
4252
43 - wfOMInitUserMessages(); // lazy init for ajax calls
44 -
45 - $wgOMMessagesInitialized = true;
 53+ $wgOMContLang = smwfOMInitLanguageObject( $wgLanguageCode );
 54+ $wgOMLang = smwfOMInitLanguageObject( $wgLang->getCode(), $wgOMContLang );
4655 }
47 -function wfOMInitUserMessages() {
48 - global $wgMessageCache, $wgOMContLang, $wgLanguageCode;
49 - smwfOMInitContentLanguage( $wgLanguageCode );
50 -
51 - global $wgOMIP, $wgOMLang;
52 - if ( !empty( $wgOMLang ) ) { return; }
53 - global $wgMessageCache, $wgLang;
54 - $mwLangClass = 'WOMLanguage' . str_replace( '-', '_', ucfirst( $wgLang->getCode() ) );
55 -
56 - if ( file_exists( $wgOMIP . '/languages/' . $mwLangClass . '.php' ) ) {
57 - include_once( $wgOMIP . '/languages/' . $mwLangClass . '.php' );
58 - }
59 - // fallback if language not supported
60 - if ( !class_exists( $mwLangClass ) ) {
61 - global $wgOMContLang;
62 - $wgOMLang = $wgOMContLang;
63 - } else {
64 - $wgOMLang = new $mwLangClass();
65 - }
66 -
67 - $wgMessageCache->addMessages( $wgOMLang->getUserMsgArray(), $wgLang->getCode() );
68 -}
69 -
70 -
71 -/**
72 - * Intializes Semantic ObjectModel Extension.
73 - * Called from WOM during initialization.
74 - */
75 -function wgOMSetupExtension() {
76 - global $wgOMIP, $wgHooks, $wgExtensionCredits, $wgAvailableRights;
77 - global $wgAutoloadClasses, $wgSpecialPages, $wgSpecialPageGroups;
78 -
79 - smwfOMInitMessages();
80 -
81 - $wgAutoloadClasses['WOMProcessor'] = $wgOMIP . '/includes/WOM_Processor.php';
82 -
83 - // Register Credits
84 - $wgExtensionCredits['parserhook'][] = array(
85 - 'name' => 'Wiki ObjectModel Extension', 'version' => WOM_VERSION,
86 - 'author' => "Ning Hu, Justin Zhang, [http://smwforum.ontoprise.com/smwforum/index.php/Jesse_Wang Jesse Wang], sponsored by [http://projecthalo.com Project Halo], [http://www.vulcan.com Vulcan Inc.]",
87 - 'url' => 'http://wiking.vulcan.com/dev',
88 - 'description' => 'Easy Page Object Model for wiki user.' );
89 -
90 - return true;
91 -}
Index: trunk/extensions/WikiObjectModel/languages/WOMLanguageEn.php
@@ -11,16 +11,6 @@
1212
1313 class WOMLanguageEn extends WOMLanguage {
1414
15 - protected $wContentMessages = array(
16 -
17 - );
18 -
19 - protected $wUserMessages = array(
20 - /*Messages for Object Model*/
21 - 'objecteditor' => 'Object Editor',
22 - 'wom_editor' => 'Object Model',
23 - );
24 -
2515 protected $wWOMTypeLabels = array(
2616 '_cat' => 'Category', // Category
2717 '_wpg' => 'Page', // Page
Index: trunk/extensions/WikiObjectModel/languages/WOMLanguage.php
@@ -9,8 +9,6 @@
1010 abstract class WOMLanguage {
1111
1212 // the message arrays ...
13 - protected $wContentMessages;
14 - protected $wUserMessages;
1513 protected $wWOMTypeLabels;
1614
1715 function geWOMTypeLabels() {
@@ -25,20 +23,4 @@
2624 function findWOMTypeMsgID( $label ) {
2725 return array_search( $label, $this->wWOMTypeLabels );
2826 }
29 -
30 - /**
31 - * Function that returns all content messages (those that are stored
32 - * in wome article, and can thus not be translated to individual users).
33 - */
34 - function getContentMsgArray() {
35 - return $this->wContentMessages;
36 - }
37 -
38 - /**
39 - * Function that returns all user messages (those that are given only to
40 - * the current user, and can thus be given in the individual user language).
41 - */
42 - function getUserMsgArray() {
43 - return $this->wUserMessages;
44 - }
45 -}
\ No newline at end of file
 27+}
Index: trunk/extensions/WikiObjectModel/languages/Messages.php
@@ -0,0 +1,9 @@
 2+<?php
 3+
 4+$messages = array();
 5+
 6+$messages['en'] = array(
 7+ 'objecteditor' => 'Object Editor',
 8+ 'wom_editor' => 'Object Model',
 9+ 'wom-desc' => 'Easy Page Object Model for wiki user',
 10+);
Property changes on: trunk/extensions/WikiObjectModel/languages/Messages.php
___________________________________________________________________
Added: svn:eol-style
111 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r97038Add extension (r96960) to translatewiki.netraymond06:59, 14 September 2011

Status & tagging log