/*=====================================================================*\
|| ###################################################################
|| # Blue Static ISSO Framework
-|| # Copyright (c)2005-2008 Blue Static
+|| # Copyright (c)2005-2009 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
\*=====================================================================*/
/**
-* ISSO Application Root (App.php)
-*
-* @package ISSO
-*/
+ * ISSO Application Root (App.php)
+ *
+ * @package ISSO
+ */
// we need PHP 5.2.0 to run
if (!function_exists('array_fill_keys'))
if ((bool)ini_get('register_globals') === true)
{
$superglobals = array('_GET', '_COOKIE', '_FILES', '_POST', '_SERVER', '_ENV');
- foreach ($superglobals AS $global)
+ foreach ($superglobals as $global)
{
if (is_array(${$global}))
{
- foreach (${$global} AS $_key => $_val)
+ foreach (${$global} as $_key => $_val)
{
if (isset(${$_key}))
{
}
}
-require_once(ISSO . '/Functions.php');
+require_once ISSO . '/ExceptionHandler.php';
+set_exception_handler(array('BSExceptionHandler', 'handle'));
/**
-* Application Class
-*
-* This is an ISSO application class. It holds all of the ISSO system variables as well
-* as serving as an object registry that is avaliable in the global scope to prevent
-* globalization of variables. There can only be one instance of this existing
-* at any given time.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Application Class
+ *
+ * This is an ISSO application class. It holds all of the ISSO system variables as well
+ * as serving as an object registry that is avaliable in the global scope to prevent
+ * globalization of variables. There can only be one instance of this existing
+ * at any given time.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2009, Blue Static
+ * @package ISSO
+ *
+ */
class BSApp
{
/**
- * Instance of this class
- * @var object
- */
- private static $instance;
-
- /**
- * Debug mode?
- * @var bool
- */
- private $debug = false;
-
- /**
- * The master registry list
- * @var array
- */
- private $registry = null;
+ * Debug mode?
+ * @var bool
+ */
+ private static $debug = false;
/**
- * An array of debug messages
- * @var array
- */
- private $debugInfo = array();
+ * An array of debug messages
+ * @var array
+ */
+ private static $debugInfo = array();
- // ###################################################################
/**
- * Constructor
- */
+ * Constructor
+ */
private function __construct()
- {
- $this->registry = new BSVariableRegistry();
- }
-
- // ###################################################################
- /**
- * Returns the single instance of the register
- *
- * @param string A string param
- *
- * @return object BSApp instance
- */
- private static function _instance()
- {
- if (!self::$instance)
- {
- self::$instance = new BSApp();
- }
- return self::$instance;
- }
+ {}
- // ###################################################################
/**
- * Sets the debug state
- *
- * @param bool Debug mode on?
- */
+ * Sets the debug state
+ *
+ * @param bool Debug mode on?
+ */
public static function set_debug($debug)
{
- self::_instance()->debug = $debug;
+ self::$debug = $debug;
}
- // ###################################################################
/**
- * Gets the debug mode state
- *
- * @return bool Debug mode on?
- */
+ * Gets the debug mode state
+ *
+ * @return bool Debug mode on?
+ */
public static function get_debug()
{
- return self::_instance()->debug;
+ return self::$debug;
}
- // ###################################################################
/**
- * Returns the registry object without it ever being able to be cleared
- * or unset
+ * Adds a debug message to the array. This only works when debug mode
+ * is enabled.
*
- * @return StdClass
+ * @param string Debug message
*/
- public static function registry()
- {
- return self::_instance()->registry;
- }
-
- // ###################################################################
- /**
- * Adds a debug message to the array. This only works when debug mode
- * is enabled.
- *
- * @param string Debug message
- */
public static function debug($msg)
{
- if (self::_instance()->debug)
+ if (self::$debug)
{
- self::_instance()->debugInfo[] = $msg;
+ self::$debugInfo[] = $msg;
}
}
- // ###################################################################
/**
- * Returns a <select> menu of all the debug notices
- *
- * @return string Debug list
- */
+ * Returns a <select> menu of all the debug notices
+ *
+ * @return string Debug list
+ */
public static function get_debug_list()
{
- $output = '<select><option>Debug Notices (' . sizeof(self::_instance()->debugInfo) . ')</option>';
- foreach (self::_instance()->debugInfo AS $notice)
+ $output = '<select><option>Debug Notices (' . sizeof(self::$debugInfo) . ')</option>';
+ foreach (self::$debugInfo as $notice)
{
$output .= "<option>--- $notice</option>";
}
}
// ###################################################################
+ // modules
+
/**
- * Loads the specified module.
- *
- * @param string Module name
- *
- * @return object Instantiated module
- */
- public static function load_module($name)
- {
- if (self::get_debug())
- {
- include_once(ISSO . "/$name.php");
- }
- else
- {
- @include_once(ISSO . "/$name.php");
- }
-
- $class = "BS$name";
-
- if (!class_exists($class))
- {
- throw new Exception('Specifed module does not conform to the ISSO specification, or the class is missing');
- return;
- }
-
- return new $class;
- }
-
- // ###################################################################
- /**
- * This function is used by other framework modules to check and see if
- * the passed array of module names have been loaded. If not, this will
- * throw an error informing the developer that the given modules are
- * required in order for the framework to work.
- *
- * @param array Array of module names to check for loadedness
- */
- public static function required_modules($modules)
- {
- foreach ($modules AS $module)
- {
- if (self::registry()->getType($module) == null)
- {
- throw new Exception('The ' . $module . ' module is required in order to use this framework module');
- }
- }
- }
-}
-
-/**
- * Variable Registry
- *
- * This class can be used to store unlimited number of properties. It is a (make believe)
- * inner class to BSApp and cannot be instantiated outside of it.
- *
- * @author Blue Static
- * @copyright Copyright (c)2005 - 2008, Blue Static
- * @version $Id$
- * @package ISSO
- *
- */
-class BSVariableRegistry
-{
- // ###################################################################
- /**
- * Constructor: only able to be called by BSApp
+ * BSDate
+ * @var object
*/
- public function __construct()
- {
- $bt = debug_backtrace();
- if (!isset($bt[1]['class']) OR $bt[1]['class'] != 'BSApp')
- {
- exit('You cannot instantiate ' . __CLASS__ . ' directly. It is an internal class.');
- }
- }
+ public static $date;
- // ###################################################################
/**
- * If you try and get a non-existent property, throw a new exception
+ * BSDb
+ * @var object
*/
- public function __get($name)
- {
- throw new Exception('Failed to get nonexistent property "' . $name . '"');
- }
+ public static $db;
- // ###################################################################
/**
- * Returns the first value of the given type in the variable registry
- *
- * @return mixed
+ * BSInput
+ * @var object
*/
- public function getType($class)
- {
- $class = 'BS' . $class;
- foreach ($this AS $object)
- {
- if ($object instanceof $class)
- {
- return $object;
- }
- }
- }
+ public static $input;
- // ###################################################################
/**
- * Returns all the objects in the registry by iterating over it
- *
- * @return array
+ * BSTemplate
+ * @var object
*/
- public function allObjects()
- {
- $registry = array();
- foreach ($this AS $key => $value)
- {
- $registry[$key] = $value;
- }
- return $registry;
- }
+ public static $template;
}
?>
\ No newline at end of file