[+] Classes : include new method isXmlHttpRequest() in Controller class, allows to make ajax request without ajax=1 in GET parameter
This commit is contained in:
@@ -139,7 +139,7 @@ abstract class ControllerCore
|
|||||||
|
|
||||||
$this->context = Context::getContext();
|
$this->context = Context::getContext();
|
||||||
$this->context->controller = $this;
|
$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)
|
public function addJS($js_uri)
|
||||||
{
|
{
|
||||||
//elog($js_uri);
|
|
||||||
if (is_array($js_uri))
|
if (is_array($js_uri))
|
||||||
foreach ($js_uri as $js_file)
|
foreach ($js_uri as $js_file)
|
||||||
{
|
{
|
||||||
@@ -338,4 +337,13 @@ abstract class ControllerCore
|
|||||||
$this->addCSS($plugin_path['css']);
|
$this->addCSS($plugin_path['css']);
|
||||||
$this->addJS($plugin_path['js']);
|
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user