Files
lulandia.pl/modules/ybc_widget/classes/ybc_widget_widget_class.php
2025-04-01 00:38:54 +02:00

64 lines
2.7 KiB
PHP

<?php
/**
* Copyright YourBestCode.com
* Email: support@yourbestcode.com
* First created: 21/12/2015
* Last updated: NOT YET
*/
if (!defined('_PS_VERSION_'))
exit;
class Ybc_widget_widget_class extends ObjectModel
{
public $id_widget;
public $title;
public $subtitle;
public $icon;
public $description;
public $enabled;
public $show_image;
public $show_title;
public $show_description;
public $link;
public $image;
public $sort_order;
public $hook;
public static $definition = array(
'table' => 'ybc_widget_widget',
'primary' => 'id_widget',
'multilang' => true,
'fields' => array(
'enabled' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'show_title' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'show_image' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'show_description' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'sort_order' => array('type' => self::TYPE_INT),
'link' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 500),
'hook' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 500),
'image' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 500),
'icon' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 500),
// Lang fields
'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 700),
'subtitle' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 700),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'size' => 900000),
)
);
public function __construct($id_item = null, $id_lang = null, $id_shop = null, Context $context = null)
{
parent::__construct($id_item, $id_lang, $id_shop);
$languages = Language::getLanguages(false);
$id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT');
foreach($languages as $lang)
{
foreach(self::$definition['fields'] as $field => $params)
{
$temp = $this->$field;
if(isset($params['lang']) && $params['lang'] && !isset($temp[$lang['id_lang']]))
{
$temp[$lang['id_lang']] = '';
}
$this->$field = $temp;
}
}
}
}