/** * 自动加载类对应的文件 * * @param string $package_name 类名 * * @return void */ public static function autoload($package_name) { $u_name = APP_NAME . 'al:' . $package_name; if (KISS::enableCache() && apc_exists($u_name)) { $filename = apc_fetch($u_name); include_once $filename; self::$_load_array[$package_name] = $filename; self::$_new_class_found = true; return; } $package_array = preg_split('/_/', $package_name); $file_array[] = join('/', $package_array); $file_array[] = strtolower($file_array[0]); array_push($package_array, 'class.' . array_pop($package_array)); $file_array[] = join('/', $package_array); $file_array[] = strtolower($file_array[2]); $path_array = explode(PATH_SEPARATOR, ini_get('include_path')); foreach ($path_array as $path) { foreach ($file_array as $file) { $filename = "{$path}/{$file}.php"; if (file_exists($filename)) { include_once $filename; if (KISS::enableCache()) { apc_store($u_name, $filename); } self::$_load_array[$package_name] = $filename; self::$_new_class_found = true; return; } } } }
static function getSystemPath($pPathName, $pWithSlash = false) { $u_name = APP_NAME . $pPathName; if (KISS::enableCache() && apc_exists($u_name)) { return apc_fetch($u_name); } if (isset(self::$_data['path'][$pPathName])) { return self::$_data['path'][$pPathName]; } $registry =& KISS_Framework_Registry::instance(); $default_config = $registry->getEntry('default'); $user_config = $registry->getEntry('user_defined'); $paths = array((string) $user_config->system_path->{$pPathName}, $registry->getEntry('root_path') . DIRECTORY_SEPARATOR . (string) $user_config->system_path->{$pPathName}, (string) $default_config->system_path->{$pPathName}, $registry->getEntry('root_path') . DIRECTORY_SEPARATOR . (string) $default_config->system_path->{$pPathName}); foreach ($paths as $path) { if (file_exists($path) && is_writable($path)) { self::$_data['path'][$pPathName] = realpath($path); if (KISS::enableCache()) { apc_store($u_name, realpath($path)); } return realpath($path); } } }