execute( 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_lang` ( `id_ws_customhtml` INT(11) NOT NULL, `id_lang` INT(11) NOT NULL, `title` VARCHAR(256) NOT NULL DEFAULT \'\', `content` LONGTEXT, `description` TEXT, `extra_description` TEXT, `link_text` VARCHAR(128) NOT NULL DEFAULT \'\', PRIMARY KEY (`id_ws_customhtml`, `id_lang`) );' ); } function migrateBlockFieldsToLangTable(): bool { $columns = Db::getInstance()->executeS( 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'title\'' ); if (empty($columns)) { // Already migrated in a previous run of this upgrade. return true; } $blocks = Db::getInstance()->executeS( 'SELECT `id_ws_customhtml`, `title`, `content`, `description`, `extra_description`, `link_text` FROM `' . _DB_PREFIX_ . 'ws_customhtml`' ); $languages = Language::getLanguages(false); foreach ($blocks as $block) { foreach ($languages as $language) { $existing = Db::getInstance()->executeS( 'SELECT 1 FROM `' . _DB_PREFIX_ . 'ws_customhtml_lang` WHERE `id_ws_customhtml` = ' . (int) $block['id_ws_customhtml'] . ' AND `id_lang` = ' . (int) $language['id_lang'] ); if (!empty($existing)) { continue; } $result = Db::getInstance()->insert('ws_customhtml_lang', [ 'id_ws_customhtml' => (int) $block['id_ws_customhtml'], 'id_lang' => (int) $language['id_lang'], 'title' => pSQL($block['title']), 'content' => pSQL($block['content'], true), 'description' => pSQL($block['description']), 'extra_description' => pSQL($block['extra_description']), 'link_text' => pSQL($block['link_text']), ]); if (!$result) { return false; } } } return true; } function dropBlockLangColumns(): bool { $columns = Db::getInstance()->executeS( 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'title\'' ); if (empty($columns)) { return true; } return Db::getInstance()->execute( 'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` DROP COLUMN `title`, DROP COLUMN `content`, DROP COLUMN `description`, DROP COLUMN `extra_description`, DROP COLUMN `link_text`' ); }