SFU.CA Burnaby | Surrey | Vancouver
 
'); } /** * displayFooter completes HTML output with the footer and all closing tags */ public function displayFooter() { print ('
 
'); } /** * Error public function. * * @param string $source The source page which caused the error * @param string $reason The reason, semi-technical, for the error. * @param string $detail The human friendly reason for the error. * @param string $title (optional) The title for the dialog box. * @param boolen $show_procedure (optional) Whether or not to show the Procedure box. * @param boolean $contact_admin (optional) Whether to show the text advising this be reported to the administrators (default false) * @param object $exception The Exception object thrown by the error. */ public function Error ($source, $reason, $detail, $title = false, $show_procedure = true, $contact_admin = false, $exception = false) { if (!$title) $title = "Error"; self::beginBox($title, false, "box_title_error"); // Show failing field, if applicable if (($exception) &&($exception instanceof MDBOException) && $exception->fieldSet()) { self::detailBox("Invalid Field Input", 'The data entered into the '.$exception->getField().' field was invalid. Please check your input and try again.'); } // Details and technical information self::detailBox("Details", ''.$detail.''); self::detailBox("Technical Error Information", 'Source: '.$source.'
Reason: '.$reason.''); if ($exception && ($exception instanceof Exception)) { self::detailBox("Exception Message", $exception->getMessage()); } // Procedure and importance if ($contact_admin && $show_procedure) { self::detailBox("Procedure: Report Error Immediately", 'This error is important and is caused by a software or hardware error.
Please inform the network administrator immediately.'); } else if ($show_procedure) { self::detailBox("Procedure: Continue", 'This error is transient and is caused by one of the following: It is recommended that you attempt to continue using the program and not contact the network administrators unless this error continues to occur. Please click the back button in your browser to return to the last page you were using.'); } // Back button print ('
'); self::endBox(); } /** * FullError wrapper public function. Takes the same params as above, but calls header and footer. * Perfect for when you just wanna die with an error. * * @see Error */ public function FullError ($source, $reason, $detail, $title = false, $show_procedure = true, $contact_admin = false, $exception = false) { if (!$title) $title = "Error"; self::displayHeader($title); self::Error($source, $reason, $detail, $title, $show_procedure, $contact_admin, $exception); self::displayFooter(); } /** * EndError wrapper public function. Takes the same params as above, but calls footer only. * Perfect for when you just wanna die with an error and someone else called the header already. * * @see Error */ public function EndError ($source, $reason, $detail, $title = false, $show_procedure = true, $contact_admin = false, $exception = false) { self::Error($source, $reason, $detail, $title, $show_procedure, $contact_admin, $exception); self::displayFooter(); } public function beginBox($title, $box_div = false, $box_title_div = false, $id = false) { $box_div_class = $box_div ? $box_div : "box"; $box_title_div_class = $box_title_div ? $box_title_div : "box_title"; $id_string = $id ? 'id="'.$id.'"' : ''; print('
'.$title.'
'); } public function endBox() { print('
'); } public function detailBox($title, $text) { print ('
'.$title.'
'.$text.'
'); } /** * Forced Page Break. Use sparingly. */ public function pageBreak() { print ('
'); } // Spacer, when used with MPF CSS clears divs nicely. public function spacer() { print ('
 
'); } // Convert associative array to HTML option list. public function mapToOptionList($map, $selected = false) { if (!is_array($map) || count($map) < 1) throw new Exception("Invalid array!"); foreach ($map as $k => $v) { if ($selected) $presel = ($k == $selected) ? 'selected="selected"' : ''; $optionlist .= ''; } return $optionlist; } // Same as the above but for non-associative (numeric) arrays. public function arrayToOptionList($array, $selected = false) { if (!is_array($array) || count($array) < 1) throw new Exception("Invalid array!"); foreach ($array as $a) { if ($selected) $presel = ($a == $selected) ? 'selected="selected"' : ''; $optionlist .= ''; } return $optionlist; } } ?>