MediaWiki master
LegacyLogFormatter.php
Go to the documentation of this file.
1<?php
12namespace MediaWiki\Logging;
13
16
36 private $comment = null;
37
45 private $revert = null;
46
47 private HookRunner $hookRunner;
48
49 public function __construct(
51 HookContainer $hookContainer
52 ) {
53 parent::__construct( $entry );
54 $this->hookRunner = new HookRunner( $hookContainer );
55 }
56
58 public function getComment() {
59 $this->comment ??= parent::getComment();
60
61 // Make sure we execute the LogLine hook so that we immediately return
62 // the correct value.
63 if ( $this->revert === null ) {
64 $this->getActionLinks();
65 }
66
67 return $this->comment;
68 }
69
74 protected function getActionMessage() {
76 $action = LogPage::actionText(
77 $entry->getType(),
80 $this->plaintext ? null : $this->context->getSkin(),
81 (array)$entry->getParameters(),
82 !$this->plaintext // whether to filter [[]] links
83 );
84
85 $performer = $this->getPerformerElement();
86 if ( !$this->irctext ) {
87 $sep = $this->msg( 'word-separator' );
88 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
89 $action = $performer . $sep . $action;
90 }
91
92 return $action;
93 }
94
96 public function getActionLinks() {
97 if ( $this->revert !== null ) {
98 return $this->revert;
99 }
100
101 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
102 $this->revert = '';
103 return $this->revert;
104 }
105
106 $title = $this->entry->getTarget();
107 $type = $this->entry->getType();
108 $subtype = $this->entry->getSubtype();
109
110 // Do nothing. The implementation is handled by the hook modifying the
111 // passed-by-ref parameters. This also changes the default value so that
112 // getComment() and getActionLinks() do not call them indefinitely.
113 $this->revert = '';
114
115 // This is to populate the $comment member of this instance so that it
116 // can be modified when calling the hook just below.
117 if ( $this->comment === null ) {
118 $this->getComment();
119 }
120
121 $params = $this->entry->getParameters();
122
123 $this->hookRunner->onLogLine(
124 $type, $subtype, $title, $params, $this->comment, $this->revert, $this->entry->getTimestamp() );
125
126 return $this->revert;
127 }
128}
129
131class_alias( LegacyLogFormatter::class, 'LegacyLogFormatter' );
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
This class formats all log entries for log types which have not been converted to the new system.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.to override string
getComment()
Gets the user provided comment.to override string HTML
__construct(LogEntry $entry, HookContainer $hookContainer)
Implements the default log formatting.
getPerformerElement()
Provides the name of the user who performed the log action.
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
Definition LogPage.php:237
An individual log entry.
Definition LogEntry.php:23
getType()
The main log type.
getParameters()
Get the extra parameters stored for this message.
getSubtype()
The log subtype.
getTarget()
Get the target page of this action.