2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 define('ERR_FATAL', E_USER_ERROR
);
14 define('ERR_ERROR', E_USER_WARNING
);
15 define('ERR_WARNING', E_USER_NOTICE
);
18 * Iris Studios Shared Object Framework (ISSO)
20 * This framework allows a common backend to be used amongst all Iris
21 * Studios applications and can is built to be abstract and flexible.
22 * The base framework handles all loading and module management.
24 * @author Iris Studios, Inc.
25 * @copyright Copyright ©2003 - [#]year[#], Iris Studios, Inc.
29 class Shared_Object_Framework
32 * Global environment variables
34 * This is where we keep the global variables that are used within the shared framework
36 * @var version ISSO version
37 * @var sourcepath The location of the framework sources
38 * @var appath The path to the application's location
39 * @var application The name of the application that is using the framework
40 * @var modules An array of loaded framework modules
42 var $version = '[#]version[#]';
45 var $application = '';
46 var $modules = array();
51 function Shared_Object_Framework()
53 set_error_handler(array(&$this, '_error_handler'));
54 $this->modules
['kernel'] = 'Shared Object Framework Core';
58 * Prepares a path for being set as the sourcepath
60 * @param str Source path or URL
62 * @return str Prepared source path
64 function fetch_sourcepath($source)
66 if (substr($source, strlen($source) - 1) != '/')
74 * Loads a framework extension
76 * @param str Name of the framework
78 function load($framework)
80 if (!$this->is_loaded($framework))
82 $newobj = $this->locate($framework);
83 $this->$newobj['OBJ'] = new $newobj['CLASS']();
84 $GLOBALS["$newobj[OBJ]"] =& $this->$newobj['OBJ'];
85 $this->modules
["$framework"] = $newobj['OBJECT'];
90 * Includes a framework module. Module definitions need three variables:
91 * class, object, and obj. Class is the name of the class, object is
92 * the name human-readable name, and obj is the name that the module
93 * should be initialized as; this is used in class extensions.
95 * @param str Name of the framework
97 * @return array List of initialization variables
99 function locate($framework)
101 require_once($this->sourcepath
. $framework . '.php');
102 return array('CLASS' => $CLASS, 'OBJECT' => $OBJECT, 'OBJ' => $OBJ);
106 * Prints a list of all currently loaded framework modules
108 * @param bool Return the data as an array?
110 * @return mixed HTML output or an array of loaded modules
112 function show_modules($return = false
)
116 return $this->modules
;
120 $output = "\n\n<ul>\n\t<li>";
121 $output .= implode("</li>\n\t<li>", $this->modules
);
122 $output .= "</li>\n</ul>\n\n";
123 $this->_message('Loaded Modules', $output, 1);
128 * Verifies to see if a framework has been loaded
130 * @param str Framework name
132 * @return bool Whether or not the framework has been loaded
134 function is_loaded($framework)
136 if (isset($this->modules
["$framework"]))
147 * Prints an ISSO message
149 * @param str The title of the message
150 * @param str The content of the message
151 * @param int Type of message to be printed
152 * @param bool Return the output?
154 * @return mixed Output or null
156 function _message($title, $message, $type, $return = false
)
181 $output = "\n<br />\n<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"500\" style=\"background-color: $color\">";
182 $output .= "\n<tr style=\"color: $font\">\n\t<td><strong>$prefix: $title</strong></td>\n</tr>";
183 $output .= "\n<tr style=\"background-color: #FFFFFF\">\n\t<td>$message</td>\n</tr>\n</table>\n<br />\n";
196 * Custom error handler for ISSO
198 * @param int Error number
199 * @param str Error message string
200 * @param str File that contains the error
201 * @param str The line number of the error
202 * @param str The active symbol table at which point the error occurred
204 function _error_handler($errno, $errstr, $errfile, $errline)
225 $errstr .= " in <strong>$errfile</strong> on line <strong>$errline</strong>";
227 $this->_message($title, $errstr, 3);
231 $_isso = new Shared_Object_Framework();
233 /*=====================================================================*\
234 || ###################################################################
237 || ###################################################################
238 \*=====================================================================*/