modules['kernel'] = '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 .= '/';
}
return $source;
}
/**
* Loads a framework extension
*
* @param str Name of the framework
*/
function load($framework)
{
if (!$this->is_loaded($framework))
{
$newobj = $this->locate($framework);
$this->$newobj['OBJ'] = new $newobj['CLASS']();
$GLOBALS["$newobj[OBJ]"] =& $this->$newobj['OBJ'];
$this->modules["$framework"] = $newobj['OBJECT'];
}
}
/**
* Includes a framework module. Module definitions need three variables:
* class, object, and obj. Class is the name of the class, object is
* the name human-readable name, and obj is the name that the module
* should be initialized as; this is used in class extensions.
*
* @param str Name of the framework
*
* @return array List of initialization variables
*/
function locate($framework)
{
require_once($this->sourcepath . $framework . '.php');
return array('CLASS' => $CLASS, 'OBJECT' => $OBJECT, 'OBJ' => $OBJ);
}
/**
* 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\t- ";
$output .= implode("
\n\t- ", $this->modules);
$output .= "
\n
\n\n";
$this->_message('Loaded Modules', $output, 1);
}
}
/**
* Verifies to see if a framework has been loaded
*
* @param str Framework name
*
* @return bool Whether or not the framework has been loaded
*/
function is_loaded($framework)
{
if (isset($this->modules["$framework"]))
{
return true;
}
else
{
return false;
}
}
/**
* 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$prefix: $title | \n
";
$output .= "\n\n\t$message | \n
\n
\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 = 'Alert';
break;
// Warning
case ERR_WARNING:
default:
$title = 'Warning';
break;
}
$errstr .= " in $errfile on line $errline";
$this->_message($title, $errstr, 3);
}
/**
* Logs a debug message for verbose output
*
* @param str Message
*/
function debug($message)
{
if ($this->debug)
{
$this->debuginfo[] = $message;
}
}
}
/**
* Global callback used for module calls back to the kernel
*/
$_isso = new Shared_Object_Framework();
/**
* Wrapper for ternary operator that has to be in the global scope
*
* @param expr Expression
* @param mixed If the expression is true
* @param mixed If the expression is false
*
* @return mixed True or false data
*/
function iff($condition, $iftrue, $iffalse = null)
{
return ($condition) ? ($iftrue) : ($iffalse);
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>