00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 function printstuff( $var )
00018 {
00019 echo "<pre>";
00020 print_r($var);
00021 echo "</pre>";
00022 }
00023
00027 class errorHandler
00028 {
00029 var $errors;
00030 var $handled = false;
00031 var $url;
00032
00036 function errorHandler( $url )
00037 {
00038 $this->errors = array();
00039 $this->url = $url;
00040 }
00041
00051 function handle( $errorName, $errorDescription )
00052 {
00053 if( is_string( $errorDescription ) )
00054 {
00055 $this->errors[$errorName] = $errorDescription;
00056 $this->handled = true;
00057 }
00058 else if( $errorDescription === false )
00059 {
00060 $this->errors[$errorName] = i18n("An unknown error occured");
00061 $this->handled = true;
00062 }
00063
00064 return $errorDescription;
00065 }
00066
00072 function render()
00073 {
00074 if( count( $this->errors ) > 0 )
00075 {
00076 if( count( $this->errors ) == 1 )
00077 $renderedErrors = "
00078 <div class=\"errorhandler\">
00079 <a class=\"command errorhandler-command\" href=\"{$this->url}\">[" . i18n( "Back" ) . "]</a>
00080 <h6 class=\"errorhandler-title\">" . i18n("The following error occured:") . "</h6>";
00081 else
00082 $renderedErrors = "
00083 <div class=\"errorhandler\">
00084 <a class=\"command errorhandler-command\" href=\"{$this->url}\">[" . i18n( "Back" ) . "]</a>
00085 <h6 class=\"errorhandler-title\">" . i18n("The following errors occured:") . "</h6>";
00086
00087 foreach( $this->errors as $errorName => $errorDescription )
00088 $renderedErrors .= "
00089 <div class=\"errorhandler-error\">
00090 <p class=\"errorhandler-name\">$errorName</p>
00091 <p class=\"errorhandler-description\">$errorDescription</p>
00092 </div>";
00093
00094 $renderedErrors .= "
00095 </div>";
00096 }
00097
00098 return $renderedErrors;
00099 }
00100 }
00101 ?>