Skip to content

Commit 5973e1d

Browse files
committed
completed
1 parent 963d9bb commit 5973e1d

File tree

3 files changed

+169
-2
lines changed

3 files changed

+169
-2
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
}

Model/ResourceModel/Post/Fulltext/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(
7979
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
8080
) {
8181

82-
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $date, $storeManager, $connection, $resource);
82+
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $storeManager, $date, $connection, $resource);
8383

8484
$this->requestBuilder = $requestBuilder;
8585
$this->searchEngine = $searchEngine;
@@ -161,7 +161,7 @@ public function addStoreFilter($store, $withAdmin = true)
161161
*
162162
* @return \Lof\ElasticsuiteBlog\Model\ResourceModel\Post\Fulltext\Collection
163163
*/
164-
public function addSearchFilter($query)
164+
public function addSearchFilter($query = "")
165165
{
166166
$this->queryText = $query;
167167

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Landofcoder
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Landofcoder.com license that is
9+
* available through the world-wide-web at this URL:
10+
* https://landofcoder.com/license
11+
*
12+
* DISCLAIMER
13+
*
14+
* Do not edit or add to this file if you wish to upgrade this extension to newer
15+
* version in the future.
16+
*
17+
* @category Landofcoder
18+
* @package Lof_ElasticsuiteBlog
19+
* @copyright Copyright (c) 2021 Landofcoder (https://landofcoder.com/)
20+
* @license https://landofcoder.com/LICENSE-1.0.html
21+
*/
22+
-->
23+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
24+
<body>
25+
<referenceBlock name="blog_post_edit_tabs">
26+
<block class="Lof\ElasticsuiteBlog\Block\Adminhtml\Post\Edit\Tab\Advanced" name="post_tabs.searchengine" as="elasticsearch">
27+
<arguments>
28+
<argument name="label" xsi:type="string" translate="true">Advanced Settings</argument>
29+
<argument name="group_code" xsi:type="string">advanced</argument>
30+
</arguments>
31+
</block>
32+
<action method="addTab">
33+
<argument name="name" xsi:type="string">advanced</argument>
34+
<argument name="block" xsi:type="string">elasticsearch</argument>
35+
</action>
36+
</referenceBlock>
37+
</body>
38+
</page>

0 commit comments

Comments
 (0)