r68080 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68079‎ | r68080 | r68081 >
Date:15:17, 15 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Add log for page translation actions
Modified paths:
  • /trunk/extensions/Translate/PageTranslation.i18n.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -59,6 +59,10 @@
6060 if ( $revision === -1 ) {
6161 $page = TranslatablePage::newFromTitle( $title );
6262 $page->removeTags();
 63+ global $wgUser;
 64+ $logger = new LogPage( 'pagetranslation' );
 65+ $params = array( 'user' => $wgUser->getName() );
 66+ $logger->addEntry( 'unmark', $page->getTitle(), null, array( serialize( $params ) ) );
6367 $wgOut->addWikiMsg( 'tpt-unmarked', $title->getPrefixedText() );
6468
6569 return;
@@ -484,6 +488,15 @@
485489 $page->addMarkedTag( $newrevision, $changed );
486490 $this->addFuzzyTags( $page, $changed );
487491
 492+ global $wgUser;
 493+ $logger = new LogPage( 'pagetranslation' );
 494+ $params = array(
 495+ 'user' => $wgUser->getName(),
 496+ 'revision' => $newrevision,
 497+ 'changed' => count( $changed ),
 498+ );
 499+ $logger->addEntry( 'mark', $page->getTitle(), null, array( serialize( $params ) ) );
 500+
488501 $this->setupRenderJobs( $page );
489502
490503 // Re-generate caches
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -525,4 +525,20 @@
526526 return true;
527527 }
528528
 529+ public static function formatLogEntry( $type, $action, $title, $forContent, $params ) {
 530+ global $wgLang, $wgContLang;
 531+
 532+ $language = $forContent ? $wgContLang : $wgLang;
 533+ $opts = array( 'parseinline', 'language' => $language );
 534+ $_ = unserialize( $params[0] );
 535+ $user = $_['user'];
 536+
 537+ if ( $action === 'mark' ) {
 538+ $revision = $_['revision'];
 539+ return wfMsgExt( 'pt-log-mark', $opts, $title->getPrefixedText(), $user, $revision );
 540+ } elseif( $action === 'unmark' ) {
 541+ return wfMsgExt( 'pt-log-unmark', $opts, $title->getPrefixedText(), $user );
 542+ }
 543+ }
 544+
529545 }
Index: trunk/extensions/Translate/Translate.php
@@ -240,6 +240,13 @@
241241 $wgSpecialPages['PageTranslation'] = 'SpecialPageTranslation';
242242 $wgAvailableRights[] = 'pagetranslation';
243243
 244+ global $wgLogNames, $wgLogActionsHandlers, $wgLogTypes, $wgLogHeaders;
 245+ $wgLogTypes[] = 'pagetranslation';
 246+ $wgLogHeaders['pagetranslation'] = 'pt-log-header';
 247+ $wgLogNames['pagetranslation'] = 'pt-log-name';
 248+ $wgLogActionsHandlers['pagetranslation/mark'] = 'PageTranslationHooks::formatLogEntry';
 249+ $wgLogActionsHandlers['pagetranslation/unmark'] = 'PageTranslationHooks::formatLogEntry';
 250+
244251 // Namespaces
245252 global $wgPageTranslationNamespace, $wgExtraNamespaces;
246253 global $wgNamespacesWithSubpages, $wgNamespaceProtection;
Index: trunk/extensions/Translate/PageTranslation.i18n.php
@@ -95,7 +95,10 @@
9696 Section text: <pre>$1</pre>',
9797 'pt-shake-empty' => 'Empty section for marker $1.',
9898
99 -
 99+ 'pt-log-header' => 'Log for actions related to the page translation system',
 100+ 'pt-log-name' => 'Page translation log',
 101+ 'pt-log-mark' => '{{GENDER:$2|marked}} revision $3 of page [[:$1]] for translation.',
 102+ 'pt-log-unmark' => '{{GENDER:$2|removed}} page [[:$1]] from translation.',
100103 );
101104
102105 /** Message documentation (Message documentation)

Status & tagging log