feat(main): Remove dead code
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
{if !empty($block.link)}<a href="{$block.link|escape:'html':'UTF-8'}">{/if}
|
||||
<p class="h1 usp__name text-center">
|
||||
<span>{$block.title|escape:'html':'UTF-8'}</span>
|
||||
</p>
|
||||
{if !empty($block.description)}
|
||||
<p class="usp__description text-center">
|
||||
{$block.description|escape:'html':'UTF-8'|nl2br}
|
||||
</p>
|
||||
{/if}
|
||||
{if !empty($block.link)}</a>{/if}
|
||||
@@ -1,11 +0,0 @@
|
||||
{if !empty($block.link)}<a href="{$block.link|escape:'html':'UTF-8'}">{/if}
|
||||
<small class="uppercase-mono-red">/{$iteration|string_format:"%02d"}</small>
|
||||
<p class="h3 font-default usp__name mt2 mt-lg-3">
|
||||
<span>{$block.title|escape:'html':'UTF-8'}</span>
|
||||
</p>
|
||||
{if !empty($block.description)}
|
||||
<p class="usp__description">
|
||||
{$block.description|escape:'html':'UTF-8'|nl2br}
|
||||
</p>
|
||||
{/if}
|
||||
{if !empty($block.link)}</a>{/if}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_10_0($module)
|
||||
{
|
||||
$columnsToAdd = [
|
||||
'alert_type' => 'VARCHAR(16) NOT NULL DEFAULT \'info\'',
|
||||
'timeout' => 'INT(11) NOT NULL DEFAULT 0',
|
||||
];
|
||||
|
||||
foreach ($columnsToAdd as $column => $definition) {
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'' . $column . '\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` ADD COLUMN `' . $column . '` ' . $definition
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_11_0($module)
|
||||
{
|
||||
$groups = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml_group` FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` ORDER BY `id_ws_customhtml_group` ASC'
|
||||
);
|
||||
|
||||
foreach ($groups as $index => $group) {
|
||||
if (!Db::getInstance()->update(
|
||||
'ws_customhtml_group',
|
||||
['ordering' => (int) $index],
|
||||
'`id_ws_customhtml_group` = ' . (int) $group['id_ws_customhtml_group']
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_13_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` LIKE \'custom_class\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_group`
|
||||
ADD COLUMN `custom_class` VARCHAR(128) NOT NULL DEFAULT \'\' AFTER `title`'
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_15_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'link_text\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
ADD COLUMN `link_text` VARCHAR(128) NOT NULL DEFAULT \'\' AFTER `link`'
|
||||
);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_16_0($module)
|
||||
{
|
||||
$columnsToAdd = [
|
||||
'slides_per_view_mobile' => 'DECIMAL(4,2) NOT NULL DEFAULT 1',
|
||||
'slides_per_view_tablet' => 'DECIMAL(4,2) NOT NULL DEFAULT 2',
|
||||
'slides_per_view_desktop' => 'DECIMAL(4,2) NOT NULL DEFAULT 3',
|
||||
'autoplay_delay' => 'INT(11) NOT NULL DEFAULT 0',
|
||||
];
|
||||
|
||||
foreach ($columnsToAdd as $column => $definition) {
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'' . $column . '\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` ADD COLUMN `' . $column . '` ' . $definition
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_slide` (
|
||||
`id_ws_customhtml_slide` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`id_ws_customhtml` INT(11) NOT NULL,
|
||||
`title` VARCHAR(256) NOT NULL DEFAULT \'\',
|
||||
`description` TEXT,
|
||||
`extra_description` TEXT,
|
||||
`link` VARCHAR(512) NOT NULL DEFAULT \'\',
|
||||
`link_text` VARCHAR(128) NOT NULL DEFAULT \'\',
|
||||
`image` VARCHAR(255) NOT NULL DEFAULT \'\',
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`date_upd` DATETIME NOT NULL,
|
||||
KEY `id_ws_customhtml` (`id_ws_customhtml`)
|
||||
)'
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_17_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'slider_mode\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
ADD COLUMN `slider_mode` VARCHAR(16) NOT NULL DEFAULT \'always\' AFTER `timeout`'
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_19_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` LIKE \'default_block_class\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_group`
|
||||
ADD COLUMN `default_block_class` VARCHAR(128) NOT NULL DEFAULT \'\' AFTER `custom_class`'
|
||||
);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_2_0($module)
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'type\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
if (!Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
ADD COLUMN `type` VARCHAR(32) NOT NULL DEFAULT \'html\' AFTER `title`'
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Db::getInstance()->execute(
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_faq` (
|
||||
`id_ws_customhtml_faq` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`id_ws_customhtml` INT(11) NOT NULL,
|
||||
`question` VARCHAR(512) NOT NULL DEFAULT \'\',
|
||||
`answer` TEXT,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`date_upd` DATETIME NOT NULL,
|
||||
KEY `id_ws_customhtml` (`id_ws_customhtml`)
|
||||
)'
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $module->registerHook('actionCustomhtmlblockGridDataModifier');
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_20_0($module)
|
||||
{
|
||||
if (!createGroupLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!migrateGroupTitlesToLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dropGroupTitleColumn();
|
||||
}
|
||||
|
||||
function createGroupLangTable(): bool
|
||||
{
|
||||
return Db::getInstance()->execute(
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_group_lang` (
|
||||
`id_ws_customhtml_group` INT(11) NOT NULL,
|
||||
`id_lang` INT(11) NOT NULL,
|
||||
`title` VARCHAR(256) NOT NULL DEFAULT \'\',
|
||||
PRIMARY KEY (`id_ws_customhtml_group`, `id_lang`)
|
||||
);'
|
||||
);
|
||||
}
|
||||
|
||||
function migrateGroupTitlesToLangTable(): bool
|
||||
{
|
||||
$groupColumns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` LIKE \'title\''
|
||||
);
|
||||
|
||||
if (empty($groupColumns)) {
|
||||
// Already migrated in a previous run of this upgrade.
|
||||
return true;
|
||||
}
|
||||
|
||||
$groups = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml_group`, `title` FROM `' . _DB_PREFIX_ . 'ws_customhtml_group`'
|
||||
);
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
foreach ($languages as $language) {
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SELECT 1 FROM `' . _DB_PREFIX_ . 'ws_customhtml_group_lang`
|
||||
WHERE `id_ws_customhtml_group` = ' . (int) $group['id_ws_customhtml_group'] . '
|
||||
AND `id_lang` = ' . (int) $language['id_lang']
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->insert('ws_customhtml_group_lang', [
|
||||
'id_ws_customhtml_group' => (int) $group['id_ws_customhtml_group'],
|
||||
'id_lang' => (int) $language['id_lang'],
|
||||
'title' => pSQL($group['title']),
|
||||
]);
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function dropGroupTitleColumn(): bool
|
||||
{
|
||||
$groupColumns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` LIKE \'title\''
|
||||
);
|
||||
|
||||
if (empty($groupColumns)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_group` DROP COLUMN `title`'
|
||||
);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_21_0($module)
|
||||
{
|
||||
if (!createBlockLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!migrateBlockFieldsToLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dropBlockLangColumns();
|
||||
}
|
||||
|
||||
function createBlockLangTable(): bool
|
||||
{
|
||||
return Db::getInstance()->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`'
|
||||
);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_22_0($module)
|
||||
{
|
||||
if (!addLinkColumnToLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!migrateBlockLinkToLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dropBlockLinkColumn();
|
||||
}
|
||||
|
||||
function addLinkColumnToLangTable(): bool
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_lang` LIKE \'link\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_lang`
|
||||
ADD COLUMN `link` VARCHAR(512) NOT NULL DEFAULT \'\' AFTER `extra_description`'
|
||||
);
|
||||
}
|
||||
|
||||
function migrateBlockLinkToLangTable(): bool
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'link\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
// Already migrated in a previous run of this upgrade.
|
||||
return true;
|
||||
}
|
||||
|
||||
$blocks = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml`, `link` FROM `' . _DB_PREFIX_ . 'ws_customhtml`'
|
||||
);
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
$result = Db::getInstance()->update(
|
||||
'ws_customhtml_lang',
|
||||
['link' => pSQL($block['link'])],
|
||||
'`id_ws_customhtml` = ' . (int) $block['id_ws_customhtml']
|
||||
);
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function dropBlockLinkColumn(): bool
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'link\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` DROP COLUMN `link`'
|
||||
);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_23_0($module)
|
||||
{
|
||||
if (!createSlideLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!migrateSlideFieldsToLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dropSlideLangColumns();
|
||||
}
|
||||
|
||||
function createSlideLangTable(): bool
|
||||
{
|
||||
return Db::getInstance()->execute(
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_slide_lang` (
|
||||
`id_ws_customhtml_slide` INT(11) NOT NULL,
|
||||
`id_lang` INT(11) NOT NULL,
|
||||
`title` VARCHAR(256) NOT NULL DEFAULT \'\',
|
||||
`description` TEXT,
|
||||
`extra_description` TEXT,
|
||||
`link` VARCHAR(512) NOT NULL DEFAULT \'\',
|
||||
`link_text` VARCHAR(128) NOT NULL DEFAULT \'\',
|
||||
PRIMARY KEY (`id_ws_customhtml_slide`, `id_lang`)
|
||||
);'
|
||||
);
|
||||
}
|
||||
|
||||
function migrateSlideFieldsToLangTable(): bool
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide` LIKE \'title\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
// Already migrated in a previous run of this upgrade.
|
||||
return true;
|
||||
}
|
||||
|
||||
$slides = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml_slide`, `title`, `description`, `extra_description`, `link`, `link_text`
|
||||
FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide`'
|
||||
);
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
foreach ($slides as $slide) {
|
||||
foreach ($languages as $language) {
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SELECT 1 FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide_lang`
|
||||
WHERE `id_ws_customhtml_slide` = ' . (int) $slide['id_ws_customhtml_slide'] . '
|
||||
AND `id_lang` = ' . (int) $language['id_lang']
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->insert('ws_customhtml_slide_lang', [
|
||||
'id_ws_customhtml_slide' => (int) $slide['id_ws_customhtml_slide'],
|
||||
'id_lang' => (int) $language['id_lang'],
|
||||
'title' => pSQL($slide['title']),
|
||||
'description' => pSQL($slide['description']),
|
||||
'extra_description' => pSQL($slide['extra_description']),
|
||||
'link' => pSQL($slide['link']),
|
||||
'link_text' => pSQL($slide['link_text']),
|
||||
]);
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function dropSlideLangColumns(): bool
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide` LIKE \'title\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_slide`
|
||||
DROP COLUMN `title`,
|
||||
DROP COLUMN `description`,
|
||||
DROP COLUMN `extra_description`,
|
||||
DROP COLUMN `link`,
|
||||
DROP COLUMN `link_text`'
|
||||
);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_24_0($module)
|
||||
{
|
||||
if (!createFaqLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!migrateFaqFieldsToLangTable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dropFaqLangColumns();
|
||||
}
|
||||
|
||||
function createFaqLangTable(): bool
|
||||
{
|
||||
return Db::getInstance()->execute(
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_faq_lang` (
|
||||
`id_ws_customhtml_faq` INT(11) NOT NULL,
|
||||
`id_lang` INT(11) NOT NULL,
|
||||
`question` VARCHAR(512) NOT NULL DEFAULT \'\',
|
||||
`answer` TEXT,
|
||||
PRIMARY KEY (`id_ws_customhtml_faq`, `id_lang`)
|
||||
);'
|
||||
);
|
||||
}
|
||||
|
||||
function migrateFaqFieldsToLangTable(): bool
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_faq` LIKE \'question\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
// Already migrated in a previous run of this upgrade.
|
||||
return true;
|
||||
}
|
||||
|
||||
$faqs = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml_faq`, `question`, `answer`
|
||||
FROM `' . _DB_PREFIX_ . 'ws_customhtml_faq`'
|
||||
);
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
foreach ($faqs as $faq) {
|
||||
foreach ($languages as $language) {
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SELECT 1 FROM `' . _DB_PREFIX_ . 'ws_customhtml_faq_lang`
|
||||
WHERE `id_ws_customhtml_faq` = ' . (int) $faq['id_ws_customhtml_faq'] . '
|
||||
AND `id_lang` = ' . (int) $language['id_lang']
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->insert('ws_customhtml_faq_lang', [
|
||||
'id_ws_customhtml_faq' => (int) $faq['id_ws_customhtml_faq'],
|
||||
'id_lang' => (int) $language['id_lang'],
|
||||
'question' => pSQL($faq['question']),
|
||||
'answer' => pSQL($faq['answer'], true),
|
||||
]);
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function dropFaqLangColumns(): bool
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_faq` LIKE \'question\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_faq`
|
||||
DROP COLUMN `question`,
|
||||
DROP COLUMN `answer`'
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_3_0($module)
|
||||
{
|
||||
$columns = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'column_class\''
|
||||
);
|
||||
|
||||
if (empty($columns)) {
|
||||
if (!Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
ADD COLUMN `column_class` VARCHAR(128) NOT NULL DEFAULT \'col-12\' AFTER `content`'
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_4_0($module)
|
||||
{
|
||||
if (!Hook::isModuleRegisteredOnHook($module, 'actionFrontControllerSetMedia', (int) Context::getContext()->shop->id)) {
|
||||
return $module->registerHook('actionFrontControllerSetMedia');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_5_0($module)
|
||||
{
|
||||
$newColumn = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'custom_class\''
|
||||
);
|
||||
|
||||
if (!empty($newColumn)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$oldColumn = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'column_class\''
|
||||
);
|
||||
|
||||
if (!empty($oldColumn)) {
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
CHANGE `column_class` `custom_class` VARCHAR(128) NOT NULL DEFAULT \'\''
|
||||
);
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
ADD COLUMN `custom_class` VARCHAR(128) NOT NULL DEFAULT \'\' AFTER `content`'
|
||||
);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_6_0($module)
|
||||
{
|
||||
$columnsToAdd = [
|
||||
'description' => 'TEXT',
|
||||
'extra_description' => 'TEXT',
|
||||
'link' => 'VARCHAR(512) NOT NULL DEFAULT \'\'',
|
||||
'template' => 'VARCHAR(32) NOT NULL DEFAULT \'image_left\'',
|
||||
'image' => 'VARCHAR(255) NOT NULL DEFAULT \'\'',
|
||||
];
|
||||
|
||||
foreach ($columnsToAdd as $column => $definition) {
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'' . $column . '\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` ADD COLUMN `' . $column . '` ' . $definition
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_7_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'template\''
|
||||
);
|
||||
|
||||
if (empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` DROP COLUMN `template`'
|
||||
);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_8_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'template_key\''
|
||||
);
|
||||
|
||||
if (!empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` ADD COLUMN `template_key` VARCHAR(64) NOT NULL DEFAULT \'\''
|
||||
);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_9_0($module)
|
||||
{
|
||||
$existing = Db::getInstance()->executeS(
|
||||
'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml` LIKE \'template_key\''
|
||||
);
|
||||
|
||||
if (empty($existing)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute(
|
||||
'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml` DROP COLUMN `template_key`'
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user