[+] 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
This commit is contained in:
1 parent
76a079bd8f
commit
f41b5ba922
1 file changed
+10
-2
@@ -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