MediaWiki  master
SpecialPageData.php
Go to the documentation of this file.
1 <?php
31 
35  private $requestHandler = null;
36 
37  public function __construct() {
38  parent::__construct( 'PageData' );
39  }
40 
52  $this->requestHandler = $requestHandler;
53  }
54 
59  protected function initDependencies() {
60  if ( $this->requestHandler === null ) {
61  $this->requestHandler = $this->newDefaultRequestHandler();
62  }
63  }
64 
70  private function newDefaultRequestHandler() {
71  return new PageDataRequestHandler();
72  }
73 
81  public function execute( $subPage ) {
82  $this->initDependencies();
83 
84  // If there is no title, show an HTML form
85  // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
86  if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
87  $this->showForm();
88  return;
89  }
90 
91  $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
92  }
93 
97  public function showForm() {
98  $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
99  }
100 
101  public function isListed() {
102  // Do not list this page in Special:SpecialPages
103  return false;
104  }
105 
106 }
Special page to act as an endpoint for accessing raw page data.
execute( $subPage)
PageDataRequestHandler null $requestHandler
setRequestHandler(PageDataRequestHandler $requestHandler)
Sets the request handler to be used by the special page.
getOutput()
Get the OutputPage being used for this instance.
newDefaultRequestHandler()
Creates a PageDataRequestHandler based on global defaults.
showForm()
Shows an informative page to the user; Called when there is no page to output.
initDependencies()
Initialize any un-initialized members from global context.
Request handler implementing a data interface for mediawiki pages.
getRequest()
Get the WebRequest being used for this instance.