From 72daba762fb36a4155c97dc729de78a5d3ade771 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 9 Oct 2005 16:24:59 +0000 Subject: [PATCH] r512: - Cleaned up the logic behind Message_Reporter - Added phpDoc documentation --- includes/class_message_reporter.php | 60 ++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/includes/class_message_reporter.php b/includes/class_message_reporter.php index 765b4dd..4f6a44b 100755 --- a/includes/class_message_reporter.php +++ b/includes/class_message_reporter.php @@ -12,20 +12,43 @@ class Message_Reporter { + /** + * The URL used for redirect + * @var string + */ var $url = ''; + + /** + * Use a Location header to redirect + * @var bool + */ var $useheaders = false; + /** + * Phrase array; null by default + * @var array + */ var $phrase = null; + + /** + * The processed text for a message + * @var string + */ var $process = ''; + /** + * Throws a fatal user-end error message + * + * @param string The text of a message + */ function error($text = '') { global $bugsys; global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - if (is_array($this->phrase) AND empty($this->process)) + if (count($this->phrase) > 0 AND empty($this->process)) { - trigger_error('Message_Reporter::phrase is an array so please use Message_Reporter::error_list_process() to prepare it', E_USER_ERROR); + trigger_error('Message_Reporter->phrase is an array so please use Message_Reporter::error_list_process() to prepare it', E_USER_ERROR); } $this->process = ($text ? $text : $this->process); @@ -36,6 +59,9 @@ class Message_Reporter exit; } + /** + * Converts the phrase array into a list for use in error() + */ function error_list_process() { if (!is_array($this->phrase) OR count($this->phrase) < 1) @@ -51,24 +77,27 @@ class Message_Reporter $this->process .= "\n"; } + /** + * Throws a common no-permission error + */ function error_permission() { global $bugsys; - $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.'); - $this->error(); + $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.')); } + /** + * Performs a front-end redirect by either header or + * + * @param string Redirect message text + * @param string URL to take the user + */ function redirect($text = '', $url = '') { global $bugsys; global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - if (is_array($this->phrase) AND empty($this->process)) - { - trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::redirect()', E_USER_ERROR); - } - $this->process = ($text ? $text : $this->process); $this->url = ($url ? $url : $this->url); @@ -84,16 +113,16 @@ class Message_Reporter exit; } + /** + * Displays a fatal warning/notice that is usually not an error + * + * @param string Warning text + */ function message($text = '') { global $bugsys; global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - if (is_array($this->phrase) AND empty($this->process)) - { - trigger_error('Message_Reporter::phrase is an array and cannot be used in Message_Reporter::message()', E_USER_ERROR); - } - $this->process = ($text ? $text : $this->process); $this->check_process(); @@ -102,6 +131,9 @@ class Message_Reporter exit; } + /** + * Checks to make sure that there is some text in the processed variable + */ function check_process() { if (empty($this->process)) -- 2.22.5