From 2a9677f60a7bd62cf1342c4a0ff78f61cdabb3e2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 13 Jan 2005 05:37:03 +0000 Subject: [PATCH] Initial SVN for base framework. --- kernel.php | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 kernel.php diff --git a/kernel.php b/kernel.php new file mode 100644 index 0000000..266aea7 --- /dev/null +++ b/kernel.php @@ -0,0 +1,198 @@ +modules[] = 'Shared Object Framework Core'; + } + + /** + * Prepares a path for being set as the sourcepath + * + * @param str Source path or URL + * + * @return str Prepared source path + */ + function fetch_sourcepath($source) + { + if (substr($source, strlen($source) - 1) == '/') + { + $source = substr($source, 0, strlen($source) - 1); + } + return $source; + } + + /** + * Loads a framework extension + * + * @param str Name of the framework + */ + function load($framework) + { + if (!in_array($framework, $this->modules)) + { + require_once($this->sourcepath . $framework); + $this->modules[] = $framework; + } + } + + /** + * Prints a list of all currently loaded framework modules + * + * @param bool Return the data as an array? + * + * @return mixed HTML output or an array of loaded modules + */ + function show_modules($return = false) + { + if ($return) + { + return $this->modules; + } + else + { + $output = "\n\n\n\n"; + $this->_message('Loaded Modules', $output, 1); + } + } + + /** + * Prints an ISSO message + * + * @param str The title of the message + * @param str The content of the message + * @param int Type of message to be printed + * @param bool Return the output? + * + * @return mixed Output or null + */ + function _message($title, $message, $type, $return = false) + { + 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; + } + + $output = "\n
\n"; + $output .= "\n\n\t\n"; + $output .= "\n\n\t\n\n
$prefix: $title
$message
\n
\n"; + + if ($return) + { + return $output; + } + else + { + print($output); + } + } + + /** + * Custom error handler for ISSO + * + * @param int Error number + * @param str Error message string + * @param str File that contains the error + * @param str The line number of the error + * @param str The active symbol table at which point the error occurred + */ + function _error_handler($errno, $errstr, $errfile, $errline) + { + switch ($errno) + { + // Fatal + case ERR_FATAL: + $title = 'Fatal'; + break; + + // Error + case ERR_ERROR: + $title = 'Error'; + break; + + // Warning + case ERR_WARNING: + default: + $title = 'Warning'; + break; + } + + $errstr .= " in $errfile on line $errline"; + + $this->_message($title, $errstr, 3); + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.43.5