Widget.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Widget\Block\Adminhtml;
  7. /**
  8. * WYSIWYG widget plugin main block
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Widget extends \Magento\Backend\Block\Widget\Form\Container
  14. {
  15. /**
  16. * @inheritdoc
  17. */
  18. protected function _construct()
  19. {
  20. parent::_construct();
  21. $this->_blockGroup = 'Magento_Widget';
  22. $this->_controller = 'adminhtml';
  23. $this->_mode = 'widget';
  24. $this->_headerText = __('Widget Insertion');
  25. $saveButtonClass = 'action-primary add-widget';
  26. $this->removeButton('back');
  27. if ($this->getRequest()->getParam('mode') === 'new') {
  28. $this->buttonList->update('save', 'label', __('Insert Widget'));
  29. $saveButtonClass .= ' disabled';
  30. }
  31. $this->buttonList->update('save', 'class', $saveButtonClass);
  32. $this->buttonList->update('save', 'id', 'insert_button');
  33. $this->buttonList->update('save', 'onclick', 'wWidget.insertWidget()');
  34. $this->buttonList->update('save', 'region', 'toolbar');
  35. $this->buttonList->update('save', 'data_attribute', []);
  36. $this->buttonList->update('reset', 'label', __('Cancel'));
  37. $this->buttonList->update('reset', 'onclick', 'wWidget.closeModal()');
  38. $this->_formScripts[] = <<<EOJS
  39. require(['mage/adminhtml/wysiwyg/widget'], function() {
  40. wWidget = new WysiwygWidget.Widget(
  41. 'widget_options_form',
  42. 'select_widget_type',
  43. 'widget_options',
  44. '{$this->getUrl('adminhtml/*/loadOptions')}',
  45. '{$this->escapeJs($this->getRequest()->getParam('widget_target_id'))}'
  46. );
  47. });
  48. EOJS;
  49. }
  50. }