MediaWiki  1.30.0
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 }
FormlessAction
An action which just does something, without showing a form first.
Definition: FormlessAction.php:28
Action\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: Action.php:197
SpecialPageAction\onView
onView()
Show something on GET request.
Definition: SpecialPageAction.php:63
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:35
Action\getContext
getContext()
Get the IContextSource in use here.
Definition: Action.php:178
SpecialPageAction
An action that just passes the request to the relevant special page.
Definition: SpecialPageAction.php:27
Action\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: Action.php:256
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2581
SpecialPageAction\getName
getName()
Return the name of the action this object responds to.
Definition: SpecialPageAction.php:36
SpecialPageAction\$actionToSpecialPageMapping
static array $actionToSpecialPageMapping
A mapping of action names to special page names.
Definition: SpecialPageAction.php:31
SpecialPageAction\requiresUnblock
requiresUnblock()
Whether this action can still be executed by a blocked user.
Definition: SpecialPageAction.php:55
$special
this hook is for auditing only RecentChangesLinked and Watchlist $special
Definition: hooks.txt:988
SpecialPageAction\doesWrites
doesWrites()
Indicates whether this action may perform database writes.
Definition: SpecialPageAction.php:79
SpecialPageAction\getSpecialPage
getSpecialPage()
Definition: SpecialPageAction.php:88
SpecialPageFactory\getPage
static getPage( $name)
Find the object with a given name and return it (or NULL)
Definition: SpecialPageFactory.php:379
SpecialPageAction\show
show()
The main action entry point.
Definition: SpecialPageAction.php:67
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
SpecialPageAction\getDescription
getDescription()
Returns the description that goes below the <h1> tag.
Definition: SpecialPageAction.php:59
array
the array() calling protocol came about after MediaWiki 1.4rc1.