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 public function isListed() {
108 // Do not list this page in Special:SpecialPages
109 return false;
110 }
111
112}
113
118class_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.
Parent class for all special pages.
getRequest()
Get the WebRequest being used for this instance.
getOutput()
Get the OutputPage being used for this instance.
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.
isListed()
Whether this special page is listed in Special:SpecialPages.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...