Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
TagLogFormatter | |
0.00% |
0 / 34 |
|
0.00% |
0 / 2 |
110 | |
0.00% |
0 / 1 |
getMessageParameters | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
42 | |||
getMessageKey | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | */ |
18 | |
19 | namespace MediaWiki\Logging; |
20 | |
21 | use MediaWiki\Message\Message; |
22 | use MediaWiki\SpecialPage\SpecialPage; |
23 | |
24 | /** |
25 | * This class formats tag log entries. |
26 | * |
27 | * Parameters (one-based indexes): |
28 | * 4::revid |
29 | * 5::logid |
30 | * 6:list:tagsAdded |
31 | * 7:number:tagsAddedCount |
32 | * 8:list:tagsRemoved |
33 | * 9:number:tagsRemovedCount |
34 | * |
35 | * @since 1.25 |
36 | */ |
37 | class TagLogFormatter extends LogFormatter { |
38 | |
39 | protected function getMessageParameters() { |
40 | $params = parent::getMessageParameters(); |
41 | |
42 | $isRevLink = !empty( $params[3] ); |
43 | if ( $isRevLink ) { |
44 | $id = $params[3]; |
45 | $target = $this->entry->getTarget(); |
46 | $query = [ |
47 | 'oldid' => $id, |
48 | 'diff' => 'prev' |
49 | ]; |
50 | } else { |
51 | $id = $params[4]; |
52 | $target = SpecialPage::getTitleValueFor( 'Log' ); |
53 | $query = [ |
54 | 'logid' => $id, |
55 | ]; |
56 | } |
57 | |
58 | $formattedNumber = $this->context->getLanguage()->formatNumNoSeparators( $id ); |
59 | if ( $this->plaintext ) { |
60 | $link = $formattedNumber; |
61 | } elseif ( !$isRevLink || $target->exists() ) { |
62 | $link = $this->getLinkRenderer()->makeKnownLink( |
63 | $target, $formattedNumber, [], $query ); |
64 | } else { |
65 | $link = htmlspecialchars( $formattedNumber ); |
66 | } |
67 | |
68 | if ( $isRevLink ) { |
69 | // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad |
70 | $params[3] = Message::rawParam( $link ); |
71 | } else { |
72 | // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad |
73 | $params[4] = Message::rawParam( $link ); |
74 | } |
75 | |
76 | return $params; |
77 | } |
78 | |
79 | protected function getMessageKey() { |
80 | $key = parent::getMessageKey(); |
81 | $rawParams = $this->entry->getParameters(); |
82 | |
83 | $add = ( $rawParams['7:number:tagsAddedCount'] > 0 ); |
84 | $remove = ( $rawParams['9:number:tagsRemovedCount'] > 0 ); |
85 | $key .= ( $remove ? ( $add ? '' : '-remove' ) : '-add' ); |
86 | |
87 | if ( $rawParams['4::revid'] ) { |
88 | // Messages: logentry-tag-update-add-revision, logentry-tag-update-remove-revision, |
89 | // logentry-tag-update-revision |
90 | $key .= '-revision'; |
91 | } else { |
92 | // Messages: logentry-tag-update-add-logentry, logentry-tag-update-remove-logentry, |
93 | // logentry-tag-update-logentry |
94 | $key .= '-logentry'; |
95 | } |
96 | |
97 | return $key; |
98 | } |
99 | |
100 | } |
101 | |
102 | /** @deprecated class alias since 1.44 */ |
103 | class_alias( TagLogFormatter::class, 'TagLogFormatter' ); |