MediaWiki master
PatrolLogFormatter.php
Go to the documentation of this file.
1<?php
12namespace MediaWiki\Logging;
13
15
23 protected function getMessageKey() {
24 $params = $this->getMessageParameters();
25 if ( isset( $params[5] ) && $params[5] ) {
26 $key = 'logentry-patrol-patrol-auto';
27 } else {
28 $key = 'logentry-patrol-patrol';
29 }
30
31 return $key;
32 }
33
35 protected function getMessageParameters() {
36 $params = parent::getMessageParameters();
37
38 $target = $this->entry->getTarget();
39 $oldid = $params[3];
40 $revision = $this->context->getLanguage()->formatNumNoSeparators( $oldid );
41
42 if ( $this->plaintext ) {
43 $revlink = $revision;
44 } elseif ( $target->exists() ) {
45 $query = [
46 'oldid' => $oldid,
47 'diff' => 'prev'
48 ];
49 $revlink = $this->getLinkRenderer()->makeLink( $target, $revision, [], $query );
50 } else {
51 $revlink = htmlspecialchars( $revision );
52 }
53
54 // @phan-suppress-next-line SecurityCheck-XSS Unlikely positive, only if language format is bad
55 $params[3] = Message::rawParam( $revlink );
56
57 return $params;
58 }
59
61 protected function getParametersForApi() {
63 $params = $entry->getParameters();
64
65 static $map = [
66 '4:number:curid',
67 '5:number:previd',
68 '6:bool:auto',
69 '4::curid' => '4:number:curid',
70 '5::previd' => '5:number:previd',
71 '6::auto' => '6:bool:auto',
72 ];
73 foreach ( $map as $index => $key ) {
74 if ( isset( $params[$index] ) ) {
75 $params[$key] = $params[$index];
76 unset( $params[$index] );
77 }
78 }
79
80 return $params;
81 }
82}
83
85class_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.1.25 to override array
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
getParameters()
Get the extra parameters stored for this message.