// 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 static $currentIndex;
|
||||
public $content;
|
||||
public $warnings = array();
|
||||
@@ -163,6 +164,9 @@ class AdminControllerCore extends Controller
|
||||
/** @var array $cache_lang cache for traduction */
|
||||
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 */
|
||||
public $required_fields = array();
|
||||
|
||||
@@ -1606,6 +1610,8 @@ class AdminControllerCore extends Controller
|
||||
// @todo remove global keyword in translations files and use static
|
||||
global $_LANGADM;
|
||||
|
||||
self::initModuleCacheTab();
|
||||
|
||||
if (!is_array($_LANGADM))
|
||||
{
|
||||
$iso = Context::getContext()->language->iso_code;
|
||||
@@ -1620,15 +1626,16 @@ class AdminControllerCore extends Controller
|
||||
$class = strtolower($class);
|
||||
// For traductions in a tpl folder with an underscore
|
||||
$class = str_replace('_', '', $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))
|
||||
if (isset(self::$tab_module_list[$class]))
|
||||
{
|
||||
$string = str_replace('\'', '\\\'', $string);
|
||||
return Module::findTranslation(Module::$classInModule[$class_name_controller], $string, $class_name_controller);
|
||||
}*/
|
||||
$class_name_controller = $class.'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));
|
||||
|
||||
@@ -1670,6 +1677,15 @@ class AdminControllerCore extends Controller
|
||||
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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user