MediaWiki master
SpecialPageData.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Specials;
24
25use HttpError;
28
37
41 private $requestHandler = null;
42
43 public function __construct() {
44 parent::__construct( 'PageData' );
45 }
46
57 public function setRequestHandler( PageDataRequestHandler $requestHandler ) {
58 $this->requestHandler = $requestHandler;
59 }
60
65 protected function initDependencies() {
66 if ( $this->requestHandler === null ) {
67 $this->requestHandler = $this->newDefaultRequestHandler();
68 }
69 }
70
76 private function newDefaultRequestHandler() {
77 return new PageDataRequestHandler();
78 }
79
87 public function execute( $subPage ) {
88 $this->initDependencies();
89
90 // If there is no title, show an HTML form
91 // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
92 if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
93 $this->showForm();
94 return;
95 }
96
97 $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
98 }
99
103 public function showForm() {
104 $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
105 }
106}
107
112class_alias( SpecialPageData::class, 'SpecialPageData' );
Show an error that looks like an HTTP server error.
Definition HttpError.php:32
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.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...