r67991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67990‎ | r67991 | r67992 >
Date:12:07, 14 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Prevent page translation sections from being categorized
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -514,4 +514,15 @@
515515
516516 return true;
517517 }
 518+
 519+ public static function preventCategorization( $updater ) {
 520+ global $wgTranslateDocumentationLanguageCode;
 521+ $title = $updater->getTitle();
 522+ list( , $code ) = TranslateUtils::figureMessage( $title );
 523+ if ( $title->getNamespace() == NS_TRANSLATIONS && $code !== $wgTranslateDocumentationLanguageCode ) {
 524+ $updater->mCategories = array();
 525+ }
 526+ return true;
 527+ }
 528+
518529 }
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -150,6 +150,8 @@
151151 }
152152
153153 static function buttonHack( $editpage, &$buttons, $tabindex ) {
 154+ global $wgTranslateDocumentationLanguageCode;
 155+
154156 if ( !self::isMessageNamespace( $editpage->mTitle ) ) {
155157 return true;
156158 }
@@ -158,7 +160,7 @@
159161
160162 list( , $code ) = self::figureMessage( $editpage->mTitle );
161163
162 - if ( $code !== 'qqq' ) {
 164+ if ( $code !== $wgTranslateDocumentationLanguageCode ) {
163165 return true;
164166 }
165167
@@ -231,10 +233,8 @@
232234 global $wgTranslateDocumentationLanguageCode, $wgOut, $wgRequest;
233235
234236 $th = new TranslationHelpers( $object->mTitle );
235 -
236237 if ( $object->firsttime && !$wgRequest->getCheck( 'oldid' ) && !$wgRequest->getCheck( 'undo' ) ) {
237 - } else {
238 - $th->setTranslation( $object->textbox1 );
 238+ $object->textbox1 = $th->getTranslation();
239239 }
240240
241241 TranslateUtils::injectCSS();
@@ -394,4 +394,12 @@
395395
396396 return true;
397397 }
 398+
 399+ public static function customDisplay( $article, &$content ) {
 400+ if ( self::isMessageNamespace( $article->getTitle() ) ) {
 401+ $content = "<pre><nowiki>$content</nowiki></pre>";
 402+ }
 403+ return true;
 404+ }
 405+
398406 }
Index: trunk/extensions/Translate/Translate.php
@@ -58,6 +58,7 @@
5959 $wgHooks['EditPageBeforeEditButtons'][] = 'TranslateEditAddons::buttonHack';
6060 $wgHooks['EditPage::showEditForm:fields'][] = 'TranslateEditAddons::keepFields';
6161 $wgHooks['SkinTemplateTabs'][] = 'TranslateEditAddons::tabs';
 62+#$wgHooks['ArticleAfterFetchContent'][] = 'TranslateEditAddons::customDisplay';
6263
6364 # Custom preferences
6465 $wgDefaultUserOptions['translate'] = 0;
@@ -291,6 +292,8 @@
292293 $wgHooks['ParserTestTables'][] = 'PageTranslationHooks::parserTestTables';
293294
294295 $wgHooks['SkinTemplateToolboxEnd'][] = 'PageTranslationHooks::exportToolbox';
 296+
 297+ $wgHooks['LinksUpdate'][] = 'PageTranslationHooks::preventCategorization';
295298 }
296299 }
297300

Status & tagging log