blob: 39a1243e91c9e8e6dc9f8c56bc5e50d4f357e6e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
/**
* Class for formatting Translate logs.
*
* @file
* @author Niklas Laxström
* @copyright Copyright © 2013, Niklas Laxström
* @license GPL-2.0-or-later
*/
/**
* Class for formatting Translate logs.
*/
class TranslateLogFormatter extends LogFormatter {
public function getMessageParameters() {
$params = parent::getMessageParameters();
$type = $this->entry->getFullType();
if ( $type === 'translationreview/message' ) {
$targetPage = $this->makePageLink(
$this->entry->getTarget(),
[ 'oldid' => $params[3] ]
);
$params[2] = Message::rawParam( $targetPage );
} elseif ( $type === 'translationreview/group' ) {
/*
* - 3: language code
* - 4: label of the message group
* - 5: old state
* - 6: new state
*/
$uiLanguage = $this->context->getLanguage();
$language = $params[3];
$targetPage = $this->makePageLinkWithText(
$this->entry->getTarget(),
$params[4],
[ 'language' => $language ]
);
$params[2] = Message::rawParam( $targetPage );
$params[3] = TranslateUtils::getLanguageName( $language, $uiLanguage->getCode() );
$params[5] = $this->formatStateMessage( $params[5] );
$params[6] = $this->formatStateMessage( $params[6] );
} elseif ( $type === 'translatorsandbox/rejected' ) {
// No point linking to the user page which cannot have existed
$params[2] = $this->entry->getTarget()->getText();
} elseif ( $type === 'translatorsandbox/promoted' ) {
// Gender for the target
$params[3] = User::newFromId( $params[3] )->getName();
}
return $params;
}
protected function formatStateMessage( $value ) {
$message = $this->msg( "translate-workflow-state-$value" );
return $message->isBlank() ? $value : $message->text();
}
protected function makePageLinkWithText(
?Title $title, $text, array $parameters = []
) {
if ( !$this->plaintext ) {
$link = Linker::link( $title, htmlspecialchars( $text ), [], $parameters );
} else {
$target = '***';
if ( $title instanceof Title ) {
$target = $title->getPrefixedText();
}
$link = "[[$target|$text]]";
}
return $link;
}
}
|