本文整理汇总了PHP中Request::isAjax方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::isAjax方法的具体用法?PHP Request::isAjax怎么用?PHP Request::isAjax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::isAjax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error
/**
* @brief error 错误输出函数
*
* @param $errCode 错误码
*
* @return void
*/
public static function error($errCode, $errMessage = '')
{
// 清除输出缓存
@ob_end_clean();
if (array_key_exists($errCode, self::$_httpCode)) {
$errMessage = self::$_httpCode[$errCode];
@header("HTTP/1.1 {$errCode} {$errMessage}");
@header("status: {$errCode} {$errMessage}");
}
if (Request::isAjax()) {
// 如果是 Ajax 请求
if (defined('LOGX_DEBUG')) {
$r = array('success' => FALSE, 'message' => $errMessage);
} else {
$r = array('success' => FALSE, 'message' => _t('Sorry, some error occured.'));
}
self::ajaxReturn($r);
} else {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
echo "<title>{$errCode}</title>";
echo '<style type="text/css">';
echo 'body { background: #f7fbe9; font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana; }';
echo '#error { background: #59c6e0; width: 360px; margin: 100px auto; color: #fff; padding: 10px; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }';
echo 'h1 { padding: 10px; margin: 0; font-size: 36px; }';
echo 'p { padding: 0 20px 20px 20px; margin: 0; font-size: 12px; }';
echo 'img { padding: 0 0 5px 300px; }';
echo '</style></head><body><div id="error">';
echo "<h1>{$errCode}</h1><p>{$errMessage}</p>";
echo '<img src="' . LOGX_PATH . '?591E-D5FC-8065-CD36-D3E8-E45C-DB86-9197" /></div></body></html>';
}
exit;
}
示例2: before_filter
/**
* Common code for all actions: set default layout and page title.
*
* @param type $action
* @param type $args
*/
function before_filter(&$action, &$args)
{
$this->validate_args($args, array('option', 'option'));
parent::before_filter($action, $args);
// set correct encoding if this is an ajax-call
if (Request::isAjax()) {
header('Content-Type: text/html; charset=Windows-1252');
}
$this->flash = Trails_Flash::instance();
// set default layout
$layout = $GLOBALS['template_factory']->open('layouts/base');
$this->set_layout($layout);
// Set help keyword for Stud.IP's user-documentation and page title
PageLayout::setHelpKeyword('Basis.Forum');
PageLayout::setTitle($_SESSION['SessSemName']['header_line'] . ' - ' . _('Forum'));
$this->AVAILABLE_DESIGNS = array('web20', 'studip');
if ($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'] && $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'] != '/') {
$this->picturepath = $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'] . '/' . $this->dispatcher->trails_root . '/img';
} else {
$this->picturepath = '/' . $this->dispatcher->trails_root . '/img';
}
// we want to display the dates in german
setlocale(LC_TIME, 'de_DE@euro', 'de_DE', 'de', 'ge');
// the default for displaying timestamps
$this->time_format_string = "%a %d. %B %Y, %H:%M";
$this->time_format_string_short = "%d.%m.%Y, %H:%M";
$this->template_factory = new Flexi_TemplateFactory(dirname(__FILE__) . '/../templates');
//$this->check_token();
ForumVisit::setVisit($this->getId());
if (Request::int('page')) {
ForumHelpers::setPage(Request::int('page'));
}
$this->seminar_id = $this->getId();
}
示例3: displayFooter
/**
* Display the HTML-Footer
*/
public function displayFooter()
{
if (!Request::isAjax()) {
include 'tpl/tpl.Frontend.footer.php';
}
Error::getInstance()->footer_sent = true;
}
示例4: BuildFromList
public function BuildFromList($list_id = null)
{
$Lid = is_null($list_id) ? $this->post->list_id : $list_id;
if (is_numeric($Lid)) {
#Retorna o array com os posts da TL
$timeline = Timeline::build_from_list($this->session->user->id, $Lid, new stdClass());
$posts = $this->render($timeline);
} elseif ($Lid == 'bookmarks') {
#Retorna os favoritos do usuário
$favs = $this->MyFavorites(new stdClass());
$posts = $this->render($favs);
} elseif ($Lid == 'all_posts') {
$posts = Timeline::get_public_posts(new stdClass());
$posts = $this->render($posts);
} else {
$posts = $this->SimpleBuild();
}
if (Request::isAjax()) {
header("Content-type:text/html; charset=utf-8");
if (is_array($posts)) {
echo implode('', $posts);
} else {
die('{status: "FAIL"}');
}
} else {
return is_array($posts) ? $posts : false;
}
}
示例5: testMethods
public function testMethods()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
$Request = new Request();
$this->assertTrue($Request->isPost());
$this->assertFalse($Request->isGet());
$this->assertEqual($Request->method(), 'POST');
$_SERVER['REQUEST_METHOD'] = 'GET';
$Request = new Request();
$this->assertFalse($Request->isPost());
$this->assertTrue($Request->isGet());
$this->assertEqual($Request->method(), 'GET');
$this->assertFalse($Request->isAjax());
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->assertTrue($Request->isAjax());
}
示例6: run
public function run()
{
$route = $this->router->match($this->request);
if ($route === false) {
$actionName = self::ACTION_NOT_FOUND;
} else {
$actionName = $route->getName();
}
if (!$this->actions->has($actionName)) {
throw new \Exception(sprintf('Action %s not found', $actionName));
}
$this->store->setFileName($actionName);
if ($this->request->isAjax()) {
$this->view->setRenderType(View::RENDER_JSON);
} else {
$this->view->setContentView('error');
}
$action = $this->actions->get($actionName);
call_user_func_array($action, array($this));
if (is_callable($this->postAction)) {
call_user_func_array($this->postAction, array($this));
}
$this->response->setContent($this->view->render());
$this->response->send();
}
示例7: _errorResponse
/**
* Send JSON error message
*
* @return string
*/
protected function _errorResponse($msg)
{
if (Request::isAjax()) {
Response::jsonError($msg);
} else {
Response::redirect(Request::url(array('index'), true));
}
}
示例8: new_topic_action
public function new_topic_action()
{
Navigation::activateItem('/course/schedule/dates');
if (Request::isAjax()) {
PageLayout::setTitle(_("Thema hinzufügen"));
}
$this->date = new CourseDate(Request::option("termin_id"));
$this->course = Course::findCurrent();
}
示例9: listAction
public function listAction()
{
if (Request::isAjax() && Request::isPost()) {
$user = UsersPDO::get(AuthModel::getUserName());
$receiverId = $_POST['receiverId'];
$model = new ChatModel($user['Id']);
$result = $model->getChat($receiverId);
$this->renderJSON($result);
}
}
示例10: isLogin
private static function isLogin()
{
if (!($userid = session_get('USERID'))) {
if (Request::isAjax()) {
exit(json_encode(array('code' => -1, 'msg' => 'please login')));
} else {
exit(app::run(array('home', 'page', 'login')));
}
}
return $userid;
}
示例11: edit_action
function edit_action($area_id)
{
ForumPerm::check('edit_area', $this->getId(), $area_id);
if (Request::isAjax()) {
ForumEntry::update($area_id, studip_utf8decode(Request::get('name')), studip_utf8decode(Request::get('content')));
$this->render_json(array('content' => ForumEntry::killFormat(ForumEntry::killEdit(studip_utf8decode(Request::get('content'))))));
} else {
ForumEntry::update($area_id, Request::get('name'), Request::get('content'));
$this->flash['messages'] = array('success' => _('Die Änderungen am Bereich wurden gespeichert.'));
$this->redirect(PluginEngine::getLink('coreforum/index/index'));
}
}
示例12: dumpError
function dumpError($sql)
{
if (Kennel::$ROOT_URL && !Request::isAjax()) {
// Non-ajax HTTP Request
$table = XML::element('table', null, array('border' => '1'));
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, array('colspan' => '2'), "SQL query returned an error");
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, null, 'query');
$td = XML::element('td', $tr, null, syntax::mysql($sql));
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, null, 'error');
$td = XML::element('td', $tr, null, mysql_error(self::$CONN));
$full_backtrace = debug_backtrace();
$backtrace = $full_backtrace[2];
if (isset($backtrace['file'])) {
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, null, 'file');
$td = XML::element('td', $tr, null, $backtrace['file']);
}
if (isset($backtrace['line'])) {
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, null, 'line');
$td = XML::element('td', $tr, null, $backtrace['line']);
}
if ($backtrace['class']) {
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, null, 'class');
$td = XML::element('td', $tr, null, $backtrace['class']);
}
if ($backtrace['function']) {
$tr = XML::element('tr', $table);
$th = XML::element('th', $tr, null, 'function');
$td = XML::element('td', $tr, null, $backtrace['function']);
}
echo $table;
} else {
// Ajax or cli
$default = "[0m";
echo "\n[1;30;41m";
// red background, bold
echo "SQL query returned an error:{$default}\n";
$lines = explode("\n", $sql);
foreach ($lines as $line) {
echo " {$line}\n";
}
$error = mysql_error(self::$CONN);
echo "[31m";
// red
echo "{$error}{$default}\n\n";
}
die;
}
示例13: execute
function execute()
{
$user = ConnectionHelper::userLogin();
$model = new connectionFeedbackAnswerModel();
$data = Request::post('answer');
$data['user'] = $user['id'];
$result = $model->add($data);
if (!Request::isAjax()) {
Request::redirect('/profile/support/' . $data['ticket'] . '/');
}
return $result ? 'success' : 'error';
}
示例14: __construct
public function __construct()
{
if (Request::isAjax()) {
Render::setReply(['reply' => false, 'message' => self::$_content]);
} else {
Layout::renderMenu(false);
Layout::renderFooter(false);
Layout::loadContent(self::$_content);
if (!Layout::haveContent()) {
Layout::putContent(self::$_content);
}
}
}
示例15: Auth
function Auth()
{
if (!Sentry::check()) {
if (Request::isAjax()) {
Response::headers()->set('Content-Type', 'application/json');
Response::setBody(json_encode(array('success' => false, 'message' => 'Session expired or unauthorized access.', 'code' => 401)));
App::stop();
} else {
$redirect = Request::getResourceUri();
Response::redirect(App::urlFor('login') . '?redirect=' . base64_encode($redirect));
}
}
}