r107367 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107366‎ | r107367 | r107368 >
Date:08:01, 27 December 2011
Author:amire80
Status:ok (Comments)
Tags:
Comment:
Workflow states logging.
Modified paths:
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/api/ApiGroupReview.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -145,7 +145,9 @@
146146
147147 // Logs
148148 $wgLogTypes[] = 'translationreview';
 149+$wgLogTypes[] = 'groupreview';
149150 $wgLogActionsHandlers['translationreview/message'] = 'TranslateHooks::formatTranslationreviewLogEntry';
 151+$wgLogActionsHandlers['translationreview/group'] = 'TranslateHooks::formatTranslationreviewLogEntry';
150152 // BC for <1.19
151153 $wgLogHeaders['pagetranslation'] = 'log-description-translationreview';
152154 $wgLogNames['pagetranslation'] = 'log-name-translationreview';
Index: trunk/extensions/Translate/TranslateHooks.php
@@ -325,6 +325,26 @@
326326 Message::rawParam( $linker->link( $title, null, array(), array( 'oldid' => $params[0] ) ) )
327327 )->inLanguage( $language )->text();
328328 }
 329+
 330+ if ( $action === 'group' ) {
 331+ $languageCode = $params[0];
 332+ $languageNames = Language::getTranslatedLanguageNames( $languageCode );
 333+ $languageName = "$languageNames[$languageCode] ($languageCode)";
 334+ $oldStateMessage = wfMessage( "translate-workflow-state-$params[2]" );
 335+ $newStateMessage = wfMessage( "translate-workflow-state-$params[3]" );
 336+ $oldState = $oldStateMessage->isBlank() ? $oldState : $oldStateMessage->text();
 337+ $newState = $newStateMessage->isBlank() ? $newState : $newStateMessage->text();
 338+
 339+ return wfMessage( 'logentry-groupreview-message' )->params(
 340+ '', // User link in the new system
 341+ '#', // User name for gender in the new system
 342+ $languageName,
 343+ $params[1], // group
 344+ $oldState,
 345+ $newState
 346+ )->inLanguage( $language )->text() . $bla;
 347+ }
 348+
329349 return '';
330350 }
331351
@@ -338,7 +358,6 @@
339359 $group = $handle->getGroup();
340360 $callParams = array( $title->getPrefixedText(), $group->getId() );
341361 $call = Xml::encodeJsCall( 'mw.translate.openDialog', $callParams );
342 -
343362 $js = <<<JAVASCRIPT
344363 mw.loader.using( 'ext.translate.quickedit', function() { $call; } ); return false;
345364 JAVASCRIPT;
@@ -355,5 +374,5 @@
356375 $output = Html::element( 'a', $a, $linktext );
357376 return $parser->insertStripItem( $output, $parser->mStripState );
358377 }
 378+}
359379
360 -}
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -1,4 +1,4 @@
2 -<?php
 2+ workflow states<?php
