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