本文整理汇总了PHP中Nette\Http\IRequest::isAjax方法的典型用法代码示例。如果您正苦于以下问题:PHP IRequest::isAjax方法的具体用法?PHP IRequest::isAjax怎么用?PHP IRequest::isAjax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IRequest
的用法示例。
在下文中一共展示了IRequest::isAjax方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSignal
/**
* @param \Ark8\Security\Authorizators\Request $request
* @return array
* @throws \Nette\InvalidStateException
*/
private function getSignal(Request $request)
{
$params = $request->getParameters();
if ($this->httpRequest->isAjax()) {
$params += $request->getPost();
} elseif (($tmp = $request->getPost(Presenter::SIGNAL_KEY)) !== NULL) {
$params[self::SIGNAL_KEY] = $tmp;
}
$signal = NULL;
$signalReceiver = '';
if (isset($params[Presenter::SIGNAL_KEY])) {
$param = $params[Presenter::SIGNAL_KEY];
$pos = strrpos($param, '-');
if ($pos) {
$signalReceiver = substr($param, 0, $pos);
$signal = substr($param, $pos + 1);
} else {
$signalReceiver = $this->getUniqueId();
$signal = $param;
}
if ($signal == NULL) {
// intentionally ==
$signal = NULL;
}
}
return [$signal, explode('-', $signalReceiver)];
}
示例2: __invoke
/**
* @param Application\Application $application
*/
public function __invoke(Application\Application $application)
{
// Redirect only normal request
if ($this->httpRequest->isAjax()) {
return;
}
// Sets the flag for the response handled by the GET switch param and the type of the view.
if ($this->deviceView->hasSwitchParam()) {
if ($response = $this->getRedirectResponseBySwitchParam()) {
$response->send($this->httpRequest, $this->httpResponse);
exit;
}
return;
}
// If the device view is either the full view or not the mobile view
if ($this->deviceView->isFullView() || $this->deviceView->isNotMobileView()) {
return;
}
// Redirects to the tablet version and set the 'tablet' device view in a cookie.
if ($this->hasTabletRedirect()) {
if ($response = $this->getTabletRedirectResponse()) {
$response->send($this->httpRequest, $this->httpResponse);
exit;
}
return;
}
// Redirects to the mobile version and set the 'mobile' device view in a cookie.
if ($this->hasMobileRedirect()) {
if ($response = $this->getMobileRedirectResponse()) {
$response->send($this->httpRequest, $this->httpResponse);
exit;
}
return;
}
// No need to redirect
// Sets the flag for the response handler
$this->onResponseHandler->needModifyResponse();
// Checking the need to modify the Response and set closure
if ($this->needTabletResponseModify()) {
$this->deviceView->setTabletView();
return;
}
// Checking the need to modify the Response and set closure
if ($this->needPhoneResponseModify()) {
$this->deviceView->setPhoneView();
return;
}
// Sets the closure modifier mobile Response
if ($this->needMobileResponseModify()) {
$this->deviceView->setMobileView();
return;
}
// Sets the closure modifier not_mobile Response
if ($this->needNotMobileResponseModify()) {
$this->deviceView->setNotMobileView();
return;
}
}
示例3: render
public function render()
{
if ($this->httpRequest->isAjax()) {
if (!isset($this->myPresenter->payload->snippets)) {
$this->myPresenter->payload->snippets = [];
}
$this->myPresenter->payload->snippets[$this->getSnippetId('state')] = $this->getStateElement()->render();
} else {
echo Html::el('span', ['id' => $this->getSnippetId('state')])->add($this->getStateElement());
}
}
示例4: run
/**
* @return Nette\Application\IResponse
*/
public function run(Application\Request $request)
{
$this->request = $request;
if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
$refUrl = clone $this->httpRequest->getUrl();
$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
}
}
$params = $request->getParameters();
if (!isset($params['callback'])) {
throw new Application\BadRequestException('Parameter callback is missing.');
}
$params['presenter'] = $this;
$callback = $params['callback'];
$reflection = Nette\Utils\Callback::toReflection(Nette\Utils\Callback::check($callback));
$params = Application\UI\PresenterComponentReflection::combineArgs($reflection, $params);
if ($this->context) {
foreach ($reflection->getParameters() as $param) {
if ($param->getClassName()) {
unset($params[$param->getPosition()]);
}
}
$params = Nette\DI\Helpers::autowireArguments($reflection, $params, $this->context);
$params['presenter'] = $this;
}
$response = call_user_func_array($callback, $params);
if (is_string($response)) {
$response = array($response, array());
}
if (is_array($response)) {
list($templateSource, $templateParams) = $response;
$response = $this->createTemplate()->setParameters($templateParams);
if (!$templateSource instanceof \SplFileInfo) {
$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
}
$response->setFile($templateSource);
}
if ($response instanceof Application\UI\ITemplate) {
return new Responses\TextResponse($response);
} else {
return $response;
}
}
示例5: isAjax
/**
* Is AJAX request?
* @return bool
*/
public function isAjax()
{
if ($this->ajaxMode === NULL) {
$this->ajaxMode = $this->httpRequest->isAjax();
}
return $this->ajaxMode;
}
示例6: run
/**
* @param \Nette\Application\Request $request
* @return \Nette\Application\IResponse
* @throws \Nette\Application\BadRequestException
*/
public function run(Application\Request $request)
{
$this->request = $request;
if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
$refUrl = clone $this->httpRequest->getUrl();
$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
}
}
$params = $request->getParameters();
if (!isset($params['id'])) {
throw new Application\BadRequestException('Parameter id is missing.');
}
if (NULL === ($item = $this->context->getService('webloader.cache')->getItem(\Nette\Utils\Strings::webalize($params['id'])))) {
return new Responses\TextResponse('');
}
return new \Lohini\WebLoader\WebLoaderResponse($item[WebLoader::CONTENT], $item[WebLoader::CONTENT_TYPE], $item[WebLoader::ETAG]);
}
示例7: processRequest
/**
* Handles incoming request and sets translations.
*/
private function processRequest()
{
if ($this->httpRequest->isMethod('post') && $this->httpRequest->isAjax() && $this->httpRequest->getHeader(self::XHR_HEADER)) {
$data = json_decode(file_get_contents('php://input'));
if ($data) {
$this->translator->setCurrentLang($data->{self::LANGUAGE_KEY});
if ($data->{self::NAMESPACE_KEY}) {
$this->translator->setNamespace($data->{self::NAMESPACE_KEY});
}
unset($data->{self::LANGUAGE_KEY}, $data->{self::NAMESPACE_KEY});
foreach ($data as $string => $translated) {
$this->translator->setTranslation($string, $translated);
}
}
exit;
}
}
示例8: run
/**
* @param Application\Request $request
*
* @return Application\IResponse
*
* @throws Application\BadRequestException
*/
public function run(Application\Request $request)
{
$this->request = $request;
if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
$refUrl = clone $this->httpRequest->getUrl();
$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
return new Application\Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
}
}
$params = $request->getParameters();
if (!isset($params['action'])) {
throw new Application\BadRequestException('Parameter action is missing.');
}
if (!isset($params['id'])) {
throw new Application\BadRequestException('Parameter id is missing.');
}
// calls $this->action<Action>()
if (!($response = $this->tryCall(Application\UI\Presenter::formatActionMethod(Utils\Strings::capitalize($params['action'])), $params))) {
throw new Application\BadRequestException('Action not callable.');
}
return $response;
}
示例9: __invoke
public function __invoke($application, $request)
{
if ($this->httpRequest->isAjax() && count($application->getRequests()) > 1) {
$this->onResponseHandler->markForward();
}
}
示例10: isAjax
/**
* @inheritdoc
*/
public function isAjax()
{
return $this->current->isAjax();
}