75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\ContentBundle\Admin;
|
|
|
|
use KupShop\I18nBundle\Translations\InfoPanelTranslation;
|
|
use KupShop\KupShopBundle\Config;
|
|
use Query\Operator;
|
|
|
|
class InfoPanel extends \Window
|
|
{
|
|
protected $tableName = 'info_panels';
|
|
protected $nameField = 'id';
|
|
protected $template = 'window/infoPanelAdmin.tpl';
|
|
|
|
public function get_vars()
|
|
{
|
|
$vars = parent::get_vars();
|
|
|
|
$infoPanelsData = Config::get()['Modules']['info_panels'] ?? null;
|
|
|
|
$infoPanelsData['types'][] = [
|
|
'type' => 'default',
|
|
'descr' => 'Výchozí',
|
|
];
|
|
|
|
$vars['body']['info_panel_types'] = $infoPanelsData['types'] ?? [];
|
|
$vars['body']['info_panel_colors'] = $infoPanelsData['colors'] ?? [];
|
|
$vars['body']['info_panelTranslationsFigure'] = $this->getTranslationUtil()?->getTranslationsFigure(InfoPanelTranslation::class, $this->getID(), 'active');
|
|
|
|
return $vars;
|
|
}
|
|
|
|
public function handleUpdate()
|
|
{
|
|
$SQL = parent::handleUpdate();
|
|
|
|
if ($SQL) {
|
|
$data = $this->getData();
|
|
$this->getTranslationUtil()?->updateTranslationsFigure(InfoPanelTranslation::class, $this->getID(), $data['translation_figure'], 'active');
|
|
}
|
|
|
|
return $SQL;
|
|
}
|
|
|
|
public function getData()
|
|
{
|
|
$data = parent::getData();
|
|
if (getVal('Submit')) {
|
|
if (empty($data['name'])) {
|
|
$this->returnError('Nejsou správně vyplněny údaje');
|
|
}
|
|
|
|
$data['date_from'] = $this->prepareDateTime($data['date_from']);
|
|
$data['date_to'] = $this->prepareDateTime($data['date_to']);
|
|
|
|
$body = sqlQueryBuilder()
|
|
->select('body')
|
|
->from('info_panels')
|
|
->andWhere(Operator::equals(['id' => $data['ID']]))
|
|
->execute()
|
|
->fetchOne();
|
|
|
|
if (!empty($data['body']) && trim($data['body']) != $body) {
|
|
$data['version'] = empty($data['version']) ? 1 : $data['version'] + 1;
|
|
}
|
|
|
|
$data['data'] = json_encode($data['data'], true);
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
return InfoPanel::class;
|