Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 34 |
|
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 | use MediaWiki\Message\Message; |
20 | use MediaWiki\SpecialPage\SpecialPage; |
21 | |
22 | /** |
23 | * This class formats tag log entries. |
24 | * |
25 | * Parameters (one-based indexes): |
26 | * 4::revid |
27 | * 5::logid |
28 | * 6:list:tagsAdded |
29 | * 7:number:tagsAddedCount |
30 | * 8:list:tagsRemoved |
31 | * 9:number:tagsRemovedCount |
32 | * |
33 | * @since 1.25 |
34 | */ |
35 | class TagLogFormatter extends LogFormatter { |
36 | |
37 | protected function getMessageParameters() { |
38 | $params = parent::getMessageParameters(); |
39 | |
40 | $isRevLink = !empty( $params[3] ); |
41 | if ( $isRevLink ) { |
42 | $id = $params[3]; |
43 | $target = $this->entry->getTarget(); |
44 | $query = [ |
45 | 'oldid' => $id, |
46 | 'diff' => 'prev' |
47 | ]; |
48 | } else { |
49 | $id = $params[4]; |
50 | $target = SpecialPage::getTitleValueFor( 'Log' ); |
51 | $query = [ |
52 | 'logid' => $id, |
53 | ]; |
54 | } |
55 | |
56 | $formattedNumber = $this->context->getLanguage()->formatNumNoSeparators( $id ); |
57 | if ( $this->plaintext ) { |
58 | $link = $formattedNumber; |
59 | } elseif ( !$isRevLink || $target->exists() ) { |
60 | $link = $this->getLinkRenderer()->makeKnownLink( |
61 | $target, $formattedNumber, [], $query ); |
62 | } else { |
63 | $link = htmlspecialchars( $formattedNumber ); |
64 | } |
65 | |
66 | if ( $isRevLink ) { |
67 | // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad |
68 | $params[3] = Message::rawParam( $link ); |
69 | } else { |
70 | // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad |
71 | $params[4] = Message::rawParam( $link ); |
72 | } |
73 | |
74 | return $params; |
75 | } |
76 | |
77 | protected function getMessageKey() { |
78 | $key = parent::getMessageKey(); |
79 | $rawParams = $this->entry->getParameters(); |
80 | |
81 | $add = ( $rawParams['7:number:tagsAddedCount'] > 0 ); |
82 | $remove = ( $rawParams['9:number:tagsRemovedCount'] > 0 ); |
83 | $key .= ( $remove ? ( $add ? '' : '-remove' ) : '-add' ); |
84 | |
85 | if ( $rawParams['4::revid'] ) { |
86 | // Messages: logentry-tag-update-add-revision, logentry-tag-update-remove-revision, |
87 | // logentry-tag-update-revision |
88 | $key .= '-revision'; |
89 | } else { |
90 | // Messages: logentry-tag-update-add-logentry, logentry-tag-update-remove-logentry, |
91 | // logentry-tag-update-logentry |
92 | $key .= '-logentry'; |
93 | } |
94 | |
95 | return $key; |
96 | } |
97 | |
98 | } |