MediaWiki master
PatrolLogFormatter.php
Go to the documentation of this file.
1<?php
11
12namespace MediaWiki\Logging;
13
14use MediaWiki\Message\Message;
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 $revLinkParam = $revision;
44 } elseif ( $target->exists() ) {
45 $query = [
46 'oldid' => $oldid,
47 'diff' => 'prev'
48 ];
49 $revLinkParam = Message::rawParam( $this->getLinkRenderer()->makeLink( $target, $revision, [], $query ) );
50 } else {
51 $revLinkParam = $revision;
52 }
53
54 $params[3] = $revLinkParam;
55
56 return $params;
57 }
58
60 protected function getParametersForApi() {
62 $params = $entry->getParameters();
63
64 static $map = [
65 '4:number:curid',
66 '5:number:previd',
67 '6:bool:auto',
68 '4::curid' => '4:number:curid',
69 '5::previd' => '5:number:previd',
70 '6::auto' => '6:bool:auto',
71 ];
72 foreach ( $map as $index => $key ) {
73 if ( isset( $params[$index] ) ) {
74 $params[$key] = $params[$index];
75 unset( $params[$index] );
76 }
77 }
78
79 return $params;
80 }
81}
82
84class_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...
getParameters()
Get the extra parameters stored for this message.