MediaWiki  REL1_31
MoveLogFormatter.php
Go to the documentation of this file.
1 <?php
32  public function getPreloadTitles() {
33  $params = $this->extractParameters();
34 
35  return [ Title::newFromText( $params[3] ) ];
36  }
37 
38  protected function getMessageKey() {
39  $key = parent::getMessageKey();
40  $params = $this->extractParameters();
41  if ( isset( $params[4] ) && $params[4] === '1' ) {
42  // Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
43  $key .= '-noredirect';
44  }
45 
46  return $key;
47  }
48 
49  protected function getMessageParameters() {
50  $params = parent::getMessageParameters();
51  $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
52  $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
53  $params[2] = Message::rawParam( $oldname );
54  $params[3] = Message::rawParam( $newname );
55  unset( $params[4] ); // handled in getMessageKey
56 
57  return $params;
58  }
59 
60  public function getActionLinks() {
61  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
62  || $this->entry->getSubtype() !== 'move'
63  || !$this->context->getUser()->isAllowed( 'move' )
64  ) {
65  return '';
66  }
67 
68  $params = $this->extractParameters();
69  $destTitle = Title::newFromText( $params[3] );
70  if ( !$destTitle ) {
71  return '';
72  }
73 
74  $revert = $this->getLinkRenderer()->makeKnownLink(
75  SpecialPage::getTitleFor( 'Movepage' ),
76  $this->msg( 'revertmove' )->text(),
77  [],
78  [
79  'wpOldTitle' => $destTitle->getPrefixedDBkey(),
80  'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(),
81  'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(),
82  'wpMovetalk' => 0
83  ]
84  );
85 
86  return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
87  }
88 
89  protected function getParametersForApi() {
92 
93  static $map = [
94  '4:title:target',
95  '5:bool:suppressredirect',
96  '4::target' => '4:title:target',
97  '5::noredir' => '5:bool:suppressredirect',
98  ];
99  foreach ( $map as $index => $key ) {
100  if ( isset( $params[$index] ) ) {
101  $params[$key] = $params[$index];
102  unset( $params[$index] );
103  }
104  }
105 
106  if ( !isset( $params['5:bool:suppressredirect'] ) ) {
107  $params['5:bool:suppressredirect'] = false;
108  }
109 
110  return $params;
111  }
112 
113 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:273
MoveLogFormatter
This class formats move log entries.
Definition: MoveLogFormatter.php:31
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:18
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:83
$params
$params
Definition: styleTest.css.php:40
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
LogFormatter\msg
msg( $key)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:735
$revert
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging a wrapping ErrorException instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters create2 Corresponds to logging log_action database field and which is displayed in the UI & $revert
Definition: hooks.txt:2206
MoveLogFormatter\getPreloadTitles
getPreloadTitles()
Definition: MoveLogFormatter.php:32
MoveLogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: MoveLogFormatter.php:89
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:32
MoveLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: MoveLogFormatter.php:60
MoveLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: MoveLogFormatter.php:38
Message\rawParam
static rawParam( $raw)
Definition: Message.php:1017
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:38
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:22
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:136
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:494
LogFormatter\makePageLink
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
Definition: LogFormatter.php:641
MoveLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: MoveLogFormatter.php:49