MediaWiki  1.23.3
HttpError.php
Go to the documentation of this file.
1 <?php
28 class HttpError extends MWException {
30 
38  public function __construct( $httpCode, $content, $header = null ) {
39  parent::__construct( $content );
40  $this->httpCode = (int)$httpCode;
41  $this->header = $header;
42  $this->content = $content;
43  }
44 
50  public function getStatusCode() {
51  return $this->httpCode;
52  }
53 
59  public function report() {
60  $httpMessage = HttpStatus::getMessage( $this->httpCode );
61 
62  header( "Status: {$this->httpCode} {$httpMessage}", true, $this->httpCode );
63  header( 'Content-type: text/html; charset=utf-8' );
64 
65  print $this->getHTML();
66  }
67 
74  public function getHTML() {
75  if ( $this->header === null ) {
76  $header = HttpStatus::getMessage( $this->httpCode );
77  } elseif ( $this->header instanceof Message ) {
78  $header = $this->header->escaped();
79  } else {
80  $header = htmlspecialchars( $this->header );
81  }
82 
83  if ( $this->content instanceof Message ) {
84  $content = $this->content->escaped();
85  } else {
86  $content = htmlspecialchars( $this->content );
87  }
88 
89  return "<!DOCTYPE html>\n" .
90  "<html><head><title>$header</title></head>\n" .
91  "<body><h1>$header</h1><p>$content</p></body></html>\n";
92  }
93 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
content
per default it will return the text for text based content
Definition: contenthandler.txt:107
HttpError\$header
$header
Definition: HttpError.php:29
HttpError\report
report()
Report the HTTP error.
Definition: HttpError.php:59
HttpError
Show an error that looks like an HTTP server error.
Definition: HttpError.php:28
HttpError\$content
$content
Definition: HttpError.php:29
HttpError\getStatusCode
getStatusCode()
Returns the HTTP status code supplied to the constructor.
Definition: HttpError.php:50
MWException
MediaWiki exception.
Definition: MWException.php:26
HttpError\$httpCode
$httpCode
Definition: HttpError.php:29
HttpError\__construct
__construct( $httpCode, $content, $header=null)
Constructor.
Definition: HttpError.php:38
HttpError\getHTML
getHTML()
Returns HTML for reporting the HTTP error.
Definition: HttpError.php:74
HttpStatus\getMessage
static getMessage( $code)
Get the message associated with HTTP response code $code.
Definition: HttpStatus.php:37