MediaWiki  1.34.0
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(),
78  $entry->getSubtype(),
79  $entry->getTarget(),
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::run( 'LogLine', [ $type, $subtype, $title, $params,
123  &$this->comment, &$this->revert, $this->entry->getTimestamp() ] );
124 
125  return $this->revert;
126  }
127 }
LegacyLogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LegacyLogFormatter.php:56
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:77
LogEntry\getTarget
getTarget()
Get the target page of this action.
LogPage\actionText
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
Definition: LogPage.php:227
LegacyLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LegacyLogFormatter.php:95
LogEntry\getType
getType()
The main log type.
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:691
LegacyLogFormatter\$revert
string null $revert
Cache for the result of getActionLinks() so that it does not need to run multiple times depending on ...
Definition: LegacyLogFormatter.php:54
$title
$title
Definition: testCompression.php:34
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:34
LegacyLogFormatter\$comment
string null $comment
Backward compatibility for extension changing the comment from the LogLine hook.
Definition: LegacyLogFormatter.php:45
LegacyLogFormatter\getActionMessage
getActionMessage()
Definition: LegacyLogFormatter.php:74
LogEntry\getSubtype
getSubtype()
The log subtype.
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:38
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:761
LegacyLogFormatter
This class formats all log entries for log types which have not been converted to the new system.
Definition: LegacyLogFormatter.php:35
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
$type
$type
Definition: testCompression.php:48