Joomla-Sermon-Distributor/admin/views/import/view.html.php

113 lines
3.9 KiB
PHP
Raw Permalink Normal View History

2015-11-30 21:30:54 +00:00
<?php
2021-08-16 17:11:22 +00:00
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/
@version 3.0.x
2021-08-16 17:11:22 +00:00
@created 22nd October, 2015
@package Sermon Distributor
@subpackage view.html.php
@author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
2022-05-27 05:37:27 +00:00
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use VDM\Joomla\Utilities\StringHelper;
2022-05-27 05:37:27 +00:00
2021-08-16 17:11:22 +00:00
/**
2022-05-27 05:37:27 +00:00
* Sermondistributor Import Html View
2021-08-16 17:11:22 +00:00
*/
2022-05-27 05:37:27 +00:00
class SermondistributorViewImport extends HtmlView
2021-08-16 17:11:22 +00:00
{
protected $headerList;
protected $hasPackage = false;
protected $headers;
protected $hasHeader = 0;
protected $dataType;
public function display($tpl = null)
{
2021-08-16 17:11:22 +00:00
if ($this->getLayout() !== 'modal')
{
// Include helper submenu
SermondistributorHelper::addSubmenu('import');
}
$paths = new stdClass;
$paths->first = '';
$state = $this->get('state');
$this->paths = &$paths;
$this->state = &$state;
// get global action permissions
2021-08-16 17:11:22 +00:00
$this->canDo = SermondistributorHelper::getActions('import');
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
}
// get the session object
$session = Factory::getSession();
2021-08-16 17:11:22 +00:00
// check if it has package
$this->hasPackage = $session->get('hasPackage', false);
$this->dataType = $session->get('dataType', false);
2021-08-16 17:11:22 +00:00
if($this->hasPackage && $this->dataType)
{
$this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true);
$this->headers = SermondistributorHelper::getFileHeaders($this->dataType);
2021-08-16 17:11:22 +00:00
// clear the data type
$session->clear('dataType');
}
2021-08-16 17:11:22 +00:00
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Display the template
parent::display($tpl);
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
ToolbarHelper::title(Text::_('COM_SERMONDISTRIBUTOR_IMPORT_TITLE'), 'upload');
2021-08-16 17:11:22 +00:00
JHtmlSidebar::setAction('index.php?option=com_sermondistributor&view=import');
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
{
ToolbarHelper::preferences('com_sermondistributor');
2021-08-16 17:11:22 +00:00
}
// set help url for this view if found
2022-03-03 03:49:35 +00:00
$this->help_url = SermondistributorHelper::getHelpUrl('import');
if (StringHelper::check($this->help_url))
2021-08-16 17:11:22 +00:00
{
ToolbarHelper::help('COM_SERMONDISTRIBUTOR_HELP_MANAGER', false, $this->help_url);
2021-08-16 17:11:22 +00:00
}
}
}