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
;
23 * This class formats tag log entries.
25 * Parameters (one-based indexes):
29 * 7:number:tagsAddedCount
31 * 9:number:tagsRemovedCount
35 class TagLogFormatter
extends LogFormatter
{
37 protected function getMessageParameters() {
38 $params = parent
::getMessageParameters();
40 $isRevLink = !empty( $params[3] );
43 $target = $this->entry
->getTarget();
50 $target = SpecialPage
::getTitleValueFor( 'Log' );
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 );
63 $link = htmlspecialchars( $formattedNumber );
67 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
68 $params[3] = Message
::rawParam( $link );
70 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
71 $params[4] = Message
::rawParam( $link );
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
90 // Messages: logentry-tag-update-add-logentry, logentry-tag-update-remove-logentry,
91 // logentry-tag-update-logentry