// Fix translations in AdminControllers from modules #PSFV-397

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12972 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-02-03 13:31:51 +00:00
parent 4b5a088b01
commit 3ca7fb1ee2
2 changed files with 10 additions and 3 deletions
+8 -1
View File
@@ -763,7 +763,13 @@ abstract class ModuleCore
$realpathModuleDir = realpath(_PS_MODULE_DIR_); $realpathModuleDir = realpath(_PS_MODULE_DIR_);
if (substr(realpath($filePath), 0, strlen($realpathModuleDir)) == $realpathModuleDir) if (substr(realpath($filePath), 0, strlen($realpathModuleDir)) == $realpathModuleDir)
{ {
self::$classInModule[$currentClass] = substr(dirname($filePath), strlen($realpathModuleDir) + 1); // For controllers in module/controllers path
if (basename(dirname(dirname($filePath))) == 'controllers')
self::$classInModule[$currentClass] = basename(dirname(dirname(dirname($filePath))));
// For old AdminTab controllers
else
self::$classInModule[$currentClass] = substr(dirname($filePath), strlen($realpathModuleDir) + 1);
$file = _PS_MODULE_DIR_.self::$classInModule[$currentClass].'/'.Context::getContext()->language->iso_code.'.php'; $file = _PS_MODULE_DIR_.self::$classInModule[$currentClass].'/'.Context::getContext()->language->iso_code.'.php';
if (Tools::file_exists_cache($file) && include_once($file)) if (Tools::file_exists_cache($file) && include_once($file))
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE; $_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
@@ -771,6 +777,7 @@ abstract class ModuleCore
else else
self::$classInModule[$currentClass] = false; self::$classInModule[$currentClass] = false;
} }
// return name of the module, or false // return name of the module, or false
return self::$classInModule[$currentClass]; return self::$classInModule[$currentClass];
} }
+2 -2
View File
@@ -1634,14 +1634,14 @@ class AdminControllerCore extends Controller
include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
} }
if (isset(self::$tab_module_list[$class])) if (isset(self::$tab_module_list[strtolower($class)]))
{ {
$class_name_controller = $class.'controller'; $class_name_controller = $class.'controller';
// if the class is extended by a module, use modules/[module_name]/xx.php lang file // 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)) if (class_exists($class_name_controller) && Module::getModuleNameFromClass($class_name_controller))
{ {
$string = str_replace('\'', '\\\'', $string); $string = str_replace('\'', '\\\'', $string);
return Module::findTranslation(Module::$classInModule[$class_name_controller], $string, $class_name_controller); return Module::findTranslation(Module::$classInModule[$class_name_controller], $string, $class);
} }
} }
$key = md5(str_replace('\'', '\\\'', $string)); $key = md5(str_replace('\'', '\\\'', $string));