Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Feature/new m1 version #131

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Magento Chatbot Integration
* Copyright (C) 2018
*
* 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/>.
*/

class Werules_Chatbot_Block_Adminhtml_Chatbotapi extends Mage_Adminhtml_Block_Widget_Grid_Container
{
/**
* constructor
*
* @access public
* @return void
*/
public function __construct()
{
$this->_controller = 'adminhtml_chatbotapi';
$this->_blockGroup = 'werules_chatbot';
parent::__construct();
$this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotAPI');
$this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add ChatbotAPI'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Magento Chatbot Integration
* Copyright (C) 2018
*
* 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/>.
*/

class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
/**
* constructor
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
$this->_blockGroup = 'werules_chatbot';
$this->_controller = 'adminhtml_chatbotapi';
$this->_updateButton(
'save',
'label',
Mage::helper('werules_chatbot')->__('Save ChatbotAPI')
);
$this->_updateButton(
'delete',
'label',
Mage::helper('werules_chatbot')->__('Delete ChatbotAPI')
);
$this->_addButton(
'saveandcontinue',
array(
'label' => Mage::helper('werules_chatbot')->__('Save And Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save',
),
-100
);
$this->_formScripts[] = "
function saveAndContinueEdit() {
editForm.submit($('edit_form').action+'back/edit/');
}
";
}

/**
* get the edit form header
*
* @access public
* @return string
*/
public function getHeaderText()
{
if (Mage::registry('current_chatbotapi') && Mage::registry('current_chatbotapi')->getId()) {
return Mage::helper('werules_chatbot')->__(
"Edit ChatbotAPI '%s'",
$this->escapeHtml(Mage::registry('current_chatbotapi')->getChatbotapiId())
);
} else {
return Mage::helper('werules_chatbot')->__('Add ChatbotAPI');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Magento Chatbot Integration
* Copyright (C) 2018
*
* 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/>.
*/

class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
/**
* prepare form
*
* @access protected
* @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Form
*/
protected function _prepareForm()
{
$form = new Varien_Data_Form(
array(
'id' => 'edit_form',
'action' => $this->getUrl(
'*/*/save',
array(
'id' => $this->getRequest()->getParam('id')
)
),
'method' => 'post',
'enctype' => 'multipart/form-data'
)
);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
<?php
/**
* Magento Chatbot Integration
* Copyright (C) 2018
*
* 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/>.
*/

class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
/**
* prepare the form
*
* @access protected
* @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Form
*/
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('chatbotapi_');
$form->setFieldNameSuffix('chatbotapi');
$this->setForm($form);
$fieldset = $form->addFieldset(
'chatbotapi_form',
array('legend' => Mage::helper('werules_chatbot')->__('ChatbotAPI'))
);

$fieldset->addField(
'chatbotapi_id',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('ChatbotAPI ID'),
'name' => 'chatbotapi_id',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'hash_key',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Hash Key'),
'name' => 'hash_key',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'logged',
'select',
array(
'label' => Mage::helper('werules_chatbot')->__('Logged?'),
'name' => 'logged',
'required' => true,
'class' => 'required-entry',

'values'=> array(
array(
'value' => 1,
'label' => Mage::helper('werules_chatbot')->__('Yes'),
),
array(
'value' => 0,
'label' => Mage::helper('werules_chatbot')->__('No'),
),
),
)
);

$fieldset->addField(
'enabled',
'select',
array(
'label' => Mage::helper('werules_chatbot')->__('Enabled?'),
'name' => 'enabled',
'required' => true,
'class' => 'required-entry',

'values'=> array(
array(
'value' => 1,
'label' => Mage::helper('werules_chatbot')->__('Yes'),
),
array(
'value' => 0,
'label' => Mage::helper('werules_chatbot')->__('No'),
),
),
)
);

$fieldset->addField(
'chatbot_type',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Chatbot Type'),
'name' => 'chatbot_type',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'chat_id',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Chat ID'),
'name' => 'chat_id',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'conversation_state',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Conversation State'),
'name' => 'conversation_state',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'fallback_qty',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Fallback Quantity'),
'name' => 'fallback_qty',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'chatbotuser_id',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Chatbotuser ID'),
'name' => 'chatbotuser_id',
'required' => true,
'class' => 'required-entry',

)
);

$fieldset->addField(
'last_command_details',
'text',
array(
'label' => Mage::helper('werules_chatbot')->__('Last Command Details'),
'name' => 'last_command_details',
'required' => true,
'class' => 'required-entry',

)
);
$fieldset->addField(
'status',
'select',
array(
'label' => Mage::helper('werules_chatbot')->__('Status'),
'name' => 'status',
'values' => array(
array(
'value' => 1,
'label' => Mage::helper('werules_chatbot')->__('Enabled'),
),
array(
'value' => 0,
'label' => Mage::helper('werules_chatbot')->__('Disabled'),
),
),
)
);
if (Mage::app()->isSingleStoreMode()) {
$fieldset->addField(
'store_id',
'hidden',
array(
'name' => 'stores[]',
'value' => Mage::app()->getStore(true)->getId()
)
);
Mage::registry('current_chatbotapi')->setStoreId(Mage::app()->getStore(true)->getId());
}
$formValues = Mage::registry('current_chatbotapi')->getDefaultValues();
if (!is_array($formValues)) {
$formValues = array();
}
if (Mage::getSingleton('adminhtml/session')->getChatbotapiData()) {
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getChatbotapiData());
Mage::getSingleton('adminhtml/session')->setChatbotapiData(null);
} elseif (Mage::registry('current_chatbotapi')) {
$formValues = array_merge($formValues, Mage::registry('current_chatbotapi')->getData());
}
$form->setValues($formValues);
return parent::_prepareForm();
}
}
Loading