Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / logging / TagLogFormatter.php
blob4bc7cf56269015702874562b3b370a0b72bcd88b
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.
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.
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
19 use MediaWiki\Message\Message;
20 use MediaWiki\SpecialPage\SpecialPage;
22 /**
23 * This class formats tag log entries.
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
33 * @since 1.25
35 class TagLogFormatter extends LogFormatter {
37 protected function getMessageParameters() {
38 $params = parent::getMessageParameters();
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'
48 } else {
49 $id = $params[4];
50 $target = SpecialPage::getTitleValueFor( 'Log' );
51 $query = [
52 'logid' => $id,
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 );
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 );
74 return $params;
77 protected function getMessageKey() {
78 $key = parent::getMessageKey();
79 $rawParams = $this->entry->getParameters();
81 $add = ( $rawParams['7:number:tagsAddedCount'] > 0 );
82 $remove = ( $rawParams['9:number:tagsRemovedCount'] > 0 );
83 $key .= ( $remove ? ( $add ? '' : '-remove' ) : '-add' );
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';
95 return $key;