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
56 public function setRequestHandler( PageDataRequestHandler $requestHandler ) {
57 $this->requestHandler = $requestHandler;
58 }
59
64 protected function initDependencies() {
65 if ( $this->requestHandler === null ) {
66 $this->requestHandler = $this->newDefaultRequestHandler();
67 }
68 }
69
75 private function newDefaultRequestHandler() {
76 return new PageDataRequestHandler();
77 }
78
86 public function execute( $subPage ) {
87 $this->initDependencies();
88
89 // If there is no title, show an HTML form
90 // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
91 if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
92 $this->showForm();
93 return;
94 }
95
96 $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
97 }
98
102 public function showForm() {
103 $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
104 }
105}
106
111class_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.