Index: trunk/extensions/Translate/SpecialTranslate_body.php |
— | — | @@ -379,12 +379,23 @@ |
380 | 380 | |
381 | 381 | protected $label = 'none'; |
382 | 382 | protected $id = 'none'; |
| 383 | + |
| 384 | + function __construct() { $this->hook(); } |
383 | 385 | function getLabel() { return $this->label; } |
384 | 386 | function getId() { return $this->id; } |
385 | 387 | abstract function export(&$array); |
386 | 388 | abstract function getArray(); |
387 | 389 | function fill(&$array) {} |
| 390 | + public function hook() { |
| 391 | + global $wgHooks; |
| 392 | + $wgHooks['SpecialTranslateAddMessageClass'][] = array( $this, 'addHook' ); |
| 393 | + } |
388 | 394 | |
| 395 | + function addHook($class) { |
| 396 | + $class[] = $this; |
| 397 | + return true; |
| 398 | + } |
| 399 | + |
389 | 400 | function exportLine($key, $m, $pad = false) { |
390 | 401 | if ( $m['ignored'] ) { return ''; } |
391 | 402 | $comment = ''; |
— | — | @@ -413,6 +424,7 @@ |
414 | 425 | class CoreMessageClass extends MessageClass { |
415 | 426 | protected $label = 'Core system messages'; |
416 | 427 | protected $id = 'core'; |
| 428 | + |
417 | 429 | function export(&$array) { |
418 | 430 | $txt = "\$messages = array(\n"; |
419 | 431 | foreach( $array as $key => $m ) { |
— | — | @@ -451,20 +463,12 @@ |
452 | 464 | $array[$key]['infile'] = isset( $infile[$key] ) ? $infile[$key] : null; |
453 | 465 | $array[$key]['infbfile'] = isset( $infbfile[$key] ) ? $infbfile[$key] : null; |
454 | 466 | } |
455 | | - |
456 | | - |
457 | 467 | } |
458 | 468 | } |
459 | 469 | |
| 470 | +new CoreMessageClass(); |
460 | 471 | |
461 | 472 | |
462 | | -global $wgHooks; |
463 | | -$wgHooks['SpecialTranslateAddMessageClass'][] = 'wfSpecialTranslateAddMessageClasses'; |
464 | | -function wfSpecialTranslateAddMessageClasses($class) { |
465 | | - $class[] = new CoreMessageClass(); |
466 | | - return true; |
467 | | -} |
468 | | - |
469 | 473 | require_once( 'SpecialTranslate_exts.php' ); |
470 | 474 | |
471 | 475 | |
Index: trunk/extensions/Translate/SpecialTranslate.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | $wgExtensionFunctions[] = 'wfSpecialTranslate'; |
15 | 15 | $wgExtensionCredits['specialpage'][] = array( |
16 | 16 | 'name' => 'Translate', |
17 | | - 'version' => '2.4', |
| 17 | + 'version' => '2.5', |
18 | 18 | 'author' => 'Niklas Laxström', |
19 | 19 | 'url' => 'http://nike.users.idler.fi/betawiki', |
20 | 20 | 'description' => 'Special page for translating Mediawiki' |
Index: trunk/extensions/Translate/SpecialTranslate_exts.php |
— | — | @@ -1,18 +1,44 @@ |
2 | 2 | <?php |
3 | 3 | |
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 | + |
10 | 32 | } |
| 33 | + |
11 | 34 | |
12 | | -class RenameUserMessageClass extends MessageClass { |
| 35 | +class RenameUserMessageClass extends ExtensionMessageClass { |
13 | 36 | |
14 | 37 | protected $label = 'Extension: Rename user'; |
15 | 38 | protected $id = 'ext-renameuser'; |
16 | | - |
| 39 | + |
| 40 | + protected $arrName = 'wgRenameuserMessages'; |
| 41 | + protected $msgArray; |
| 42 | + |
17 | 43 | function export(&$array) { |
18 | 44 | global $wgLang; |
19 | 45 | $code = $wgLang->getCode(); |
— | — | @@ -43,40 +69,22 @@ |
44 | 70 | return $txt; |
45 | 71 | } |
46 | 72 | |
47 | | - function getArray() { |
48 | | - global $wgRenameuserMessages; |
49 | | - return $wgRenameuserMessages['en']; |
50 | | - } |
51 | | - |
52 | 73 | function fill(&$array) { |
53 | 74 | $array['renameuserlogentry']['ignored'] = true; |
54 | 75 | } |
55 | 76 | |
56 | 77 | } |
57 | 78 | |
58 | | -class TranslateMessageClass extends MessageClass { |
| 79 | +new RenameUserMessageClass(); |
59 | 80 | |
| 81 | +class TranslateMessageClass extends ExtensionMessageClass { |
| 82 | + |
60 | 83 | protected $label = 'Extension: Translate'; |
61 | 84 | 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"; |
68 | 85 | |
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; |
75 | 88 | |
76 | | - function getArray() { |
77 | | - global $wgTranslateMessages; |
78 | | - return $wgTranslateMessages['en']; |
79 | | - } |
80 | | - |
81 | 89 | function fill(&$array) { |
82 | 90 | global $wgLang; |
83 | 91 | global $wgTranslateMessages; |
— | — | @@ -97,33 +105,16 @@ |
98 | 106 | } |
99 | 107 | } |
100 | 108 | |
| 109 | +new TranslateMessageClass(); |
101 | 110 | |
102 | | -class ConfirmEditMessageClass extends MessageClass { |
103 | 111 | |
| 112 | +class ConfirmEditMessageClass extends ExtensionMessageClass { |
| 113 | + |
104 | 114 | protected $label = 'Extension: ConfirmEdit'; |
105 | 115 | protected $id = 'ext-confirmedit'; |
106 | | - protected $arrName = 'wgConfirmEditMessages'; |
107 | | - protected $msgArray= null; |
108 | | - #protected $msgFile = 'ConfirmEdit/ConfirmEdit.i18n.php'; |
109 | 116 | |
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; |
128 | 119 | |
129 | 120 | function export(&$array) { |
130 | 121 | global $wgLang; |
— | — | @@ -137,10 +128,6 @@ |
138 | 129 | return $txt; |
139 | 130 | } |
140 | 131 | |
141 | | - function getArray() { |
142 | | - return $this->msgArray['en']; |
143 | | - } |
144 | | - |
145 | 132 | function fill(&$array) { |
146 | 133 | global $wgLang; |
147 | 134 | |
— | — | @@ -162,20 +149,20 @@ |
163 | 150 | |
164 | 151 | new ConfirmEditMessageClass(); |
165 | 152 | |
166 | | -class DuplicatorMessageClass extends ConfirmEditMessageClass { |
| 153 | +class DuplicatorMessageClass extends ExtensionMessageClass { |
167 | 154 | protected $label = 'Extension: Duplicator'; |
168 | 155 | protected $id = 'ext-duplicator'; |
169 | 156 | |
| 157 | + protected $arrName = 'NONE'; |
| 158 | + protected $msgArray; |
| 159 | + |
| 160 | + |
170 | 161 | function __construct() { |
| 162 | + if (!function_exists('efDuplicatorMessages')) { return; } |
171 | 163 | $this->msgArray = efDuplicatorMessages(); |
172 | 164 | $this->hook(); |
173 | 165 | } |
174 | 166 | |
175 | | - function addHook($class) { |
176 | | - $class[] = new self(); |
177 | | - return true; |
178 | | - } |
179 | | - |
180 | 167 | function export(&$array) { |
181 | 168 | global $wgLang; |
182 | 169 | $code = $wgLang->getCode(); |