Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

autoload.inc.php

Go to the documentation of this file.
00001 <?
00014 class Autoload
00015 {
00019     private static $classes = null;
00020 
00024     private static $functions = null;
00025     
00029     private function __construct()
00030     {
00031     }
00032 
00037     public static function init()
00038     {
00039         //only init if its new.
00040         if (self::$classes === null)
00041         {
00042             self::$classes = array();
00043         
00044             //basejumper is the main one =)
00045             self::register('BaseJumper', 'basejumper.inc.php');
00046 
00047             //here are all our modules!!
00048             self::register('BaseAlert', 'modules/base-alert.inc.php');
00049             self::register('BaseAlerts', 'modules/base-alerts.inc.php');
00050             self::register('BaseAdmin', 'modules/base-admin.inc.php');
00051             self::register('BaseCalendar', 'modules/base-calendar.inc.php');
00052             self::register('BaseComment', 'modules/base-comment.inc.php');
00053             self::register('BaseCrons', 'modules/base-crons.inc.php');
00054             self::register('BaseEvent', 'modules/base-event.inc.php');
00055             self::register('BaseForum', 'modules/base-forum.inc.php');
00056             self::register('BaseForums', 'modules/base-forums.inc.php');
00057             self::register('BaseForumThread', 'modules/base-forum-thread.inc.php');
00058             self::register('BaseForumThreads', 'modules/base-forum-threads.inc.php');
00059             self::register('BaseGallery', 'modules/base-gallery.inc.php');
00060             self::register('BaseGroup', 'modules/base-group.inc.php');
00061             self::register('BaseImage', 'modules/base-image.inc.php');
00062             self::register('BaseInvitation', 'modules/base-invitation.inc.php');
00063             self::register('BaseInvitations', 'modules/base-invitations.inc.php');
00064             self::register('BaseInbox', 'modules/base-inbox.inc.php');
00065             self::register('BaseMain', 'modules/base-main.inc.php');
00066             self::register('BaseMap', 'modules/base-map.inc.php');
00067             self::register('BaseMessage', 'modules/base-message.inc.php');
00068             self::register('BaseModule', 'modules/base-module.inc.php');
00069             self::register('BaseObject', 'modules/base-object.inc.php');
00070             self::register('BaseOutbox', 'modules/base-outbox.inc.php');
00071             self::register('BaseRPSGame', 'modules/base-rps-game.inc.php');
00072             self::register('BaseTags', 'modules/base-tags.inc.php');
00073             self::register('BaseTags', 'modules/base-tags.inc.php');
00074             self::register('BaseThread', 'modules/base-thread.inc.php');
00075             self::register('BaseTicket', 'modules/base-ticket.inc.php');
00076             self::register('BaseUser', 'modules/base-user.inc.php');
00077             self::register('BaseUserAction', 'modules/base-user-action.inc.php');
00078             self::register('BaseUserActions', 'modules/base-user-actions.inc.php');
00079             self::register('MyManager', 'modules/my-manager.inc.php');
00080             self::register('MyModule', 'modules/my-module.inc.php');
00081             self::register('MyObject', 'modules/my-object.inc.php');
00082             self::register('ObjectManager', 'modules/object-manager.inc.php');
00083             
00084             //our stub modules
00085             self::register('Ticket', 'modules/stubs/ticket.inc.php');
00086 
00087             //stuff for side boxes..
00088             self::register('BaseBox', 'boxes/base-box.inc.php');
00089             self::register('DateBox', 'boxes/date-box.inc.php');
00090             self::register('CalendarBox', 'boxes/calendar-box.inc.php');
00091             self::register('HelpBox', 'boxes/help-box.inc.php');
00092             self::register('LoginBox', 'boxes/login-box.inc.php');
00093 
00094             //stuff for our form class
00095             self::register('Form', 'form/form.inc.php');
00096             self::register('SyncForm', 'form/sync.inc.php');
00097             self::register('FCKeditor', 'FCKeditor/fckeditor.php');
00098 
00099             //our templates..
00100             self::register('BaseTemplate', 'templates/base-template.inc.php');
00101             self::register('BlankTemplate', 'templates/blank-template.inc.php');
00102             self::register('HTMLTemplate', 'templates/html-template.inc.php');
00103             self::register('JSONTemplate', 'templates/json-template.inc.php');
00104             self::register('XMLTemplate', 'templates/xml-template.inc.php');
00105 
00106             //our caching classes
00107             self::register('CacheBot', 'cache.inc.php');
00108             self::register('EasyCache', 'cache.inc.php');
00109             self::register('NoCache', 'cache.inc.php');
00110             self::register('EasyMemCache', 'cache.inc.php');
00111             self::register('EasyFileCache', 'cache.inc.php');
00112             self::register('EasyDBCache', 'cache.inc.php');
00113 
00114             //utilities are pretty handy.
00115             self::register('Config', 'config.inc.php');
00116             self::register('Img', 'image.inc.php');
00117             self::register('JSON', 'json.inc.php');
00118             self::register('Linkify', 'linkify.inc.php');
00119             self::register('Mail', 'mail.inc.php');
00120             self::register('SMS', 'sms.inc.php');
00121             self::register('Site', 'site.inc.php');
00122             self::register('Time', 'time.inc.php');
00123             self::register('Util', 'util.inc.php');
00124 
00125             //errors are good(?) too..
00126             self::register('ErrorHandler', 'error.inc.php');
00127             self::register('PageError', 'exceptions.inc.php');
00128             self::register('DbException', 'exceptions.inc.php');
00129 
00130             //our REST classes!
00131             self::register('REST', 'REST/rest.inc.php');
00132             self::register('Amazon', 'REST/amazon.inc.php');
00133             self::register('Geocode', 'REST/geocode.inc.php');
00134             self::register('Traffic', 'REST/traffic.inc.php');
00135             self::register('YahooWeather', 'REST/weather.inc.php');
00136 
00137             //our PEAR classes
00138             self::register("XML_Serializer", "XML/Serializer.php");
00139 
00140             //here we have our YMenu stuff
00141             self::register("YMenu", "yahoo/menu.php");
00142             self::register("YMenuItem", "yahoo/menu.php");
00143         }
00144 
00145         //what about our functions?
00146         if (self::$functions === null)
00147         {
00148             self::$functions = array();
00149 
00150             //add our other loaders.
00151             self::registerFunction('Form::autoload');
00152             self::registerFunction('BaseJumper::autoload');
00153         }
00154     }
00155 
00162     public static function register($class, $path)
00163     {
00164         self::$classes[strtolower($class)] = $path;
00165     }
00166 
00176     public static function registerFunction($function)
00177     {
00178         self::$functions[] = $function;
00179         self::$functions = array_unique(self::$functions);
00180     }
00181     
00190     public static function load($class)
00191     {
00192         //if its in our list of classes, include it.
00193         if (self::$classes[strtolower($class)])
00194             require_once(self::$classes[strtolower($class)]);
00195         //nope, maybe one of our other autoload guys has it.
00196         else if (count(self::$functions))
00197         {
00198             //loop thru all our functions.
00199             foreach (self::$functions AS $function)
00200             {
00201                 //look until we find it.
00202                 if (!class_exists($class, false))
00203                     eval("$function('$class');");
00204             }
00205         }
00206     }
00207 }
00208 
00209 //define our autoload function
00210 if (!function_exists('__autoload'))
00211 {
00216     function __autoload($class)
00217     {
00218         Autoload::load($class);
00219     }
00220 }
00221 //oops, autoload already defined... throw an error
00222 else
00223 {
00224     throw new Exception("__autoload() already defined.  If you want BaseJumper to
00225     work, register your autoload function with Autoload:registerFunction() and
00226     use the built-in __autoload()");
00227 }
00230 //initialize our autoload system.
00231 Autoload::init();
00232 ?>

Generated on Fri Oct 27 12:26:39 2006 for BaseJumper by doxygen 1.3.9.1