first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?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');
|
||||
|
||||
if ($this->download_link)
|
||||
{
|
||||
JFactory::getDocument()->addScriptDeclaration('
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
window.location.href = "' . $this->download_link . '";
|
||||
});
|
||||
');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="export_tool completed text-center tmpl-<?php echo $this->tmpl ?>">
|
||||
<div class="container">
|
||||
<span class="icon-checkmark-2"></span>
|
||||
<h2>
|
||||
<?php echo JText::sprintf('COM_CONVERTFORMS_EXPORT_COMPLETED', number_format($this->total_submissions_exported)) ?>
|
||||
</h2>
|
||||
<p>
|
||||
<?php echo JText::_('COM_CONVERTFORMS_DOWNLOAD_WILL_START') ?>
|
||||
</p>
|
||||
<a class="btn" href="<?php echo $this->start_over_link ?>">
|
||||
<?php echo JText::_('NR_START_OVER') ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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');
|
||||
|
||||
JFactory::getDocument()->addScriptDeclaration('
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var form = document.querySelector(".export_tool form");
|
||||
form.addEventListener("submit", function(e) {
|
||||
var btn = form.querySelector("button[type=\'submit\']");
|
||||
btn.innerText = "' . JText::_('NR_PLEASE_WAIT') . '...";
|
||||
document.querySelector(".export_tool").classList.add("working");
|
||||
});
|
||||
|
||||
// Joomla\'s showOn attribute doesn\'t support showing/hiding a field when another field is empty.
|
||||
let formIDInput = document.getElementById("filter_search");
|
||||
formIDInput.addEventListener("input", showHideFields);
|
||||
showHideFields();
|
||||
|
||||
function showHideFields() {
|
||||
let state = formIDInput.value.startsWith("id:") == "" ? "block" : "none";
|
||||
document.getElementById("filter_state").closest(".control-group").style.display = state;
|
||||
document.getElementById("filter_period").closest(".control-group").style.display = state;
|
||||
}
|
||||
});
|
||||
');
|
||||
|
||||
?>
|
||||
|
||||
<div class="export_tool form tmpl-<?php echo $this->tmpl ?>">
|
||||
<div class="container">
|
||||
<h1><?php echo JText::_('COM_CONVERTFORMS_LEADS_EXPORT') ?></h1>
|
||||
<form method="post" action="<?php echo JRoute::_('index.php') ?>" name="adminForm" id="adminForm" >
|
||||
<?php echo $this->form->renderFieldset('submission'); ?>
|
||||
<button class="btn btn-primary" type="submit">
|
||||
<?php echo JText::_('COM_CONVERTFORMS_LEADS_EXPORT') ?>
|
||||
</button>
|
||||
<input type="hidden" name="option" value="com_convertforms"/>
|
||||
<input type="hidden" name="task" value="export.export"/>
|
||||
<input type="hidden" name="tmpl" value="<?php echo $this->tmpl ?>"/>
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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');
|
||||
|
||||
?>
|
||||
|
||||
<div class="export_tool error text-center tmpl-<?php echo $this->tmpl ?>">
|
||||
<div class="container">
|
||||
<span class="icon-smiley-sad-2"></span>
|
||||
<h2><?php echo JText::_('NR_ERROR') ?></h2>
|
||||
<p class="error_message"><?php echo $this->error; ?></p>
|
||||
<a class="btn" href="<?php echo $this->start_over_link ?>">
|
||||
<?php echo JText::_('NR_TRY_AGAIN') ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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');
|
||||
|
||||
?>
|
||||
|
||||
<div class="export_tool inprogress text-center tmpl-<?php echo $this->tmpl ?>">
|
||||
<div class="container">
|
||||
<span class="icon-health"></span>
|
||||
<h2>
|
||||
<?php echo JText::_('COM_CONVERTFORMS_EXPORT_WORKING') ?>
|
||||
</h2>
|
||||
<p>
|
||||
<?php echo \JText::sprintf('COM_CONVERTFORMS_EXPORT_PROCESSING', number_format($this->processed), number_format($this->total)); ?>
|
||||
</p>
|
||||
<a href="<?php echo $this->start_over_link ?>" onclick="return confirm('<?php echo JText::_('NR_ARE_YOU_SURE') ?>')">
|
||||
<?php echo JText::_('NR_CANCEL'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?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');
|
||||
|
||||
use ConvertForms\Export;
|
||||
|
||||
/**
|
||||
* Templates View
|
||||
*/
|
||||
class ConvertFormsViewExport extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Items view display method
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return mixed A string if successful, otherwise a JError object.
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$input = $app->input;
|
||||
$viewLayout = $input->get('layout', 'default');
|
||||
|
||||
$this->tmpl = $input->get('tmpl');
|
||||
$this->baseURL = 'index.php?option=com_convertforms&view=export';
|
||||
$this->start_over_link = $this->baseURL . ($this->tmpl == 'component' ? '&tmpl=component' : '');
|
||||
|
||||
switch ($viewLayout)
|
||||
{
|
||||
case 'completed':
|
||||
$file = $input->get('filename');
|
||||
|
||||
if (!Export::exportFileExists($file))
|
||||
{
|
||||
Export::error(JText::_('COM_CONVERTFORMS_EXPORT_ERROR_CANT_FIND_FILE'));
|
||||
}
|
||||
|
||||
$this->download_link = 'index.php?option=com_convertforms&task=export.download&filename=' . $file;
|
||||
$this->total_submissions_exported = $input->get('total');
|
||||
$this->export_type = $input->get('export_type');
|
||||
break;
|
||||
|
||||
case 'progress':
|
||||
JSession::checkToken('request') or die(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
try
|
||||
{
|
||||
$data = Export::export($input->getArray());
|
||||
|
||||
$pagination = $data['pagination'];
|
||||
$options = $data['options'];
|
||||
|
||||
$totalProcessedSoFar = $pagination->pagesCurrent * $pagination->limit;
|
||||
$totalProcessedSoFar = $pagination->total > $totalProcessedSoFar ? $totalProcessedSoFar : $pagination->total;
|
||||
|
||||
$this->processed = $totalProcessedSoFar;
|
||||
$this->total = $pagination->total;
|
||||
|
||||
if ($pagination->pagesCurrent < $pagination->pagesTotal)
|
||||
{
|
||||
$new_url = \JURI::getInstance();
|
||||
|
||||
$new_url->setVar('offset', $options['offset'] + $options['limit']);
|
||||
$new_url->setVar('processed', $this->processed);
|
||||
$new_url->setVar('total', $this->total);
|
||||
|
||||
header('Refresh:0; url=' . $new_url->toString());
|
||||
} else
|
||||
{
|
||||
// Export completed
|
||||
$optionsQuery = http_build_query(array_filter([
|
||||
'total' => $this->total,
|
||||
'filename' => $options['filename'],
|
||||
'export_type' => $options['export_type'],
|
||||
'tmpl' => $this->tmpl
|
||||
]));
|
||||
|
||||
$app->redirect($this->baseURL . '&layout=completed&' . $optionsQuery);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th)
|
||||
{
|
||||
Export::error($th->getMessage());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
$this->error = $input->get('error', '', 'RAW');
|
||||
break;
|
||||
|
||||
default:
|
||||
$form = new JForm('export');
|
||||
$form->loadFile(JPATH_COMPONENT_ADMINISTRATOR . '/models/forms/export_submissions.xml');
|
||||
$form->bind($app->input->getArray());
|
||||
|
||||
$this->form = $form;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->tmpl == 'component')
|
||||
{
|
||||
JFactory::getDocument()->addStyleDeclaration('
|
||||
body {
|
||||
background:none !important;
|
||||
}
|
||||
');
|
||||
} else
|
||||
{
|
||||
$this->addToolBar();
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (!is_null($this->get('Errors')) && count($errors = $this->get('Errors')))
|
||||
{
|
||||
$app->enqueueMessage(implode("\n", $errors), 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display the template
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Toolbar to layout
|
||||
*/
|
||||
protected function addToolBar()
|
||||
{
|
||||
JToolBarHelper::title(JText::_('COM_CONVERTFORMS') . ": " . JText::_('COM_CONVERTFORMS_LEADS_EXPORT'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user