This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from blopa/develop
develop
- Loading branch information
Showing
21 changed files
with
633 additions
and
67 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
...nto2/app/code/Werules/Chatbot/Block/Adminhtml/System/Config/Form/Field/DefaultReplies.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?php | ||
/** | ||
* Magento Chatbot Integration | ||
* Copyright (C) 2017 | ||
* | ||
* This file is part of Werules/Chatbot. | ||
* | ||
* Werules/Chatbot is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
class DefaultReplies extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray | ||
{ | ||
/** | ||
* @var \Magento\Framework\Data\Form\Element\Factory | ||
*/ | ||
protected $_elementFactory; | ||
protected $_itemRendererMatchCase; | ||
protected $_itemRendererMatchMode; | ||
protected $_itemRendererEnable; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Data\Form\Element\Factory $elementFactory, | ||
array $data = array() | ||
) | ||
{ | ||
$this->_elementFactory = $elementFactory; | ||
parent::__construct($context,$data); | ||
} | ||
protected function _construct() | ||
{ | ||
$this->addColumn('enable_reply', array( | ||
'label' => __("Enable"), | ||
'renderer' => $this->_getRendererEnable() | ||
)); | ||
// $this->addColumn('stop_processing', array( | ||
// 'label' => __("Stop Processing"), | ||
// 'renderer' => $this->_getRendererEnable() | ||
// )); | ||
$this->addColumn('match_mode', array( | ||
'label' => __("Match Mode"), | ||
'renderer' => $this->_getRendererMatchMode() | ||
)); | ||
$this->addColumn('match_sintax', array( | ||
'label' => __("Match Text or Regex"), | ||
//'style' => 'width: 100%', | ||
'class' => 'validate-no-html-tags' | ||
)); | ||
$this->addColumn('match_case', array( | ||
'label' => __("Match Case"), | ||
'renderer' => $this->_getRendererMatchCase() | ||
)); | ||
$this->addColumn('reply_text', array( | ||
'label' => __("Reply Text"), | ||
//'style' => 'width: 100%', | ||
'class' => 'validate-no-html-tags' | ||
)); | ||
|
||
$this->_addAfter = false; | ||
$this->_addButtonLabel = __("Add"); | ||
parent::_construct(); | ||
} | ||
|
||
protected function _getRendererYesNo() | ||
{ | ||
return $this->getLayout()->createBlock( | ||
'Werules\Chatbot\Block\Adminhtml\System\Config\Options\YesNo', | ||
'', | ||
array('data' => array('is_render_to_js_template' => true)) | ||
// array('is_render_to_js_template' => true) | ||
); // ->setExtraParams('style="width: 100%;"'); | ||
} | ||
|
||
protected function _getRendererEnable() | ||
{ | ||
if (!$this->_itemRendererEnable) | ||
{ | ||
$this->_itemRendererEnable = $this->_getRendererYesNo(); | ||
} | ||
return $this->_itemRendererEnable; | ||
} | ||
|
||
protected function _getRendererMatchCase() | ||
{ | ||
if (!$this->_itemRendererMatchCase) | ||
{ | ||
$this->_itemRendererMatchCase = $this->_getRendererYesNo(); | ||
} | ||
return $this->_itemRendererMatchCase; | ||
} | ||
|
||
protected function _getRendererMatchMode() | ||
{ | ||
if (!$this->_itemRendererMatchMode) | ||
{ | ||
$this->_itemRendererMatchMode = $this->getLayout()->createBlock( | ||
'Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field\MatchModeSelect', | ||
'', | ||
array('data' => array('is_render_to_js_template' => true)) | ||
// array('is_render_to_js_template' => true) | ||
); // ->setExtraParams('style="width: 100%;"'); | ||
} | ||
return $this->_itemRendererMatchMode; | ||
} | ||
|
||
protected function _prepareArrayRow(\Magento\Framework\DataObject $row) | ||
{ | ||
$optionExtraAttr = array(); | ||
$optionExtraAttr['option_' . $this->_getRendererEnable()->calcOptionHash($row->getData('enable_reply'))] = 'selected="selected"'; | ||
$optionExtraAttr['option_' . $this->_getRendererMatchMode()->calcOptionHash($row->getData('match_mode'))] = 'selected="selected"'; | ||
$optionExtraAttr['option_' . $this->_getRendererMatchCase()->calcOptionHash($row->getData('match_case'))] = 'selected="selected"'; | ||
|
||
$row->setData( | ||
'option_extra_attrs', $optionExtraAttr | ||
); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Magento2/app/code/Werules/Chatbot/Block/Adminhtml/System/Config/Form/Field/MatchModeList.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Magento Chatbot Integration | ||
* Copyright (C) 2017 | ||
* | ||
* This file is part of Werules/Chatbot. | ||
* | ||
* Werules/Chatbot is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
class MatchModeList implements \Magento\Framework\Option\ArrayInterface | ||
{ | ||
/** | ||
* Provide available options as a value/label array | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return array( | ||
array('value' => 0, 'label' => __("Equals to")), | ||
array('value' => 1, 'label' => __("Starts With")), | ||
array('value' => 2, 'label' => __("Ends With")), | ||
array('value' => 3, 'label' => __("Contains")), | ||
array('value' => 4, 'label' => __("Match RegEx")) | ||
); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...to2/app/code/Werules/Chatbot/Block/Adminhtml/System/Config/Form/Field/MatchModeSelect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Magento Chatbot Integration | ||
* Copyright (C) 2017 | ||
* | ||
* This file is part of Werules/Chatbot. | ||
* | ||
* Werules/Chatbot is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
class MatchModeSelect extends \Magento\Framework\View\Element\Html\Select | ||
{ | ||
/** | ||
* @var \Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field\MatchModeList | ||
*/ | ||
protected $_matchModeList; | ||
|
||
public function __construct( | ||
\Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field\MatchModeList $MatchModeList, | ||
\Magento\Backend\Block\Template\Context $context, array $data = array()) | ||
{ | ||
parent::__construct($context, $data); | ||
$this->_matchModeList = $MatchModeList; | ||
} | ||
|
||
public function _toHtml() | ||
{ | ||
if (!$this->getOptions()) { | ||
foreach ($this->_matchModeList->toOptionArray() as $option) { | ||
$this->addOption($option['value'], $option['label']); | ||
} | ||
} | ||
return parent::_toHtml(); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->getInputName(); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...nto2/app/code/Werules/Chatbot/Block/Adminhtml/System/Config/Form/Field/WelcomeOptions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
/** | ||
* Magento Chatbot Integration | ||
* Copyright (C) 2017 | ||
* | ||
* This file is part of Werules/Chatbot. | ||
* | ||
* Werules/Chatbot is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace Werules\Chatbot\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
class WelcomeOptions extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray | ||
{ | ||
/** | ||
* @var \Magento\Framework\Data\Form\Element\Factory | ||
*/ | ||
protected $_elementFactory; | ||
protected $_itemRendererEnable; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Data\Form\Element\Factory $elementFactory, | ||
array $data = array() | ||
) | ||
{ | ||
$this->_elementFactory = $elementFactory; | ||
parent::__construct($context,$data); | ||
} | ||
protected function _construct() | ||
{ | ||
$this->addColumn('enable_option', array( | ||
'label' => __("Enable"), | ||
'renderer' => $this->_getRendererEnable() | ||
)); | ||
$this->addColumn('option_text', array( | ||
'label' => __("Option Text"), | ||
//'style' => 'width: 100%', | ||
'class' => 'validate-no-html-tags' | ||
)); | ||
|
||
$this->_addAfter = false; | ||
$this->_addButtonLabel = __("Add"); | ||
parent::_construct(); | ||
} | ||
|
||
protected function _getRendererYesNo() | ||
{ | ||
return $this->getLayout()->createBlock( | ||
'Werules\Chatbot\Block\Adminhtml\System\Config\Options\YesNo', | ||
'', | ||
array('data' => array('is_render_to_js_template' => true)) | ||
// array('is_render_to_js_template' => true) | ||
); // ->setExtraParams('style="width: 100%;"'); | ||
} | ||
|
||
protected function _getRendererEnable() | ||
{ | ||
if (!$this->_itemRendererEnable) | ||
{ | ||
$this->_itemRendererEnable = $this->_getRendererYesNo(); | ||
} | ||
return $this->_itemRendererEnable; | ||
} | ||
|
||
protected function _prepareArrayRow(\Magento\Framework\DataObject $row) | ||
{ | ||
$optionExtraAttr = array(); | ||
$optionExtraAttr['option_' . $this->_getRendererEnable()->calcOptionHash($row->getData('enable_option'))] = 'selected="selected"'; | ||
|
||
$row->setData( | ||
'option_extra_attrs', $optionExtraAttr | ||
); | ||
} | ||
} |
Oops, something went wrong.