MediaWiki master
TagLogFormatter.php
Go to the documentation of this file.
1<?php
21
36
37 protected function getMessageParameters() {
38 $params = parent::getMessageParameters();
39
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'
47 ];
48 } else {
49 $id = $params[4];
50 $target = SpecialPage::getTitleValueFor( 'Log' );
51 $query = [
52 'logid' => $id,
53 ];
54 }
55
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 );
64 }
65
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 );
72 }
73
74 return $params;
75 }
76
77 protected function getMessageKey() {
78 $key = parent::getMessageKey();
79 $rawParams = $this->entry->getParameters();
80
81 $add = ( $rawParams['7:number:tagsAddedCount'] > 0 );
82 $remove = ( $rawParams['9:number:tagsRemovedCount'] > 0 );
83 $key .= ( $remove ? ( $add ? '' : '-remove' ) : '-add' );
84
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';
93 }
94
95 return $key;
96 }
97
98}
array $params
The job parameters.
Implements the default log formatting.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:150
Parent class for all special pages.
This class formats tag log entries.
getMessageKey()
Returns a key to be used for formatting the action sentence.
getMessageParameters()
Formats parameters intended for action message from array of all parameters.