MediaWiki master
TagLogFormatter.php
Go to the documentation of this file.
1<?php
20
35
36 protected function getMessageParameters() {
37 $params = parent::getMessageParameters();
38
39 $isRevLink = !empty( $params[3] );
40 if ( $isRevLink ) {
41 $id = $params[3];
42 $target = $this->entry->getTarget();
43 $query = [
44 'oldid' => $id,
45 'diff' => 'prev'
46 ];
47 } else {
48 $id = $params[4];
49 $target = SpecialPage::getTitleValueFor( 'Log' );
50 $query = [
51 'logid' => $id,
52 ];
53 }
54
55 $formattedNumber = $this->context->getLanguage()->formatNumNoSeparators( $id );
56 if ( $this->plaintext ) {
57 $link = $formattedNumber;
58 } elseif ( !$isRevLink || $target->exists() ) {
59 $link = $this->getLinkRenderer()->makeKnownLink(
60 $target, $formattedNumber, [], $query );
61 } else {
62 $link = htmlspecialchars( $formattedNumber );
63 }
64
65 if ( $isRevLink ) {
66 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
67 $params[3] = Message::rawParam( $link );
68 } else {
69 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
70 $params[4] = Message::rawParam( $link );
71 }
72
73 return $params;
74 }
75
76 protected function getMessageKey() {
77 $key = parent::getMessageKey();
79
80 $add = ( isset( $params[6] ) && isset( $params[6]['num'] ) && $params[6]['num'] );
81 $remove = ( isset( $params[8] ) && isset( $params[8]['num'] ) && $params[8]['num'] );
82 $key .= ( $remove ? ( $add ? '' : '-remove' ) : '-add' );
83
84 if ( isset( $params[3] ) && $params[3] ) {
85 // Messages: logentry-tag-update-add-revision, logentry-tag-update-remove-revision,
86 // logentry-tag-update-revision
87 $key .= '-revision';
88 } else {
89 // Messages: logentry-tag-update-add-logentry, logentry-tag-update-remove-logentry,
90 // logentry-tag-update-logentry
91 $key .= '-logentry';
92 }
93
94 return $key;
95 }
96
97}
array $params
The job parameters.
Implements the default log formatting.
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.