MediaWiki master
LegacyLogFormatter.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Logging;
27
30
50 private $comment = null;
51
59 private $revert = null;
60
61 private HookRunner $hookRunner;
62
63 public function __construct(
65 HookContainer $hookContainer
66 ) {
67 parent::__construct( $entry );
68 $this->hookRunner = new HookRunner( $hookContainer );
69 }
70
71 public function getComment() {
72 $this->comment ??= parent::getComment();
73
74 // Make sure we execute the LogLine hook so that we immediately return
75 // the correct value.
76 if ( $this->revert === null ) {
77 $this->getActionLinks();
78 }
79
80 return $this->comment;
81 }
82
87 protected function getActionMessage() {
89 $action = LogPage::actionText(
90 $entry->getType(),
93 $this->plaintext ? null : $this->context->getSkin(),
94 (array)$entry->getParameters(),
95 !$this->plaintext // whether to filter [[]] links
96 );
97
98 $performer = $this->getPerformerElement();
99 if ( !$this->irctext ) {
100 $sep = $this->msg( 'word-separator' );
101 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
102 $action = $performer . $sep . $action;
103 }
104
105 return $action;
106 }
107
108 public function getActionLinks() {
109 if ( $this->revert !== null ) {
110 return $this->revert;
111 }
112
113 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
114 $this->revert = '';
115 return $this->revert;
116 }
117
118 $title = $this->entry->getTarget();
119 $type = $this->entry->getType();
120 $subtype = $this->entry->getSubtype();
121
122 // Do nothing. The implementation is handled by the hook modifying the
123 // passed-by-ref parameters. This also changes the default value so that
124 // getComment() and getActionLinks() do not call them indefinitely.
125 $this->revert = '';
126
127 // This is to populate the $comment member of this instance so that it
128 // can be modified when calling the hook just below.
129 if ( $this->comment === null ) {
130 $this->getComment();
131 }
132
133 $params = $this->entry->getParameters();
134
135 $this->hookRunner->onLogLine(
136 $type, $subtype, $title, $params, $this->comment, $this->revert, $this->entry->getTimestamp() );
137
138 return $this->revert;
139 }
140}
141
143class_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.
getComment()
Gets the user provided comment.
__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:250
An individual log entry.
Definition LogEntry.php:37
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.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...