本文整理汇总了PHP中is_ajax_request函数的典型用法代码示例。如果您正苦于以下问题:PHP is_ajax_request函数的具体用法?PHP is_ajax_request怎么用?PHP is_ajax_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_ajax_request函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
include ROOT . "/library/browser/Browser.php";
$browser = new Browser();
if ($browser->getBrowser() == Browser::BROWSER_IE && $browser->getVersion() < 7) {
flash_error(lang("ie browser outdated"));
}
if (is_ajax_request()) {
$timezone = array_var($_GET, 'utz');
if ($timezone && $timezone != '') {
$usu = logged_user();
if ($usu instanceof Contact && $usu->isUser() && !$usu->getDisabled()) {
$usu->setTimezone($timezone);
$usu->save();
}
}
$this->redirectTo('dashboard', 'main_dashboard');
} else {
if (!(logged_user() instanceof Contact && logged_user()->isUser())) {
$this->redirectTo('access', 'login');
}
$this->setLayout("website");
$this->setTemplate(get_template_path("empty"));
}
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:25,代码来源:AccessController.class.php
示例2: header
<?php
include 'include/function.php';
include 'include/config.php';
include 'include/db.php';
if (!is_logged() or !isset($_GET['id'])) {
header("location: {$config['base_url']}");
exit;
}
$db = new DB();
if (isset($_POST['update'])) {
$id = $db->escape_string($_POST['id']);
$title = $db->escape_string($_POST['title']);
$artist = $db->escape_string($_POST['artist']);
$url = $db->escape_string($_POST['url']);
$db->query("UPDATE songs SET title='{$title}', artist='{$artist}', path='{$url}' WHERE id={$id}");
header('Location: ' . $config['base_url'] . 'dashboard?msg=update_success');
exit;
}
$db = new DB();
$row = $db->query("SELECT * FROM songs WHERE id={$_GET['id']}");
$row = $row->fetch_array();
$title = 'Update ' . $row['title'];
if (!is_ajax_request()) {
include './views/header.php';
}
include './views/update.php';
if (!is_ajax_request()) {
include './views/footer.php';
}
$db->close();
开发者ID:L200130083,项目名称:php-musicsharing-with-ajax,代码行数:31,代码来源:update.php
示例3: info_page
function info_page($info, $title = '系统消息')
{
if (is_ajax_request()) {
$layout = 'ajax';
} else {
$layout = 'web';
}
$data['top_title'] = $data['title'] = $title;
$data['info'] = $info;
render($data, $layout, 'info');
}
开发者ID:jfojfo,项目名称:LazyPHP,代码行数:11,代码来源:core.function.php
示例4: render
function render($view)
{
$viewFile = DUP_VIEWS_DIR . "/" . $view . ".php";
if (file_exists($viewFile)) {
if (!empty($this->layout) && !is_ajax_request()) {
ob_start();
include $viewFile;
$content_for_page = ob_get_contents();
ob_end_clean();
$layoutFile = DUP_VIEWS_DIR . "/layouts/" . $this->layout . ".php";
include $layoutFile;
} else {
include $viewFile;
}
}
}
开发者ID:hypenotic,项目名称:slowfood,代码行数:16,代码来源:view.class.php
示例5: output
function output()
{
global $lang;
if ($_SERVER['REQUEST_METHOD'] == 'POST' && method_exists($this, 'output_onpost_' . $_POST['form_name'])) {
return call_user_func(array($this, 'output_onpost_' . $_POST['form_name']));
}
$this->tpl['lang'] = $lang;
$this->tpl['link_restore_password'] = make_ref('/users', array("action" => "restore"));
$this->tpl['form_submit_url'] = make_ref('/users/loginform');
$output = template($this->tpl, __FILE__);
if (is_ajax_request()) {
print $output;
exit;
} else {
return $output;
}
}
开发者ID:southern-wind,项目名称:wind,代码行数:17,代码来源:users_loginform.php
示例6: render
public function render($data = NULL, $layout = NULL, $sharp = 'default')
{
if ($layout == null) {
if (is_ajax_request()) {
$layout = 'ajax';
} elseif (is_mobile_request()) {
//$layout = 'mobile';
$layout = 'web';
} else {
$layout = 'web';
}
}
$layout_file = AROOT . 'view/layout/' . $layout . '/' . $sharp . '.tpl.html';
if (file_exists($layout_file)) {
@extract($data);
require $layout_file;
}
}
开发者ID:wangfakang,项目名称:yaf-1,代码行数:18,代码来源:zlp.php
示例7: define
//Define the OS file path separator
define('DS', DIRECTORY_SEPARATOR);
//Define the base file system path to MicroMVC
define('SYSTEM_PATH', realpath(dirname(__FILE__)) . DS);
//Define the base file system path to libraries
define('LIBRARY_PATH', SYSTEM_PATH . 'libraries' . DS);
//Define the base file system path to functions
define('FUNCTION_PATH', SYSTEM_PATH . 'functions' . DS);
//Define the base file system path to modules
define('MODULE_PATH', SYSTEM_PATH . 'modules' . DS);
//Define the base file system path to logs
define('LOG_PATH', SYSTEM_PATH . 'logs' . DS);
//Include the common file to continue loading
require_once FUNCTION_PATH . 'common.php';
//Discover whether this is an AJAX request or not
define('AJAX_REQUEST', is_ajax_request());
//Discover the current domain for the whole script
define('DOMAIN', current_domain());
//Define the file system path to the current site
define('SITE_PATH', SYSTEM_PATH . DOMAIN . DS);
//The file system path of the site's cache folder
define('CACHE_PATH', SITE_PATH . 'cache' . DS);
//The file system path of the site's config folder
define('CONFIG_PATH', SITE_PATH . 'config' . DS);
//The file system path of the site's models folder
define('MODEL_PATH', SITE_PATH . 'models' . DS);
//The file system path of the site's uploads folder
define('UPLOAD_PATH', SITE_PATH . 'uploads' . DS);
//The file system path of the site's views folder
define('VIEW_PATH', SITE_PATH . 'views' . DS);
//Override the PHP error handler
开发者ID:stas,项目名称:facebook-ideas-app,代码行数:31,代码来源:index.php
示例8: session_start
<?php
session_start();
define('DS', DIRECTORY_SEPARATOR);
define('PATH', dirname(__FILE__) . DS);
define('DOC_ROOT', str_replace(DS, '/', realpath($_SERVER['DOCUMENT_ROOT'])));
header("Content-type:text/html; charset=utf-8");
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
$default_lang = 'uk';
if (isset($_REQUEST['lang'])) {
$_SESSION['install']['lang'] = $_REQUEST['lang'];
header('Location: ' . $_SERVER['SCRIPT_NAME']);
}
$is_lang_selected = isset($_SESSION['install']['lang']);
$lang = $is_lang_selected ? $_SESSION['install']['lang'] : $default_lang;
define('LANG', $lang);
include PATH . "functions.php";
include PATH . DS . 'languages' . DS . LANG . DS . "language.php";
$steps = array(array('id' => 'start', 'title' => LANG_STEP_START), array('id' => 'license', 'title' => LANG_STEP_LICENSE), array('id' => 'php', 'title' => LANG_STEP_PHP_CHECK), array('id' => 'paths', 'title' => LANG_STEP_PATHS), array('id' => 'database', 'title' => LANG_STEP_DATABASE), array('id' => 'site', 'title' => LANG_STEP_SITE), array('id' => 'admin', 'title' => LANG_STEP_ADMIN), array('id' => 'config', 'title' => LANG_STEP_CONFIG), array('id' => 'cron', 'title' => LANG_STEP_CRON), array('id' => 'finish', 'title' => LANG_STEP_FINISH));
$current_step = 0;
if (is_ajax_request()) {
$step = $steps[(int) $_POST['step']];
$is_submit = isset($_POST['submit']);
echo json_encode(run_step($step, $is_submit));
exit;
}
$step_result = run_step($steps[$current_step], false);
echo render('main', array('steps' => $steps, 'is_lang_selected' => $is_lang_selected, 'lang' => LANG, 'current_step' => $current_step, 'step_html' => $step_result['html']));
开发者ID:andriy85if,项目名称:instantcms-2.4.0-uk,代码行数:29,代码来源:index.php
示例9: execute_questions
function execute_questions()
{
$game = R::load('game', $_SESSION['quiz_id']);
if (quiz_has_expired($game)) {
finish_game($game);
redirect('result');
}
if (($question_id = find_first_unanswered_question(unserialize($game->answers))) == null) {
redirect('result');
}
$question = R::load('question', $question_id);
$answers = R::find('answer', 'question_id = ? ORDER BY RAND()', array($question_id));
$seconds_left = strtotime($game->started_at) - time() + QUIZ_TIMELIMIT;
ob_start();
if (is_ajax_request()) {
include_once dirname(__FILE__) . '/views/_question.php';
} else {
include_once dirname(__FILE__) . '/views/test-middle.php';
}
$content = ob_get_clean();
echo $content;
}
开发者ID:nev3rm0re,项目名称:hondex,代码行数:22,代码来源:index.php
示例10: makeProperties
/**
* @return Model $this
* @throws Exception
*/
public function makeProperties()
{
if ($this->getStoredAql()) {
$this->makeAqlArray();
$i = 0;
foreach ($this->getStoredAqlArray() as $table) {
if ($i == 0) {
$this->_primary_table = $table['table'];
$this->addProperty($this->_primary_table . '_id');
}
$this->tableMakeProperties($table);
$i++;
}
} else {
$e = sprintf(self::E_INVALID_MODEL, $this->_model_name);
if (!is_ajax_request()) {
throw new Exception($e);
return $this;
} else {
exit_json(array('status' => 'Error', 'errors' => array($e)));
}
}
return $this;
}
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:28,代码来源:class.Model.php
示例11: __construct
/**
* Create the page object and set if this is an ajax request
* Optionally set other properties
* @param array $config
*/
public function __construct(array $config = array())
{
$this->is_ajax_request = \is_ajax_request();
$this->uri = $_SERVER['REQUEST_URI'];
foreach ($config as $k => $v) {
$this->{$k} = $v;
}
}
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:13,代码来源:Page.php
示例12: redirect_to_referer
/**
* Redirect to referer
*
* @access public
* @param string $alternative Alternative URL is used if referer is not valid URL
* @return null
*/
function redirect_to_referer($alternative = nulls)
{
$referer = get_referer();
if (true || !is_valid_url($referer)) {
if (is_ajax_request()) {
$alternative = make_ajax_url($alternative);
}
redirect_to($alternative);
} else {
if (is_ajax_request()) {
$referer = make_ajax_url($referer);
}
redirect_to($referer);
}
// if
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:23,代码来源:general.php
示例13: is_ajax_request
<?php
function is_ajax_request()
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'BAWXMLHttpRequest';
}
$ajax = is_ajax_request();
if (!$ajax) {
?>
<html>
<head>
<style>
img {
display: block;
max-width: 100%;
height: auto;
background-size: cover;
backface-visibility: hidden;
}
section {
width: 50%;
}
main {
display: flex;
opacity: 1;
transition: opacity 0.5s ease-out;
}
main.loading {
opacity: 0;
开发者ID:kirpalmakanga,项目名称:ajaxloader,代码行数:31,代码来源:index.php
示例14: smart_box
function smart_box($info)
{
if (is_json_request()) {
$array = array();
$array['error_code'] = intval(20001);
$array['error_message'] = $info;
return ajax_echo(json_encode($array));
} elseif (is_ajax_request()) {
return ajax_echo($info);
} else {
return info_page($info);
}
}
开发者ID:oxmcvusd,项目名称:nowboard,代码行数:13,代码来源:core.function.php
示例15: initFolder
public function initFolder($refresh = false)
{
$path = is_object($this->folder) ? $this->folder->folders_path : $this->folder;
$e = $refresh || is_ajax_request() ? array('refresh_memcached' => true) : null;
return $this->folder = vf::getFolder($path, array('limit' => $this->limit), $e);
}
开发者ID:hshoghi,项目名称:cms,代码行数:6,代码来源:class.vf_gallery_inc.php
示例16: send_error
function send_error($type, $info = null, $force_json = false)
{
if ($error = get_error($type)) {
if ($info != null) {
$error['message'] = $error['message'] . ' -' . $info;
}
} else {
$error['message'] = $info;
}
//print_r( $error );
//send_json($error);
if (is_json_request() || $force_json) {
return send_json($error);
} elseif (is_ajax_request()) {
return render_ajax($error, 'info');
} else {
return render_web($error, 'info');
}
}
开发者ID:Rongya,项目名称:LazyPHP4,代码行数:19,代码来源:functions.php
示例17: set_notification
/**
* Save a notification message for displaying on the subsequent page view
*
* Optionally supply a url for redirecting to before displaying the message
* and/or an options array.
*
* Currently the options array only supports a 'class' entry for passing as
* the second parameter to notification()
*
* @param string $message Message to display
* @param string $redirect Url to redirect to (optional)
* @param array $options Options array (optional)
* @return void
*/
function set_notification($message, $redirect = null, $options = array()) {
// Check options is an array
if (!is_array($options)) {
print_error('error:notificationsparamtypewrong', 'local_core');
}
// Add message to options array
$options['message'] = $message;
// Add to notifications queue
queue_append('notifications', $options);
// Redirect if requested
if ($redirect !== null) {
// Cancel redirect for AJAX scripts.
if (is_ajax_request($_SERVER)) {
ajax_result(true, queue_shift('notifications'));
} else {
redirect($redirect);
}
exit();
}
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:38,代码来源:lib.php
示例18: executeAction
/**
* Contruct controller and execute specific action
*
* @access public
* @param string $controller_name
* @param string $action
* @return null
*/
static function executeAction($controller_name, $action)
{
$max_users = config_option('max_users');
if ($max_users && Users::count() > $max_users) {
echo lang("error") . ": " . lang("maximum number of users exceeded error");
return;
}
ajx_check_login();
if (isset($_GET['active_project']) && logged_user() instanceof User) {
$dont_update = false;
if (GlobalCache::isAvailable()) {
$option_value = GlobalCache::get('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $success);
if ($success) {
$dont_update = $option_value == $_GET['active_project'];
}
}
if (!$dont_update) {
set_user_config_option('lastAccessedWorkspace', $_GET['active_project'], logged_user()->getId());
if (GlobalCache::isAvailable()) {
GlobalCache::update('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $_GET['active_project']);
}
}
}
Env::useController($controller_name);
$controller_class = Env::getControllerClass($controller_name);
if (!class_exists($controller_class, false)) {
throw new ControllerDnxError($controller_name);
}
// if
$controller = new $controller_class();
if (!instance_of($controller, 'Controller')) {
throw new ControllerDnxError($controller_name);
}
// if
if (is_ajax_request()) {
// if request is an ajax request return a json response
// execute the action
$controller->setAutoRender(false);
$controller->execute($action);
// fill the response
$response = AjaxResponse::instance();
if (!$response->hasCurrent()) {
// set the current content
$response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel());
}
$response->setEvents(evt_pop());
$error = flash_pop('error');
$success = flash_pop('success');
if (!is_null($error)) {
$response->setError(1, clean($error));
} else {
if (!is_null($success)) {
$response->setError(0, clean($success));
}
}
// display the object as json
tpl_assign("object", $response);
$content = tpl_fetch(Env::getTemplatePath("json"));
tpl_assign("content_for_layout", $content);
TimeIt::start("Transfer");
if (is_iframe_request()) {
tpl_display(Env::getLayoutPath("iframe"));
} else {
tpl_display(Env::getLayoutPath("json"));
}
TimeIt::stop();
} else {
return $controller->execute($action);
}
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:78,代码来源:Env.class.php
示例19: add_inline_script
/**
* Add an inline javascript
* @return unknown_type
*/
function add_inline_script($script) {
if (is_ajax_request()) {
AjaxResponse::instance()->addInlineScript($script);
}
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:9,代码来源:ajax.php
示例20: executeAction
/**
* Contruct controller and execute specific action
*
* @access public
* @param string $controller_name
* @param string $action
* @return null
*/
static function executeAction($controller_name, $action) {
$max_users = config_option('max_users');
if ($max_users && Contacts::count() > $max_users) {
echo lang("error").": ".lang("maximum number of users exceeded error");
return;
}
ajx_check_login();
Env::useController($controller_name);
$controller_class = Env::getControllerClass($controller_name);
if(!class_exists($controller_class, false)) {
throw new ControllerDnxError($controller_name);
} // if
$controller = new $controller_class();
if(!instance_of($controller, 'Controller')) {
throw new ControllerDnxError($controller_name);
} // if
if (is_ajax_request()) {
// if request is an ajax request return a json response
// execute the action
$controller->setAutoRender(false);
$controller->execute($action);
// fill the response
$response = AjaxResponse::instance();
if (!$response->hasCurrent()) {
// set the current content
$response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel());
}
$response->setEvents(evt_pop());
$error = flash_pop('error');
$success = flash_pop('success');
if (!is_null($error)) {
$response->setError(1, clean($error));
} else if (!is_null($success)) {
$response->setError(0, clean($success));
}
// display the object as json
tpl_assign("object", $response);
$content = tpl_fetch(Env::getTemplatePath("json"));
tpl_assign("content_for_layout", $content);
TimeIt::start("Transfer");
if (is_iframe_request()) {
tpl_display(Env::getLayoutPath("iframe"));
} else {
tpl_display(Env::getLayoutPath("json"));
}
TimeIt::stop();
} else {
return $controller->execute($action);
}
} // executeAction
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:66,代码来源:Env.class.php
注:本文中的is_ajax_request函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论