99 lines
2.5 KiB
PHP
99 lines
2.5 KiB
PHP
<?php
|
||
defined('IN_IA') or exit('Access Denied');
|
||
|
||
|
||
function load() {
|
||
static $loader;
|
||
if(empty($loader)) {
|
||
$loader = new Loader();
|
||
}
|
||
return $loader;
|
||
}
|
||
|
||
|
||
class Loader {
|
||
// 缓存数组
|
||
private $cache = array();
|
||
// 加载指定的函数文件,并在$cache中做好已经加载成功的标识
|
||
function func($name) {
|
||
global $_W;
|
||
if (isset($this->cache['func'][$name])) {
|
||
return true;
|
||
}
|
||
$file = IA_ROOT . '/framework/function/' . $name . '.func.php';
|
||
if (file_exists($file)) {
|
||
include $file;
|
||
$this->cache['func'][$name] = true;
|
||
return true;
|
||
} else {
|
||
trigger_error('Invalid Helper Function /framework/function/' . $name . '.func.php', E_USER_ERROR);
|
||
return false;
|
||
}
|
||
}
|
||
// 加载指定的model,并在$cache用cache['model']的方式标识好是否加载成功
|
||
function model($name) {
|
||
global $_W;
|
||
if (isset($this->cache['model'][$name])) {
|
||
return true;
|
||
}
|
||
$file = IA_ROOT . '/framework/model/' . $name . '.mod.php';
|
||
if (file_exists($file)) {
|
||
include $file;
|
||
$this->cache['model'][$name] = true;
|
||
return true;
|
||
} else {
|
||
trigger_error('Invalid Model /framework/model/' . $name . '.mod.php', E_USER_ERROR);
|
||
return false;
|
||
}
|
||
}
|
||
// 加载指定的类,并在$cache用cache['class']的方式标识好是否加载成功
|
||
function classs($name) {
|
||
global $_W;
|
||
if (isset($this->cache['class'][$name])) {
|
||
return true;
|
||
}
|
||
$file = IA_ROOT . '/framework/class/' . $name . '.class.php';
|
||
if (file_exists($file)) {
|
||
include $file;
|
||
$this->cache['class'][$name] = true;
|
||
return true;
|
||
} else {
|
||
trigger_error('Invalid Class /framework/class/' . $name . '.class.php', E_USER_ERROR);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function web($name) {
|
||
global $_W;
|
||
if (isset($this->cache['web'][$name])) {
|
||
return true;
|
||
}
|
||
$file = IA_ROOT . '/web/common/' . $name . '.func.php';
|
||
if (file_exists($file)) {
|
||
include $file;
|
||
$this->cache['web'][$name] = true;
|
||
return true;
|
||
} else {
|
||
trigger_error('Invalid Web Helper /web/common/' . $name . '.func.php', E_USER_ERROR);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// 加载指定的前端app函数,并在$cache用cache['app']的方式标识好是否加载成功
|
||
function app($name) {
|
||
global $_W;
|
||
if (isset($this->cache['app'][$name])) {
|
||
return true;
|
||
}
|
||
$file = IA_ROOT . '/app/common/' . $name . '.func.php';
|
||
if (file_exists($file)) {
|
||
include $file;
|
||
$this->cache['app'][$name] = true;
|
||
return true;
|
||
} else {
|
||
trigger_error('Invalid App Function /app/common/' . $name . '.func.php', E_USER_ERROR);
|
||
return false;
|
||
}
|
||
}
|
||
}
|