';
- if (Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL)
+ if (!$ajaxMode && Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL)
{
echo '
';
if (Context::shop() == Shop::CONTEXT_GROUP)
@@ -499,65 +503,106 @@ function runAdminTab()
printf(translate('You are configuring your store for shop %s'), ''.Context::getContext()->shop->name.'');
echo '
';
}
-
if (Validate::isLoadedObject($adminObj))
{
if ($adminObj->checkToken())
{
- /* Filter memorization */
- if (isset($_POST) AND !empty($_POST) AND isset($adminObj->table))
- foreach ($_POST AS $key => $value)
- if (is_array($adminObj->table))
- {
- foreach ($adminObj->table AS $table)
- if (strncmp($key, $table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
- $cookie->$key = !is_array($value) ? $value : serialize($value);
- }
- elseif (strncmp($key, $adminObj->table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
- $cookie->$key = !is_array($value) ? $value : serialize($value);
+ if($ajaxMode)
+ {
+ // the differences with index.php is here
+ $adminObj->ajaxPreProcess();
+ $action = Tools::getValue('action');
+ // no need to use displayConf() here
- if (isset($_GET) AND !empty($_GET) AND isset($adminObj->table))
- foreach ($_GET AS $key => $value)
- if (is_array($adminObj->table))
- {
- foreach ($adminObj->table AS $table)
- if (strncmp($key, $table.'OrderBy', 7) === 0 OR strncmp($key, $table.'Orderway', 8) === 0)
- $cookie->$key = $value;
- }
- elseif (strncmp($key, $adminObj->table.'OrderBy', 7) === 0 OR strncmp($key, $adminObj->table.'Orderway', 12) === 0)
- $cookie->$key = $value;
- $adminObj->displayConf();
- $adminObj->postProcess();
- $adminObj->displayErrors();
- $adminObj->display();
+ if (!empty($action) AND method_exists($adminObj, 'ajaxProcess'.Tools::toCamelCase($action)) )
+ $adminObj->{'ajaxProcess'.Tools::toCamelCase($action)}();
+ else
+ $adminObj->ajaxProcess();
+
+ // @TODO We should use a displayAjaxError
+ $adminObj->displayErrors();
+ if (!empty($action) AND method_exists($adminObj, 'displayAjax'.Tools::toCamelCase($action)) )
+ $adminObj->{'displayAjax'.$action}();
+ else
+ $adminObj->displayAjax();
+
+
+ }
+ else
+ {
+ /* Filter memorization */
+ if (isset($_POST) AND !empty($_POST) AND isset($adminObj->table))
+ foreach ($_POST AS $key => $value)
+ if (is_array($adminObj->table))
+ {
+ foreach ($adminObj->table AS $table)
+ if (strncmp($key, $table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
+ $cookie->$key = !is_array($value) ? $value : serialize($value);
+ }
+ elseif (strncmp($key, $adminObj->table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
+ $cookie->$key = !is_array($value) ? $value : serialize($value);
+
+ if (isset($_GET) AND !empty($_GET) AND isset($adminObj->table))
+ foreach ($_GET AS $key => $value)
+ if (is_array($adminObj->table))
+ {
+ foreach ($adminObj->table AS $table)
+ if (strncmp($key, $table.'OrderBy', 7) === 0 OR strncmp($key, $table.'Orderway', 8) === 0)
+ $cookie->$key = $value;
+ }
+ elseif (strncmp($key, $adminObj->table.'OrderBy', 7) === 0 OR strncmp($key, $adminObj->table.'Orderway', 12) === 0)
+ $cookie->$key = $value;
+ $adminObj->displayConf();
+ $adminObj->postProcess();
+ $adminObj->displayErrors();
+ $adminObj->display();
+ include(_PS_ADMIN_DIR_.'/footer.inc.php');
+ }
}
else
{
- // If this is an XSS attempt, then we should only display a simple, secure page
- ob_clean();
+ if($ajaxMode)
+ {
+ // If this is an XSS attempt, then we should only display a simple, secure page
+ ob_clean();
- // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17)
- $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$adminObj->token.'$2', $_SERVER['REQUEST_URI']);
- if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
- $url .= '&token='.$adminObj->token;
+ // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17)
+ $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$adminObj->token.'$2', $_SERVER['REQUEST_URI']);
+ if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
+ $url .= '&token='.$adminObj->token;
- $message = translate('Invalid security token');
- echo ''.$message.'
-
-
- '.$message.'
-
';
- echo '
-
-
-
-
-
- ';
- die;
+
+ // we can display the correct url
+ // die(Tools::jsonEncode(array(translate('Invalid security token'),$url)));
+ die(Tools::jsonEncode(translate('Invalid security token')));
+ }
+ else
+ {
+ // If this is an XSS attempt, then we should only display a simple, secure page
+ ob_clean();
+
+ // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17)
+ $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$adminObj->token.'$2', $_SERVER['REQUEST_URI']);
+ if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
+ $url .= '&token='.$adminObj->token;
+
+ $message = translate('Invalid security token');
+ echo ''.$message.'
+
+
+ '.$message.'
+
';
+ echo '
+
+
+
+
+
+ ';
+ die;
+ }
}
}
- include(_PS_ADMIN_DIR_.'/footer.inc.php');
}
}
}
diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php
index fa6ca1028..6f8609cb2 100644
--- a/classes/Dispatcher.php
+++ b/classes/Dispatcher.php
@@ -236,14 +236,15 @@ class DispatcherCore
$this->getController();
$controllers = Dispatcher::getControllers($this->controller_directories);
- if (!$this->controller)
+ if (!$this->controller || $this->controller == 'index')
$this->controller = (defined('_PS_ADMIN_DIR_')) ? 'adminhome' : 'index';
// For retrocompatibility with admin/tabs/ old system
if (isset($controllers[$this->controller]) && defined('_PS_ADMIN_DIR_') && file_exists(_PS_ADMIN_DIR_.'/tabs/'.$controllers[$this->controller].'.php'))
{
require_once(_PS_ADMIN_DIR_.'/functions.php');
- runAdminTab();
+ $ajaxMode = !empty($_REQUEST['ajaxMode']);
+ runAdminTab($ajaxMode);
return;
}
else if (!isset($controllers[$this->controller]))