diff --git a/modules/themeinstallator/themeinstallator.php b/modules/themeinstallator/themeinstallator.php index 5e0d51888..316ea40c0 100644 --- a/modules/themeinstallator/themeinstallator.php +++ b/modules/themeinstallator/themeinstallator.php @@ -96,11 +96,11 @@ class ThemeInstallator extends Module { $files = scandir($dirname); foreach ($files as $file) - if ($file != '.' AND $file != '..') + if ($file != '.' && $file != '..') { if (is_dir($dirname.'/'.$file)) self::deleteDirectory($dirname.'/'.$file); - elseif (file_exists($dirname.'/'.$file)) + else if (file_exists($dirname.'/'.$file)) unlink($dirname.'/'.$file); } rmdir($dirname); @@ -117,7 +117,7 @@ class ThemeInstallator extends Module { if (is_dir($src.'/'.$file)) self::recurseCopy($src.'/'.$file, $dst.'/'.$file); - else if (is_readable($src.'/'.$file) AND $file != 'Thumbs.db' AND $file != '.DS_Store' AND substr($file, -1) != '~') + else if (is_readable($src.'/'.$file) && $file != 'Thumbs.db' && $file != '.DS_Store' && substr($file, -1) != '~') copy($src.'/'.$file, $dst.'/'.$file); } closedir($dir); @@ -166,16 +166,16 @@ class ThemeInstallator extends Module define('_EXPORT_FOLDER_', dirname(__FILE__).'/export/'); define('_IMPORT_FOLDER_', dirname(__FILE__).'/import/'); $this->page = 1; - if (!file_exists(_EXPORT_FOLDER_) OR !is_dir(_EXPORT_FOLDER_)) + if (!file_exists(_EXPORT_FOLDER_) || !is_dir(_EXPORT_FOLDER_)) mkdir(_EXPORT_FOLDER_, 0777); - if (!file_exists(_IMPORT_FOLDER_) OR !is_dir(_IMPORT_FOLDER_)) + if (!file_exists(_IMPORT_FOLDER_) || !is_dir(_IMPORT_FOLDER_)) mkdir(_IMPORT_FOLDER_, 0777); - if (!Tools::isSubmit('cancelExport') AND (Tools::isSubmit('exportTheme') OR Tools::isSubmit('submitExport'))) + if (!Tools::isSubmit('cancelExport') && (Tools::isSubmit('exportTheme') || Tools::isSubmit('submitExport'))) $this->page = 'exportPage'; $this->_html = '
'; - if (Tools::isSubmit('modulesToExport') OR Tools::isSubmit('submitModules')) + if (Tools::isSubmit('modulesToExport') || Tools::isSubmit('submitModules')) $this->to_export = Tools::getValue('modulesToExport'); if (Tools::isSubmit('submitThemes')) $this->selectedVariations = Tools::getValue('variation'); @@ -197,7 +197,7 @@ class ThemeInstallator extends Module $this->to_disable = false; $this->to_install = false; $this->errors = false; - if ($this->page == 'exportPage' AND Tools::isSubmit('exportTheme') AND ($id_theme = Tools::getValue('mainTheme'))) + if ($this->page == 'exportPage' && Tools::isSubmit('exportTheme') && ($id_theme = Tools::getValue('mainTheme'))) { $theme = new Theme($id_theme); if (!(is_dir(_PS_ALL_THEMES_DIR_.$theme->directory) && file_exists(_PS_ALL_THEMES_DIR_.$theme->directory.'/index.tpl'))) @@ -212,13 +212,13 @@ class ThemeInstallator extends Module { if (Tools::isSubmit('submitImport1')) { - if ($_FILES['themearchive']['error'] OR !file_exists($_FILES['themearchive']['tmp_name'])) + if ($_FILES['themearchive']['error'] || !file_exists($_FILES['themearchive']['tmp_name'])) $this->errors .= parent::displayError($this->l('An error has occurred during the file upload.')); else if (substr($_FILES['themearchive']['name'], -4) != '.zip') $this->errors .= parent::displayError($this->l('Only zip files are allowed')); else if (!rename($_FILES['themearchive']['tmp_name'], ARCHIVE_NAME)) $this->errors .= parent::displayError($this->l('An error has occurred during the file copy.')); - elseif (Tools::ZipTest(ARCHIVE_NAME)) + else if (Tools::ZipTest(ARCHIVE_NAME)) $this->page = 2; else $this->errors .= parent::displayError($this->l('Zip file seems to be broken')); @@ -229,7 +229,7 @@ class ThemeInstallator extends Module $this->errors .= parent::displayError($this->l('Only zip files are allowed')); else if (!copy($url, ARCHIVE_NAME)) $this->errors .= parent::displayError($this->l('Error during the file download')); - elseif (Tools::ZipTest(ARCHIVE_NAME)) + else if (Tools::ZipTest(ARCHIVE_NAME)) $this->errors .= parent::displayError($this->l('Zip file seems to be broken')); else $this->page = 2; @@ -241,7 +241,7 @@ class ThemeInstallator extends Module $this->errors .= parent::displayError($this->l('Only zip files are allowed')); else if (!copy($filename, ARCHIVE_NAME)) $this->errors .= parent::displayError($this->l('An error has occurred during the file copy.')); - elseif (Tools::ZipTest(ARCHIVE_NAME)) + else if (Tools::ZipTest(ARCHIVE_NAME)) $this->page = 2; else $this->errors .= parent::displayError($this->l('Zip file seems to be broken')); @@ -252,7 +252,7 @@ class ThemeInstallator extends Module $this->page = 3; else if (Tools::isSubmit('submitModules')) $this->page = 4; - if ($this->page == 2 AND file_exists(ARCHIVE_NAME)) + if ($this->page == 2 && file_exists(ARCHIVE_NAME)) { if (!Tools::ZipExtract(ARCHIVE_NAME, _IMPORT_FOLDER_)) { @@ -277,18 +277,18 @@ class ThemeInstallator extends Module private function checkXmlFields() { - if (!file_exists(_IMPORT_FOLDER_.XMLFILENAME) OR !$xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME)) + if (!file_exists(_IMPORT_FOLDER_.XMLFILENAME) || !$xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME)) return false; - if (!$xml['version'] OR !$xml['name']) + if (!$xml['version'] || !$xml['name']) return false; foreach ($xml->variations->variation as $val) - if (!$val['name'] OR !$val['directory'] OR !$val['from'] OR !$val['to']) + if (!$val['name'] || !$val['directory'] || !$val['from'] || !$val['to']) return false; foreach ($xml->modules->module as $val) - if (!$val['action'] OR !$val['name']) + if (!$val['action'] || !$val['name']) return false; foreach ($xml->modules->hooks->hook as $val) - if (!$val['module'] OR !$val['hook'] OR !$val['position']) + if (!$val['module'] || !$val['hook'] || !$val['position']) return false; return true; } @@ -300,7 +300,7 @@ class ThemeInstallator extends Module self::getModuleState(); self::displayInformations(); - if (Tools::isSubmit('submitExport') AND $this->error === false AND $this->checkPostedDatas() == true) + if (Tools::isSubmit('submitExport') && $this->error === false && $this->checkPostedDatas() == true) { self::getThemeVariations(); self::getDocumentation(); @@ -329,7 +329,7 @@ class ThemeInstallator extends Module } self::init_defines(); - if (!Tools::isSubmit('cancelExport') AND $this->page == 'exportPage') + if (!Tools::isSubmit('cancelExport') && $this->page == 'exportPage') return self::getContentExport(); self::handleInformations(); switch ($this->page) @@ -386,7 +386,7 @@ class ThemeInstallator extends Module $this->native_modules = self::getTheNativeModules(); foreach ($this->xml->modules->module as $row) { - if (strval($row['action']) == 'install' AND !in_array(strval($row['name']), $this->native_modules)) + if (strval($row['action']) == 'install' && !in_array(strval($row['name']), $this->native_modules)) $this->to_install[] = strval($row['name']); else if (strval($row['action']) == 'enable') $this->to_enable[] = strval($row['name']); @@ -450,11 +450,11 @@ class ThemeInstallator extends Module $exceptions[] = (isset($row['exceptions']) ? explode(',', strval($row['exceptions'])) : array()); } - if (file_exists(_IMPORT_FOLDER_.'doc') AND sizeof($xml->docs->doc) != 0) + if (file_exists(_IMPORT_FOLDER_.'doc') && count($xml->docs->doc) != 0) self::_loadDocForm(); // install selected modules $flag = 0; - if (isset($this->to_export) AND $this->to_export) + if (isset($this->to_export) && $this->to_export) foreach ($this->to_export as $row) { if (in_array($row, $this->native_modules)) @@ -468,7 +468,7 @@ class ThemeInstallator extends Module UPDATE `'._DB_PREFIX_.'module` SET `active`= 1 WHERE `name` = \''.pSQL($row).'\''); - else if (!$obj OR !$obj->install()) + else if (!$obj || !$obj->install()) continue; Db::getInstance()->execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.$shopID.')'); $msg .= '- '.pSQL($row).'
'; @@ -493,7 +493,7 @@ class ThemeInstallator extends Module { $flag = 0; // Disable native modules - if ($val == 2 AND $this->to_disable AND count($this->to_disable)) + if ($val == 2 && $this->to_disable && count($this->to_disable)) foreach ($this->to_disable as $row) { $obj = Module::getInstanceByName($row); @@ -508,7 +508,7 @@ class ThemeInstallator extends Module } } $flag = 0; - if ($this->to_enable AND count($this->to_enable)) + if ($this->to_enable && count($this->to_enable)) foreach ($this->to_enable as $row) { $obj = Module::getInstanceByName($row); @@ -520,7 +520,7 @@ class ThemeInstallator extends Module WHERE `name` = \''.pSQL($row).'\''); Db::getInstance()->execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.$shopID.')'); } - else if (!is_object($obj) OR !$obj->install()) + else if (!is_object($obj) || !$obj->install()) continue ; if ($flag++ == 0) $msg .= ''.$this->l('The following modules have been enabled').' :
'; @@ -579,10 +579,10 @@ class ThemeInstallator extends Module $xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME); $this->xml = $xml; - if ($this->selectedVariations AND count($this->selectedVariations) > 0) + if ($this->selectedVariations && count($this->selectedVariations) > 0) { $ok = array(); - foreach ($this->selectedVariations as $count => $variation) + foreach ($this->selectedVariations as $variation) { if ($variation == 'prestashop') continue; @@ -594,7 +594,7 @@ class ThemeInstallator extends Module $res &= self::recurseCopy(_IMPORT_FOLDER_.'themes/'.$variation, $target_dir); $new_theme = new Theme(); $new_theme->name = (string)$this->xml['name']; - if( isset($this->xml['directory'])) + if (isset($this->xml['directory'])) $new_theme->directory = (string)$this->xml['directory']; else $new_theme->directory = (string)$this->xml['name']; @@ -604,7 +604,7 @@ class ThemeInstallator extends Module $ok[] = $variation; } - if (sizeof($ok) > 0) + if (count($ok) > 0) { $msg = $this->l('The following themes were successfully imported').':