Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/calendar/lib/OpenEvents/Component/ |
Upload File : |
<?php namespace Bitrix\Calendar\OpenEvents\Component; use Bitrix\Calendar\Core\Event\Tools\Dictionary; use Bitrix\Calendar\Core\Property\ColorHelper; use Bitrix\Calendar\OpenEvents\Filter\Filter; use Bitrix\Main\Engine\CurrentUser; use Bitrix\Main\Localization\Loc; use Bitrix\Main\UI\Filter\Options; use Bitrix\UI; class Toolbar { public function build(): void { $this->addCreateButton(); $this->addFilter(); } protected function addCreateButton(): void { $calendarType = Dictionary::CALENDAR_TYPE['open_event']; $userId = CurrentUser::get()->getId(); $colors = \Bitrix\Main\Web\Json::encode(ColorHelper::OUR_COLORS); $addButton = new UI\Buttons\Button([ 'color' => UI\Buttons\Color::SUCCESS, 'text' => Loc::getMessage('CALENDAR_OPEN_EVENTS_TOOLBAR_BUTTON_CREATE'), 'click' => new UI\Buttons\JsCode(" BX.Runtime.loadExtension('calendar.entry').then(({ EntryManager }) => { const colors = $colors; EntryManager.openEditSlider({ type: '$calendarType', userId: $userId, formDataValue: { color: colors[Math.floor(Math.random()*colors.length)], }, }); }); "), 'events' => [ 'mouseover' => new UI\Buttons\JsCode("BX.Runtime.loadExtension('calendar.entry');"), ], ]); UI\Toolbar\Facade\Toolbar::addButton($addButton, UI\Toolbar\ButtonLocation::AFTER_TITLE); } protected function addFilter(): void { $filter = new Filter(); (new Options($filter::getId()))->reset(); UI\Toolbar\Facade\Toolbar::addFilter($filter->getOptions()); } }