本文整理汇总了PHP中sfRequest::isXmlHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP sfRequest::isXmlHttpRequest方法的具体用法?PHP sfRequest::isXmlHttpRequest怎么用?PHP sfRequest::isXmlHttpRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfRequest
的用法示例。
在下文中一共展示了sfRequest::isXmlHttpRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _redirectError
/**
* Redirect process for a failed login
*
* @param sfRequest $request
* @param sfUser $user
* @return mixed
*/
protected function _redirectError($request, $user)
{
if ($request->isXmlHttpRequest()) {
$this->getResponse()->setHeaderOnly(true);
$this->getResponse()->setStatusCode(401);
return sfView::NONE;
}
// if we have been forwarded, then the referer is the current URL
// if not, this is the referer of the current request
$user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer());
$this->redirect(sfConfig::get('sf_login_module') . '/' . sfConfig::get('sf_login_action'));
}
示例2: executeSortProfileOption
/**
* Executes sortProfileOption action
*
* @param sfRequest $request A request object
*/
public function executeSortProfileOption($request)
{
if ($request->isXmlHttpRequest()) {
$request->checkCSRFProtection();
$parameters = $request->getParameterHolder();
$keys = $parameters->getNames();
foreach ($keys as $key) {
if (preg_match('/^profile_options_\\d+$/', $key, $match)) {
$order = $parameters->get($match[0]);
for ($i = 0; $i < count($order); $i++) {
$profileOption = Doctrine::getTable('ProfileOption')->find($order[$i]);
if ($profileOption) {
$profileOption->setSortOrder($i * 10);
$profileOption->save();
}
}
break;
}
}
}
return sfView::NONE;
}
示例3: executeLoadUserData
/**
* Загрузить данные пользователя, AJAX
*/
public function executeLoadUserData(sfRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$result = array();
// будем возвращать
$user = $this->getUser()->getUserRecord();
$subscribtion = Doctrine::getTable('ServiceSubscription')->getActiveUserServiceSubscription($user, Service::SERVICE_SMS);
# Svel:
# а не лучше ли мапить это во вью?
$result['profile'] = array('login' => $user->getUserLogin(), 'name' => $user->getUserName(), 'mail' => $user->getUserMail(), 'timezone' => $user->getTimeZone(), 'integration' => array('email' => str_replace('@mail.easyfinance.ru', '', $user->getUserServiceMail())), 'reminders' => array('enabled' => is_object($subscribtion) ? 1 : 0, 'mailEnabled' => $user->getReminderMailDefaultEnabled(), 'mailDaysBefore' => $user->getReminderMailDays(), 'mailHour' => $user->getReminderMailHour(), 'mailMinutes' => $user->getReminderMailMinutes(), 'smsPhone' => $user->getSmsPhone(), 'smsEnabled' => $user->getReminderSmsDefaultEnabled(), 'smsDaysBefore' => $user->getReminderSmsDays(), 'smsHour' => $user->getReminderSmsHour(), 'smsMinutes' => $user->getReminderSmsMinutes()));
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
return $this->renderText(json_encode($result));
}