[+] Classes : include new method isXmlHttpRequest() in Controller class, allows to make ajax request without ajax=1 in GET parameter

This commit is contained in:
aFolletete
2012-05-21 09:38:11 +00:00
parent 14cdca92d8
commit 9bb2a07e6f
+10 -2
View File
@@ -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');
}
}