r19530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19529‎ | r19530 | r19531 >
Date:21:14, 20 January 2007
Author:nikerabbit
Status:old
Tags:
Comment:
* Fixy fixy
Modified paths:
  • /trunk/extensions/Translate/SpecialTranslate.php (modified) (history)
  • /trunk/extensions/Translate/SpecialTranslate_body.php (modified) (history)
  • /trunk/extensions/Translate/SpecialTranslate_exts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialTranslate_body.php
@@ -379,12 +379,23 @@
380380
381381 protected $label = 'none';
382382 protected $id = 'none';
 383+
 384+ function __construct() { $this->hook(); }
383385 function getLabel() { return $this->label; }
384386 function getId() { return $this->id; }
385387 abstract function export(&$array);
386388 abstract function getArray();
387389 function fill(&$array) {}
 390+ public function hook() {
 391+ global $wgHooks;
 392+ $wgHooks['SpecialTranslateAddMessageClass'][] = array( $this, 'addHook' );
 393+ }
388394
 395+ function addHook($class) {
 396+ $class[] = $this;
 397+ return true;
 398+ }
 399+
389400 function exportLine($key, $m, $pad = false) {
390401 if ( $m['ignored'] ) { return ''; }
391402 $comment = '';
@@ -413,6 +424,7 @@
414425 class CoreMessageClass extends MessageClass {
415426 protected $label = 'Core system messages';
416427 protected $id = 'core';
 428+
417429 function export(&$array) {
418430 $txt = "\$messages = array(\n";
419431 foreach( $array as $key => $m ) {
@@ -451,20 +463,12 @@
452464 $array[$key]['infile'] = isset( $infile[$key] ) ? $infile[$key] : null;
453465 $array[$key]['infbfile'] = isset( $infbfile[$key] ) ? $infbfile[$key] : null;
454466 }
455 -
456 -
457467 }
458468 }
459469
 470+new CoreMessageClass();
460471
461472
462 -global $wgHooks;
463 -$wgHooks['SpecialTranslateAddMessageClass'][] = 'wfSpecialTranslateAddMessageClasses';
464 -function wfSpecialTranslateAddMessageClasses($class) {
465 - $class[] = new CoreMessageClass();
466 - return true;
467 -}
468 -
469473 require_once( 'SpecialTranslate_exts.php' );
470474
471475
Index: trunk/extensions/Translate/SpecialTranslate.php
@@ -13,7 +13,7 @@
1414 $wgExtensionFunctions[] = 'wfSpecialTranslate';
1515 $wgExtensionCredits['specialpage'][] = array(
1616 'name' => 'Translate',
17 - 'version' => '2.4',
 17+ 'version' => '2.5',
1818 'author' => 'Niklas Laxström',
1919 'url' => 'http://nike.users.idler.fi/betawiki',
2020 'description' => 'Special page for translating Mediawiki'
Index: trunk/extensions/Translate/SpecialTranslate_exts.php
@@ -1,18 +1,44 @@
22 <?php
33
4 -global $wgHooks;
5 -$wgHooks['SpecialTranslateAddMessageClass'][] = 'wfSpecialTranslateAddMessageClasses2';
6 -function wfSpecialTranslateAddMessageClasses2($class) {
7 - $class[] = new RenameUserMessageClass();
8 - $class[] = new TranslateMessageClass();
9 - return true;
 4+abstract class ExtensionMessageClass extends MessageClass {
 5+ protected $arrName;
 6+ protected $msgArray;
 7+
 8+ function __construct() {
 9+ global ${$this->arrName};
 10+ if ( isset( ${$this->arrName} ) ) {
 11+ $this->msgArray = ${$this->arrName};
 12+ $this->hook();
 13+ }
 14+ }
 15+
 16+ function export(&$array) {
 17+ global $wgLang;
 18+ $code = $wgLang->getCode();
 19+ $txt = "\$$this->arrName['$code'] = array(\n";
 20+
 21+ foreach ($this->msgArray['en'] as $key => $msg) {
 22+ $txt .= "\t" . $this->exportLine($key, $array[$key], false);
 23+ }
 24+ $txt .= ");";
 25+ return $txt;
 26+ }
 27+
 28+ function getArray() {
 29+ return $this->msgArray['en'];
 30+ }
 31+
1032 }
 33+
1134
12 -class RenameUserMessageClass extends MessageClass {
 35+class RenameUserMessageClass extends ExtensionMessageClass {
1336
1437 protected $label = 'Extension: Rename user';
1538 protected $id = 'ext-renameuser';
16 -
 39+
 40+ protected $arrName = 'wgRenameuserMessages';
 41+ protected $msgArray;
 42+
1743 function export(&$array) {
1844 global $wgLang;
1945 $code = $wgLang->getCode();
@@ -43,40 +69,22 @@
4470 return $txt;
4571 }
4672
47 - function getArray() {
48 - global $wgRenameuserMessages;
49 - return $wgRenameuserMessages['en'];
50 - }
51 -
5273 function fill(&$array) {
5374 $array['renameuserlogentry']['ignored'] = true;
5475 }
5576
5677 }
5778
58 -class TranslateMessageClass extends MessageClass {
 79+new RenameUserMessageClass();
5980
 81+class TranslateMessageClass extends ExtensionMessageClass {
 82+
6083 protected $label = 'Extension: Translate';
6184 protected $id = 'ext-translate';
62 -
63 - function export(&$array) {
64 - global $wgLang;
65 - global $wgTranslateMessages;
66 - $code = $wgLang->getCode();
67 - $txt = "\$wgTranslateMessages['$code'] = array(\n";
6885
69 - foreach ($wgTranslateMessages['en'] as $key => $msg) {
70 - $txt .= "\t" . $this->exportLine($key, $array[$key]);
71 - }
72 - $txt .= ");";
73 - return $txt;
74 - }
 86+ protected $arrName = 'wgTranslateMessages';
 87+ protected $msgArray;
7588
76 - function getArray() {
77 - global $wgTranslateMessages;
78 - return $wgTranslateMessages['en'];
79 - }
80 -
8189 function fill(&$array) {
8290 global $wgLang;
8391 global $wgTranslateMessages;
@@ -97,33 +105,16 @@
98106 }
99107 }
100108
 109+new TranslateMessageClass();
101110
102 -class ConfirmEditMessageClass extends MessageClass {
103111
 112+class ConfirmEditMessageClass extends ExtensionMessageClass {
 113+
104114 protected $label = 'Extension: ConfirmEdit';
105115 protected $id = 'ext-confirmedit';
106 - protected $arrName = 'wgConfirmEditMessages';
107 - protected $msgArray= null;
108 - #protected $msgFile = 'ConfirmEdit/ConfirmEdit.i18n.php';
109116
110 - function __construct() {
111 - global ${$this->arrName};
112 - if ( isset( ${$this->arrName} ) ) {
113 - $this->msgArray = ${$this->arrName};
114 - $this->hook();
115 - }
116 - }
117 -
118 - protected function hook( ) {
119 - global $wgHooks;
120 - $wgHooks['SpecialTranslateAddMessageClass'][] = array( $this, 'addHook' );
121 - }
122 -
123 - function addHook($class) {
124 - $class[] = new self();
125 - return true;
126 - }
127 -
 117+ protected $arrName = 'wgConfirmEditMessages';
 118+ protected $msgArray;
128119
129120 function export(&$array) {
130121 global $wgLang;
@@ -137,10 +128,6 @@
138129 return $txt;
139130 }
140131
141 - function getArray() {
142 - return $this->msgArray['en'];
143 - }
144 -
145132 function fill(&$array) {
146133 global $wgLang;
147134
@@ -162,20 +149,20 @@
163150
164151 new ConfirmEditMessageClass();
165152
166 -class DuplicatorMessageClass extends ConfirmEditMessageClass {
 153+class DuplicatorMessageClass extends ExtensionMessageClass {
167154 protected $label = 'Extension: Duplicator';
168155 protected $id = 'ext-duplicator';
169156
 157+ protected $arrName = 'NONE';
 158+ protected $msgArray;
 159+
 160+
170161 function __construct() {
 162+ if (!function_exists('efDuplicatorMessages')) { return; }
171163 $this->msgArray = efDuplicatorMessages();
172164 $this->hook();
173165 }
174166
175 - function addHook($class) {
176 - $class[] = new self();
177 - return true;
178 - }
179 -
180167 function export(&$array) {
181168 global $wgLang;
182169 $code = $wgLang->getCode();