33 /**
44 * Translations for the core of the Translate extension.
55 *
@@ -398,6 +398,7 @@
399399 'log-name-translationreview' => 'Translation review log',
400400 'log-description-translationreview' => 'Log of all reviews to translations and message groups.',
401401 'logentry-translationreview-message' => '$1 {{GENDER:$2|accepted}} translation $3',
 402+ 'logentry-groupreview-message' => '$1 {{GENDER:$2|changed}} the status of $3 translations of message group $4 from $5 to $6',
402403
403404 // The actual states, when set, come after the hyphen.
404405 // The dangling hyphen hints that it's unset.
@@ -649,6 +650,13 @@
650651 'group-translate-proofr-member' => '{{doc-group|translate-proofr|member}}',
651652 'grouppage-translate-proofr' => '{{doc-group|translate-proofr|page}}',
652653 'logentry-translationreview-message' => '{{Logentry}}',
 654+ 'logentry-groupreview-message' => '{{Logentry}} Params:
 655+
 656+* $1, $2: Performing user account name
 657+* $3: Language
 658+* $4: Message group name
 659+* $5: Previous workflow state
 660+* $6: New workflow state',
653661 'translate-workflow-state-' => 'Unselectable select option in Special:Translate if workflow state editing is on. The dangling hyphen in the message key hints that this state is unset; the actual states have the same key with something after the hyphen.',
654662 'translate-workflowstatus' => 'In Special:Translate if workflow states are in use, $1 is selector or the current state',
655663 'translate-workflow-set-do' => 'Submit button text when active',
@@ -9335,6 +9343,7 @@
93369344 'log-name-translationreview' => 'יומן סקירת תרגומים',
93379345 'log-description-translationreview' => 'יומן של כל הסקירות של תרגומים ושל קבוצות תרגומים.',
93389346 'logentry-translationreview-message' => '$1 {{GENDER:$2|אישר|אישרה}} את התרגום $3',
 9347+ 'logentry-groupreview-message' => '$1 {{GENDER:$2|שינה|שינתה}} את מצב התרגום ל$3 של הקבוצה $4 מ"$5" ל"$6"',
93399348 'translate-workflow-state-' => '(לא מוגדר)',
93409349 'translate-workflowstatus' => 'מצב: $1',
93419350 'translate-workflow-set-do' => 'הגדרה',
Index: trunk/extensions/Translate/api/ApiGroupReview.php
@@ -26,38 +26,57 @@
2727 $this->dieUsage( 'Permission denied', 'permissiondenied' );
2828 }
2929
30 - $params = $this->extractRequestParams();
 30+ $requestParams = $this->extractRequestParams();
3131
32 - $group = MessageGroups::getGroup( $params['group'] );
 32+ $group = MessageGroups::getGroup( $requestParams['group'] );
3333 if ( !$group ) {
3434 $this->dieUsageMsg( array( 'missingparam', 'group' ) );
3535 }
3636
 37+ // XXX Is this part needed?
3738 $languages = Language::getLanguageNames( false );
38 - if ( !isset( $languages[$params['language']] ) ) {
 39+ if ( !isset( $languages[$requestParams['language']] ) ) {
3940 $this->dieUsageMsg( array( 'missingparam', 'language' ) );
4041 }
4142
 43+ $dbr = wfGetDB( DB_SLAVE );
 44+ $currentState = $dbr->selectField(
 45+ 'translate_groupreviews',
 46+ 'tgr_state',
 47+ array( 'tgr_group' => $groupid, 'tgr_lang' => $requestParams['language'] ),
 48+ __METHOD__
 49+ );
 50+
4251 $dbw = wfGetDB( DB_MASTER );
4352 $table = 'translate_groupreviews';
 53+ $groupid = $group->getId();
4454 $row = array(
45 - 'tgr_group' => $group->getId(),
46 - 'tgr_lang' => $params['language'],
47 - 'tgr_state' => $params['state'],
 55+ 'tgr_group' => $groupid,
 56+ 'tgr_lang' => $requestParams['language'],
 57+ 'tgr_state' => $requestParams['state'],
4858 );
4959 $index = array( 'tgr_group', 'tgr_language' );
5060 $res = $dbw->replace( $table, array( $index ), $row, __METHOD__ );
5161
52 - /* Will be implemented later
5362 $logger = new LogPage( 'translationreview' );
54 - $params = array( $revision->getId() );
55 - $logger->addEntry( 'group', $title, null, $params, $wgUser );
56 - */
 63+ $logParams = array(
 64+ $requestParams['language'],
 65+ $group->getLabel(),
 66+ $currentState,
 67+ $requestParams['state'],
 68+ );
 69+ $logger->addEntry(
 70+ 'group',
 71+ SpecialPage::getTitleFor( 'Translate', $groupid ), // It's not really a page
 72+ '', // No comments
 73+ $logParams,
 74+ $wgUser
 75+ );
5776
5877 $output = array( 'review' => array(
5978 'group' => $group->getId(),
60 - 'language' => $params['language'],
61 - 'state' => $params['state'],
 79+ 'language' => $requestParams['language'],
 80+ 'state' => $requestParams['state'],
6281 ) );
6382
6483 $this->getResult()->addValue( null, $this->getModuleName(), $output );

Follow-up revisions

RevisionCommit summaryAuthorDate
r107369Follow up to r107367, fixed wrong variables.amire8008:30, 27 December 2011
r107370Follow up to r107367, made the previous state appear correctly.amire8008:44, 27 December 2011
r107371Flwup r107367 - garbagenikerabbit09:04, 27 December 2011
r107374Follow up to r107367 - removed leftover variable.amire8009:22, 27 December 2011
r107642Follow up to r107367. According to Niklas' request there, changed the paramet...amire8018:31, 30 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   12:15, 27 December 2011

Could you make the nonstandard message parameters start from $4 to be forward compatible with the new logging system. More info at Logging_to_Special:Log.

#Comment by Amire80 (talk | contribs)   18:34, 30 December 2011

Addressed in r107642. Probably now it's functionally better, too.

Status & tagging log