MediaWiki master
SpecialPageData.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
12
22
26 private $requestHandler = null;
27
28 public function __construct() {
29 parent::__construct( 'PageData' );
30 }
31
40 public function setRequestHandler( PageDataRequestHandler $requestHandler ) {
41 $this->requestHandler = $requestHandler;
42 }
43
48 protected function initDependencies() {
49 if ( $this->requestHandler === null ) {
50 $this->requestHandler = $this->newDefaultRequestHandler();
51 }
52 }
53
59 private function newDefaultRequestHandler() {
60 return new PageDataRequestHandler();
61 }
62
70 public function execute( $subPage ) {
71 $this->initDependencies();
72
73 // If there is no title, show an HTML form
74 // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
75 if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
76 $this->showForm();
77 return;
78 }
79
80 $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
81 }
82
86 public function showForm() {
87 $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
88 }
89}
90
95class_alias( SpecialPageData::class, 'SpecialPageData' );
Show an error that looks like an HTTP server error.
Definition HttpError.php:23
Request handler implementing a data interface for mediawiki pages.
getRequest()
Get the WebRequest being used for this instance.
getOutput()
Get the OutputPage being used for this instance.
Shortcut to construct a special page which is unlisted by default.
Special page to act as an endpoint for accessing raw page data.
initDependencies()
Initialize any un-initialized members from global context.
setRequestHandler(PageDataRequestHandler $requestHandler)
Sets the request handler to be used by the special page.
showForm()
Shows an informative page to the user; Called when there is no page to output.