private function ExecuteAction() { //禁止使用模块检测 if (in_array(MODULE, C('http.deny_module'))) { throw new Exception(MODULE . '模块禁止使用'); } $class = MODULE . '\\controller\\' . CONTROLLER; //控制器不存在 if (!class_exists($class)) { throw new Exception("{$class} 不存在"); } $controller = new $class(); //执行动作 try { $action = new ReflectionMethod($controller, ACTION); if ($action->isPublic()) { //控制器前置钩子 $this->app->make('Hook')->listen('controller_begin'); //执行动作 $result = call_user_func_array(array($controller, ACTION), Route::getArg()); if (IS_AJAX) { Response::ajax($result); } else { die($result); } } else { throw new ReflectionException('动作不存在'); } } catch (ReflectionException $e) { $action = new ReflectionMethod($controller, '__call'); $action->invokeArgs($controller, array(ACTION, '')); } }
public function carianStaf($carian) { if (Response::ajax()) { if ($carian != '') { return 1; } else { return 0; } } }
/** * Ajax输出 * @param $data 数据 * @param string $type 数据类型 text html xml json */ public function ajax($data, $type = "JSON") { Response::ajax($data, $type); }
/** * 错误页面 * * @param string $message 提示内容 * @param string $url 跳转URL * @param int $time 跳转时间 * @param string $tpl 模板文件 */ public function error($message = '出错了', $url = '', $time = 2) { if (IS_AJAX) { Response::ajax(array('status' => 0, 'message' => $message)); } else { $url = U($url); $url = $url ? "window.location.href='" . $url . "'" : "window.location.href='" . __HISTORY__ . "'"; $this->with(array('message' => $message, 'url' => $url, 'time' => $time)); $this->make(Config::get('view.error')); } exit; }
/** * Ajax输出 * @param $data 数据 * @param string $type 数据类型 text html xml json */ protected function ajax($data, $type = "JSON") { Response::ajax($data, $type); }
/** * Ajax调用返回的数据处理 * * 返回json数据,供前台ajax调用 * * @access public * * @param boolean $status 执行状态 : true/false 或 1/0 * @param string $info 返回信息 * @param array $data 返回数据,支持数组 * * @return string */ public function ajax($status = true, $info = null, $data = array()) { return Response::ajax($status, $info, $data); }