r344: Finished errors and notices
[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 if (empty($this->process))
32 {
33 $this->process = lang::p($this->phrase);
34 }
35
36 $this->process = (($text) ? $text : $this->process);
37
38 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");');
39 exit;
40 }
41
42 function error_list_process()
43 {
44 if (!is_array($this->phrase) OR count($this->phrase) < 1)
45 {
46 return;
47 }
48
49 $this->process = "\n\n<ol style=\"list-style-type: decimal\">";
50 foreach ($this->phrase AS $phrase)
51 {
52 $this->process .= "\n\t<li>" . lang::p($phrase) . "</li>";
53 }
54 $this->process .= "\n</ol>";
55 }
56
57 function error_permission()
58 {
59 $this->phrase = 'error_no_permission';
60 $this->error();
61 }
62
63 function redirect($text = '', $url = '')
64 {
65 global $bugsys;
66 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
67
68 if (is_array($this->phrase) AND empty($this->process))
69 {
70 trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::redirect()', E_USER_ERROR);
71 }
72
73 if (empty($this->process))
74 {
75 $this->process = lang::p($this->phrase);
76 }
77
78 $this->process = (($text) ? $text : $this->process);
79 $this->url = (($url) ? $url : $this->url);
80
81 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect') . '");');
82
83 if ($this->useheaders)
84 {
85 header("Location: {$this->url}");
86 }
87
88 exit;
89 }
90
91 function message($text = '')
92 {
93 global $bugsys;
94 global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
95
96 if (is_array($this->phrase) AND empty($this->process))
97 {
98 trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::message()', E_USER_ERROR);
99 }
100
101 if (empty($this->process))
102 {
103 $this->process = lang::p($this->phrase);
104 }
105
106 $this->process = (($text) ? $text : $this->process);
107
108 eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message') . '");');
109 exit;
110 }
111 }
112
113 /*=====================================================================*\
114 || ###################################################################
115 || # $HeadURL$
116 || # $Id$
117 || ###################################################################
118 \*=====================================================================*/
119 ?>