|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Landofcoder |
| 4 | + * |
| 5 | + * NOTICE OF LICENSE |
| 6 | + * |
| 7 | + * This source file is subject to the Landofcoder.com license that is |
| 8 | + * available through the world-wide-web at this URL: |
| 9 | + * https://landofcoder.com/license |
| 10 | + * |
| 11 | + * DISCLAIMER |
| 12 | + * |
| 13 | + * Do not edit or add to this file if you wish to upgrade this extension to newer |
| 14 | + * version in the future. |
| 15 | + * |
| 16 | + * @category Landofcoder |
| 17 | + * @package Lof_ElasticsuiteBlog |
| 18 | + * @copyright Copyright (c) 2021 Landofcoder (https://landofcoder.com/) |
| 19 | + * @license https://landofcoder.com/LICENSE-1.0.html |
| 20 | + */ |
| 21 | +namespace Lof\ElasticsuiteBlog\Block\Adminhtml\Post\Edit\Tab; |
| 22 | + |
| 23 | +class Advanced extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface |
| 24 | +{ |
| 25 | + /** |
| 26 | + * Prepare form |
| 27 | + * |
| 28 | + * @return $this |
| 29 | + */ |
| 30 | + protected function _prepareForm() |
| 31 | + { |
| 32 | + $this->_eventManager->dispatch( |
| 33 | + 'ves_check_license', |
| 34 | + ['obj' => $this,'ex'=>'Ves_Blog'] |
| 35 | + ); |
| 36 | + |
| 37 | + /* |
| 38 | + * Checking if user have permissions to save information |
| 39 | + */ |
| 40 | + if ($this->_isAllowedAction('Ves_Blog::post_edit')) { |
| 41 | + $isElementDisabled = false; |
| 42 | + } else { |
| 43 | + $isElementDisabled = true; |
| 44 | + } |
| 45 | + |
| 46 | + if (!$this->getData('is_valid') && !$this->getData('local_valid')) { |
| 47 | + $isElementDisabled = true; |
| 48 | + } |
| 49 | + |
| 50 | + /** @var \Magento\Framework\Data\Form $form */ |
| 51 | + $form = $this->_formFactory->create(); |
| 52 | + |
| 53 | + $form->setHtmlIdPrefix('post_'); |
| 54 | + |
| 55 | + $model = $this->_coreRegistry->registry('current_post'); |
| 56 | + |
| 57 | + $fieldset = $form->addFieldset( |
| 58 | + 'meta_fieldset', |
| 59 | + ['legend' => __('Advanced Settings'), 'class' => 'fieldset-wide'] |
| 60 | + ); |
| 61 | + |
| 62 | + $fieldset->addField( |
| 63 | + 'is_searchable', |
| 64 | + 'select', |
| 65 | + [ |
| 66 | + 'label' => __('Is searchable (fulltext)'), |
| 67 | + 'title' => __('Is searchable (fulltext)'), |
| 68 | + 'name' => 'is_searchable', |
| 69 | + 'options' => $model->getAvailableStatuses(), |
| 70 | + 'disabled' => $isElementDisabled |
| 71 | + ] |
| 72 | + ); |
| 73 | + |
| 74 | + $this->_eventManager->dispatch('adminhtml_blog_post_edit_tab_main_prepare_form', ['form' => $form]); |
| 75 | + |
| 76 | + $form->setValues($model->getData()); |
| 77 | + |
| 78 | + $this->setForm($form); |
| 79 | + |
| 80 | + return parent::_prepareForm(); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Prepare label for tab |
| 85 | + * |
| 86 | + * @return \Magento\Framework\Phrase |
| 87 | + */ |
| 88 | + public function getTabLabel() |
| 89 | + { |
| 90 | + return __('Advanced Settings'); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Prepare title for tab |
| 95 | + * |
| 96 | + * @return \Magento\Framework\Phrase |
| 97 | + */ |
| 98 | + public function getTabTitle() |
| 99 | + { |
| 100 | + return __('Advanced Settings'); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * {@inheritdoc} |
| 105 | + */ |
| 106 | + public function canShowTab() |
| 107 | + { |
| 108 | + return true; |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * {@inheritdoc} |
| 113 | + */ |
| 114 | + public function isHidden() |
| 115 | + { |
| 116 | + return false; |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Check permission for passed action |
| 121 | + * |
| 122 | + * @param string $resourceId |
| 123 | + * @return bool |
| 124 | + */ |
| 125 | + protected function _isAllowedAction($resourceId) |
| 126 | + { |
| 127 | + return $this->_authorization->isAllowed($resourceId); |
| 128 | + } |
| 129 | +} |
0 commit comments