-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.ini.php
More file actions
50 lines (47 loc) · 1.5 KB
/
common.ini.php
File metadata and controls
50 lines (47 loc) · 1.5 KB
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
<?php
/**
* The common.ini.php file contains the function and methods used by the CoreAPI.
* It should be required when using the CoreAPI.
*
* @link https://github.com/thenderson21/CorAPI/
* @copyright Copyright © 2013 Todd Henderson
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
* @author Todd Henderson <todd@todd-henderson.me>
* @version $Id$
* @since 8/13/13
* @package CoreAPI
*/
//Setup if not all ready included.
if (! defined('COREAPI')){
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'constants.ini.php');
/**
* Magic function that attempt to load undefined class.
*
* @param string The name of class load.
* @return void
*/
function coreAPI_autoload($class) {
$dirPath = COREAPI_ROOT;
//class directories
$directorys = array(
$dirPath . DIRECTORY_SEPARATOR . 'Libraries',
$dirPath . DIRECTORY_SEPARATOR . 'Models',
$dirPath . DIRECTORY_SEPARATOR . 'Controllers',
$dirPath . DIRECTORY_SEPARATOR . 'Views'
);
if (strpos($class, "\\") !== false) {
$namespaced = explode("\\", $class);
$class = end($namespaced);
}
//for each directory
foreach ($directorys as $directory) {
//see if the file exsists
if (is_file($directory . DIRECTORY_SEPARATOR . $class . '.class.php')) {
require_once $directory . DIRECTORY_SEPARATOR . $class . '.class.php';
//Only require the class once, so quit after to save effort, if you have more, then name them something else.
return;
}
}
}
spl_autoload_register('coreAPI_autoload');
}