forked from Minds/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
51 lines (45 loc) · 1.2 KB
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
if (!defined('__MINDS_ROOT__')) {
define('__MINDS_ROOT__', dirname(__FILE__));
}
// prep core classes to be autoloadable
spl_autoload_register('_minds_autoload');
/**
* Autoload classes
*
* @param string $class The name of the class
*
* @return void
* @throws Exception
* @access private
*/
function _minds_autoload($class)
{
global $CONFIG;
if (file_exists(__MINDS_ROOT__."/classes/$class.php")) {
include(__MINDS_ROOT__."/classes/$class.php");
return true;
}
if (isset($CONFIG->classes[$class])) {
include($CONFIG->classes[$class]);
return true;
}
$file = dirname(__FILE__) . '/'. preg_replace('/minds/i', '', str_replace('\\', '/', $class), 1) . '.php';
//echo $file;
if (file_exists($file)) {
require_once $file;
return true;
}
//plugins follow a different path (new style)
$file = str_replace('/Plugin/', '/../plugins/', $file);
if (file_exists($file)) {
require_once $file;
return true;
}
//plugins follow a different path (old style)
$file = str_replace('/plugin/', '/../plugins/', $file);
if (file_exists($file)) {
require_once $file;
return true;
}
}