Promo block * @copyright Tamaranga */ class IndexPromoBlock extends Block { /** @var bool Включен блок с магазином */ public $company_enabled = true; /** @var string Иконка блока с магазином */ public $company_icon = ''; /** @var string Заголовок блока с магазином */ public $company_title = ''; /** @var string Описание блока с магазином */ public $company_descr = ''; /** @var string Текст на кнопке создать магазин */ public $company_button = ''; /** @var string Цвет кнопки создать магазин */ public $company_background = '#FF9D00'; /** @var string Адрес перехода кнопки создать магазин */ public $company_url = ''; /** @var string Иконка блока с объявлением */ public $listings_icon = ''; /** @var string Изображение для блока с магазином, если блок выключен */ public $listings_image = ''; /** @var string Заголовок блока с объявлением */ public $listings_title = ''; /** @var string Описание блока с объявлением */ public $listings_descr = ''; /** @var string Текст на кнопке создать объявление */ public $listings_button = ''; /** @var string Цвет кнопки создать объявление */ public $listings_background = '#74b31b'; /** @var string Адрес перехода кнопки создать магазин */ public $listings_url = ''; public function init() { parent::init(); $this->setTemplate('index/promo', 'site'); $this->setKey('promo'); $this->setTitle(_t('site', 'Promo')); } public function data() { $data = parent::data(); if (! bff::businessEnabled()) { $data['company_enabled'] = $this->company_enabled = false; } if ($this->company_url !== '') { # relative => absolute $this->company_url = Url::to($this->company_url, ['lang' => $this->locale->current()]); } if ($this->listings_url !== '') { # relative => absolute $this->listings_url = Url::to($this->listings_url, ['lang' => $this->locale->current()]); } return $data; } public function settingsForm($form) { $companiesOn = bff::businessEnabled(); $form ->checkbox('company_enabled', _t('@', 'Enabled'), true) ->boundaryInit(['title' => _t('@business', 'Create Company')]) ->hidden(! $companiesOn) ->text('company_title', _t('@', 'Title'), _t('business', 'Create Your Company Page from Scratch Simply and Inexpensively', true)) ->boundaryIn('company_enabled') ->visibleIf('company_enabled', true) ->hidden(! $companiesOn) ->images('company_icon', _t('@', 'Icon'), 1) ->preload(bff::path('/static/img/default/icon_company_add.svg')) ->boundaryIn('company_enabled') ->visibleIf('company_enabled', true) ->hidden(! $companiesOn) ->wysiwyg('company_descr', _t('@', 'Description'), _t('business', 'Create a company page and triple your sales with our marketplace', true)) ->boundaryIn('company_enabled') ->visibleIf('company_enabled', true) ->hidden(! $companiesOn) ->text('company_button', _t('@', 'Button'), _t('business', 'Create Company', true)) ->boundaryIn('company_enabled') ->visibleIf('company_enabled', true) ->hidden(! $companiesOn) ->color('company_background', _t('@', 'Button Color'), '#FF9D00') ->boundaryIn('company_enabled') ->visibleIf('company_enabled', true) ->hidden(! $companiesOn) ->text('company_url', _t('@', 'URL'), '', false) ->onValue(function ($value) { if (empty($value)) { $value = Users::url('login'); } return $value; }) ->boundaryIn('company_enabled') ->visibleIf('company_enabled', true) ->hidden(! $companiesOn); $form ->text('listings_title', _t('@', 'Title'), _t('listings', 'Shop among thousands of offers - it\'s quick and easy!', true)) ->boundaryInit(['title' => _t('@listings', 'Add Listing')]); $form ->images('listings_icon', _t('@', 'Icon'), 1) ->boundaryIn('listings_title') ->preload(bff::path('/static/img/default/icon_listings_add.svg')); if ($companiesOn) { $form->visibleIf('company_enabled', true); } $form ->images('listings_image', _t('@', 'Image'), 1) ->preload(bff::path('/static/img/default/image_listings_add.jpg')) ->boundaryIn('listings_title'); if ($companiesOn) { $form->visibleIf('company_enabled', false); } $form ->wysiwyg('listings_descr', _t('@', 'Description'), _t('listings', 'Buy exactly what you need at the best price. All your shopping history in one place - it\'s convenient!', true)) ->boundaryIn('listings_title') ->text('listings_button', _t('@site', 'Button'), _t('listings', 'Post Private Listing', true)) ->boundaryIn('listings_title') ->color('listings_background', _t('@site', 'Button Color'), '#74b31b') ->boundaryIn('listings_title') ->text('listings_url', _t('@', 'URL'), '', false) ->onValue(function ($value) { if (empty($value)) { $value = Listings::url('item.add'); } return $value; }) ->boundaryIn('listings_title') ; } }