// Code cleaning
This commit is contained in:
1 parent
a7f6e91ac0
commit
1a81191c09
2 files changed
+22
-31
No files matched your search
+20
-25
@@ -488,7 +488,8 @@ class LanguageCore extends ObjectModel
|
|||||||
// Files deletion
|
// Files deletion
|
||||||
foreach (Language::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file)
|
foreach (Language::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file)
|
||||||
if (file_exists($key))
|
if (file_exists($key))
|
||||||
unlink($key);
|
unlink($key);
|
||||||
|
|
||||||
$modList = scandir(_PS_MODULE_DIR_);
|
$modList = scandir(_PS_MODULE_DIR_);
|
||||||
foreach ($modList as $mod)
|
foreach ($modList as $mod)
|
||||||
{
|
{
|
||||||
@@ -510,37 +511,32 @@ class LanguageCore extends ObjectModel
|
|||||||
Language::recurseDeleteDir(_PS_MAIL_DIR_.$this->iso_code);
|
Language::recurseDeleteDir(_PS_MAIL_DIR_.$this->iso_code);
|
||||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code))
|
if (file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code))
|
||||||
Language::recurseDeleteDir(_PS_TRANSLATIONS_DIR_.$this->iso_code);
|
Language::recurseDeleteDir(_PS_TRANSLATIONS_DIR_.$this->iso_code);
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent::delete())
|
$images = array(
|
||||||
return false;
|
'.jpg',
|
||||||
if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL)
|
'-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
||||||
{
|
'-default-'.ImageType::getFormatedName('home').'.jpg',
|
||||||
// delete images
|
'-default-'.ImageType::getFormatedName('large').'.jpg',
|
||||||
$files_copy = array(
|
'-default-'.ImageType::getFormatedName('medium').'.jpg',
|
||||||
'/en.jpg',
|
'-default-'.ImageType::getFormatedName('small').'.jpg'
|
||||||
'/en-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
|
||||||
'/en-default-'.ImageType::getFormatedName('home').'.jpg',
|
|
||||||
'/en-default-'.ImageType::getFormatedName('large').'.jpg',
|
|
||||||
'/en-default-'.ImageType::getFormatedName('medium').'.jpg',
|
|
||||||
'/en-default-'.ImageType::getFormatedName('small').'.jpg'
|
|
||||||
);
|
);
|
||||||
$tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
$image_directories = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||||
foreach ($tos as $to)
|
foreach ($images_directories as $image_directory)
|
||||||
foreach ($files_copy as $file)
|
foreach ($images as $image)
|
||||||
{
|
{
|
||||||
$name = str_replace('/en', ''.$this->iso_code, $file);
|
if (file_exists($image_directory.$this->iso_code.$image))
|
||||||
|
unlink($image_directory.$this->iso_code.$image);
|
||||||
if (file_exists($to.$name))
|
|
||||||
unlink($to.$name);
|
|
||||||
if (file_exists(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg'))
|
if (file_exists(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg'))
|
||||||
unlink(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg');
|
unlink(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!parent::delete())
|
||||||
|
return false;
|
||||||
|
|
||||||
return Tools::generateHtaccess();
|
return Tools::generateHtaccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function deleteSelection($selection)
|
public function deleteSelection($selection)
|
||||||
{
|
{
|
||||||
if (!is_array($selection))
|
if (!is_array($selection))
|
||||||
@@ -549,11 +545,10 @@ class LanguageCore extends ObjectModel
|
|||||||
$result = true;
|
$result = true;
|
||||||
foreach ($selection as $id)
|
foreach ($selection as $id)
|
||||||
{
|
{
|
||||||
$this->id = (int)($id);
|
$language = new Language($id);
|
||||||
$result = $result && $this->delete();
|
$result = $result && $language->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tools::generateHtaccess();
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -696,16 +696,12 @@ class InstallXmlLoader
|
|||||||
|
|
||||||
if (is_null($tables))
|
if (is_null($tables))
|
||||||
{
|
{
|
||||||
$sql = 'SHOW TABLES';
|
|
||||||
$tables = array();
|
$tables = array();
|
||||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
foreach (Db::getInstance()->executeS('SHOW TABLES') as $row)
|
||||||
{
|
{
|
||||||
$table = current($row);
|
$table = current($row);
|
||||||
if (preg_match('#^'._DB_PREFIX_.'(.+?)(_lang)?$#i', $table, $m))
|
if (preg_match('#^'._DB_PREFIX_.'(.+?)(_lang)?$#i', $table, $m))
|
||||||
if (preg_match('#^'._DB_PREFIX_.'(.+?)_shop$#i', $table, $m2) && !isset($tables[$m2[1]]))
|
$tables[$m[1]] = (isset($m[2]) && $m[2]) ? true : false;
|
||||||
$tables[$m[1]] = (isset($m[2]) && $m[2]) ? true : false;
|
|
||||||
else
|
|
||||||
$tables[$m[1]] = (isset($m[2]) && $m[2]) ? true : false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user