Index: trunk/extensions/Translate/SpecialManageGroups.php |
— | — | @@ -1,6 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * @todo Needs documentation. |
| 4 | + * Implements classes for Special:Translate/manage from where file based message |
| 5 | + * groups are be managed. |
| 6 | + * |
5 | 7 | * @ingroup SpecialPage |
6 | 8 | * @author Niklas Laxström |
7 | 9 | * @author Siebrand Mazeland |
— | — | @@ -9,6 +11,11 @@ |
10 | 12 | */ |
11 | 13 | |
12 | 14 | /** |
| 15 | + * Class for special page Special:Translate/manage. On this special page file |
| 16 | + * based message groups can be managed (FileBasedMessageGroup). This page |
| 17 | + * allows updating of the file cache, import and fuzzy for source language |
| 18 | + * messages, as well as import/update of messages in other languages. |
| 19 | + * |
13 | 20 | * @todo Needs documentation. |
14 | 21 | */ |
15 | 22 | class SpecialManageGroups { |
— | — | @@ -18,6 +25,9 @@ |
19 | 26 | */ |
20 | 27 | protected $processingTime = 30; |
21 | 28 | |
| 29 | + /** |
| 30 | + * Constructor |
| 31 | + */ |
22 | 32 | public function __construct() { |
23 | 33 | global $wgOut, $wgUser; |
24 | 34 | $this->out = $wgOut; |
— | — | @@ -60,9 +70,8 @@ |
61 | 71 | $cache = new MessageGroupCache( $group ); |
62 | 72 | $code = $wgRequest->getText( 'language', 'en' ); |
63 | 73 | |
64 | | - /** |
65 | | - * Go to English for undefined codes. |
66 | | - */ |
| 74 | + |
| 75 | + // Go to English for undefined codes. |
67 | 76 | $codes = array_keys( Language::getLanguageNames( false ) ); |
68 | 77 | if ( !in_array( $code, $codes ) ) { |
69 | 78 | $code = 'en'; |
— | — | @@ -116,6 +125,9 @@ |
117 | 126 | } |
118 | 127 | } |
119 | 128 | |
| 129 | + /** |
| 130 | + * Special:Translate/manage. |
| 131 | + */ |
120 | 132 | public function getTitle() { |
121 | 133 | return SpecialPage::getTitleFor( 'Translate', 'manage' ); |
122 | 134 | } |
— | — | @@ -152,9 +164,7 @@ |
153 | 165 | Xml::hidden( 'process', 1 ) |
154 | 166 | ); |
155 | 167 | |
156 | | - /** |
157 | | - * BEGIN |
158 | | - */ |
| 168 | + // BEGIN |
159 | 169 | $messages = $group->load( $code ); |
160 | 170 | |
161 | 171 | if ( !$cache->exists() && $code === 'en' ) { |
— | — | @@ -175,9 +185,7 @@ |
176 | 186 | |
177 | 187 | $changed = array(); |
178 | 188 | foreach ( $messages as $key => $value ) { |
179 | | - /** |
180 | | - * ignored? ignore! |
181 | | - */ |
| 189 | + // ignored? ignore! |
182 | 190 | if ( in_array( $key, $ignoredMessages ) ) { |
183 | 191 | continue; |
184 | 192 | } |
— | — | @@ -191,9 +199,7 @@ |
192 | 200 | $old = str_replace( TRANSLATE_FUZZY, '', $old ); |
193 | 201 | } |
194 | 202 | |
195 | | - /** |
196 | | - * No changes at all, ignore. |
197 | | - */ |
| 203 | + // No changes at all, ignore. |
198 | 204 | if ( $old === $value ) { |
199 | 205 | continue; |
200 | 206 | } |
— | — | @@ -317,9 +323,7 @@ |
318 | 324 | $changed[] = "<li>$message</li></ul>"; |
319 | 325 | $this->out->addHTML( implode( "\n", $changed ) ); |
320 | 326 | } else { |
321 | | - /** |
322 | | - * END |
323 | | - */ |
| 327 | + // END |
324 | 328 | if ( count( $changed ) ) { |
325 | 329 | if ( $code === 'en' ) { |
326 | 330 | $this->out->addWikiMsg( 'translate-manage-intro-en' ); |
— | — | @@ -411,10 +415,22 @@ |
412 | 416 | } |
413 | 417 | } |
414 | 418 | |
| 419 | + /** |
| 420 | + * Reports if processing time for current page has exceeded the set |
| 421 | + * maximum ($processingTime). |
| 422 | + */ |
415 | 423 | protected function checkProcessTime() { |
416 | 424 | return wfTimestamp() - $this->time >= $this->processingTime; |
417 | 425 | } |
418 | 426 | |
| 427 | + /** |
| 428 | + * Set a subtitle like "Manage > FreeCol (open source game) > German" |
| 429 | + * based on group and language code. The language part is not shown if |
| 430 | + * it is 'en', and all three possible parts of the subtitle are linked. |
| 431 | + * |
| 432 | + * @param $group Object MessageGroup. |
| 433 | + * @param $code \string Language code. |
| 434 | + */ |
419 | 435 | protected function setSubtitle( $group, $code ) { |
420 | 436 | global $wgLang; |
421 | 437 | |
— | — | @@ -430,6 +446,7 @@ |
431 | 447 | array( 'group' => $group->getId() ) |
432 | 448 | ); |
433 | 449 | |
| 450 | + // Do not show language part for English. |
434 | 451 | if ( $code !== 'en' ) { |
435 | 452 | $links[] = $this->skin->link( |
436 | 453 | $this->getTitle(), |