]>
src.bluestatic.org Git - bugdar.git/blob - includes/class_message_reporter.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2008 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
25 * Phrase array; null by default
29 var $errors = array();
32 * The processed text for a compound error
38 // ###################################################################
40 * Adds an error to the cumulative error list
44 * @param string Error message
46 function addError($message)
48 $this->errors
[] = $message;
51 // ###################################################################
53 * Returns TRUE if there are any errors from addError(), and FALSE if
54 * there are not. This also processes all the errors into a message
55 * block that can then be used in error()
57 * @return bool Whether there are any errors present
61 if (sizeof($this->errors
) < 1)
66 $this->errorBox
= "\n\n<ol style=\"list-style-type: decimal\">";
67 foreach ($this->errors
AS $err)
69 $this->errorBox
.= "\n\t<li>" . $err . "</li>";
71 $this->errorBox
.= "\n</ol>";
76 // ###################################################################
78 * Throws an actual error. If an error text is passed, it takes
79 * precedence over any processed list errors
81 * @param string Error text
83 function error($error = null)
87 $error = $this->errorBox
;
90 $tpl = new BSTemplate('std_error');
91 $tpl->vars
= array('error' => $error);
92 $tpl->evaluate()->flush();
96 // ###################################################################
98 * Throws a common no-permission error
100 function errorPermission()
102 $this->error(T('You do not have permission to access this page. If you think that this is an error, please contact an administrator.'));
105 // ###################################################################
107 * Performs a front-end redirect by either header or <meta>
109 * @param string Redirect message text
110 * @param string URL to take the user
112 function redirect($message, $url)
114 if (bugdar
::$options['redirectheaders'])
116 header("Location: $url");
120 $tpl = new BSTemplate('std_redirect');
122 'message' => $message,
125 $tpl->evaluate()->flush();
129 // ###################################################################
131 * Displays a fatal warning/notice that is usually not an error
133 * @param string Warning text
135 function message($message)
137 $tpl = new BSTemplate('std_message');
139 'message' => $message
141 $tpl->evaluate()->flush();
145 // ###################################################################
147 * Displays a standard message template with extra confirm data on it
151 * @param string Message to confirm to
152 * @param string Form action
153 * @param string Do branch
154 * @param string Button text
155 * @param string Cancel action
156 * @param array Extra hidden information
158 function confirm($message, $action, $do, $button, $cancel, $arrextra)
162 $show['confirm'] = true;
164 foreach ($arrextra as $name => $value)
166 $extra .= '<input type="hidden
" name="' . $name . '" value="' . $value . '" />' . "\n
";
169 $tpl = new BSTemplate('std_message');
171 'message' => $message,
178 $tpl->evaluate()->flush();