Index: trunk/extensions/Translate/TranslateEditAddons.php |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Add some tabs for navigation for users who do not use Ajax interface. |
| 23 | + * Hooks: SkinTemplateNavigation, SkinTemplateTabs |
23 | 24 | * @param $skin Skin |
24 | 25 | * @param $tabs Array |
25 | 26 | */ |
— | — | @@ -95,7 +96,7 @@ |
96 | 97 | ); |
97 | 98 | self::addTab( $skin, $tabs, 'list', $data, $tabindex ); |
98 | 99 | |
99 | | - if ( $next !== null && $next !== true ) { |
| 100 | + if ( $next !== null ) { |
100 | 101 | $linktitle = Title::makeTitleSafe( $ns, "$next/$code" ); |
101 | 102 | $data = array( |
102 | 103 | 'text' => wfMsg( 'translate-edit-tab-next' ), |
— | — | @@ -119,12 +120,13 @@ |
120 | 121 | |
121 | 122 | /** |
122 | 123 | * Keep the usual diiba daaba hidden from translators. |
| 124 | + * Hook: AlternateEdit |
123 | 125 | */ |
124 | | - static function intro( $object ) { |
| 126 | + public static function intro( $editpage ) { |
125 | 127 | $object->suppressIntro = true; |
126 | 128 | |
127 | 129 | $msg = wfMsgForContent( 'translate-edit-tag-warning' ); |
128 | | - if ( $msg !== '' && $msg !== '-' && TranslatablePage::isSourcePage( $object->mTitle ) ) { |
| 130 | + if ( $msg !== '' && $msg !== '-' && TranslatablePage::isSourcePage( $editpage->mTitle ) ) { |
129 | 131 | global $wgOut; |
130 | 132 | $object->editFormTextTop .= $wgOut->parse( $msg ); |
131 | 133 | } |
— | — | @@ -133,6 +135,7 @@ |
134 | 136 | |
135 | 137 | /** |
136 | 138 | * Adds the translation aids and navigation to the normal edit page. |
| 139 | + * Hook: EditPage::showEditForm:initial |
137 | 140 | */ |
138 | 141 | static function addTools( $object ) { |
139 | 142 | if ( !self::isMessageNamespace( $object->mTitle ) ) { |
— | — | @@ -147,6 +150,7 @@ |
148 | 151 | /** |
149 | 152 | * Replace the normal save button with one that says if you are editing |
150 | 153 | * message documentation to try to avoid accidents. |
| 154 | + * Hook: EditPageBeforeEditButtons |
151 | 155 | */ |
152 | 156 | static function buttonHack( $editpage, &$buttons, $tabindex ) { |
153 | 157 | global $wgTranslateDocumentationLanguageCode, $wgLang; |
— | — | @@ -199,8 +203,8 @@ |
200 | 204 | } |
201 | 205 | |
202 | 206 | /** |
203 | | - * @return Array of the message and the language |
204 | | - */ |
| 207 | + * @return Array of the message and the language |
| 208 | + */ |
205 | 209 | public static function figureMessage( Title $title ) { |
206 | 210 | $text = $title->getDBkey(); |
207 | 211 | $pos = strrpos( $text, '/' ); |
— | — | @@ -273,8 +277,8 @@ |
274 | 278 | return strpos( $text, TRANSLATE_FUZZY ) !== false; |
275 | 279 | } |
276 | 280 | |
277 | | - /** Check if a title is marked as fuzzy. |
278 | | - * |
| 281 | + /** |
| 282 | + * Check if a title is marked as fuzzy. |
279 | 283 | * @param $title Title |
280 | 284 | * @return \bool If title is marked fuzzy. |
281 | 285 | */ |
— | — | @@ -282,7 +286,7 @@ |
283 | 287 | $dbr = wfGetDB( DB_SLAVE ); |
284 | 288 | |
285 | 289 | $tables = array( 'page', 'revtag' ); |
286 | | - $fields = array( 'rt_type' ); |
| 290 | + $fields = 'rt_type'; |
287 | 291 | $conds = array( |
288 | 292 | 'page_namespace' => $title->getNamespace(), |
289 | 293 | 'page_title' => $title->getDBkey(), |
— | — | @@ -291,14 +295,14 @@ |
292 | 296 | 'page_latest=rt_revision' |
293 | 297 | ); |
294 | 298 | |
295 | | - $res = $dbr->selectField( $tables, $fields, $conds, __METHOD__ ); |
| 299 | + $res = $dbr->selectField( $tables, $field, $conds, __METHOD__ ); |
296 | 300 | |
297 | | - return $res === RevTag::getType( 'fuzzy' ); |
| 301 | + return $res !== false; |
298 | 302 | } |
299 | 303 | |
300 | 304 | |
301 | | - /** Check if a title is in a message namespace. |
302 | | - * |
| 305 | + /** |
| 306 | + * Check if a title is in a message namespace. |
303 | 307 | * @param $title Title |
304 | 308 | * @return \bool If title is in a message namespace. |
305 | 309 | */ |
— | — | @@ -311,10 +315,8 @@ |
312 | 316 | } |
313 | 317 | |
314 | 318 | /** |
315 | | - * @static |
316 | | - * @param $skin Skin |
317 | | - * @param $tabs |
318 | | - * @return bool |
| 319 | + * Removes protection tab for message namespaces - not useful. |
| 320 | + * Hook: SkinTemplateTabs |
319 | 321 | */ |
320 | 322 | public static function tabs( $skin, &$tabs ) { |
321 | 323 | if ( !self::isMessageNamespace( $skin->getTitle() ) ) { |
— | — | @@ -326,6 +328,7 @@ |
327 | 329 | return true; |
328 | 330 | } |
329 | 331 | |
| 332 | + /// Hook: EditPage::showEditForm:fields |
330 | 333 | public static function keepFields( $edit, $out ) { |
331 | 334 | global $wgRequest; |
332 | 335 | |
— | — | @@ -338,6 +341,7 @@ |
339 | 342 | return true; |
340 | 343 | } |
341 | 344 | |
| 345 | + /// Hook: ArticleSaveComplete |
342 | 346 | public static function onSave( $article, $user, $text, $summary, |
343 | 347 | $minor, $_, $_, $flags, $revision |
344 | 348 | ) { |
— | — | @@ -444,6 +448,7 @@ |
445 | 449 | return $text; |
446 | 450 | } |
447 | 451 | |
| 452 | + /// Hook: LanguageGetTranslatedLanguageNames |
448 | 453 | public static function translateMessageDocumentationLanguage( &$names, $code ) { |
449 | 454 | global $wgTranslateDocumentationLanguageCode; |
450 | 455 | if ( $wgTranslateDocumentationLanguageCode ) { |
— | — | @@ -453,6 +458,7 @@ |
454 | 459 | return true; |
455 | 460 | } |
456 | 461 | |
| 462 | + /// Hook: ArticlePrepareTextForEdit |
457 | 463 | public static function disablePreSaveTransform( $article, $popts ) { |
458 | 464 | global $wgTranslateDocumentationLanguageCode; |
459 | 465 | $keycodegroup = self::getKeyCodeGroup( $article->getTitle() ); |
— | — | @@ -463,6 +469,7 @@ |
464 | 470 | return true; |
465 | 471 | } |
466 | 472 | |
| 473 | + /// Hook: ArticleContentOnDiff |
467 | 474 | public static function displayOnDiff( $de, $out ) { |
468 | 475 | $title = $de->getTitle(); |
469 | 476 | $handle = new MessageHandle( $title ); |
— | — | @@ -488,6 +495,7 @@ |
489 | 496 | return false; |
490 | 497 | } |
491 | 498 | |
| 499 | + /// Hook: SpecialSearchProfiles |
492 | 500 | public static function searchProfile( &$profiles ) { |
493 | 501 | global $wgTranslateMessageNamespaces; |
494 | 502 | $insert = array(); |
— | — | @@ -501,6 +509,7 @@ |
502 | 510 | return true; |
503 | 511 | } |
504 | 512 | |
| 513 | + /// Hook: SpecialSearchProfileForm |
505 | 514 | public static function searchProfileForm( $search, &$form, $profile, $term, $opts ) { |
506 | 515 | if ( $profile !== 'translation' ) { |
507 | 516 | return true; |
— | — | @@ -547,6 +556,7 @@ |
548 | 557 | return false; |
549 | 558 | } |
550 | 559 | |
| 560 | + /// Hook: SpecialSearchSetupEngine |
551 | 561 | public static function searchProfileSetupEngine( $search, $profile, $engine ) { |
552 | 562 | if ( $profile !== 'translation' ) { |
553 | 563 | return true; |