X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Ferror.php;h=762425dc44ade45ccb3e46c77aec6bfcf07cda1b;hb=24f9a991b6ac8edfc7936b7adfcb7dd5955c66a3;hp=87a4d913b41b1287f7af821926c5a8dea82a8439;hpb=78fc9483d4d1fde4561905edf6594b86c4dc374e;p=quix0rs-gnu-social.git diff --git a/lib/error.php b/lib/error.php index 87a4d913b4..762425dc44 100644 --- a/lib/error.php +++ b/lib/error.php @@ -33,6 +33,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once INSTALLDIR . '/lib/info.php'; + /** * Base class for displaying HTTP errors * @@ -42,7 +44,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://status.net/ */ -class ErrorAction extends Action +class ErrorAction extends InfoAction { static $status = array(); @@ -52,10 +54,11 @@ class ErrorAction extends Action function __construct($message, $code, $output='php://output', $indent=null) { - parent::__construct($output, $indent); + parent::__construct(null, $message, $output, $indent); $this->code = $code; $this->message = $message; + $this->minimal = StatusNet::isApi(); // XXX: hack alert: usually we aren't going to // call this page directly, but because it's @@ -63,15 +66,19 @@ class ErrorAction extends Action $this->prepare($_REQUEST); } - /** - * To specify additional HTTP headers for the action - * - * @return void - */ - function extraHeaders() + function showPage() { - $status_string = @self::$status[$this->code]; - header('HTTP/1.1 '.$this->code.' '.$status_string); + if ($this->minimal) { + // Even more minimal -- we're in a machine API + // and don't want to flood the output. + $this->extraHeaders(); + $this->showContent(); + } else { + parent::showPage(); + } + + // We don't want to have any more output after this + exit(); } /** @@ -84,56 +91,6 @@ class ErrorAction extends Action $this->element('div', array('class' => 'error'), $this->message); } - /** - * Page title. - * - * @return page title - */ - - function title() - { - return @self::$status[$this->code]; - } - - function isReadOnly($args) - { - return true; - } - function showPage() - { - parent::showPage(); - - // We don't want to have any more output after this - exit(); - } - - // Overload a bunch of stuff so the page isn't too bloated - - function showBody() - { - $this->elementStart('body', array('id' => 'error')); - $this->elementStart('div', array('id' => 'wrap')); - $this->showHeader(); - $this->showCore(); - $this->showFooter(); - $this->elementEnd('div'); - $this->elementEnd('body'); - } - - function showCore() - { - $this->elementStart('div', array('id' => 'core')); - $this->showContentBlock(); - $this->elementEnd('div'); - } - - function showHeader() - { - $this->elementStart('div', array('id' => 'header')); - $this->showLogo(); - $this->showPrimaryNav(); - $this->elementEnd('div'); - } }