Update version.php to 3.3.0
[isso.git] / App.php
diff --git a/App.php b/App.php
index 54215d57f5e165df865c727e966c66071acfa288..98b04bdb0c50508403044306dba2e16a12d1e53b 100644 (file)
--- a/App.php
+++ b/App.php
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # Blue Static ISSO Framework
-|| # Copyright (c)2002-2007 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'))
@@ -36,11 +36,11 @@ 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}))
                                {
@@ -51,245 +51,85 @@ if ((bool)ini_get('register_globals') === true)
        }
 }
 
-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)2002 - 2007, 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;
-       
-       /**
-       * Application name
-       * @var  string
-       */
-       private $application = 'Unknown ISSO Project';
-       
-       /**
-       * Application path
-       * @var  string
-       */
-       private $appPath;
-       
-       /**
-       * Application version
-       * @var  string
-       */
-       private $appVersion;
-       
-       /**
-       * Web path
-       * @var  string
-       */
-       private $webPath;
-       
-       /**
-       * 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 application name
-       *
-       * @param        string  Application name
-       */
-       public static function SetApplication($name)
-       {
-               self::_Instance()->application = $name;
-       }
-       
-       // ###################################################################
-       /**
-       * Gets the application name
-       *
-       * @return       string  Application name
-       */
-       public static function GetApplication()
-       {
-               return self::_Instance()->application;
-       }
-       
-       // ###################################################################
-       /**
-       * Sets the application's working path
-       *
-       * @param        string  Path
-       */
-       public static function SetAppPath($path)
-       {
-               self::_Instance()->appPath = BSFunctions::FetchSourcePath($path);
-       }
-       
-       // ###################################################################
-       /**
-       * Returns the path to the application
-       *
-       * @return       string  Application path
-       */
-       public static function GetAppPath()
-       {
-               return self::_Instance()->appPath;
-       }
-       
-       // ###################################################################
-       /**
-       * Sets the application version
-       *
-       * @param        string  Application version
-       */
-       public static function SetAppVersion($vers)
-       {
-               self::_Instance()->appVersion = $vers;
-       }
-       
-       // ###################################################################
-       /**
-       * Gets the application version
-       *
-       * @return       string  Application version
-       */
-       public static function GetAppVersion()
-       {
-               return self::_Instance()->appVersion;
-       }
-       
-       // ###################################################################
-       /**
-       * Sets the application's web path, which is the full path from the
-       * server's web root
-       *
-       * @param        string  Path
-       */
-       public static function SetWebPath($path)
-       {
-               self::_Instance()->webPath = BSFunctions::FetchSourcePath($path);
-       }
-       
-       // ###################################################################
-       /**
-       * Returns the web path to the application
-       *
-       * @return       string  Application's web path
-       */
-       public static function GetWebPath()
-       {
-               return self::_Instance()->webPath;
-       }
+       {}
        
-       // ###################################################################
        /**
-       * Sets the debug state
-       *
-       * @param        bool    Debug mode on?
-       */
-       public static function SetDebug($debug)
-       {
-               self::_Instance()->debug = $debug;
-       }
-       
-       // ###################################################################
-       /**
-       * Gets the debug mode state
-       *
-       * @return       bool    Debug mode on?
-       */
-       public static function GetDebug()
+        * Sets the debug state
+        *
+        * @param       bool    Debug mode on?
+        */
+       public static function set_debug($debug)
        {
-               return self::_Instance()->debug;
+               self::$debug = $debug;
        }
        
-       // ###################################################################
        /**
-        * Returns the registry object without it ever being able to be cleared
-        * or unset
+        * Gets the debug mode state
         *
-        * @return      StdClass
+        * @return      bool    Debug mode on?
         */
-       public static function Registry()
+       public static function get_debug()
        {
-               return self::_Instance()->registry;
+               return self::$debug;
        }
        
-       // ###################################################################
        /**
-       * Adds a debug message to the array. This only works when debug mode
-       * is enabled.
-       *
-       * @param        string  Debug message
-       */
-       public static function Debug($msg)
+        * 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
-       */
-       public static function GetDebugList()
+        * 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>";
                }
@@ -297,125 +137,31 @@ class BSApp
        }
        
        // ###################################################################
+       // modules
+       
        /**
-       * Loads the specified module.
-       *
-       * @param        string  Module name
-       *
-       * @return       object  Instantiated module
-       */
-       public static function LoadModule($name)
-       {
-               if (self::GetDebug())
-               {
-                       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 RequiredModules($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)2002 - 2007, 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