r433: Merging the locale-change branch onto trunk; we now use ISSO's localize system
[bugdar.git] / includes / class_message_reporter.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 class Message_Reporter
14 {
15 var $url = '';
16 var $useheaders = false;
17
18 var $phrase = null;
19 var $process = '';
20
21 function error($text = '')
22 {
23 global $bugsys;
24 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
25
26 if (is_array($this->phrase) AND empty($this->process))
27 {
28 trigger_error('Message_Reporter::phrase is an array so please use Message_Reporter::error_list_process() to prepare it', E_USER_ERROR);
29 }
30
31 $this->process = ($text ? $text : $this->process);
32
33 $this->check_process();
34
35 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");');
36 exit;
37 }
38
39 function error_list_process()
40 {
41 if (!is_array($this->phrase) OR count($this->phrase) < 1)
42 {
43 return;
44 }
45
46 $this->process = "\n\n<ol style=\"list-style-type: decimal\">";
47 foreach ($this->phrase AS $phrase)
48 {
49 $this->process .= "\n\t<li>" . $phrase . "</li>";
50 }
51 $this->process .= "\n</ol>";
52 }
53
54 function error_permission()
55 {
56 global $bugsys;
57
58 $this->phrase = $bugsys->lang->string('You do not have permission to access this page. If you think that this is an error, please contact an administrator.');
59 $this->error();
60 }
61
62 function redirect($text = '', $url = '')
63 {
64 global $bugsys;
65 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
66
67 if (is_array($this->phrase) AND empty($this->process))
68 {
69 trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::redirect()', E_USER_ERROR);
70 }
71
72 $this->process = ($text ? $text : $this->process);
73 $this->url = ($url ? $url : $this->url);
74
75 $this->check_process();
76
77 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect') . '");');
78
79 if ($this->useheaders)
80 {
81 header("Location: {$this->url}");
82 }
83
84 exit;
85 }
86
87 function message($text = '')
88 {
89 global $bugsys;
90 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
91
92 if (is_array($this->phrase) AND empty($this->process))
93 {
94 trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::message()', E_USER_ERROR);
95 }
96
97 $this->process = ($text ? $text : $this->process);
98
99 $this->check_process();
100
101 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message') . '");');
102 exit;
103 }
104
105 function check_process()
106 {
107 if (empty($this->process))
108 {
109 trigger_error('Message_Reporter requires some text to display a message', E_USER_ERROR);
110 }
111 }
112 }
113
114 /*=====================================================================*\
115 || ###################################################################
116 || # $HeadURL$
117 || # $Id$
118 || ###################################################################
119 \*=====================================================================*/
120 ?>