MediaWiki master
PatrolLogFormatter.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Logging;
27
29
36 protected function getMessageKey() {
37 $params = $this->getMessageParameters();
38 if ( isset( $params[5] ) && $params[5] ) {
39 $key = 'logentry-patrol-patrol-auto';
40 } else {
41 $key = 'logentry-patrol-patrol';
42 }
43
44 return $key;
45 }
46
47 protected function getMessageParameters() {
48 $params = parent::getMessageParameters();
49
50 $target = $this->entry->getTarget();
51 $oldid = $params[3];
52 $revision = $this->context->getLanguage()->formatNumNoSeparators( $oldid );
53
54 if ( $this->plaintext ) {
55 $revlink = $revision;
56 } elseif ( $target->exists() ) {
57 $query = [
58 'oldid' => $oldid,
59 'diff' => 'prev'
60 ];
61 $revlink = $this->getLinkRenderer()->makeLink( $target, $revision, [], $query );
62 } else {
63 $revlink = htmlspecialchars( $revision );
64 }
65
66 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
67 $params[3] = Message::rawParam( $revlink );
68
69 return $params;
70 }
71
72 protected function getParametersForApi() {
74 $params = $entry->getParameters();
75
76 static $map = [
77 '4:number:curid',
78 '5:number:previd',
79 '6:bool:auto',
80 '4::curid' => '4:number:curid',
81 '5::previd' => '5:number:previd',
82 '6::auto' => '6:bool:auto',
83 ];
84 foreach ( $map as $index => $key ) {
85 if ( isset( $params[$index] ) ) {
86 $params[$key] = $params[$index];
87 unset( $params[$index] );
88 }
89 }
90
91 return $params;
92 }
93}
94
96class_alias( PatrolLogFormatter::class, 'PatrolLogFormatter' );
Implements the default log formatting.
This class formats patrol log entries.
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
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
getParameters()
Get the extra parameters stored for this message.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...