feat(main): Made group and blocks translatable.

Still need to do slide and FAQ entities
This commit is contained in:
2026-09-09 11:56:18 +02:00
parent 85b56f1a13
commit 7cafc376b7
23 changed files with 451 additions and 82 deletions
+21 -18
View File
@@ -77,18 +77,19 @@ class CustomHtmlBlock extends ObjectModel
public $date_upd;
public static $definition = [
'table' => 'ws_customhtml',
'primary' => 'id_ws_customhtml',
'fields' => [
'table' => 'ws_customhtml',
'primary' => 'id_ws_customhtml',
'multilang' => true,
'fields' => [
'id_ws_customhtml_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 256],
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 256, 'lang' => true],
'type' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32],
'content' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'],
'content' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'lang' => true],
'custom_class' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 128],
'description' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 1024],
'extra_description' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 1024],
'link' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 512],
'link_text' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 128],
'description' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 1024, 'lang' => true],
'extra_description' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 1024, 'lang' => true],
'link' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 512, 'lang' => true],
'link_text' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 128, 'lang' => true],
'image' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 255],
'alert_type' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 16],
'timeout' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => false],
@@ -119,7 +120,7 @@ class CustomHtmlBlock extends ObjectModel
return _MODULE_DIR_ . 'ws_customhtml/views/img/banners/' . $filename;
}
public static function getActiveByGroupIds(array $groupIds): array
public static function getActiveByGroupIds(array $groupIds, int $idLang): array
{
$groupIds = array_map('intval', $groupIds);
@@ -128,14 +129,16 @@ class CustomHtmlBlock extends ObjectModel
}
$result = Db::getInstance()->executeS(
'SELECT `id_ws_customhtml`, `id_ws_customhtml_group`, `title`, `type`, `content`, `custom_class`,
`description`, `extra_description`, `link`, `link_text`, `image`, `alert_type`, `timeout`,
`slider_mode`, `slides_per_view_mobile`, `slides_per_view_tablet`, `slides_per_view_desktop`, `autoplay_delay`,
`active`, `show_title`, `ordering`
FROM `' . _DB_PREFIX_ . 'ws_customhtml`
WHERE `id_ws_customhtml_group` IN (' . implode(',', $groupIds) . ')
AND `active` = 1
ORDER BY `ordering` ASC'
'SELECT wch.`id_ws_customhtml`, wch.`id_ws_customhtml_group`, wchl.`title`, wch.`type`, wchl.`content`, wch.`custom_class`,
wchl.`description`, wchl.`extra_description`, wchl.`link`, wchl.`link_text`, wch.`image`, wch.`alert_type`, wch.`timeout`,
wch.`slider_mode`, wch.`slides_per_view_mobile`, wch.`slides_per_view_tablet`, wch.`slides_per_view_desktop`, wch.`autoplay_delay`,
wch.`active`, wch.`show_title`, wch.`ordering`
FROM `' . _DB_PREFIX_ . 'ws_customhtml` wch
LEFT JOIN `' . _DB_PREFIX_ . 'ws_customhtml_lang` wchl
ON wchl.`id_ws_customhtml` = wch.`id_ws_customhtml` AND wchl.`id_lang` = ' . (int) $idLang . '
WHERE wch.`id_ws_customhtml_group` IN (' . implode(',', $groupIds) . ')
AND wch.`active` = 1
ORDER BY wch.`ordering` ASC'
);
$blocksByGroup = [];