X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Ferror.php;h=762425dc44ade45ccb3e46c77aec6bfcf07cda1b;hb=24f9a991b6ac8edfc7936b7adfcb7dd5955c66a3;hp=bbf9987cff4632281c888ec0fd08c9815ad50a2a;hpb=97373d845cd68d6145f3751c9f602b13f04b37df;p=quix0rs-gnu-social.git diff --git a/lib/error.php b/lib/error.php index bbf9987cff..762425dc44 100644 --- a/lib/error.php +++ b/lib/error.php @@ -6,14 +6,14 @@ * PHP version 5 * * @category Action - * @package Laconica - * @author Evan Prodromou - * @author Zach Copley + * @package StatusNet + * @author Evan Prodromou + * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://laconi.ca/ + * @link http://status.net/ * - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -29,32 +29,36 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once INSTALLDIR . '/lib/info.php'; + /** * Base class for displaying HTTP errors * * @category Action - * @package Laconica - * @author Zach Copley + * @package StatusNet + * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://laconi.ca/ + * @link http://status.net/ */ -class ErrorAction extends Action +class ErrorAction extends InfoAction { + static $status = array(); + var $code = null; var $message = null; - var $status = null; var $default = null; - function __construct($message, $code, $output='php://output', $indent=true) + 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 @@ -62,17 +66,21 @@ class ErrorAction extends Action $this->prepare($_REQUEST); } - /** - * To specify additional HTTP headers for the action - * - * @return void - */ - function extraHeaders() + function showPage() { - $status_string = $this->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(); } - + /** * Display content. * @@ -83,55 +91,6 @@ class ErrorAction extends Action $this->element('div', array('class' => 'error'), $this->message); } - /** - * Page title. - * - * @return page title - */ - function title() - { - return $this->message; - } - - 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'); - } }