/** * The autoload function is used to load class files when needed * * This function will be used to load any class files when they * are required instead of in every file. * * It searchs the configuration array for the common class directory * as well as the class directory specifically for this project. * @global array * @param string $class_name The name of the class being loaded */ function i2ce_class_autoload($class_name) { $class_file = I2CE::getfileSearch()->search('CLASSES', $class_name . '.php'); $class_found = false; if ($class_file) { require_once $class_file; if (class_exists($class_name, false) || interface_exists($class_name, false)) { $class_found = true; } else { I2CE::raiseError("Defintion for class {$class_name} is not contained in {$class_file}", E_USER_WARNING); } } if (!$class_found) { $classes = I2CE_ModuleFactory::callHooks('autoload_search_for_class', $class_name); $count = count($classes); foreach ($classes as $class) { if (!is_string($class) || strlen($class) == 0) { continue; } if (false === eval($class)) { I2CE::raiseError("While looking for {$class_name}, could not parse: {$class}"); } if (class_exists($class_name, false)) { $class_found = true; break; } } } if (!$class_found) { $debug = debug_backtrace(); $msg = "Cannot find the defintion for class ({$class_name})"; if (array_key_exists(1, $debug) && array_key_exists('line', $debug[1])) { $msg .= "called from line " . $debug[1]['line'] . ' of file ' . $debug[1]['file']; } $msg .= "\nSearch Path is:\n" . print_r(I2CE::getFileSearch()->getSearchPath('CLASSES'), true); // I2CE::raiseError( $msg, E_USER_NOTICE); } }