Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap

This commit is contained in:
gRoussac
2013-11-26 11:27:41 +01:00
5 changed files with 52 additions and 11 deletions
@@ -385,7 +385,6 @@
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} {if isset($input.disabled) && $input.disabled}disabled="disabled"{/if}
/> />
<label <label
class="radio"
{if $value.value == 1} {if $value.value == 1}
for="{$input.name}_on" for="{$input.name}_on"
{else} {else}
+2 -2
View File
@@ -838,8 +838,8 @@ class LanguageCore extends ObjectModel
if (file_exists($file)) if (file_exists($file))
{ {
$gz = new Archive_Tar($file, true); $gz = new Archive_Tar($file, true);
$files_list = $gz->listContent(); $files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) if (!$gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_.'../'))
$errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$iso; $errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$iso;
// Clear smarty modules cache // Clear smarty modules cache
Tools::clearCache(); Tools::clearCache();
@@ -699,11 +699,12 @@ class AdminTranslationsControllerCore extends AdminController
if (Validate::isLangIsoCode($iso_code)) if (Validate::isLangIsoCode($iso_code))
{ {
$themes_selected = Tools::getValue('theme', array(self::DEFAULT_THEME_NAME)); $themes_selected = Tools::getValue('theme', array(self::DEFAULT_THEME_NAME));
$files_list = $gz->listContent(); $files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
$files_paths = AdminTranslationsController::filesListToPaths($files_list);
$uniqid = uniqid(); $uniqid = uniqid();
$sandbox = _PS_CACHE_DIR_.'sandbox'.DIRECTORY_SEPARATOR.$uniqid.DIRECTORY_SEPARATOR; $sandbox = _PS_CACHE_DIR_.'sandbox'.DIRECTORY_SEPARATOR.$uniqid.DIRECTORY_SEPARATOR;
if ($gz->extract($sandbox, false)) if ($gz->extractList($files_paths, $sandbox))
{ {
foreach ($files_list as $file2check) foreach ($files_list as $file2check)
{ {
@@ -725,7 +726,7 @@ class AdminTranslationsControllerCore extends AdminController
if (count($this->errors)) if (count($this->errors))
return false; return false;
if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) if ($gz->extractList($files_paths, _PS_TRANSLATIONS_DIR_.'../'))
{ {
foreach ($files_list as $file2check) foreach ($files_list as $file2check)
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent())) if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent()))
@@ -763,6 +764,47 @@ class AdminTranslationsControllerCore extends AdminController
} }
} }
/**
* Filter the translation files contained in a .gzip pack
* and return only the ones that we want.
*
* Right now the function only needs to check that
* the modules for which we want to add translations
* are present on the shop (installed or not).
*
* $list is the output of Archive_Tar::listContent()
*/
public static function filterTranslationFiles($list)
{
$kept = array();
foreach ($list as $file)
{
$m = array();
if (preg_match('#^modules/([^/]+)/#', $file['filename'], $m))
{
if (is_dir(_PS_MODULE_DIR_.$m[1]))
$kept[] = $file;
}
else
$kept[] = $file;
}
return $kept;
}
/**
* Turn the list returned by
* AdminTranslationsController::filterTranslationFiles()
* into a list of paths that can be passed to
* Archive_Tar::extractList()
*/
public static function filesListToPaths($list)
{
$paths = array();
foreach ($list as $item)
$paths[] = $item['filename'];
return $paths;
}
public function submitAddLang() public function submitAddLang()
{ {
$arr_import_lang = explode('|', Tools::getValue('params_import_language')); /* 0 = Language ISO code, 1 = PS version */ $arr_import_lang = explode('|', Tools::getValue('params_import_language')); /* 0 = Language ISO code, 1 = PS version */
@@ -776,8 +818,8 @@ class AdminTranslationsControllerCore extends AdminController
if ((bool)@file_put_contents($file, $content)) if ((bool)@file_put_contents($file, $content))
{ {
$gz = new Archive_Tar($file, true); $gz = new Archive_Tar($file, true);
$files_list = $gz->listContent(); $files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
if ($error = $gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) if ($error = $gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_.'../'))
{ {
if (is_object($error) && !empty($error->message)) if (is_object($error) && !empty($error->message))
$this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message; $this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message;
@@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<entity_carrier> <entity_carrier>
<carrier id="My_carrier" id_shop="1"> <carrier id="My_carrier" id_shop="1">
<delay>Delivery next day!</delay> <delay>Livraison le lendemain</delay>
</carrier> </carrier>
</entity_carrier> </entity_carrier>
+1 -1
View File
@@ -72,7 +72,7 @@ class Dashactivity extends Module
$this->context->controller->addJquery(); $this->context->controller->addJquery();
$this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js'); $this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js');
$this->context->controller->addJs(_PS_JS_DIR_.'date.js'); $this->context->controller->addJs(array(_PS_JS_DIR_.'date.js', _PS_JS_DIR_.'tools.js'));
} }
} }