From 58cce94cd152977476e4be3065374d83aa5c3063 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 14 Jan 2005 03:36:04 +0000 Subject: [PATCH] Added $apppath global variable, changed procedure for ISSO::fetch_sourcepath(), finished module loading system, added ISSO::locate to load a framework, added ISSO::is_loaded to check and see if a framework is loaded. --- kernel.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/kernel.php b/kernel.php index 266aea7..f089409 100644 --- a/kernel.php +++ b/kernel.php @@ -35,11 +35,13 @@ class Shared_Object_Framework * * @var version ISSO version * @var sourcepath The location of the framework sources + * @var appath The path to the application's location * @var application The name of the application that is using the framework * @var modules An array of loaded framework modules */ var $version = '[#]version[#]'; var $sourcepath = ''; + var $apppath = ''; var $application = ''; var $modules = array(); @@ -49,7 +51,7 @@ class Shared_Object_Framework function Shared_Object_Framework() { set_error_handler(array(&$this, '_error_handler')); - $this->modules[] = 'Shared Object Framework Core'; + $this->modules['kernel'] = 'Shared Object Framework Core'; } /** @@ -61,9 +63,9 @@ class Shared_Object_Framework */ function fetch_sourcepath($source) { - if (substr($source, strlen($source) - 1) == '/') + if (substr($source, strlen($source) - 1) != '/') { - $source = substr($source, 0, strlen($source) - 1); + $source .= '/'; } return $source; } @@ -75,13 +77,31 @@ class Shared_Object_Framework */ function load($framework) { - if (!in_array($framework, $this->modules)) + if (!$this->is_loaded($framework)) { - require_once($this->sourcepath . $framework); - $this->modules[] = $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 * @@ -104,6 +124,25 @@ class Shared_Object_Framework } } + /** + * 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 * @@ -189,6 +228,8 @@ class Shared_Object_Framework } } +$_isso = new Shared_Object_Framework(); + /*=====================================================================*\ || ################################################################### || # $HeadURL$ -- 2.43.5