first commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
// import Joomla controlleradmin library
|
||||
jimport('joomla.application.component.controlleradmin');
|
||||
|
||||
/**
|
||||
* Addons list controller class.
|
||||
*/
|
||||
class ConvertFormsControllerAddons extends JControllerAdmin
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_ADDONS';
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return JModelLegacy The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Addon', $prefix = 'ConvertFormsModel', $config = array('ignore_request' => true))
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.application.component.controllerform');
|
||||
|
||||
/**
|
||||
* Campaign controller class
|
||||
*/
|
||||
class ConvertFormsControllerCampaign extends JControllerForm
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_CAMPAIGN';
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
// import Joomla controlleradmin library
|
||||
jimport('joomla.application.component.controlleradmin');
|
||||
|
||||
/**
|
||||
* Campaigns list controller class.
|
||||
*/
|
||||
class ConvertFormsControllerCampaigns extends JControllerAdmin
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_CAMPAIGN';
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return JModelLegacy The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Campaign', $prefix = 'ConvertFormsModel', $config = array('ignore_request' => true))
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy items specified by array cid and set Redirection to the list of items
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function duplicate()
|
||||
{
|
||||
$ids = JFactory::getApplication()->input->get('cid', array(), 'array');
|
||||
|
||||
// Get the model.
|
||||
$model = $this->getModel('Campaign');
|
||||
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$model->copy($id);
|
||||
}
|
||||
|
||||
JFactory::getApplication(JText::sprintf('COM_CONVERTFORMS_CAMPAIGN_N_ITEMS_COPIED', count($ids)));
|
||||
JFactory::getApplication()->redirect('index.php?option=com_convertforms&view=campaigns');
|
||||
}
|
||||
|
||||
/**
|
||||
* Export campaign submissions specified by campaign ids
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function export()
|
||||
{
|
||||
$ids = JFactory::getApplication()->input->get('cid', null, 'INT');
|
||||
|
||||
// Get the Conversions model
|
||||
$model = $this->getModel('Conversions');
|
||||
$model->export(null, $ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.application.component.controllerform');
|
||||
|
||||
/**
|
||||
* Conversion controller class
|
||||
*/
|
||||
class ConvertFormsControllerConversion extends JControllerForm
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_SUBMISSION';
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
// import Joomla controlleradmin library
|
||||
jimport('joomla.application.component.controlleradmin');
|
||||
|
||||
/**
|
||||
* Conversions list controller class.
|
||||
*/
|
||||
class ConvertFormsControllerConversions extends JControllerAdmin
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_SUBMISSION';
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return JModelLegacy The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Conversion', $prefix = 'ConvertFormsModel', $config = array('ignore_request' => true))
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Method
|
||||
* Export the selected items specified by id
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$ids = JFactory::getApplication()->input->get('cid', array(), 'array');
|
||||
|
||||
// Get the model.
|
||||
$model = $this->getModel('Conversions');
|
||||
$model->export($ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
// import Joomla controlleradmin library
|
||||
jimport('joomla.application.component.controlleradmin');
|
||||
|
||||
/**
|
||||
* Export controller class.
|
||||
*/
|
||||
class ConvertFormsControllerExport extends JControllerAdmin
|
||||
{
|
||||
/**
|
||||
* Used by the export form to submit the data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
JSession::checkToken('request') or die(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$input = $app->input;
|
||||
|
||||
$tz = new \DateTimeZone($app->getCfg('offset', 'GMT'));
|
||||
$date = \JFactory::getDate()->setTimezone($tz)->format('YmdHis', true);
|
||||
$filename = 'convertforms_submissions_' . $date . '.' . $input->get('export_type');
|
||||
|
||||
$options = $input->getArray();
|
||||
$options['filter_search'] = $input->get('filter_search', null, 'RAW'); // Allow commas and special characters.
|
||||
$options['filename'] = $input->get('filename', $filename);
|
||||
|
||||
$app->redirect('index.php?option=com_convertforms&view=export&layout=progress&' . http_build_query($options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Force download of the exported file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
if (!$filename = JFactory::getApplication()->input->get('filename', '', 'RAW'))
|
||||
{
|
||||
throw new Exception('Invalid filename');
|
||||
}
|
||||
|
||||
$filename = NRFramework\File::getTempFolder() . $filename;
|
||||
|
||||
if (!JFile::exists($filename))
|
||||
{
|
||||
throw new Exception('Invalid filename');
|
||||
}
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
// Send the appropriate headers to force the download in the browser
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
|
||||
header('Expires: 0');
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
header("Cache-Control: public", false);
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . @filesize($filename));
|
||||
|
||||
// Read exported file to buffer
|
||||
readfile($filename);
|
||||
|
||||
// Don't leave any clues on the server. Delete the file.
|
||||
JFile::delete($filename);
|
||||
|
||||
jexit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.application.component.controllerform');
|
||||
|
||||
/**
|
||||
* Form Controller Class
|
||||
*/
|
||||
class ConvertFormsControllerForm extends JControllerForm
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_FORM';
|
||||
|
||||
public function ajaxSave()
|
||||
{
|
||||
$data = $this->getFormDataFromRequest();
|
||||
$model = $this->getModel('Form');
|
||||
$validData = $model->validate('jform', $data);
|
||||
|
||||
JPluginHelper::importPlugin('convertforms');
|
||||
JPluginHelper::importPlugin('convertformstools');
|
||||
|
||||
if (!$model->save($validData))
|
||||
{
|
||||
header('HTTP/1.1 500');
|
||||
$response = [
|
||||
'error' => \JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $model->getState('form.id');
|
||||
$isNew = $data['id'] == 0;
|
||||
|
||||
$response = [
|
||||
'id' => $id,
|
||||
'isNew' => $isNew,
|
||||
'redirect' => JRoute::_('index.php?option=com_convertforms&task=form.edit&id=' . $id)
|
||||
];
|
||||
}
|
||||
|
||||
jexit(json_encode($response, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function preview()
|
||||
{
|
||||
$data = $this->getModel('Form')->validate('jform', $this->getFormDataFromRequest());
|
||||
$data['params'] = json_decode($data['params'], true);
|
||||
$data['fields'] = $data['params']['fields'];
|
||||
|
||||
$response = [
|
||||
'html' => '
|
||||
<div>
|
||||
<div class="b">
|
||||
' . ConvertForms\Helper::renderForm($data) . '
|
||||
</div>
|
||||
</div>
|
||||
'
|
||||
];
|
||||
|
||||
echo json_encode($response, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
jexit();
|
||||
}
|
||||
|
||||
private function getFormDataFromRequest()
|
||||
{
|
||||
$data = json_decode(file_get_contents('php://input'));
|
||||
|
||||
$xx = new JRegistry();
|
||||
|
||||
foreach ($data as $value)
|
||||
{
|
||||
$key = str_replace(['jform[', ']', '['], ['', '', '.'], $value->name);
|
||||
|
||||
// Why?
|
||||
if ($key == 'emails')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$xx->set($key, $value->value);
|
||||
}
|
||||
|
||||
return $xx->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
// import Joomla controlleradmin library
|
||||
jimport('joomla.application.component.controlleradmin');
|
||||
|
||||
class ConvertformsControllerForms extends JControllerAdmin
|
||||
{
|
||||
protected $text_prefix = 'COM_CONVERTFORMS_FORM';
|
||||
|
||||
/**
|
||||
* Proxy for getModel.
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getModel($name = 'form', $prefix = 'ConvertFormsModel', $config = array('ignore_request' => true))
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import Method
|
||||
* Set layout to import
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$file = $app->input->files->get("file");
|
||||
|
||||
if (!empty($file))
|
||||
{
|
||||
if (isset($file['name']))
|
||||
{
|
||||
// Get the model.
|
||||
$model = $this->getModel('Forms');
|
||||
$model_item = $this->getModel('Form');
|
||||
$model->import($model_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
$app->enqueueMessage(JText::_('NR_PLEASE_CHOOSE_A_VALID_FILE'), 'error');
|
||||
$app->redirect('index.php?option=com_convertforms&view=forms&layout=import');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$app->redirect('index.php?option=com_convertforms&view=forms&layout=import');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Method
|
||||
* Export the selected items specified by id
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$ids = JFactory::getApplication()->input->get('cid', array(), 'array');
|
||||
|
||||
// Get the model.
|
||||
$model = $this->getModel('Forms');
|
||||
$model->export($ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Method
|
||||
* Copy all items specified by array cid
|
||||
* and set Redirection to the list of items
|
||||
*/
|
||||
public function duplicate()
|
||||
{
|
||||
$ids = JFactory::getApplication()->input->get('cid', array(), 'array');
|
||||
|
||||
// Get the model.
|
||||
$model = $this->getModel('Form');
|
||||
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$model->copy($id);
|
||||
}
|
||||
|
||||
JFactory::getApplication(JText::sprintf('COM_CONVERTFORMS_FORM_N_ITEMS_COPIED', count($ids)));
|
||||
JFactory::getApplication()->redirect('index.php?option=com_convertforms&view=forms');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user