51 if ( $subPage ===
'' || $subPage ===
null ) {
52 return $request->
getText(
'target' ) !==
'';
55 $parts = explode(
'/', $subPage, 2 );
57 $title = $parts[1] ??
'';
58 return ( $slot === SlotRecord::MAIN || $slot ===
'' ) && $title !==
'';
78 $output->
getRequest()->response()->header(
'Access-Control-Allow-Origin: *' );
86 if ( $subPage !==
'' ) {
87 $parts = explode(
'/', $subPage, 2 );
88 $title = $parts[1] ??
'';
90 $title = $request->
getText(
'target' );
93 $revision = $request->
getInt(
'oldid', $revision );
94 $revision = $request->
getInt(
'revision', $revision );
96 if ( $title ===
null || $title ===
'' ) {
102 $title = MediaWikiServices::getInstance()->getTitleFactory()->
newFromTextThrow( $title );
128 $mimeTypes = MediaWikiServices::getInstance()
129 ->getContentHandlerFactory()
131 ->getSupportedFormats();
133 $acceptHeader = $request->
getHeader(
'Accept' );
134 if ( $acceptHeader !==
false ) {
136 $accept = $parser->parseWeights( $acceptHeader );
143 $accept[$mimeTypes[0]] = 1;
147 $format = $negotiator->getBestSupportedKey( $accept );
149 if ( $format ===
null ) {
150 $format = isset( $accept[
'text/html'] ) ?
'text/html' :
null;
153 if ( $format ===
null ) {
154 throw new HttpError( 406,
wfMessage(
'pagedata-not-acceptable', implode(
', ', $mimeTypes ) ) );
157 $url = $this->getDocUrl( $title, $format, $revision );
169 private function getDocUrl(
Title $title, $format =
'', $revision = 0 ) {
172 if ( $revision > 0 ) {
173 $params[
'oldid'] = $revision;
176 if ( $format ===
'text/html' ) {
180 $params[
'action' ] =
'raw';
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Show an error that looks like an HTTP server error.
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.
Request handler implementing a data interface for mediawiki pages.
canHandleRequest( $subPage, WebRequest $request)
Checks whether the request is complete, i.e.
handleRequest( $subPage, WebRequest $request, OutputPage $output)
Main method for handling requests.
httpContentNegotiation(WebRequest $request, OutputPage $output, Title $title, $revision=0)
Applies HTTP content negotiation.