MediaWiki master
SpecialPageData.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
23use HttpError;
26
36
40 private $requestHandler = null;
41
42 public function __construct() {
43 parent::__construct( 'PageData' );
44 }
45
54 public function setRequestHandler( PageDataRequestHandler $requestHandler ) {
55 $this->requestHandler = $requestHandler;
56 }
57
62 protected function initDependencies() {
63 if ( $this->requestHandler === null ) {
64 $this->requestHandler = $this->newDefaultRequestHandler();
65 }
66 }
67
73 private function newDefaultRequestHandler() {
74 return new PageDataRequestHandler();
75 }
76
84 public function execute( $subPage ) {
85 $this->initDependencies();
86
87 // If there is no title, show an HTML form
88 // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
89 if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
90 $this->showForm();
91 return;
92 }
93
94 $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
95 }
96
100 public function showForm() {
101 $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
102 }
103}
104
109class_alias( SpecialPageData::class, 'SpecialPageData' );
Show an error that looks like an HTTP server error.
Definition HttpError.php:33
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.