diff --git a/admin-dev/functions.php b/admin-dev/functions.php index d1093fad3..e9a84528b 100644 --- a/admin-dev/functions.php +++ b/admin-dev/functions.php @@ -233,6 +233,11 @@ function translate($string) */ function checkingTab($tab) { + static $controllers; + + if (is_null($controllers)) + $controllers = Dispatcher::getControllers(_PS_ADMIN_DIR_.'/tabs/'); + $tab = trim($tab); if (!Validate::isTabName($tab)) return false; @@ -244,10 +249,10 @@ function checkingTab($tab) echo sprintf(Tools::displayError('Tab %s cannot be found.'),$tab); return false; } - if ($row['module'] AND file_exists(_PS_MODULE_DIR_.'/'.$row['module'].'/'.Dispatcher::$controllers[$tab].'.php')) - include_once(_PS_MODULE_DIR_.'/'.$row['module'].'/'.Dispatcher::$controllers[$tab].'.php'); - elseif (file_exists(_PS_ADMIN_DIR_.'/tabs/'.Dispatcher::$controllers[$tab].'.php')) - include_once(_PS_ADMIN_DIR_.'/tabs/'.Dispatcher::$controllers[$tab].'.php'); + if ($row['module'] AND file_exists(_PS_MODULE_DIR_.'/'.$row['module'].'/'.$controllers[$tab].'.php')) + include_once(_PS_MODULE_DIR_.'/'.$row['module'].'/'.$controllers[$tab].'.php'); + elseif (file_exists(_PS_ADMIN_DIR_.'/tabs/'.$controllers[$tab].'.php')) + include_once(_PS_ADMIN_DIR_.'/tabs/'.$controllers[$tab].'.php'); if (!class_exists($tab, false) OR !$row['id_tab']) { echo sprintf(Tools::displayError('Tab file %s cannot be found.'),$tab); diff --git a/admin-dev/header.inc.php b/admin-dev/header.inc.php index 6b490d64b..e135d7db2 100644 --- a/admin-dev/header.inc.php +++ b/admin-dev/header.inc.php @@ -278,7 +278,8 @@ echo ' if (empty($tab)) echo ''; // This is made to display the subtab list -$id_current_tab = (int)(Tab::getIdFromClassName(Dispatcher::$controllers[$tab])); +$controllers = Dispatcher::getControllers(_PS_ADMIN_DIR_.'/tabs/'); +$id_current_tab = (int)Tab::getIdFromClassName($controllers[$tab]); $myCurrentTab = new Tab($id_current_tab); $tabs = Tab::getTabs(Context::getContext()->language->id, 0); $echoLis = ''; diff --git a/admin-dev/index.php b/admin-dev/index.php index 6f3e4b4aa..89dd48a91 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -28,5 +28,8 @@ define('_PS_ADMIN_DIR_', getcwd()); require(dirname(__FILE__).'/../config/config.inc.php'); require(dirname(__FILE__).'/functions.php'); -Dispatcher::getInstance()->dispatch(); +Dispatcher::getInstance()->setDefaultController('adminhome'); +Dispatcher::getInstance()->setControllerNotFound('adminhome'); +Dispatcher::getInstance()->setControllerDirectories(array(_PS_ADMIN_DIR_.'/tabs/', _PS_ADMIN_CONTROLLER_DIR_)); +Dispatcher::getInstance()->dispatch(); diff --git a/admin-dev/tabs/AdminModulesPositions.php b/admin-dev/tabs/AdminModulesPositions.php index 92b896463..a8f0d7ffa 100644 --- a/admin-dev/tabs/AdminModulesPositions.php +++ b/admin-dev/tabs/AdminModulesPositions.php @@ -1,6 +1,6 @@ _errors && !$module->registerExceptions($id_hook, $exceptions, Context::getContext()->shop->getListOfID())) $this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.'); } - + if (!$this->_errors) Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); } @@ -100,7 +100,7 @@ class AdminModulesPositions extends AdminTab else $this->_errors[] = Tools::displayError('You do not have permission to add here.'); } - + // Edit module from hook elseif (Tools::isSubmit('submitEditGraft')) { @@ -111,7 +111,7 @@ class AdminModulesPositions extends AdminTab $module = Module::getInstanceById($id_module); $id_hook = (int)(Tools::getValue('id_hook')); $hook = new Hook($id_hook); - + if (!$id_module OR !Validate::isLoadedObject($module)) $this->_errors[] = Tools::displayError('module cannot be loaded'); elseif (!$id_hook OR !Validate::isLoadedObject($hook)) @@ -124,19 +124,19 @@ class AdminModulesPositions extends AdminTab foreach ($exceptions as $id => $exception) { $exception = explode(',', str_replace(' ', '', $exception)); - + // Check files name foreach ($exception AS $except) if (!Validate::isFileName($except)) $this->_errors[] = Tools::displayError('No valid value for field exceptions'); - + $exceptions[$id] = $exception; } // Add files exceptions if (!$module->editExceptions($id_hook, $exceptions)) $this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.'); - + if (!$this->_errors) Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token); } @@ -226,7 +226,7 @@ class AdminModulesPositions extends AdminTab { $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); - + echo '