65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Websmid\CustomHtml\Model;
|
|
|
|
use ObjectModel;
|
|
use Db;
|
|
|
|
class CustomHtml extends ObjectModel
|
|
{
|
|
/** @var int */
|
|
public $id;
|
|
|
|
/** @var string */
|
|
public $hook_name = '';
|
|
|
|
/** @var string */
|
|
public $title = '';
|
|
|
|
/** @var string */
|
|
public $content = '';
|
|
|
|
/** @var int */
|
|
public $active = 1;
|
|
|
|
/** @var int */
|
|
public $show_title = 0;
|
|
|
|
/** @var int */
|
|
public $ordering = 0;
|
|
|
|
/** @var string */
|
|
public $date_add;
|
|
|
|
/** @var string */
|
|
public $date_upd;
|
|
|
|
public static $definition = [
|
|
'table' => 'ws_customhtml',
|
|
'primary' => 'id_ws_customhtml',
|
|
'fields' => [
|
|
'hook_name' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64],
|
|
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 256],
|
|
'content' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'],
|
|
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
|
|
'show_title' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
|
|
'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 getActiveByHookName(string $hookName): array
|
|
{
|
|
$result = Db::getInstance()->executeS(
|
|
'SELECT `id_ws_customhtml`, `title`, `content`, `active`, `show_title`, `ordering`
|
|
FROM `' . _DB_PREFIX_ . 'ws_customhtml`
|
|
WHERE `hook_name` = \'' . pSQL($hookName) . '\'
|
|
AND `active` = 1
|
|
ORDER BY `ordering` ASC'
|
|
);
|
|
|
|
return $result ?: [];
|
|
}
|
|
}
|