registers[] = $return = new BSRegister(); return $return; } // ################################################################### /** * Returns the array of all the registers * * @return array The array of all the registers */ public static function GetAllRegisters() { return self::SharedInstance()->registers; } // ################################################################### /** * Sets the main register * * @param object New main register */ public static function SetRegister($register) { if (get_class($register) != 'BSRegister') { trigger_error('BSLoader::SetRegister() was not passed a BSRegister object'); return; } self::SharedInstance()->main = $register; } // ################################################################### /** * Gets the main register if no argument is passed, or an arbitrary * one if the index of a register is passed. * * @param integer Register index * * @return object Specified register */ public static function &GetRegister($index = null) { if (is_null($index)) { if (!isset(self::SharedInstance()->main)) { trigger_error('Cannot fetch the main register because it has not been set with BSLoader::SetRegister()'); return; } return self::SharedInstance()->main; } else { if (!isset(self::SharedInstance()->registers["$index"])) { trigger_error('Invalid register index passed to BSLoader::GetRegister()'); return; } return self::SharedInstance()->registers["$index"]; } } // ################################################################### /** * Determines if there's a main register set. If not, returns FALSE. * * @return bool Is there a main register set? */ public static function HasRegister() { return (isset(self::SharedInstance()->main) AND self::SharedInstance()->main instanceof BSRegister); } // ################################################################### /** * Loads the specified module. * * @param string Module name * * @return object Instantiated module */ public static function LoadModule($name) { @include_once("ISSO/$name.php"); $class = "BS$name"; if (!class_exists($class)) { trigger_error('Specifed module does not conform to the ISSO specification, or the class is missing'); return; } return new $class; } // ################################################################### /** * Prints an ISSO message * * @param string The title of the message * @param string The content of the message * @param integer Type of message to be printed * @param bool Return the output? * @param bool Show the debug stack? * @param integer Message width * * @return mixed Output or null */ public static function Message($title, $message, $type, $return = false, $stack = true, $width = 500) { switch ($type) { // Message case 1: $prefix = 'Message'; $color = '#669900'; $font = '#000000'; break; // Warning case 2: $prefix = 'Warning'; $color = '#003399'; $font = '#FFFFFF'; break; case 3: $prefix = 'Error'; $color = '#990000'; $font = '#EFEFEF'; break; } echo "\n
\n"; echo "\n\n\t\n"; echo "\n\n\t\n"; if ($stack AND self::HasRegister() AND self::GetRegister()->getDebug()) { echo "\n\n\t\n"; } echo "\n
$prefix: $title
$message
Debug Stack:
";
			debug_print_backtrace();
			echo "
\n
\n"; } // ################################################################### /** * Custom error handler for ISSO; only handle E_WARNING, E_NOTICE, * E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE * * @param integer Error number * @param string Error message string * @param string File that contains the error * @param string The line number of the error * @param string The active symbol table at which point the error occurred */ private function _error_handler($errno, $errstr, $errfile, $errline, $errcontext) { $level = ini_get('error_reporting'); switch ($errno) { // So we don't need to specify the error type in trigger_error(), all E_USER_NOTICEs // are fatal and automatically kill the script case E_USER_NOTICE: $title = 'Fatal'; $mode = 3; break; // A non-fatal but important warning case E_WARNING: $title = 'Warning'; $mode = 2; if (!($level & E_WARNING)) { return; } break; // A non-fatal notice that should all but be ignored unless in dev environments case E_NOTICE: case E_STRICT: $title = 'Notice'; $mode = 1; if (!($level & E_NOTICE)) { return; } break; case E_USER_WARNING: case E_USER_NOTICE: default: trigger_error('The only error types supported are E_USER_NOTICE (fatal), E_WARNING, and E_NOTICE'); break; } $errstr .= " in $errfile on line $errline"; $errstr = str_replace(array(getcwd(), dirname(getcwd())), '', $errstr); self::Message($title, $errstr, $mode); if ($errno == E_USER_NOTICE) { exit; } } // ################################################################### /** * Creates a table that explains the error reporting levels and their * state */ public static function ExplainErrorReporting() { $levels = array( 'E_ERROR' => E_ERROR, 'E_WARNING' => E_WARNING, 'E_PARSE' => E_PARSE, 'E_NOTICE' => E_NOTICE, 'E_CORE_ERROR' => E_CORE_ERROR, 'E_CORE_WARNING' => E_CORE_WARNING, 'E_COMPILE_ERROR' => E_COMPILE_ERROR, 'E_COMPILE_WARNING' => E_COMPILE_WARNING, 'E_USER_ERROR' => E_USER_ERROR, 'E_USER_WARNING' => E_USER_WARNING, 'E_USER_NOTICE' => E_USER_NOTICE, 'E_ALL' => E_ALL, 'E_STRICT' => E_STRICT ); $table = ''; foreach ($levels AS $name => $value) { $table .= ' '; } $table .= '
' . $name . ' ' . (ini_get('error_reporting') & $value) . '
'; self::Message('Error Reporting', $table, 1); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>