46 if ( $subPage ===
'' || $subPage ===
null ) {
47 return $request->
getText(
'target' ) !==
'';
50 $parts = explode(
'/', $subPage, 2 );
53 return ( $slot ===
'main' || $slot ===
'' ) &&
$title !==
'';
73 $output->
getRequest()->response()->header(
'Access-Control-Allow-Origin: *' );
81 if ( $subPage !==
'' ) {
82 $parts = explode(
'/', $subPage, 2 );
88 $revision = $request->
getInt(
'oldid', $revision );
89 $revision = $request->
getInt(
'revision', $revision );
123 $mimeTypes = MediaWikiServices::getInstance()
124 ->getContentHandlerFactory()
125 ->getContentHandler(
$title->getContentModel() )
126 ->getSupportedFormats();
128 $acceptHeader = $request->
getHeader(
'Accept' );
129 if ( $acceptHeader !==
false ) {
131 $accept = $parser->parseWeights( $acceptHeader );
138 $accept[$mimeTypes[0]] = 1;
142 $format = $negotiator->getBestSupportedKey( $accept );
144 if ( $format ===
null ) {
145 $format = isset( $accept[
'text/html'] ) ?
'text/html' :
null;
148 if ( $format ===
null ) {
149 throw new HttpError( 406,
wfMessage(
'pagedata-not-acceptable', implode(
', ', $mimeTypes ) ) );
152 $url = $this->getDocUrl(
$title, $format, $revision );
164 private function getDocUrl(
Title $title, $format =
'', $revision = 0 ) {
167 if ( $revision > 0 ) {
168 $params[
'oldid'] = $revision;
171 if ( $format ===
'text/html' ) {
172 return $title->getFullURL( $params );
175 $params[
'action' ] =
'raw';
177 return $title->getFullURL( $params );
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.
Represents a title within MediaWiki.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getInt( $name, $default=0)
Fetch an integer value from the input or return $default if not set.
getText( $name, $default='')
Fetch a text string and return it in normalized form.
getHeader( $name, $flags=0)
Get a request header, or false if it isn't set.