diff --git a/admin-dev/functions.php b/admin-dev/functions.php index 923f44b78..04c99cbb6 100644 --- a/admin-dev/functions.php +++ b/admin-dev/functions.php @@ -49,13 +49,20 @@ function bindDatepicker($id, $time) });'; } -// id can be a identifier or an array of identifiers +/** + * Deprecated since 1.5 + * Use Controller::addJqueryUi('ui.datepicker') instead + * + * @param int|array $id id can be a identifier or an array of identifiers + * @param unknown_type $time + */ function includeDatepicker($id, $time = false) { + Tools::displayAsDeprecated(); echo ''; $iso = Db::getInstance()->getValue('SELECT iso_code FROM '._DB_PREFIX_.'lang WHERE `id_lang` = '.(int)Context::getContext()->language->id); if ($iso != 'en') - echo ''; + echo ''; echo ''; -echo '
-
{$conf}
+ {$conf}
-
{if count($errors) == 1}
{$errors[0]}
{else}
@@ -71,7 +70,6 @@
-
{if count($warnings) > 1}
{l s='There are'} {count($warnings)} {l s='warnings'}
{else}
diff --git a/classes/AdminController.php b/classes/AdminController.php
index 5a9f4bd51..7858efe69 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -61,7 +61,7 @@ class AdminControllerCore extends Controller
/** @var integer Tab id */
public $id = -1;
- /** @var array noTabLink array of admintab names witch have no content */
+ /** @var array noTabLink array of admintabs with no content */
public $noTabLink = array('AdminCatalog', 'AdminTools', 'AdminStock', 'AdminAccounting');
/** @var string Security token */
@@ -748,7 +748,6 @@ class AdminControllerCore extends Controller
if ($this->tabAccess['edit'] === '1')
{
$this->beforeUpdateOptions();
-
$languages = Language::getLanguages(false);
foreach ($this->options as $category => $category_data)
@@ -852,7 +851,7 @@ class AdminControllerCore extends Controller
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
-
+
// todo : return value ?
}
diff --git a/classes/AdminTab.php b/classes/AdminTab.php
index 377b5dc29..3a2bff7a8 100644
--- a/classes/AdminTab.php
+++ b/classes/AdminTab.php
@@ -199,6 +199,9 @@ abstract class AdminTabCore
'AdminStatsTab' => 'AdminStats'
);
+ /** @var array noTabLink array of admintabs with no content */
+ public $noTabLink = array('AdminCatalog', 'AdminTools', 'AdminStock', 'AdminAccounting');
+
public function __construct()
{
$this->context = Context::getContext();
diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php
index 9886bbed1..f739cf38f 100644
--- a/classes/Dispatcher.php
+++ b/classes/Dispatcher.php
@@ -144,12 +144,12 @@ class DispatcherCore
/**
* @var string Set default controller, which will be used if http parameter 'controller' is empty
*/
- protected $default_controller = 'index';
+ protected $default_controller = 'Index';
/**
* @var string Controller to use if found controller doesn't exist
*/
- protected $controller_not_found = 'pagenotfound';
+ protected $controller_not_found = 'PageNotFound';
/**
* @var array List of controllers where are stored controllers
@@ -217,6 +217,30 @@ class DispatcherCore
$this->controller_directories = $dir;
}
+ public static function getAdminController($name)
+ {
+ if (!Validate::isTabName($name))
+ return false;
+
+ $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('SELECT id_tab, class_name, module FROM `'._DB_PREFIX_.'tab` WHERE LOWER(class_name) = \''.pSQL($name).'\'');
+ return $row;
+ }
+
+ public static function includeModuleClass($module, $name)
+ {
+ if (file_exists(_PS_MODULE_DIR_.$module.'/'.$name.'Controller.php'))
+ {
+ include(_PS_MODULE_DIR_.$module.'/'.$name.'Controller.php');
+ return true;
+ }
+
+ if (file_exists(_PS_MODULE_DIR_.$module.'/'.$name.'.php'))
+ {
+ include(_PS_MODULE_DIR_.$module.'/'.$name.'.php');
+ return false;
+ }
+ }
+
/**
* Find the controller and instantiate it
*/
@@ -234,26 +258,54 @@ class DispatcherCore
// Get current controller and list of controllers
$this->getController();
- $controllers = Dispatcher::getControllers($this->controller_directories);
if (!$this->controller)
$this->controller = $this->default_controller;
- // 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'))
+ // FO dispatch
+ if (!defined('_PS_ADMIN_DIR_'))
{
- require_once(_PS_ADMIN_DIR_.'/functions.php');
- $ajaxMode = !empty($_REQUEST['ajaxMode']);
- runAdminTab($ajaxMode);
- return;
+ $controllers = self::getControllers($this->controller_directories);
+ if (isset($controllers[$this->controller]))
+ $this->controller = $controllers[$this->controller];
+ else
+ $this->controller = $this->controller_not_found;
+ }
+ // BO dispatch
+ else
+ {
+ // Get controller class name
+ $controller_row = self::getAdminController($this->controller);
+ if (empty($controller_row))
+ $this->controller = $this->controller_not_found;
+ else
+ $this->controller = $controller_row['class_name'];
+
+ // If Tab/Controller is in module, include it
+ if (!empty($controller_row['module']))
+ $is_controller = self::includeModuleClass($controller_row['module'], $this->controller);
+ // If it is an AdminTab, include it
+ elseif (file_exists(_PS_ADMIN_DIR_.'/tabs/'.$this->controller.'.php'))
+ {
+ include(_PS_ADMIN_DIR_.'/tabs/'.$this->controller.'.php');
+ $is_controller = false;
+ }
+ // For retrocompatibility with admin/tabs/ old system
+ if (isset($is_controller) && !$is_controller)
+ {
+ require_once(_PS_ADMIN_DIR_.'/functions.php');
+ $ajaxMode = !empty($_REQUEST['ajaxMode']);
+ runAdminTab($this->controller, $ajaxMode);
+ return;
+ }
+ else
+ $this->controller = $this->controller.'Controller';
}
- else if (!isset($controllers[$this->controller]))
- $this->controller = $this->controller_not_found;
// Instantiate controller
try
{
- Controller::getController($controllers[$this->controller])->run();
+ Controller::getController($this->controller)->run();
}
catch (PrestashopException $e)
{