MediaWiki master
LegacyLogFormatter.php
Go to the documentation of this file.
1<?php
28
48 private $comment = null;
49
57 private $revert = null;
58
59 private HookRunner $hookRunner;
60
61 public function __construct(
63 HookContainer $hookContainer
64 ) {
65 parent::__construct( $entry );
66 $this->hookRunner = new HookRunner( $hookContainer );
67 }
68
69 public function getComment() {
70 $this->comment ??= parent::getComment();
71
72 // Make sure we execute the LogLine hook so that we immediately return
73 // the correct value.
74 if ( $this->revert === null ) {
75 $this->getActionLinks();
76 }
77
78 return $this->comment;
79 }
80
85 protected function getActionMessage() {
87 $action = LogPage::actionText(
88 $entry->getType(),
91 $this->plaintext ? null : $this->context->getSkin(),
92 (array)$entry->getParameters(),
93 !$this->plaintext // whether to filter [[]] links
94 );
95
96 $performer = $this->getPerformerElement();
97 if ( !$this->irctext ) {
98 $sep = $this->msg( 'word-separator' );
99 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
100 $action = $performer . $sep . $action;
101 }
102
103 return $action;
104 }
105
106 public function getActionLinks() {
107 if ( $this->revert !== null ) {
108 return $this->revert;
109 }
110
111 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
112 $this->revert = '';
113 return $this->revert;
114 }
115
116 $title = $this->entry->getTarget();
117 $type = $this->entry->getType();
118 $subtype = $this->entry->getSubtype();
119
120 // Do nothing. The implementation is handled by the hook modifying the
121 // passed-by-ref parameters. This also changes the default value so that
122 // getComment() and getActionLinks() do not call them indefinitely.
123 $this->revert = '';
124
125 // This is to populate the $comment member of this instance so that it
126 // can be modified when calling the hook just below.
127 if ( $this->comment === null ) {
128 $this->getComment();
129 }
130
131 $params = $this->entry->getParameters();
132
133 $this->hookRunner->onLogLine(
134 $type, $subtype, $title, $params, $this->comment, $this->revert, $this->entry->getTimestamp() );
135
136 return $this->revert;
137 }
138}
array $params
The job parameters.
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.
__construct(LogEntry $entry, HookContainer $hookContainer)
getComment()
Gets the user provided comment.
Implements the default log formatting.
LogEntryBase $entry
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
getPerformerElement()
Provides the name of the user who performed the log action.
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
An individual log entry.
Definition LogEntry.php:35
getParameters()
Get the extra parameters stored for this message.
getTarget()
Get the target page of this action.
getSubtype()
The log subtype.
getType()
The main log type.