]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/error.php
Merge branch 'master' into testing
[quix0rs-gnu-social.git] / lib / error.php
index 410a9da3f883ce8aa15cddae623b52c9ea33a215..a6a29119f7f612046f2f2c0075167c5d03acef84 100644 (file)
@@ -7,12 +7,12 @@
  *
  * @category Action
  * @package  StatusNet
- * @author   Evan Prodromou <evan@controlyourself.ca>
- * @author   Zach Copley <zach@controlyourself.ca>
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Zach Copley <zach@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  *
- * StatusNet - a distributed open-source microblogging tool
+ * 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
@@ -29,7 +29,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -38,23 +38,25 @@ if (!defined('LACONICA')) {
  *
  * @category Action
  * @package  StatusNet
- * @author   Zach Copley <zach@controlyourself.ca>
+ * @author   Zach Copley <zach@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
 class ErrorAction extends Action
 {
+    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);
 
         $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
@@ -69,7 +71,7 @@ class ErrorAction extends Action
      */
     function extraHeaders()
     {
-        $status_string = $this->status[$this->code];
+        $status_string = @self::$status[$this->code];
         header('HTTP/1.1 '.$this->code.' '.$status_string);
     }
 
@@ -88,9 +90,10 @@ class ErrorAction extends Action
      *
      * @return page title
      */
+
     function title()
     {
-        return $this->message;
+        return @self::$status[$this->code];
     }
 
     function isReadOnly($args)
@@ -100,7 +103,14 @@ class ErrorAction extends Action
 
     function showPage()
     {
-        parent::showPage();
+        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();