MediaWiki master
TagLogFormatter.php
Go to the documentation of this file.
1<?php
19namespace MediaWiki\Logging;
20
23
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
103class_alias( TagLogFormatter::class, 'TagLogFormatter' );
Implements the default log formatting.
This class formats tag log entries.
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
getMessageKey()
Returns a key to be used for formatting the action sentence.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:157
Parent class for all special pages.
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...