1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* KumbiaPHP web & app Framework |
4
|
|
|
* |
5
|
|
|
* LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the new BSD license that is bundled |
8
|
|
|
* with this package in the file LICENSE.txt. |
9
|
|
|
* It is also available through the world-wide-web at this URL: |
10
|
|
|
* http://wiki.kumbiaphp.com/Licencia |
11
|
|
|
* If you did not receive a copy of the license and are unable to |
12
|
|
|
* obtain it through the world-wide-web, please send an email |
13
|
|
|
* to [email protected] so we can send you a copy immediately. |
14
|
|
|
* |
15
|
|
|
* @category Kumbia |
16
|
|
|
* @package Core |
17
|
|
|
* @copyright Copyright (c) 2005 - 2016 Kumbia Team (http://www.kumbiaphp.com) |
18
|
|
|
* @license http://wiki.kumbiaphp.com/Licencia New BSD License |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
// @see Util |
22
|
|
|
require CORE_PATH.'kumbia/util.php'; |
23
|
|
|
|
24
|
|
|
// Autocarga de clases |
25
|
|
|
function kumbia_autoload($class) |
26
|
|
|
{ |
27
|
|
|
// Optimizando carga |
28
|
|
|
static $classes; |
29
|
|
|
if (!isset($classes)) { |
30
|
|
|
$classes = array ( |
31
|
|
|
'ActiveRecord' => APP_PATH.'libs/active_record.php', |
32
|
|
|
'Load' => CORE_PATH.'kumbia/load.php', |
33
|
|
|
'KumbiaException' => CORE_PATH.'kumbia/kumbia_exception.php', |
34
|
|
|
'KumbiaRouter' => CORE_PATH.'kumbia/kumbia_router.php', |
35
|
|
|
'KumbiaFacade' => CORE_PATH.'kumbia/kumbia_facade.php' |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
if (array_key_exists($class, $classes)) { |
39
|
|
|
return include $classes[$class]; |
40
|
|
|
} |
41
|
|
|
// PSR0 |
42
|
|
|
if (strpos($class, '\\')) { |
43
|
|
|
return kumbia_autoload_vendor($class); |
44
|
|
|
} |
45
|
|
|
// for legacy apps |
46
|
|
|
if ($class == 'Flash') { |
47
|
|
|
return kumbia_autoload_helper('Flash'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// Convert to smallcase |
51
|
|
|
$sclass = Util::smallcase($class); |
52
|
|
|
if (is_file(APP_PATH."models/$sclass.php")) { |
53
|
|
|
return include APP_PATH."models/$sclass.php"; |
54
|
|
|
} |
55
|
|
|
if (is_file(APP_PATH."libs/$sclass.php")) { |
56
|
|
|
return include APP_PATH."libs/$sclass.php"; |
57
|
|
|
} |
58
|
|
|
if (is_file(CORE_PATH."libs/$sclass/$sclass.php")) { |
59
|
|
|
return include CORE_PATH."libs/$sclass/$sclass.php"; |
60
|
|
|
} |
61
|
|
|
// Perhaps is PEAR, zend framework 1, ... |
62
|
|
|
return kumbia_autoload_vendor($class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
function kumbia_autoload_vendor($class) |
66
|
|
|
{ |
67
|
|
|
//Autoload PSR0 |
68
|
|
|
$psr0 = dirname(CORE_PATH).'/vendor/'.str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class).'.php'; |
69
|
|
|
if (is_file($psr0)) { |
70
|
|
|
include $psr0; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
function kumbia_autoload_helper($class) |
75
|
|
|
{ |
76
|
|
|
$sclass = Util::smallcase($class); |
77
|
|
|
if (is_file(APP_PATH."extensions/helpers/$sclass.php")) { |
78
|
|
|
return include APP_PATH."extensions/helpers/$sclass.php"; |
79
|
|
|
} |
80
|
|
|
if (is_file(CORE_PATH."extensions/helpers/$sclass.php")) { |
81
|
|
|
return include CORE_PATH."extensions/helpers/$sclass.php"; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
// Registrar la autocarga |
87
|
|
|
spl_autoload_register('kumbia_autoload'); |
88
|
|
|
|