Add model
This commit is contained in:
parent
c3f5f5f54c
commit
679179bc74
@ -7,40 +7,52 @@ require_once PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php';
|
||||
|
||||
class AdminSkinStatic extends AdminTab
|
||||
{
|
||||
public $_html = '';
|
||||
|
||||
protected $maxImageSize = NULL;
|
||||
protected $maxFileSize = NULL;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'skinstatic';
|
||||
$this->className = 'Skinstatic';
|
||||
$this->lang = true;
|
||||
$this->view = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->maxImageSize = (Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1000000);
|
||||
$this->maxFileSize = (Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_skinstatic' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'name', 'orderby' => false),
|
||||
'a!active' => array('title' => $this->l('Active'), 'active' => 'status', 'filter_key' => 'a!active', 'align' => 'center', 'type' => 'bool', 'orderby' => false),
|
||||
'start_at' => array('title' => $this->l('Start at'), 'widthColumn' => 100, 'width' => 140),
|
||||
'end_at' => array('title' => $this->l('End at'), 'widthColumn' => 100, 'width' => 140),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
echo "Display";
|
||||
parent::display();
|
||||
}
|
||||
|
||||
// List
|
||||
public function displayList()
|
||||
{
|
||||
echo "DisplayList";
|
||||
parent::displayList();
|
||||
}
|
||||
|
||||
// Form
|
||||
public function displayForm()
|
||||
{
|
||||
echo "DisplayForm";
|
||||
parent::displayForm();
|
||||
echo "TEST";
|
||||
}
|
||||
|
||||
// Fallback
|
||||
private function displayFallback()
|
||||
{
|
||||
echo "DisplayFallback";
|
||||
}
|
||||
|
||||
// Form fallback
|
||||
private function displayFallbackForm()
|
||||
{
|
||||
echo "DisplayFallbackForm";
|
||||
}
|
||||
|
||||
}
|
||||
|
15
modules/skinstatic/AdminSkinStaticFallback.php
Normal file
15
modules/skinstatic/AdminSkinStaticFallback.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php';
|
||||
|
||||
class AdminSkinStaticFallback extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
87
modules/skinstatic/classes/Skinstatic.php
Normal file
87
modules/skinstatic/classes/Skinstatic.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
class Skinstatic extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $id_skinstatic;
|
||||
public $name;
|
||||
public $active;
|
||||
public $start_at;
|
||||
public $end_at;
|
||||
|
||||
public $image;
|
||||
public $link_left;
|
||||
public $link_right;
|
||||
public $new_window;
|
||||
|
||||
protected $fieldRequired = array();
|
||||
protected $fieldValidate = array(
|
||||
'id_skinstatic' => 'isUnsignedId',
|
||||
'name' => 'isString',
|
||||
'active' => 'isBool',
|
||||
'start_at' => 'isDate',
|
||||
'end_at' => 'isDate',
|
||||
);
|
||||
|
||||
protected $tables = array('skinstatic', 'skinstatic_lang');
|
||||
|
||||
protected $table = 'skinstatic';
|
||||
protected $identifier = 'id_skinstatic';
|
||||
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
parent::validateFields();
|
||||
if (isset($this->id)) {
|
||||
$fields['id_skinstatic'] = (int)($this->id);
|
||||
}
|
||||
$fields['name'] = (int)($this->name);
|
||||
$fields['active'] = (int)($this->active);
|
||||
$fields['start_at'] = pSQL($this->start_at);
|
||||
$fields['end_at'] = pSQL($this->end_at);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check then return multilingual fields for database interaction
|
||||
*
|
||||
* @return array Multilingual fields
|
||||
*/
|
||||
public function getTranslationsFieldsChild()
|
||||
{
|
||||
self::validateFieldsLang();
|
||||
|
||||
$fieldsArray = array('image', 'link_left', 'link_right', 'new_window');
|
||||
$fields = array();
|
||||
$languages = Language::getLanguages(false);
|
||||
$defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$fields[$language['id_lang']]['id_lang'] = $language['id_lang'];
|
||||
$fields[$language['id_lang']][$this->identifier] = (int)($this->id);
|
||||
$fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? pSQL($this->description[$language['id_lang']], true) : '';
|
||||
$fields[$language['id_lang']]['description_short'] = (isset($this->description_short[$language['id_lang']])) ? pSQL($this->description_short[$language['id_lang']], true) : '';
|
||||
foreach ($fieldsArray as $field)
|
||||
{
|
||||
if (!Validate::isTableOrIdentifier($field))
|
||||
die(Tools::displayError());
|
||||
|
||||
/* Check fields validity */
|
||||
if (isset($this->{$field}[$language['id_lang']]) AND !empty($this->{$field}[$language['id_lang']]))
|
||||
$fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]);
|
||||
elseif (in_array($field, $this->fieldsRequiredLang))
|
||||
{
|
||||
if ($this->{$field} != '')
|
||||
$fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]);
|
||||
}
|
||||
else
|
||||
$fields[$language['id_lang']][$field] = '';
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
}
|
6
modules/skinstatic/classes/SkinstaticFallback.php
Normal file
6
modules/skinstatic/classes/SkinstaticFallback.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class SkinstaticFallback extends ObjectModel
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -30,5 +30,11 @@ class SkinStatic extends Module
|
||||
public function install()
|
||||
{
|
||||
// See SQL file for installation
|
||||
|
||||
if (!(parent::install()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user