feat(main): Add banner option
This commit is contained in:
@@ -25,6 +25,18 @@ class CustomHtmlBlock extends ObjectModel
|
||||
/** @var string */
|
||||
public $custom_class = '';
|
||||
|
||||
/** @var string */
|
||||
public $description = '';
|
||||
|
||||
/** @var string */
|
||||
public $extra_description = '';
|
||||
|
||||
/** @var string */
|
||||
public $link = '';
|
||||
|
||||
/** @var string */
|
||||
public $image = '';
|
||||
|
||||
/** @var int */
|
||||
public $active = 1;
|
||||
|
||||
@@ -49,6 +61,10 @@ class CustomHtmlBlock extends ObjectModel
|
||||
'type' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32],
|
||||
'content' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'],
|
||||
'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],
|
||||
'image' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 255],
|
||||
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
|
||||
'show_title' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
|
||||
'ordering' => ['type' => self::TYPE_INT, 'validate' => 'isInt'],
|
||||
@@ -57,6 +73,20 @@ class CustomHtmlBlock extends ObjectModel
|
||||
],
|
||||
];
|
||||
|
||||
public static function getBannerImageDir(): string
|
||||
{
|
||||
return _PS_MODULE_DIR_ . 'ws_customhtml/views/img/banners/';
|
||||
}
|
||||
|
||||
public static function getBannerImageUrl(string $filename): string
|
||||
{
|
||||
if (empty($filename)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return _MODULE_DIR_ . 'ws_customhtml/views/img/banners/' . $filename;
|
||||
}
|
||||
|
||||
public static function getActiveByGroupIds(array $groupIds): array
|
||||
{
|
||||
$groupIds = array_map('intval', $groupIds);
|
||||
@@ -66,7 +96,8 @@ class CustomHtmlBlock extends ObjectModel
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml`, `id_ws_customhtml_group`, `title`, `type`, `content`, `custom_class`, `active`, `show_title`, `ordering`
|
||||
'SELECT `id_ws_customhtml`, `id_ws_customhtml_group`, `title`, `type`, `content`, `custom_class`,
|
||||
`description`, `extra_description`, `link`, `image`, `active`, `show_title`, `ordering`
|
||||
FROM `' . _DB_PREFIX_ . 'ws_customhtml`
|
||||
WHERE `id_ws_customhtml_group` IN (' . implode(',', $groupIds) . ')
|
||||
AND `active` = 1
|
||||
|
||||
Reference in New Issue
Block a user