本文整理汇总了PHP中alias_import函数的典型用法代码示例。如果您正苦于以下问题:PHP alias_import函数的具体用法?PHP alias_import怎么用?PHP alias_import使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了alias_import函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoload
/**
+----------------------------------------------------------
* 系统自动加载ThinkPHP类库
* 并且支持配置自动加载路径
+----------------------------------------------------------
* @param string $classname 对象类名
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
*/
public static function autoload($classname)
{
// 检查是否存在别名定义
if (alias_import($classname)) {
return;
}
// 自动加载当前项目的Actioon类和Model类
if (substr($classname, -5) == "Model") {
require_cache(LIB_PATH . 'Model/' . $classname . '.class.php');
} elseif (substr($classname, -6) == "Action") {
require_cache(LIB_PATH . 'Action/' . $classname . '.class.php');
} else {
// 根据自动加载路径设置进行尝试搜索
if (C('APP_AUTOLOAD_PATH')) {
$paths = explode(',', C('APP_AUTOLOAD_PATH'));
foreach ($paths as $path) {
if (import($path . $classname . '.class.php')) {
// 如果加载类成功则返回
return;
}
}
}
}
return;
}
示例2: S
function S($name, $value = '', $expire = '', $type = '', $options = null)
{
static $_cache = array();
alias_import('Cache');
//取得缓存对象实例
$cache = Cache::getInstance($type, $options);
if ('' !== $value) {
if (is_null($value)) {
// 删除缓存
$result = $cache->rm($name);
if ($result) {
unset($_cache[$type . '_' . $name]);
}
return $result;
} else {
// 缓存数据
$cache->set($name, $value, $expire);
$_cache[$type . '_' . $name] = $value;
}
return;
}
if (isset($_cache[$type . '_' . $name])) {
return $_cache[$type . '_' . $name];
}
// 获取缓存数据
$value = $cache->get($name);
$_cache[$type . '_' . $name] = $value;
return $value;
}
示例3: __call
/**
* 执行不存在的函数时会自动执行的魔术方法
* 编辑器上传时执行php脚本及ispost或_post等都会执行这个方法
* @access protected
* @param string $method 方法名
* @param mixed $args 方法参数
* @return mixed
*/
public function __call($method, $args)
{
//调用的方法不存在
if (strcasecmp($method, METHOD) == 0) {
//执行插件如uploadify|ueditor|keditor
if (alias_import($method)) {
require alias_import($method);
} elseif (method_exists($this, "__empty")) {
//执行空方法_empty
$this->__empty($args);
} else {
//方法不存在时抛出404错误页
_404('模块中不存在方法' . $method);
}
}
}
示例4: __call
/**
* 执行不存在的函数时会自动执行的魔术方法
* 编辑器上传时执行php脚本及ispost或_post等都会执行这个方法
* @param $action 方法名
* @param $args 方法参数
*/
public function __call($action, $args)
{
//调用的方法不存在
if (strcasecmp($action, ACTION) == 0) {
//执行插件如uploadify|ueditor|keditor
if (alias_import($action)) {
require alias_import($action);
} elseif (method_exists($this, "__empty")) {
//执行空方法_empty
$this->__empty($args);
} else {
//方法不存在时抛出404错误页
_404('控制器中不存在动作' . $action);
}
}
}
示例5: compile
/**
* 编译核心文件
* @access private
*/
private static function compile()
{
if (DEBUG) {
is_file(TEMP_FILE) and unlink(TEMP_FILE);
return;
}
$compile = '';
//常量编译
$_define = get_defined_constants(true);
foreach ($_define['user'] as $n => $d) {
if ($d == '\\') {
$d = "'\\\\'";
} else {
$d = is_int($d) ? intval($d) : "'{$d}'";
}
$compile .= "defined('{$n}') OR define('{$n}',{$d});";
}
$files = array(HDPHP_CORE_PATH . 'App.class.php', HDPHP_CORE_PATH . 'Controller.class.php', HDPHP_CORE_PATH . 'Debug.class.php', HDPHP_CORE_PATH . 'Hook.class.php', HDPHP_CORE_PATH . 'HDPHP.class.php', HDPHP_CORE_PATH . 'HdException.class.php', HDPHP_CORE_PATH . 'Log.class.php', HDPHP_CORE_PATH . 'Route.class.php', HDPHP_FUNCTION_PATH . 'Functions.php', HDPHP_DRIVER_PATH . 'Cache/Cache.class.php', HDPHP_DRIVER_PATH . 'Cache/CacheFactory.class.php', HDPHP_DRIVER_PATH . 'Cache/CacheFile.class.php', HDPHP_DRIVER_PATH . 'Db/Db.class.php', HDPHP_DRIVER_PATH . 'Db/DbFactory.class.php', HDPHP_DRIVER_PATH . 'Db/DbInterface.class.php', HDPHP_DRIVER_PATH . 'Db/DbMysql.class.php', HDPHP_DRIVER_PATH . 'Model/Model.class.php', HDPHP_DRIVER_PATH . 'Model/RelationModel.class.php', HDPHP_DRIVER_PATH . 'Model/ViewModel.class.php', HDPHP_DRIVER_PATH . 'View/ViewHd.class.php', HDPHP_DRIVER_PATH . 'View/View.class.php', HDPHP_DRIVER_PATH . 'View/ViewFactory.class.php', HDPHP_DRIVER_PATH . 'View/ViewCompile.class.php', HDPHP_EXTEND_PATH . 'Tool/Dir.class.php');
foreach ($files as $f) {
$con = compress(trim(file_get_contents($f)));
$compile .= substr($con, -2) == '?>' ? trim(substr($con, 5, -2)) : trim(substr($con, 5));
}
//HDPHP框加核心配置
$compile .= 'C(' . var_export(C(), true) . ');';
//HDPHP框架核心语言包
$compile .= 'L(' . var_export(L(), true) . ');';
//别名配置文件
$compile .= 'alias_import(' . var_export(alias_import(), true) . ');';
//编译内容
$compile = '<?php if(!defined(\'DEBUG\'))exit;' . $compile . 'HDPHP::init();App::run();?>';
//创建Boot编译文件
if (is_dir(TEMP_PATH) or dir_create(TEMP_PATH) and is_writable(TEMP_PATH)) {
return file_put_contents(TEMP_FILE, compress($compile));
}
header("Content-type:text/html;charset=utf-8");
exit("<div style='border:solid 1px #dcdcdc;padding:30px;'>请修改" . realpath(dirname(TEMP_PATH)) . "目录权限</div>");
}
示例6: autoload
/**
* The system automatically loads the library Senthot
* And Support configure automatic loading path
* @param string $class Object class name
* @return void
*/
public static function autoload($class)
{
// Check for alias definitions
if (alias_import($class)) {
return;
}
$libPath = defined('BASE_LIB_PATH') ? BASE_LIB_PATH : LIB_PATH;
$group = defined('GROUP_NAME') && C('APP_GROUP_MODE') == 0 ? GROUP_NAME . '/' : '';
$file = $class . '.class.php';
if (substr($class, -8) == 'Behavior') {
// Load Behavior
if (require_array(array(CORE_PATH . 'Behavior/' . $file, ADDONS_PATH . 'Behavior/' . $file, LIB_PATH . 'Behavior/' . $file, $libPath . 'Behavior/' . $file), true) || defined('MODE_NAME') && require_cache(MODE_PATH . ucwords(MODE_NAME) . '/Behavior/' . $file)) {
return;
}
} elseif (substr($class, -5) == 'Model') {
// Load Model
if (require_array(array(LIB_PATH . 'Model/' . $group . $file, $libPath . 'Model/' . $file, ADDONS_PATH . 'Model/' . $file), true)) {
return;
}
} elseif (substr($class, -6) == 'Action') {
// Load Controller
if (require_array(array(LIB_PATH . 'Action/' . $group . $file, $libPath . 'Action/' . $file, ADDONS_PATH . 'Action/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 5) == 'Cache') {
// Load cache drive
if (require_array(array(ADDONS_PATH . 'Driver/Cache/' . $file, CORE_PATH . 'Driver/Cache/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 2) == 'Db') {
// Load database driver
if (require_array(array(ADDONS_PATH . 'Driver/Db/' . $file, CORE_PATH . 'Driver/Db/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 8) == 'Template') {
// Loading template engine driven
if (require_array(array(ADDONS_PATH . 'Driver/Template/' . $file, CORE_PATH . 'Driver/Template/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 6) == 'TagLib') {
// Load tag library drive
if (require_array(array(ADDONS_PATH . 'Driver/TagLib/' . $file, CORE_PATH . 'Driver/TagLib/' . $file), true)) {
return;
}
}
// According to the settings automatically load path try to search
$paths = explode(',', C('APP_AUTOLOAD_PATH'));
foreach ($paths as $path) {
if (import($path . '.' . $class)) {
// If you load the class success, returns
return;
}
}
}
示例7: buildApp
function buildApp()
{
// 读取运行模式
if (defined('MODE_NAME')) {
// 读取模式的设置
$mode = (include MODE_PATH . strtolower(MODE_NAME) . '.php');
} else {
$mode = array();
}
if (isset($mode['config'])) {
// 加载模式配置文件
C(is_array($mode['config']) ? $mode['config'] : (include $mode['config']));
} else {
// 加载底层惯例配置文件
C(include THINK_PATH . 'Conf/convention.php');
}
// 加载项目配置文件
if (is_file(CONF_PATH . 'config.php')) {
C(include CONF_PATH . 'config.php');
}
//[sae]惯例配置
C(include SAE_PATH . 'Conf/convention_sae.php');
//[sae]专有配置
if (is_file(CONF_PATH . 'config_sae.php')) {
C(include CONF_PATH . 'config_sae.php');
}
// 加载框架底层语言包
L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
// 加载模式系统行为定义
if (C('APP_TAGS_ON')) {
if (isset($mode['extends'])) {
C('extends', is_array($mode['extends']) ? $mode['extends'] : (include $mode['extends']));
} else {
//[sae] 默认加载系统行为扩展定义
C('extends', include SAE_PATH . 'Conf/tags.php');
}
}
// 加载应用行为定义
if (isset($mode['tags'])) {
C('tags', is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags']));
} elseif (is_file(CONF_PATH . 'tags.php')) {
// 默认加载项目配置目录的tags文件定义
C('tags', include CONF_PATH . 'tags.php');
}
$compile = '';
// 读取核心编译文件列表
if (isset($mode['core'])) {
$list = $mode['core'];
} else {
$list = array(SAE_PATH . 'Common/functions.php', SAE_PATH . 'Common/sae_functions.php', SAE_PATH . 'Lib/Core/Log.class.php', SAE_PATH . 'Lib/Core/Sms.class.php', CORE_PATH . 'Core/Dispatcher.class.php', CORE_PATH . 'Core/App.class.php', SAE_PATH . 'Lib/Core/Action.class.php', CORE_PATH . 'Core/View.class.php');
}
// 项目追加核心编译列表文件
if (is_file(CONF_PATH . 'core.php')) {
$list = array_merge($list, include CONF_PATH . 'core.php');
}
foreach ($list as $file) {
if (is_file($file)) {
require_cache($file);
$compile .= compile($file);
}
}
// 加载项目公共文件
if (is_file(COMMON_PATH . 'common.php')) {
include COMMON_PATH . 'common.php';
// 编译文件
$compile .= compile(COMMON_PATH . 'common.php');
}
// 加载模式别名定义
if (isset($mode['alias'])) {
$alias = is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias']);
} else {
//[sae] 别名文件
$alias = (include SAE_PATH . 'Conf/alias.php');
}
alias_import($alias);
$compile .= 'alias_import(' . var_export($alias, true) . ');';
// 加载项目别名定义
if (is_file(CONF_PATH . 'alias.php')) {
$alias = (include CONF_PATH . 'alias.php');
alias_import($alias);
$compile .= 'alias_import(' . var_export($alias, true) . ');';
}
// 部署模式下面生成编译文件
build_runtime_cache($compile);
return;
}
示例8: autoload
/**
+----------------------------------------------------------
* 系统自动加载ThinkPHP类库
* 并且支持配置自动加载路径
+----------------------------------------------------------
* @param string $class 对象类名
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
*/
public static function autoload($class)
{
// 检查是否存在别名定义
if (alias_import($class)) {
return;
}
if (substr($class, -8) == 'Behavior') {
// 加载行为
if (require_cache(CORE_PATH . 'Behavior/' . $class . '.class.php') || require_cache(EXTEND_PATH . 'Behavior/' . $class . '.class.php') || require_cache(LIB_PATH . 'Behavior/' . $class . '.class.php') || defined('MODE_NAME') && require_cache(MODE_PATH . ucwords(MODE_NAME) . '/Behavior/' . $class . '.class.php')) {
return;
}
} elseif (substr($class, -5) == 'Model') {
// 加载模型
if (require_cache(LIB_PATH . 'Model/' . $class . '.class.php') || require_cache(EXTEND_PATH . 'Model/' . $class . '.class.php')) {
return;
}
} elseif (substr($class, -6) == 'Action') {
// 加载控制器
if (defined('GROUP_NAME') && require_cache(LIB_PATH . 'Action/' . GROUP_NAME . '/' . $class . '.class.php') || require_cache(LIB_PATH . 'Action/' . $class . '.class.php') || require_cache(EXTEND_PATH . 'Action/' . $class . '.class.php')) {
return;
}
}
// 根据自动加载路径设置进行尝试搜索
$paths = explode(',', C('APP_AUTOLOAD_PATH'));
foreach ($paths as $path) {
if (import($path . '.' . $class)) {
// 如果加载类成功则返回
return;
}
}
}
示例9: load_runtime_file
function load_runtime_file()
{
// 加载系统基础函数库
require THINK_PATH . 'Common/common.php';
// 读取核心编译文件列表
$list = array(CORE_PATH . 'Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php');
// 加载模式文件列表
foreach ($list as $key => $file) {
if (is_file($file)) {
require_cache($file);
}
}
// 加载系统类库别名定义
alias_import(include THINK_PATH . 'Conf/alias.php');
// 检查项目目录结构 如果不存在则自动创建
if (!is_dir(LIB_PATH)) {
// 创建项目目录结构
build_app_dir();
} elseif (!is_dir(CACHE_PATH)) {
// 检查缓存目录
check_runtime();
} elseif (APP_DEBUG) {
// 调试模式切换删除编译缓存
if (is_file(RUNTIME_FILE)) {
unlink(RUNTIME_FILE);
}
}
}
示例10: autoload
/**
* 系统自动加载ThinkPHP类库
* 并且支持配置自动加载路径
* @param string $class 对象类名
* @return void
*/
public static function autoload($class)
{
// 检查是否存在别名定义
if (alias_import($class)) {
return;
}
$libPath = defined('BASE_LIB_PATH') ? BASE_LIB_PATH : LIB_PATH;
$group = defined('GROUP_NAME') && C('APP_GROUP_MODE') == 0 ? GROUP_NAME . '/' : '';
$file = $class . '.class.php';
if (substr($class, -8) == 'Behavior') {
// 加载行为
if (require_array(array(CORE_PATH . 'Behavior/' . $file, EXTEND_PATH . 'Behavior/' . $file, LIB_PATH . 'Behavior/' . $file, $libPath . 'Behavior/' . $file), true) || defined('MODE_NAME') && require_cache(MODE_PATH . ucwords(MODE_NAME) . '/Behavior/' . $file)) {
return;
}
} elseif (substr($class, -5) == 'Model') {
// 加载模型
if (require_array(array(LIB_PATH . 'Model/' . $group . $file, $libPath . 'Model/' . $file, EXTEND_PATH . 'Model/' . $file), true)) {
return;
}
} elseif (substr($class, -6) == 'Action') {
// 加载控制器
if (require_array(array(LIB_PATH . 'Action/' . $group . $file, $libPath . 'Action/' . $file, EXTEND_PATH . 'Action/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 5) == 'Cache') {
// 加载缓存驱动
if (require_array(array(EXTEND_PATH . 'Driver/Cache/' . $file, CORE_PATH . 'Driver/Cache/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 2) == 'Db') {
// 加载数据库驱动
if (require_array(array(EXTEND_PATH . 'Driver/Db/' . $file, CORE_PATH . 'Driver/Db/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 8) == 'Template') {
// 加载模板引擎驱动
if (require_array(array(EXTEND_PATH . 'Driver/Template/' . $file, CORE_PATH . 'Driver/Template/' . $file), true)) {
return;
}
} elseif (substr($class, 0, 6) == 'TagLib') {
// 加载标签库驱动
if (require_array(array(EXTEND_PATH . 'Driver/TagLib/' . $file, CORE_PATH . 'Driver/TagLib/' . $file), true)) {
return;
}
}
// 根据自动加载路径设置进行尝试搜索
$paths = explode(',', C('APP_AUTOLOAD_PATH'));
foreach ($paths as $path) {
if (import($path . '.' . $class)) {
// 如果加载类成功则返回
return;
}
}
}
示例11: compile
/**
* 编译核心文件
* @access private
*/
private static function compile()
{
$boot = TEMP_PATH . TEMP_FILE;
if (DEBUG) {
is_file($boot) and unlink($boot);
return;
}
$compile = '';
//常量编译
$_define = get_defined_constants(true);
foreach ($_define['user'] as $n => $d) {
if ($d == '\\') {
$d = "'\\\\'";
} else {
$d = is_int($d) ? intval($d) : "'{$d}'";
}
$compile .= "defined('{$n}') OR define('{$n}',{$d});";
}
$files = array(HDPHP_CORE_PATH . 'HDPHP.class.php', HDPHP_CORE_PATH . 'HdphpException.class.php', HDPHP_CORE_PATH . 'App.class.php', HDPHP_CORE_PATH . 'Route.class.php', HDPHP_CORE_PATH . 'Log.class.php', HDPHP_CORE_PATH . 'Event.class.php', HDPHP_FUNCTION_PATH . 'Functions.php', HDPHP_FUNCTION_PATH . 'Common.php', HDPHP_DRIVER_PATH . 'View/View.class.php', HDPHP_DRIVER_PATH . 'View/Hd/Compile.class.php');
foreach ($files as $f) {
$con = compress(trim(file_get_contents($f)));
$compile .= substr($con, -2) == '?>' ? trim(substr($con, 5, -2)) : trim(substr($con, 5));
}
$compile .= 'C(' . var_export(C(), true) . ');';
$compile .= 'L(' . var_export(L(), true) . ');';
$compile .= 'alias_import(' . var_export(alias_import(), true) . ');';
self::$_compile = $compile;
}
示例12: load_runtime_file
function load_runtime_file()
{
//[sae] 加载系统基础函数库
require SAE_PATH . 'Common/common.php';
//[sae] 读取核心编译文件列表
$list = array(SAE_PATH . 'Lib/Extend/Tool/SaeCacheBuilder/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php');
// 加载模式文件列表
foreach ($list as $key => $file) {
if (is_file($file)) {
require_cache($file);
}
}
//[sae] 加载系统类库别名定义
alias_import(include SAE_PATH . 'Conf/alias.php');
if (!is_dir(LIB_PATH)) {
// 创建项目目录结构
build_app_dir();
} elseif (!is_dir(CACHE_PATH)) {
// 检查缓存目录
check_runtime();
}
//[saebuilder] 去掉了删除缓存的操作
}
示例13: alias_import
<?php
// +----------------------------------------------------------------------
// | ThinkPHP
// +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$
// 导入别名定义
alias_import(array('Db' => THINK_PATH . '/Lib/Think/Db/Db.class.php', 'DbMysql' => THINK_PATH . '/Lib/Think/Db/Driver/DbMysql.class.php', 'ThinkTemplate' => THINK_PATH . '/Template/ThinkTemplate.class.php', 'Template' => THINK_PATH . '/Lib/Think/Util/Template.class.php', 'TagLib' => THINK_PATH . '/Template/TagLib.class.php', 'TagLibCx' => THINK_PATH . '/Template/TagLib/TagLibCx.class.php', 'AdvModel' => THINK_PATH . '/Lib/Think/Core/Model/AdvModel.class.php', 'Cache' => THINK_PATH . '/Lib/Think/Util/Cache.class.php', 'HtmlCache' => THINK_PATH . '/Lib/Think/Util/HtmlCache.class.php', 'Cookie' => THINK_PATH . '/Lib/Think/Util/Cookie.class.php', 'Session' => THINK_PATH . '/Lib/Think/Util/Session.class.php', 'Service' => CORE_PATH . '/sociax/Service.class.php', 'Model' => CORE_PATH . '/sociax/Model.class.php', 'Action' => CORE_PATH . '/sociax/Action.class.php', 'View' => CORE_PATH . '/sociax/View.class.php', 'Widget' => CORE_PATH . '/sociax/Widget.class.php', 'Api' => CORE_PATH . '/sociax/Api.class.php', 'AddonsInterface' => CORE_PATH . '/sociax/addons/AddonsInterfaces.class.php', 'NormalAddons' => CORE_PATH . '/sociax/addons/NormalAddons.class.php', 'SimpleAddons' => CORE_PATH . '/sociax/addons/SimpleAddons.class.php', 'Addons' => CORE_PATH . '/sociax/Addons.class.php', 'Hooks' => CORE_PATH . '/sociax/addons/Hooks.class.php', 'AbstractAddons' => CORE_PATH . '/sociax/addons/AbstractAddons.class.php'));
示例14: autoload
public static function autoload($className)
{
$class = ucfirst($className) . '.class.php';
if (substr($className, -5) == 'Model') {
if (require_array(array(HDPHP_DRIVER_PATH . 'Model/' . $class, MODEL_PATH . $class, COMMON_MODEL_PATH . $class))) {
return;
}
} elseif (substr($className, -7) == 'Control') {
if (require_array(array(HDPHP_CORE_PATH . $class, CONTROL_PATH . $class, COMMON_CONTROL_PATH . $class))) {
return;
}
} elseif (substr($className, 0, 2) == 'Db') {
if (require_array(array(HDPHP_DRIVER_PATH . 'Db/' . $class))) {
return;
}
} elseif (substr($className, 0, 5) == 'Cache') {
if (require_array(array(HDPHP_DRIVER_PATH . 'Cache/' . $class))) {
return;
}
} elseif (substr($className, 0, 4) == 'View') {
if (require_array(array(HDPHP_DRIVER_PATH . 'View/' . $class))) {
return;
}
} elseif (substr($className, -5) == 'Event') {
if (require_array(array(EVENT_PATH . $class, COMMON_EVENT_PATH . $class))) {
return;
}
} elseif (substr($className, -3) == 'Tag') {
if (require_array(array(TAG_PATH . $class, COMMON_TAG_PATH . $class))) {
return;
}
} elseif (alias_import($className)) {
return;
} elseif (require_array(array(LIB_PATH . $class, COMMON_LIB_PATH . $class, HDPHP_CORE_PATH . $class, HDPHP_EXTEND_PATH . $class, HDPHP_EXTEND_PATH . '/Tool/' . $class))) {
return;
}
$msg = "Class {$className} not found";
Log::write($msg);
halt($msg);
}
示例15: __call
/**
* 执行不存在的函数时会自动执行的魔术方法
* 编辑器上传时执行php脚本及ispost或_post等都会执行这个方法
* @access protected
* @param string $method 方法名
* @param mixed $args 方法参数
* @return mixed
*/
public function __call($method, $args)
{
//调用的方法不存在
if (strcasecmp($method, METHOD) == 0) {
//执行插件如uploadify|ueditor|keditor
if (alias_import($method)) {
include alias_import($method);
//执行空方法_empty
} elseif (method_exists($this, "__empty")) {
$this->__empty($args);
//方法不存在时抛出404错误页
} else {
_404("控制器中不存在方法" . $method);
}
//调用方法含有Model时,即$this->userModel()
} else {
if (substr(ucfirst($method), -5) == "Model") {
if (strstr($method, '_')) {
$method = str_replace("_", "/", substr($method, 0, -5));
return $this->kmodel($method);
} else {
return $this->kmodel(substr($method, 0, -5));
}
} else {
switch (strtolower($method)) {
//检测请求类型ispost等方法
case 'ispost':
case 'isget':
case 'ishead':
case 'isdelete':
case 'isput':
return strtolower($_SERVER['REQUEST_METHOD']) == strtolower(substr($method, 2));
//获得数据并执行相应的安全处理
//获得数据并执行相应的安全处理
case '_get':
$data =& $_GET;
break;
case '_post':
$data =& $_POST;
break;
case '_request':
$data =& $_REQUEST;
break;
case '_files':
$data =& $_FILES;
break;
case '_session':
$data =& $_SESSION;
break;
case '_cookie':
$data =& $_COOKIE;
break;
case '_server':
$data =& $_SERVER;
break;
case '_globals':
$data =& $GLOBALS;
break;
default:
throw_exception($method . '方法不存在');
}
//没有执行参数如$this->_get()时返回所有数据
if (!isset($args[0])) {
return $data;
//如果存在数据如$this->_get("page"),$_GET中存在page数据
} else {
if (isset($data[$args[0]])) {
//要获得参数如$this->_get("page")中的page
$value = $data[$args[0]];
//如果没有函数时,直接返回值
if (count($args) > 1 && empty($args[1])) {
return $value;
}
//对参数进行过滤的函数
$filterFunc = isset($args[1]) ? $args[1] : C("FILTER_FUNCTION");
//参数过滤函数
$funcArr = explode(",", $filterFunc);
//是否存在过滤函数
if ($funcArr) {
//对数据进行过滤处理
foreach ($funcArr as $func) {
if (!function_exists($func)) {
continue;
}
$value = is_array($value) ? array_map($func, $value) : $func($value);
}
$data[$args[0]] = $value;
return $value;
}
return $value;
//不存在值时返回第2个参数,例:$this->_get("page")当$_GET['page']不存在page时执行
} else {
//.........这里部分代码省略.........