From c50a83cd8d9387aa221236aa261ebcc7e71bdd41 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 2 Aug 2011 18:31:42 +0200 Subject: [PATCH] Introducing a semiautoload. Enables autoload for classes that are not in lib/ --- lib/base.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index 98c6fbb8e3..d3097f7ee8 100644 --- a/lib/base.php +++ b/lib/base.php @@ -20,9 +20,22 @@ * */ +/** + * Class that is a namespace for all global OC variables + */ +class OC{ + /** + * Assoziative array for autoloading. classname => filename + */ + public static $CLASSPATH = array(); +} + // Get rid of this stupid require_once OC_... -function OC_autoload($className) { - if(strpos($className,'OC_')===0) { +function OC_autoload($className){ + if(array_key_exists($className,OC::$CLASSPATH)){ + require_once OC::$CLASSPATH[$className]; + } + elseif(strpos($className,'OC_')===0){ require_once strtolower(str_replace('_','/',substr($className,3)) . '.php'); } }