MediaWiki REL1_37
SpecialPageAction.php
Go to the documentation of this file.
1<?php
22
34 'revisiondelete' => 'Revisiondelete',
35 'editchangetags' => 'EditTags',
36 ];
37
40
42 private $actionName;
43
50 public function __construct(
51 Page $page,
52 IContextSource $context,
53 SpecialPageFactory $specialPageFactory,
54 string $actionName
55 ) {
56 parent::__construct( $page, $context );
57 $this->specialPageFactory = $specialPageFactory;
58 if ( !isset( self::$actionToSpecialPageMapping[$actionName] ) ) {
59 throw new InvalidArgumentException(
60 __CLASS__ . " does not support the action $actionName"
61 );
62 }
63 $this->actionName = $actionName;
64 }
65
69 public function getName() {
70 return $this->actionName;
71 }
72
73 public function requiresUnblock() {
74 return false;
75 }
76
77 public function getDescription() {
78 return '';
79 }
80
81 public function onView() {
82 return '';
83 }
84
85 public function show() {
86 $special = $this->getSpecialPage();
87 if ( !$special ) {
88 throw new ErrorPageError(
89 $this->msg( 'nosuchaction' ), $this->msg( 'nosuchactiontext' ) );
90 }
91
92 $special->setContext( $this->getContext() );
93 $special->getContext()->setTitle( $special->getPageTitle() );
94 $special->run( '' );
95 }
96
97 public function doesWrites() {
98 $special = $this->getSpecialPage();
99
100 return $special ? $special->doesWrites() : false;
101 }
102
106 protected function getSpecialPage() {
107 // map actions to (allowed) special pages
108 return $this->specialPageFactory->getPage(
109 self::$actionToSpecialPageMapping[$this->actionName]
110 );
111 }
112}
getContext()
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition Action.php:228
An error page which can definitely be safely rendered using the OutputPage.
An action which just does something, without showing a form first.
Factory for handling the special page list and generating SpecialPage objects.
An action that just passes the request to the relevant special page.
string $actionName
Name of this action, must exist as a key in $actionToSpecialPageMapping.
onView()
Show something on GET request.
static array $actionToSpecialPageMapping
A mapping of action names to special page names.
SpecialPageFactory $specialPageFactory
doesWrites()
Indicates whether this action may perform database writes.
getName()
Return the name of the action this object responds to.1.17string Lowercase name
getDescription()
Returns the description that goes below the <h1> tag.
requiresUnblock()
Whether this action can still be executed by a blocked user.
__construct(Page $page, IContextSource $context, SpecialPageFactory $specialPageFactory, string $actionName)
Interface for objects which can provide a MediaWiki context on request.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition Page.php:29