]>
src.bluestatic.org Git - isso.git/blob - kernel.php
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 debug Variable for debug mode
41 * @var debuginfo Listing of all debug notices
42 * @var modules An array of loaded framework modules
44 var $version = '[#]version[#]';
47 var $application = '';
49 var $debuginfo = array();
50 var $modules = array();
55 function Shared_Object_Framework()
57 set_error_handler(array(&$this, '_error_handler'));
58 $this->modules
['kernel'] = 'Shared Object Framework Core';
62 * Prepares a path for being set as the sourcepath
64 * @param str Source path or URL
66 * @return str Prepared source path
68 function fetch_sourcepath($source)
70 if (substr($source, strlen($source) - 1) != '/')
78 * Loads a framework extension
80 * @param str Name of the framework
82 function load($framework)
84 if (!$this->is_loaded($framework))
86 $newobj = $this->locate($framework);
87 $this->$newobj['OBJ'] = new $newobj['CLASS']();
88 $GLOBALS["$newobj[OBJ]"] =& $this->$newobj['OBJ'];
89 $this->modules
["$framework"] = $newobj['OBJECT'];
94 * Includes a framework module. Module definitions need three variables:
95 * class, object, and obj. Class is the name of the class, object is
96 * the name human-readable name, and obj is the name that the module
97 * should be initialized as; this is used in class extensions.
99 * @param str Name of the framework
101 * @return array List of initialization variables
103 function locate($framework)
105 require_once($this->sourcepath . $framework . '.php');
106 return array('CLASS' => $CLASS, 'OBJECT' => $OBJECT, 'OBJ' => $OBJ);
110 * Prints a list of all currently loaded framework modules
112 * @param bool Return the data as an array?
114 * @return mixed HTML output or an array of loaded modules
116 function show_modules($return = false)
120 return $this->modules;
124 $output = "\n\n
<ul
>\n\t<li
>";
125 $output .= implode("</li
>\n\t<li
>", $this->modules);
126 $output .= "</li
>\n</ul
>\n\n";
127 $this->_message('Loaded Modules', $output, 1);
132 * Verifies to see if a framework has been loaded
134 * @param str Framework name
136 * @return bool Whether or not the framework has been loaded
138 function is_loaded($framework)
140 if (isset($this->modules["$framework"]))
151 * Prints an ISSO message
153 * @param str The title of the message
154 * @param str The content of the message
155 * @param int Type of message to be printed
156 * @param bool Return the output?
158 * @return mixed Output or null
160 function _message($title, $message, $type, $return = false)
185 $output = "\n<br />\n<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"500\" style=\"background-color: $color; font-family: Verdana, sans-serif; font-size: 12px;\">";
186 $output .= "\n<tr style=\"color: $font\">\n\t<td><strong>$prefix: $title</strong></td>\n</tr>";
187 $output .= "\n<tr style=\"background-color: #FFFFFF\">\n\t<td>$message</td>\n</tr>\n</table>\n<br />\n";
200 * Custom error handler for ISSO
202 * @param int Error number
203 * @param str Error message string
204 * @param str File that contains the error
205 * @param str The line number of the error
206 * @param str The active symbol table at which point the error occurred
208 function _error_handler($errno, $errstr, $errfile, $errline)
229 $errstr .= " in <strong>$errfile</strong> on line <strong>$errline</strong>";
231 $this->_message($title, $errstr, 3);
235 * Logs a debug message for verbose output
239 function debug($message)
243 $this->debuginfo
[] = $message;
249 * Global callback used for module calls back to the kernel
251 $_isso = new Shared_Object_Framework();
254 * Wrapper for ternary operator that has to be in the global scope
256 * @param expr Expression
257 * @param mixed If the expression is true
258 * @param mixed If the expression is false
260 * @return mixed True or false data
262 function iff($condition, $iftrue, $iffalse = null)
264 return ($condition) ? ($iftrue) : ($iffalse);
267 /*=====================================================================*\
268 || ###################################################################
271 || ###################################################################
272 \*=====================================================================*/