// Fix translation performance for any tab used by module
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11939 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -29,6 +29,7 @@ class AdminControllerCore extends Controller
|
|||||||
{
|
{
|
||||||
public $path;
|
public $path;
|
||||||
|
|
||||||
|
|
||||||
public static $currentIndex;
|
public static $currentIndex;
|
||||||
public $content;
|
public $content;
|
||||||
public $warnings = array();
|
public $warnings = array();
|
||||||
@@ -163,6 +164,9 @@ class AdminControllerCore extends Controller
|
|||||||
/** @var array $cache_lang cache for traduction */
|
/** @var array $cache_lang cache for traduction */
|
||||||
public static $cache_lang = array();
|
public static $cache_lang = array();
|
||||||
|
|
||||||
|
/** @var array list the the tab using under a module */
|
||||||
|
public static $tab_module_list = array();
|
||||||
|
|
||||||
/** @var array required_fields to display in the Required Fields form */
|
/** @var array required_fields to display in the Required Fields form */
|
||||||
public $required_fields = array();
|
public $required_fields = array();
|
||||||
|
|
||||||
@@ -1606,6 +1610,8 @@ class AdminControllerCore extends Controller
|
|||||||
// @todo remove global keyword in translations files and use static
|
// @todo remove global keyword in translations files and use static
|
||||||
global $_LANGADM;
|
global $_LANGADM;
|
||||||
|
|
||||||
|
self::initModuleCacheTab();
|
||||||
|
|
||||||
if (!is_array($_LANGADM))
|
if (!is_array($_LANGADM))
|
||||||
{
|
{
|
||||||
$iso = Context::getContext()->language->iso_code;
|
$iso = Context::getContext()->language->iso_code;
|
||||||
@@ -1620,15 +1626,16 @@ class AdminControllerCore extends Controller
|
|||||||
$class = strtolower($class);
|
$class = strtolower($class);
|
||||||
// For traductions in a tpl folder with an underscore
|
// For traductions in a tpl folder with an underscore
|
||||||
$class = str_replace('_', '', $class);
|
$class = str_replace('_', '', $class);
|
||||||
|
if (isset(self::$tab_module_list[$class]))
|
||||||
$class_name_controller = $class.'controller';
|
|
||||||
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
|
|
||||||
// @TODO this makes the BO very slow on some systems, needs to be changed
|
|
||||||
/*if (class_exists($class_name_controller) && Module::getModuleNameFromClass($class_name_controller))
|
|
||||||
{
|
{
|
||||||
$string = str_replace('\'', '\\\'', $string);
|
$class_name_controller = $class.'controller';
|
||||||
return Module::findTranslation(Module::$classInModule[$class_name_controller], $string, $class_name_controller);
|
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
|
||||||
}*/
|
if (class_exists($class_name_controller) && Module::getModuleNameFromClass($class_name_controller))
|
||||||
|
{
|
||||||
|
$string = str_replace('\'', '\\\'', $string);
|
||||||
|
return Module::findTranslation(Module::$classInModule[$class_name_controller], $string, $class_name_controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$key = md5(str_replace('\'', '\\\'', $string));
|
$key = md5(str_replace('\'', '\\\'', $string));
|
||||||
|
|
||||||
@@ -1670,6 +1677,15 @@ class AdminControllerCore extends Controller
|
|||||||
return self::translate($string, $class, $addslashes, $htmlentities);
|
return self::translate($string, $class, $addslashes, $htmlentities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init a cache list of tab existing in a module
|
||||||
|
*/
|
||||||
|
public static function initModuleCacheTab()
|
||||||
|
{
|
||||||
|
if (!self::$tab_module_list)
|
||||||
|
self::$tab_module_list = Tab::getModuleTabList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init context and dependencies, handles POST and GET
|
* Init context and dependencies, handles POST and GET
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -173,6 +173,26 @@ class TabCore extends ObjectModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of tab used by a module
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getModuleTabList()
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
|
||||||
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
|
SELECT t.`class_name`, t.`module`
|
||||||
|
FROM `'._DB_PREFIX_.'tab` t
|
||||||
|
WHERE t.`module` IS NOT NULL AND t.`module` != ""');
|
||||||
|
|
||||||
|
foreach ($result as $detail)
|
||||||
|
$list[strtolower($detail['class_name'])] = $detail;
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tabs
|
* Get tabs
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user