From 0538fc812a8691bdf6e347e8e20bd1749f4c1316 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 May 2005 05:58:08 +0000 Subject: [PATCH] r170: - Error reporting backend now in place - Docs for global.php --- global.php | 14 ++++++++++--- includes/class_error.php | 37 ++++++++++++++++++++++++++------- templates/default/std_error.tpl | 3 +++ 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 templates/default/std_error.tpl diff --git a/global.php b/global.php index 6faf3bd..3669d34 100755 --- a/global.php +++ b/global.php @@ -46,21 +46,23 @@ else } // ################################################################### - +// check for userinfo -- temp +// #*# remove if ($bugsys->userinfo['userid']) { echo '
You are logged in as ' . construct_user_display($bugsys->userinfo) . ' | [Home] | [New Bug]' . ((can_perform('canadminpanel')) ? ' | [Admin]' : '') . '

' . "\n\n\n\n"; } // ################################################################### - +// cache templates $globaltemplates = array( 'doctype', 'header', 'headinclude', 'footer', 'selectoption', - 'selectoptgroup' + 'selectoptgroup', + 'std_error' ); $template->cache(array_merge($globaltemplates, (array)$fetchtemplates)); @@ -69,6 +71,12 @@ $template->cache(array_merge($globaltemplates, (array)$fetchtemplates)); // initialize template variables $show = array(); +// ################################################################### +// create error reporter +require_once('./includes/class_error.php'); +$error = new Error(); +$bugsys->error =& $error; + /*=====================================================================*\ || ################################################################### || # $HeadURL$ diff --git a/includes/class_error.php b/includes/class_error.php index e134d86..92bed9c 100755 --- a/includes/class_error.php +++ b/includes/class_error.php @@ -15,32 +15,53 @@ class Error var $phrase = null; var $process = ''; - function throw() + function throw($text = '') { global $bugsys; + if (is_array($this->phrase) AND empty($this->process)) + { + trigger_error('Error::phrase is an array so please use Error::construct() to prepare it', E_USER_ERROR); + } + if (empty($this->process)) { - $this->process = $this->phrase; + $this->process = phrase($this->phrase);; } - return + $this->process = (($text) ? $text : $this->process); + + $errormessage = $this->process; + + eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");'); + exit; } - function list() + function construct() { - if (!is_array($phrase)) + if (!is_array($this->phrase)) { - trigger_error('Error::list() requires Error::phrase to be an array', E_USER_ERROR); + trigger_error('Error::construct() requires Error::phrase to be an array', E_USER_ERROR); } - $this->process = "\n\n
    "; + if (count($this->phrase) < 1) + { + trigger_error('Error::phrase needs to have one or more elements to be an array', E_USER_ERROR); + } + + $this->process = "\n\n
      "; foreach ($this->phrase AS $phrase) { - $this->process .= "\n\t
        " . phrase($this->phrase); + $this->process .= "\n\t
      • " . phrase($phrase) . "
      • "; } $this->process .= "\n
    "; } + + function throw_permission() + { + $this->phrase = 'error_no_permission'; + $this->throw(); + } } /*=====================================================================*\ diff --git a/templates/default/std_error.tpl b/templates/default/std_error.tpl new file mode 100644 index 0000000..62dfa92 --- /dev/null +++ b/templates/default/std_error.tpl @@ -0,0 +1,3 @@ + +$errormessage + \ No newline at end of file -- 2.43.5