54 if ( $subPage ===
'' || $subPage ===
null ) {
55 return $request->
getText(
'target' ) !==
'';
58 $parts = explode(
'/', $subPage, 2 );
60 $title = $parts[1] ??
'';
61 return ( $slot === SlotRecord::MAIN || $slot ===
'' ) && $title !==
'';
81 $output->
getRequest()->response()->header(
'Access-Control-Allow-Origin: *' );
89 if ( $subPage !==
'' ) {
90 $parts = explode(
'/', $subPage, 2 );
91 $title = $parts[1] ??
'';
93 $title = $request->
getText(
'target' );
96 $revision = $request->
getInt(
'oldid', $revision );
97 $revision = $request->
getInt(
'revision', $revision );
99 if ( $title ===
null || $title ===
'' ) {
132 ->getContentHandlerFactory()
134 ->getSupportedFormats();
136 $acceptHeader = $request->
getHeader(
'Accept' );
137 if ( $acceptHeader !==
false ) {
139 $accept = $parser->parseWeights( $acceptHeader );
146 $accept[$mimeTypes[0]] = 1;
150 $format = $negotiator->getBestSupportedKey( $accept );
152 if ( $format ===
null ) {
153 $format = isset( $accept[
'text/html'] ) ?
'text/html' :
null;
156 if ( $format ===
null ) {
157 throw new HttpError( 406,
wfMessage(
'pagedata-not-acceptable', implode(
', ', $mimeTypes ) ) );
160 $url = $this->getDocUrl( $title, $format, $revision );
172 private function getDocUrl(
Title $title, $format =
'', $revision = 0 ) {
175 if ( $revision > 0 ) {
179 if ( $format ===
'text/html' ) {
191class_alias( PageDataRequestHandler::class,
'PageDataRequestHandler' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
array $params
The job parameters.
Show an error that looks like an HTTP server error.
Request handler implementing a data interface for mediawiki pages.
httpContentNegotiation(WebRequest $request, OutputPage $output, Title $title, $revision=0)
Applies HTTP content negotiation.
handleRequest( $subPage, WebRequest $request, OutputPage $output)
Main method for handling requests.
canHandleRequest( $subPage, WebRequest $request)
Checks whether the request is complete, i.e.
This is one of the Core classes and should be read at least once by any new developers.
redirect( $url, $responsecode='302')
Redirect to $url rather than displaying the normal page.