MediaWiki master
TagLogFormatter.php
Go to the documentation of this file.
1<?php
6namespace MediaWiki\Logging;
7
10
25
27 protected function getMessageParameters() {
28 $params = parent::getMessageParameters();
29
30 $isRevLink = !empty( $params[3] );
31 if ( $isRevLink ) {
32 $id = $params[3];
33 $target = $this->entry->getTarget();
34 $query = [
35 'oldid' => $id,
36 'diff' => 'prev'
37 ];
38 } else {
39 $id = $params[4];
40 $target = SpecialPage::getTitleValueFor( 'Log' );
41 $query = [
42 'logid' => $id,
43 ];
44 }
45
46 $formattedNumber = $this->context->getLanguage()->formatNumNoSeparators( $id );
47 if ( $this->plaintext ) {
48 $link = $formattedNumber;
49 } elseif ( !$isRevLink || $target->exists() ) {
50 $link = $this->getLinkRenderer()->makeKnownLink(
51 $target, $formattedNumber, [], $query );
52 } else {
53 $link = htmlspecialchars( $formattedNumber );
54 }
55
56 if ( $isRevLink ) {
57 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
58 $params[3] = Message::rawParam( $link );
59 } else {
60 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
61 $params[4] = Message::rawParam( $link );
62 }
63
64 return $params;
65 }
66
68 protected function getMessageKey() {
69 $key = parent::getMessageKey();
70 $rawParams = $this->entry->getParameters();
71
72 $add = ( $rawParams['7:number:tagsAddedCount'] > 0 );
73 $remove = ( $rawParams['9:number:tagsRemovedCount'] > 0 );
74 $key .= ( $remove ? ( $add ? '' : '-remove' ) : '-add' );
75
76 if ( $rawParams['4::revid'] ) {
77 // Messages: logentry-tag-update-add-revision, logentry-tag-update-remove-revision,
78 // logentry-tag-update-revision
79 $key .= '-revision';
80 } else {
81 // Messages: logentry-tag-update-add-logentry, logentry-tag-update-remove-logentry,
82 // logentry-tag-update-logentry
83 $key .= '-logentry';
84 }
85
86 return $key;
87 }
88
89}
90
92class_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.There are three hardcoded...
getMessageKey()
Returns a key to be used for formatting the action sentence.Default is logentry-TYPE-SUBTYPE for mode...
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:144
Parent class for all special pages.
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.