feat(main): Add slider block type

This commit is contained in:
2026-08-25 14:32:21 +02:00
parent 06e98a429b
commit be9a676d9d
28 changed files with 729 additions and 120 deletions
+76
View File
@@ -0,0 +1,76 @@
<?php
namespace Websmid\CustomHtml\Model;
use ObjectModel;
use Db;
class CustomHtmlSlide extends ObjectModel
{
/** @var int */
public $id;
/** @var int */
public $id_ws_customhtml;
/** @var string */
public $title = '';
/** @var string */
public $description = '';
/** @var string */
public $extra_description = '';
/** @var string */
public $link = '';
/** @var string */
public $link_text = '';
/** @var string */
public $image = '';
/** @var int */
public $ordering = 0;
/** @var string */
public $date_add;
/** @var string */
public $date_upd;
public static $definition = [
'table' => 'ws_customhtml_slide',
'primary' => 'id_ws_customhtml_slide',
'fields' => [
'id_ws_customhtml' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 256],
'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],
'image' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 255],
'ordering' => ['type' => self::TYPE_INT, 'validate' => 'isInt'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
public static function getByBlockId(int $idBlock): array
{
$result = Db::getInstance()->executeS(
'SELECT `id_ws_customhtml_slide`, `title`, `description`, `extra_description`, `link`, `link_text`, `image`, `ordering`
FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide`
WHERE `id_ws_customhtml` = ' . (int) $idBlock . '
ORDER BY `ordering` ASC'
);
return $result ?: [];
}
public static function deleteByBlockId(int $idBlock): void
{
Db::getInstance()->delete('ws_customhtml_slide', '`id_ws_customhtml` = ' . (int) $idBlock);
}
}