Code

99f096951c46f53e1c1b66cdd1b354d4d24890b2
[gosa.git] / include / autoload.inc
1 <?php
3 /* This function needs the pre-defined class mapping from autoload-data.inc */
4 require_once("autoload-data.inc");
6 /* FIXME: this does not belong here */
7 require_once("smarty/Smarty.class.php");
9 /* Set BASE_DIR for the complete code as constant */
10 define('BASE_DIR', dirname(dirname(__FILE__)));
13 /**
14  * AutoloadException to handle exceptions that happen inside
15  * the autoloader module.
16  */
17 class AutoloadException extends Exception {
18         public function __construct($message, $code = 0) {
19                 parent::__construct($message, $code);
20         }
21 }
24 /**
25  * Loads the requested class from the filesystem.
26  * @param string $class_name
27  * @return -
28  */
29 function __autoload($class_name) {
30         global $class_mapping;
32         /* Load data for class locations */
34         if (isset($class_mapping[$class_name])){
35                 require_once(BASE_DIR."/".$class_mapping[$class_name]);
36         } else {
37                 eval("class $class_name {}");
38                 throw new AutoloadException(sprintf(_("Cannot load class '%s'!"), $class_name));
39         }
40 }
42 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
43 ?>