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  public function getComment() {
60  $this->comment ??= parent::getComment();
61 
62  // Make sure we execute the LogLine hook so that we immediately return
63  // the correct value.
64  if ( $this->revert === null ) {
65  $this->getActionLinks();
66  }
67 
68  return $this->comment;
69  }
70 
75  protected function getActionMessage() {
77  $action = LogPage::actionText(
78  $entry->getType(),
79  $entry->getSubtype(),
80  $entry->getTarget(),
81  $this->plaintext ? null : $this->context->getSkin(),
82  (array)$entry->getParameters(),
83  !$this->plaintext // whether to filter [[]] links
84  );
85 
86  $performer = $this->getPerformerElement();
87  if ( !$this->irctext ) {
88  $sep = $this->msg( 'word-separator' );
89  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
90  $action = $performer . $sep . $action;
91  }
92 
93  return $action;
94  }
95 
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  ( new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )->onLogLine(
124  $type, $subtype, $title, $params, $this->comment, $this->revert, $this->entry->getTimestamp() );
125 
126  return $this->revert;
127  }
128 }
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.
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:238
const DELETED_ACTION
Definition: LogPage.php:42
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:565
Service locator for MediaWiki core services.
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.