本文整理汇总了PHP中waRequest::isXMLHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP waRequest::isXMLHttpRequest方法的具体用法?PHP waRequest::isXMLHttpRequest怎么用?PHP waRequest::isXMLHttpRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waRequest
的用法示例。
在下文中一共展示了waRequest::isXMLHttpRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (!shopAffiliate::isEnabled()) {
throw new waException(_w('Unknown page'), 404);
}
$scm = new shopCustomerModel();
$customer = $scm->getById(wa()->getUser()->getId());
$atm = new shopAffiliateTransactionModel();
$affiliate_history = $atm->getByContact(wa()->getUser()->getId());
$url_tmpl = wa()->getRouteUrl('/frontend/myOrder', array('id' => '%ID%'));
foreach ($affiliate_history as &$row) {
if ($row['order_contact_id'] == $row['contact_id']) {
$row['order_url'] = str_replace('%ID%', $row['order_id'], $url_tmpl);
}
}
$this->view->assign('customer', $customer);
$this->view->assign('affiliate_history', $affiliate_history);
// Set up layout and template from theme
$this->setThemeTemplate('my.affiliate.html');
$this->view->assign('my_nav_selected', 'affiliate');
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new shopFrontendLayout());
$this->getResponse()->setTitle(_w('Affiliate program'));
$this->view->assign('breadcrumbs', self::getBreadcrumbs());
$this->layout->assign('nofollow', true);
}
/**
*
* @event frontend_my_affiliate
* @return array[string]string $return[%plugin_id%] html output
*/
$this->view->assign('frontend_my_affiliate', wa()->event('frontend_my_affiliate'));
}
示例2: execute
public function execute()
{
$cache = null;
if ($cache_time = $this->getConfig()->getOption('cache_time')) {
//$cache = new waSerializeCache('pages/'.$domain.$url.'page');
}
$page = array();
if ($cache && $cache->isCached()) {
$page = $cache->get();
} else {
$site = new siteFrontend();
if (waRequest::param('error')) {
$page = array();
} else {
$page = $site->getPage(waRequest::param('url', ''));
}
if ($page && $cache) {
$cache->set($page);
}
}
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new siteFrontendLayout());
}
try {
$this->executeAction(new siteFrontendAction($page));
} catch (Exception $e) {
if (waSystemConfig::isDebug()) {
echo $e;
} else {
waSystem::setActive('site');
$this->executeAction(new siteFrontendAction($e));
}
}
}
示例3: execute
public function execute()
{
parent::execute();
$this->view->assign('my_nav_selected', 'profile');
$user = wa()->getUser();
$user_info = array();
foreach ($this->form->fields as $id => $field) {
if (!in_array($id, array('password', 'password_confirm'))) {
if ($id === 'photo') {
$user_info[$id] = array('name' => _ws('Photo'), 'value' => '<img src="' . $user->getPhoto() . '">');
} else {
$user_info[$id] = array('name' => $this->form->fields[$id]->getName(null, true), 'value' => $user->get($id, 'html'));
}
}
}
$this->view->assign('user_info', $user_info);
// Set up layout and template from theme
$this->setThemeTemplate('my.profile.html');
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new photosDefaultFrontendLayout());
$this->getResponse()->setTitle(_w('My account') . ' — ' . _w('My profile'));
$this->layout->assign('breadcrumbs', $this->getBreadcrumbs());
$this->layout->assign('nofollow', true);
}
}
示例4: __construct
public function __construct($params = null)
{
parent::__construct($params);
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new shopFrontendLayout());
}
}
示例5: __construct
public function __construct($params = null)
{
parent::__construct($params);
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new photosDefaultFrontendLayout());
}
$this->view->getHelper()->globals($this->getRequest()->param());
return $this;
}
示例6: execute
public function execute()
{
$code = waRequest::param('code');
$encoded_order_id = waRequest::param('id');
$order_id = shopHelper::decodeOrderId($encoded_order_id);
if (!$order_id) {
// fall back to non-encoded id
$order_id = $encoded_order_id;
$encoded_order_id = shopHelper::encodeOrderId($order_id);
}
if (!$order_id || $order_id != substr($code, 16, -16)) {
throw new waException(_w('Order not found'), 404);
}
// When user is authorized, check if order belongs to him.
// When it does, redirect to plain order page.
if (wa()->getUser()->isAuth()) {
$om = new shopOrderModel();
$order = $om->getOrder($order_id);
if (!$order) {
throw new waException(_w('Order not found'), 404);
}
if ($order['contact_id'] == wa()->getUser()->getId()) {
$this->redirect(wa()->getRouteUrl('/frontend/myOrder', array('id' => $order_id)));
}
}
// Check auth code
$opm = new shopOrderParamsModel();
$params = $opm->get($order_id);
if (ifset($params['auth_code']) !== $code || empty($params['auth_pin'])) {
throw new waException(_w('Order not found'), 404);
}
// Check auth pin and show order page if pin is correct
$pin = waRequest::request('pin', wa()->getStorage()->get('shop/pin/' . $order_id));
if ($pin && $pin == $params['auth_pin']) {
wa()->getStorage()->set('shop/pin/' . $order_id, $pin);
parent::execute();
if (!waRequest::isXMLHttpRequest()) {
$this->layout->assign('breadcrumbs', self::getBreadcrumbs());
}
return;
}
//
// No pin or pin is incorrect: show form to enter pin
//
$this->view->assign('wrong_pin', !!$pin);
$this->view->assign('pin_required', true);
$this->view->assign('encoded_order_id', $encoded_order_id);
$this->view->assign('my_nav_selected', 'orders');
// Set up layout and template from theme
$this->setThemeTemplate('my.order.html');
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new shopFrontendLayout());
$this->getResponse()->setTitle(_w('Order') . ' ' . $encoded_order_id);
$this->view->assign('breadcrumbs', self::getBreadcrumbs());
$this->layout->assign('nofollow', true);
}
}
示例7: updateLastPage
public function updateLastPage()
{
if (waRequest::isXMLHttpRequest() || !$this->id || wa()->getEnv() !== 'backend' || waRequest::method() == 'post') {
return;
}
$page = wa()->getRequest()->server('REQUEST_URI');
$backend = wa()->getConfig()->getBackendUrl(true);
if ($page === $backend || substr($page, 0, strlen($backend) + 1) === $backend . '?') {
return;
}
wa()->getResponse()->setCookie('last_page', $this->getId() . '^^^' . $page, null, null, '', false, true);
}
示例8: display
public function display()
{
if (waRequest::isXMLHttpRequest()) {
$this->getResponse()->addHeader('Content-Type', 'application/json');
}
$this->getResponse()->sendHeaders();
if (!$this->errors) {
$data = array('status' => 'ok', 'data' => $this->response);
echo json_encode($data);
} else {
echo json_encode(array('status' => 'fail', 'errors' => $this->errors));
}
}
示例9: execute
public function execute()
{
parent::execute();
$this->view->assign('my_nav_selected', 'profile');
// Set up layout and template from theme
$this->setThemeTemplate('my.profile.html');
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new shopFrontendLayout());
$this->getResponse()->setTitle(_w('Account'));
$this->view->assign('breadcrumbs', self::getBreadcrumbs());
$this->layout->assign('nofollow', true);
}
}
示例10: finite
public function finite()
{
$collection = new photosCollection($this->hash);
$photos = $collection->getPhotos("*,thumb,frontend_link,tags", $this->offset, $this->photos_per_page);
$photos = photosCollection::extendPhotos($photos);
if ($this->hash) {
$title = $collection->getTitle();
if (!$title) {
$this->getResponse()->setTitle(waRequest::param('title') ? waRequest::param('title') : wa()->accountName());
} else {
$this->getResponse()->setTitle($title);
}
$this->view->assign('title', photosPhoto::escape($title));
} else {
$this->getResponse()->setTitle(waRequest::param('title') ? waRequest::param('title') : wa()->accountName());
$this->getResponse()->setMeta('keywords', waRequest::param('meta_keywords'));
$this->getResponse()->setMeta('description', waRequest::param('meta_description'));
$this->view->assign('title', '');
}
$this->workupPhotos($photos);
$total_count = $collection->count();
$this->view->assign('photos_per_page', $this->photos_per_page);
$this->view->assign('pages_count', floor($total_count / $this->photos_per_page) + 1);
$this->view->assign('total_photos_count', $total_count);
$this->view->assign('offset', $this->offset);
$this->view->assign('photos', $photos);
$is_xhr = waRequest::isXMLHttpRequest();
$this->view->assign('is_xhr', $is_xhr);
if ($is_xhr) {
$this->view->assign('frontend_collection', array());
} else {
/**
* @event frontend_collection
* @return array[string][string]string $return[%plugin_id%]['name'] Extra name info
* @return array[string][string]string $return[%plugin_id%]['content'] Extra album description and etc
* @return array[string][string]string $return[%plugin_id%]['footer'] Footer section
* @return array[string][string]string $return[%plugin_id%]['sidebar'] Footer section
* @return array[string][string]string $return[%plugin_id%]['footer'] Footer section
*/
$this->view->assign('frontend_collection', wa()->event('frontend_collection'));
}
$this->view->assign('lazy_load', !is_null(waRequest::get('lazy')));
$v = wa()->getVersion();
$this->getResponse()->addJs('js/lazy.load.js?v=' . $v, true);
$this->getResponse()->addJs('js/frontend.photos.js?v=' . $v, true);
}
示例11: execute
public function execute()
{
wa()->getStorage()->close();
$filters = waRequest::post();
if (waRequest::post('save_filters')) {
unset($filters['save_filters']);
wa()->getUser()->setSettings('webasyst', 'dashboard_activity', waRequest::post('app_id'));
}
$logs = $this->getLogs($filters, $count);
$this->view->assign('activity', $logs);
if ($logs && waRequest::isXMLHttpRequest()) {
$row = reset($logs);
$this->view->assign('datetime_group', $this->getDatetimeGroup($row['datetime']));
}
if ($count == 50) {
$this->view->assign('activity_load_more', true);
}
}
示例12: execute
public function execute()
{
$contact = wa()->getUser();
$scm = new shopCustomerModel();
// Customer orders
$om = new shopOrderModel();
$orders = $om->where('contact_id=?', $contact->getId())->order('id DESC')->fetchAll('id');
// Items for all orders, one query
$im = new shopOrderItemsModel();
foreach ($im->getByField('order_id', array_keys($orders), true) as $row) {
$orders[$row['order_id']]['items'][] = $row;
}
// Params for all orders, one query
$opm = new shopOrderParamsModel();
foreach ($opm->getByField('order_id', array_keys($orders), true) as $row) {
$orders[$row['order_id']]['params'][$row['name']] = $row['value'];
}
// Prepare order data for template
$url_tmpl = wa()->getRouteUrl('/frontend/myOrder', array('id' => '%ID%'));
$workflow = new shopWorkflow();
foreach ($orders as $k => &$o) {
if ($o['state_id'] == 'deleted') {
unset($orders[$k]);
continue;
}
$o['id_str'] = shopHelper::encodeOrderId($o['id']);
$o['total_formatted'] = waCurrency::format('%{s}', $o['total'], $o['currency']);
$o['shipping_name'] = ifset($o['params']['shipping_name'], '');
$o['payment_name'] = ifset($o['params']['payment_name'], '');
$o['state'] = $workflow->getStateById($o['state_id']);
$o['url'] = str_replace('%ID%', $o['id'], $url_tmpl);
}
$this->view->assign('orders', array_values($orders));
$this->view->assign('my_nav_selected', 'orders');
// Set up layout and template from theme
$this->setThemeTemplate('my.orders.html');
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new shopFrontendLayout());
$this->getResponse()->setTitle(_w('Orders'));
$this->view->assign('breadcrumbs', self::getBreadcrumbs());
$this->layout->assign('nofollow', true);
}
}
示例13: execute
public function execute()
{
/**
*
* @event frontend_my
* @return array[string]string $return[%plugin_id%] html output
*/
$this->view->assign('frontend_my', wa()->event('frontend_my'));
// Set up layout and template from theme
$this->setThemeTemplate('my.html');
if (!file_exists($this->getTheme()->path . '/my.html')) {
$this->redirect(wa()->getRouteUrl('/frontend/myOrders'));
}
if (!waRequest::isXMLHttpRequest()) {
$this->setLayout(new shopFrontendLayout());
$this->getResponse()->setTitle(_w('My account'));
$this->view->assign('breadcrumbs', self::getBreadcrumbs());
$this->layout->assign('nofollow', true);
}
}
示例14: checkXMLHttpRequest
protected function checkXMLHttpRequest()
{
// Voodoo magic: reload page when user performs an AJAX request after session died.
if (waRequest::isXMLHttpRequest() && (waRequest::param('secure') || waRequest::param('auth'))) {
//
// The idea behind this is quite complicated.
//
// When browser expects JSON and gets this response then the error handler is called.
// Default error handler (see wa.core.js) looks for the wa-session-expired header
// and reloads the page when it's found.
//
// On the other hand, when browser expects HTML, it's most likely to insert it to the DOM.
// In this case <script> gets executed and browser reloads the whole layout to show login page.
// (This is also the reason to use 200 HTTP response code here: no error handler required at all.)
//
header('wa-session-expired: 1');
echo _ws('Session has expired. Please reload current page and log in again.') . '<script>window.location.reload();</script>';
exit;
}
}
示例15: __toString
public function __toString()
{
$wa_url = wa()->getRootUrl();
$app_settings_model = new waAppSettingsModel();
$account_name = $app_settings_model->get('webasyst', 'name', 'Webasyst');
$wa_header = wa_header();
$t = "_ws";
$html = "";
if (!waRequest::isXMLHttpRequest()) {
$html .= <<<HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{$t("Welcome")} — {$account_name}</title>
<link href="{$wa_url}wa-content/css/wa/wa-1.0.css" rel="stylesheet">
<!--[if IE 8]><link type="text/css" href="{$wa_url}wa-content/css/wa/wa-1.0.ie8.css" rel="stylesheet"><![endif]-->
<!--[if IE 7]><link type="text/css" href="{$wa_url}wa-content/css/wa/wa-1.0.ie7.css" rel="stylesheet"><![endif]-->
<script src="{$wa_url}wa-content/js/jquery/jquery-1.7.1.min.js"></script>
</head>
<body>
{$wa_header}
<div id="wa-app" class="block double-padded">
HTML;
} else {
$response = new waResponse();
$response->setStatus(403);
$response->sendHeaders();
}
$html .= <<<HTML
<h1>{$t("Error")} #403</h1>
<div style="border:1px solid #EAEAEA;padding:10px; margin:10px 0">
<p style="color:red; font-weight: bold">{$t("You have no permission to access this page.")}</p>
<p>{$t("Please refer to your system administrator.")}</p>
</div>
HTML;
if (!waRequest::isXMLHttpRequest()) {
$html .= "</div></body></html>";
}
return $html;
}