MediaWiki REL1_37
LegacyLogFormatter.php
Go to the documentation of this file.
1<?php
45 private $comment = null;
46
54 private $revert = null;
55
56 public function getComment() {
57 if ( $this->comment === null ) {
58 $this->comment = parent::getComment();
59 }
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
95 public function getActionLinks() {
96 if ( $this->revert !== null ) {
97 return $this->revert;
98 }
99
100 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
101 $this->revert = '';
102 return $this->revert;
103 }
104
105 $title = $this->entry->getTarget();
106 $type = $this->entry->getType();
107 $subtype = $this->entry->getSubtype();
108
109 // Do nothing. The implementation is handled by the hook modifiying the
110 // passed-by-ref parameters. This also changes the default value so that
111 // getComment() and getActionLinks() do not call them indefinitely.
112 $this->revert = '';
113
114 // This is to populate the $comment member of this instance so that it
115 // can be modified when calling the hook just below.
116 if ( $this->comment === null ) {
117 $this->getComment();
118 }
119
120 $params = $this->entry->getParameters();
121
122 Hooks::runner()->onLogLine( $type, $subtype, $title, $params, $this->comment,
123 $this->revert, $this->entry->getTimestamp() );
124
125 return $this->revert;
126 }
127}
This class formats all log entries for log types which have not been converted to the new system.
string null $revert
Cache for the result of getActionLinks() so that it does not need to run multiple times depending on ...
string null $comment
Backward compatibility for extension changing the comment from the LogLine hook.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
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.
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
Definition LogPage.php:235
const DELETED_ACTION
Definition LogPage.php:39
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.