MediaWiki  master
DisabledSpecialPage.php
Go to the documentation of this file.
1 <?php
25 
38 
40  protected $errorMessage;
41 
48  public static function getCallback( $name, $errorMessage = null ) {
49  return static function () use ( $name, $errorMessage ) {
50  return new DisabledSpecialPage( $name, $errorMessage );
51  };
52  }
53 
58  public function __construct( $name, $errorMessage = null ) {
59  parent::__construct( $name );
60  $this->errorMessage = $errorMessage ?: 'disabledspecialpage-disabled';
61  }
62 
63  public function execute( $subPage ) {
64  $this->setHeaders();
65  $this->outputHeader();
66 
67  $error = Html::rawElement( 'div', [
68  'class' => 'error',
69  ], $this->msg( $this->errorMessage )->parseAsBlock() );
70  $this->getOutput()->addHTML( $error );
71  }
72 
73 }
This class is a drop-in replacement for other special pages that need to be manually disabled.
__construct( $name, $errorMessage=null)
static getCallback( $name, $errorMessage=null)
Create a callback suitable for use in $wgSpecialPages.
execute( $subPage)
Default execute method Checks user permissions.
This class is a collection of static functions that serve two purposes:
Definition: Html.php:55
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Shortcut to construct a special page which is unlisted by default.