]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/error.php
change Laconica and Control Yourself to StatusNet in PHP files
[quix0rs-gnu-social.git] / lib / error.php
1 <?php
2
3 /**
4  * Error action.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  StatusNet
10  * @author   Evan Prodromou <evan@controlyourself.ca>
11  * @author   Zach Copley <zach@controlyourself.ca>
12  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13  * @link     http://laconi.ca/
14  *
15  * StatusNet - a distributed open-source microblogging tool
16  * Copyright (C) 2008, 2009, StatusNet, Inc.
17  *
18  * This program is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU Affero General Public License as published by
20  * the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU Affero General Public License for more details.
27  *
28  * You should have received a copy of the GNU Affero General Public License
29  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
30  */
31
32 if (!defined('LACONICA')) {
33     exit(1);
34 }
35
36 /**
37  * Base class for displaying HTTP errors
38  *
39  * @category Action
40  * @package  StatusNet
41  * @author   Zach Copley <zach@controlyourself.ca>
42  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43  * @link     http://laconi.ca/
44  */
45 class ErrorAction extends Action
46 {
47     var $code    = null;
48     var $message = null;
49     var $status  = null;
50     var $default = null;
51
52     function __construct($message, $code, $output='php://output', $indent=true)
53     {
54         parent::__construct($output, $indent);
55
56         $this->code = $code;
57         $this->message = $message;
58
59         // XXX: hack alert: usually we aren't going to
60         // call this page directly, but because it's
61         // an action it needs an args array anyway
62         $this->prepare($_REQUEST);
63     }
64
65     /**
66      *  To specify additional HTTP headers for the action
67      *
68      *  @return void
69      */
70     function extraHeaders()
71     {
72         $status_string = $this->status[$this->code];
73         header('HTTP/1.1 '.$this->code.' '.$status_string);
74     }
75
76     /**
77      * Display content.
78      *
79      * @return nothing
80      */
81     function showContent()
82     {
83         $this->element('div', array('class' => 'error'), $this->message);
84     }
85
86     /**
87      * Page title.
88      *
89      * @return page title
90      */
91     function title()
92     {
93         return $this->message;
94     }
95
96     function isReadOnly($args)
97     {
98         return true;
99     }
100
101     function showPage()
102     {
103         parent::showPage();
104
105         // We don't want to have any more output after this
106         exit();
107     }
108
109     // Overload a bunch of stuff so the page isn't too bloated
110
111     function showBody()
112     {
113         $this->elementStart('body', array('id' => 'error'));
114         $this->elementStart('div', array('id' => 'wrap'));
115         $this->showHeader();
116         $this->showCore();
117         $this->showFooter();
118         $this->elementEnd('div');
119         $this->elementEnd('body');
120     }
121
122     function showCore()
123     {
124         $this->elementStart('div', array('id' => 'core'));
125         $this->showContentBlock();
126         $this->elementEnd('div');
127     }
128
129     function showHeader()
130     {
131         $this->elementStart('div', array('id' => 'header'));
132         $this->showLogo();
133         $this->showPrimaryNav();
134         $this->elementEnd('div');
135     }
136
137 }