]>
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 * Use a Location header to redirect
34 var $useheaders = false ;
37 * Phrase array; null by default
43 * The processed text for a message
48 // ###################################################################
50 * Adds an error to the cumulative error list
54 * @param string Error message
56 function add_error ( $message )
58 $this- > items
[] = $message ;
62 * Throws a fatal user-end error message
64 * @param string The text of a message
66 function error ( $text = '' )
69 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
71 if ( sizeof ( $this- > items
) > 0 AND empty ( $this- > process
))
73 trigger_error ( 'Message_Reporter->items is an array so please use Message_Reporter->error_list_process() to prepare it' , E_USER_ERROR
);
76 $this- > process
= ( $text ? $text : $this- > process
);
78 $this- > check_process ();
80 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_error' ) . '");' );
85 * Converts the phrase array into a list for use in error()
87 function error_list_process ()
89 if (! is_array ( $this- > items
) OR sizeof ( $this- > items
) < 1 )
94 $this- > process
= " \n\n <ol style= \" list-style-type: decimal \" >" ;
95 foreach ( $this- > items
AS $phrase )
97 $this- > process
.= " \n\t <li>" . $phrase . "</li>" ;
99 $this- > process
.= " \n </ol>" ;
103 * Throws a common no-permission error
105 function error_permission ()
109 $this- > error ( $bugsys- > lang
-> string ( 'You do not have permission to access this page. If you think that this is an error, please contact an administrator.' ));
113 * Performs a front-end redirect by either header or <meta>
115 * @param string Redirect message text
116 * @param string URL to take the user
118 function redirect ( $text = '' , $url = '' )
121 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
123 $this- > process
= ( $text ? $text : $this- > process
);
124 $this- > url
= ( $url ? $url : $this- > url
);
126 $this- > check_process ();
128 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_redirect' ) . '");' );
130 if ( $this- > useheaders
)
132 header ( "Location: {$this->url} " );
139 * Displays a fatal warning/notice that is usually not an error
141 * @param string Warning text
143 function message ( $text = '' )
146 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
148 $this- > process
= ( $text ? $text : $this- > process
);
150 $this- > check_process ();
152 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_message' ) . '");' );
156 // ###################################################################
158 * Displays a standard message template with extra confirm data on it
162 * @param string Message to confirm to
163 * @param string Form action
164 * @param string Do branch
165 * @param string Button text
166 * @param string Cancel action
167 * @param array Extra hidden information
169 function confirm ( $message , $action , $do , $button , $cancel , $arrextra )
172 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
174 $show [ 'confirm' ] = true ;
176 $this- > process
= $message ;
178 foreach ( $arrextra AS $name => $value )
180 $extra .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . " \n " ;
183 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_message' ) . '");' );
188 * Checks to make sure that there is some text in the processed variable
190 function check_process ()
192 if ( empty ( $this- > process
))
194 trigger_error ( 'Message_Reporter requires some text to display a message' , E_USER_ERROR
);
199 /*=====================================================================*\
200 || ###################################################################
203 || ###################################################################
204 \*=====================================================================*/