MediaWiki  1.27.2
SpecialPageAction.php
Go to the documentation of this file.
1 <?php
31  public static $actionToSpecialPageMapping = [
32  'revisiondelete' => 'Revisiondelete',
33  'editchangetags' => 'EditTags',
34  ];
35 
36  public function getName() {
37  $request = $this->getRequest();
38  $actionName = $request->getVal( 'action', 'view' );
39  // TODO: Shouldn't need to copy-paste this code from Action::getActionName!
40  if ( $actionName === 'historysubmit' ) {
41  if ( $request->getBool( 'revisiondelete' ) ) {
42  $actionName = 'revisiondelete';
43  } elseif ( $request->getBool( 'editchangetags' ) ) {
44  $actionName = 'editchangetags';
45  }
46  }
47 
48  if ( isset( self::$actionToSpecialPageMapping[$actionName] ) ) {
49  return $actionName;
50  }
51 
52  return 'nosuchaction';
53  }
54 
55  public function requiresUnblock() {
56  return false;
57  }
58 
59  public function getDescription() {
60  return '';
61  }
62 
63  public function onView() {
64  return '';
65  }
66 
67  public function show() {
68  $special = $this->getSpecialPage();
69  if ( !$special ) {
70  throw new ErrorPageError(
71  $this->msg( 'nosuchaction' ), $this->msg( 'nosuchactiontext' ) );
72  }
73 
74  $special->setContext( $this->getContext() );
75  $special->getContext()->setTitle( $special->getPageTitle() );
76  $special->run( '' );
77  }
78 
79  public function doesWrites() {
80  $special = $this->getSpecialPage();
81 
82  return $special ? $special->doesWrites() : false;
83  }
84 
88  protected function getSpecialPage() {
89  $action = $this->getName();
90  if ( $action === 'nosuchaction' ) {
91  return null;
92  }
93 
94  // map actions to (whitelisted) special pages
95  return SpecialPageFactory::getPage( self::$actionToSpecialPageMapping[$action] );
96  }
97 }
this hook is for auditing only RecentChangesLinked and Watchlist $special
Definition: hooks.txt:965
An action that just passes the request to the relevant special page.
static getPage($name)
Find the object with a given name and return it (or NULL)
An error page which can definitely be safely rendered using the OutputPage.
getContext()
Get the IContextSource in use here.
Definition: Action.php:178
static array $actionToSpecialPageMapping
A mapping of action names to special page names.
An action which just does something, without showing a form first.
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:35
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2418
static array getName()
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: Action.php:256
getRequest()
Get the WebRequest being used for this instance.
Definition: Action.php:197