]>
src.bluestatic.org Git - bugdar.git/blob - includes/class_message_reporter.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] 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 [#]gpl[#] 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 \*=====================================================================*/
22 class Message_Reporter
25 * The URL used for redirect
31 * Phrase array; null by default
37 * The processed text for a message
42 // ###################################################################
44 * Adds an error to the cumulative error list
48 * @param string Error message
50 function add_error($message)
52 $this->items
[] = $message;
56 * Throws a fatal user-end error message
58 * @param string The text of a message
60 function error($text = '')
63 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
65 if (sizeof($this->items
) > 0 AND empty($this->process
))
67 trigger_error('Message_Reporter->items is an array so please use Message_Reporter->error_list_process() to prepare it', E_USER_ERROR
);
70 $this->process
= ($text ? $text : $this->process
);
72 $this->check_process();
74 eval('$bugsys->template->flush("' . $bugsys->template
->fetch('std_error') . '");');
79 * Converts the phrase array into a list for use in error()
81 function error_list_process()
83 if (!is_array($this->items
) OR sizeof($this->items
) < 1)
88 $this->process
= "\n\n<ol style=\"list-style-type: decimal\">";
89 foreach ($this->items
AS $phrase)
91 $this->process
.= "\n\t<li>" . $phrase . "</li>";
93 $this->process
.= "\n</ol>";
97 * Throws a common no-permission error
99 function error_permission()
103 $this->error(_('You do not have permission to access this page. If you think that this is an error, please contact an administrator.'));
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($text = '', $url = '')
115 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
117 $this->process
= ($text ? $text : $this->process
);
118 $this->url
= ($url ? $url : $this->url
);
120 if ($bugsys->options
['redirectheaders'])
122 header("Location: $url");
126 $this->check_process();
128 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect
') . '");');
134 * Displays a fatal warning/notice that is usually not an error
136 * @param string Warning text
138 function message($text = '')
141 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
143 $this->process = ($text ? $text : $this->process);
145 $this->check_process();
147 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message
') . '");');
151 // ###################################################################
153 * Displays a standard message template with extra confirm data on it
157 * @param string Message to confirm to
158 * @param string Form action
159 * @param string Do branch
160 * @param string Button text
161 * @param string Cancel action
162 * @param array Extra hidden information
164 function confirm($message, $action, $do, $button, $cancel, $arrextra)
167 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
169 $show['confirm'] = true;
171 $this->process = $message;
173 foreach ($arrextra AS $name => $value)
175 $extra .= '<input type="hidden
" name="' . $name . '" value="' . $value . '" />' . "\n
";
178 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message
') . '");');
183 * Checks to make sure that there is some text in the processed variable
185 function check_process()
187 if (empty($this->process))
189 trigger_error('Message_Reporter requires some text to display a message', E_USER_ERROR);
194 /*=====================================================================*\
195 || ###################################################################
198 || ###################################################################
199 \*=====================================================================*/