]>
src.bluestatic.org Git - bugdar.git/blob - includes/class_message_reporter.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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
49 * Throws a fatal user-end error message
51 * @param string The text of a message
53 function error ( $text = '' )
56 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
58 if ( count ( $this- > items
) > 0 AND empty ( $this- > process
))
60 trigger_error ( 'Message_Reporter->items is an array so please use Message_Reporter->error_list_process() to prepare it' , E_USER_ERROR
);
63 $this- > process
= ( $text ? $text : $this- > process
);
65 $this- > check_process ();
67 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_error' ) . '");' );
72 * Converts the phrase array into a list for use in error()
74 function error_list_process ()
76 if (! is_array ( $this- > items
) OR count ( $this- > items
) < 1 )
81 $this- > process
= " \n\n <ol style= \" list-style-type: decimal \" >" ;
82 foreach ( $this- > items
AS $phrase )
84 $this- > process
.= " \n\t <li>" . $phrase . "</li>" ;
86 $this- > process
.= " \n </ol>" ;
90 * Throws a common no-permission error
92 function error_permission ()
96 $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.' ));
100 * Performs a front-end redirect by either header or <meta>
102 * @param string Redirect message text
103 * @param string URL to take the user
105 function redirect ( $text = '' , $url = '' )
108 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
110 $this- > process
= ( $text ? $text : $this- > process
);
111 $this- > url
= ( $url ? $url : $this- > url
);
113 $this- > check_process ();
115 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_redirect' ) . '");' );
117 if ( $this- > useheaders
)
119 header ( "Location: {$this->url} " );
126 * Displays a fatal warning/notice that is usually not an error
128 * @param string Warning text
130 function message ( $text = '' )
133 global $doctype , $header , $headinclude , $footer , $focus , $show , $stylevar ;
135 $this- > process
= ( $text ? $text : $this- > process
);
137 $this- > check_process ();
139 eval ( ' $bugsys- >template->flush("' . $bugsys- > template
-> fetch ( 'std_message' ) . '");' );
144 * Checks to make sure that there is some text in the processed variable
146 function check_process ()
148 if ( empty ( $this- > process
))
150 trigger_error ( 'Message_Reporter requires some text to display a message' , E_USER_ERROR
);
155 /*=====================================================================*\
156 || ###################################################################
159 || ###################################################################
160 \*=====================================================================*/