3 * Special page for replacing manually disabled special pages
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 namespace MediaWiki\SpecialPage
;
27 use MediaWiki\Html\Html
;
28 use MediaWiki\Message\Message
;
31 * This class is a drop-in replacement for other special pages that need to be manually
32 * disabled. To use it, just put something like
34 * $wgSpecialPages['Name'] = DisabledSpecialPage::getCallback( 'Name', 'message' );
36 * in the local configuration (where 'Name' is the canonical name of the special page
37 * to be disabled, and 'message' is a message key for explaining the reason for disabling).
41 class DisabledSpecialPage
extends UnlistedSpecialPage
{
43 /** @var Message|string */
44 protected $errorMessage;
47 * Create a callback suitable for use in $wgSpecialPages.
48 * @param string $name Canonical name of the special page that's being replaced.
49 * @param Message|string|null $errorMessage Error message to show when users try to use the page.
52 public static function getCallback( $name, $errorMessage = null ) {
53 return static function () use ( $name, $errorMessage ) {
54 return new DisabledSpecialPage( $name, $errorMessage );
59 * @param string $name Canonical name of the special page that's being replaced.
60 * @param Message|string|null $errorMessage Error message to show when users try to use the page.
62 public function __construct( $name, $errorMessage = null ) {
63 parent
::__construct( $name );
64 $this->errorMessage
= $errorMessage ?
: 'disabledspecialpage-disabled';
67 public function execute( $subPage ) {
69 $this->outputHeader();
71 $this->getOutput()->addModuleStyles( 'mediawiki.codex.messagebox.styles' );
72 $this->getOutput()->addHTML( Html
::errorBox(
73 $this->msg( $this->errorMessage
)->parse()
79 /** @deprecated class alias since 1.41 */
80 class_alias( DisabledSpecialPage
::class, 'DisabledSpecialPage' );