From f41b5ba922e21225ac06db9d172e69fd05703fa6 Mon Sep 17 00:00:00 2001 From: aFolletete Date: Mon, 21 May 2012 09:38:11 +0000 Subject: [PATCH] [+] Classes : include new method isXmlHttpRequest() in Controller class, allows to make ajax request without ajax=1 in GET parameter git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15479 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/controller/Controller.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index f8c65f73c..b8688e1e5 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -139,7 +139,7 @@ abstract class ControllerCore $this->context = Context::getContext(); $this->context->controller = $this; - $this->ajax = Tools::getValue('ajax') || Tools::isSubmit('ajax'); + $this->ajax = Tools::getValue('ajax') || Tools::isSubmit('ajax') || $this->isXmlHttpRequest(); } /** @@ -267,7 +267,6 @@ abstract class ControllerCore */ public function addJS($js_uri) { -//elog($js_uri); if (is_array($js_uri)) foreach ($js_uri as $js_file) { @@ -338,4 +337,13 @@ abstract class ControllerCore $this->addCSS($plugin_path['css']); $this->addJS($plugin_path['js']); } + + /** + * @since 1.5 + * @return bool return true if Controller is called from XmlHttpRequest + */ + public function isXmlHttpRequest() + { + return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); + } }