2016-01-30 20:28:43 +00:00
|
|
|
<?php
|
2018-08-07 13:27:08 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
|
|
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
|
|
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
2021-01-03 16:49:35 +00:00
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
2018-08-07 13:27:08 +00:00
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
2016-01-30 20:28:43 +00:00
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
?>
|
|
|
|
###BOM###
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2020-05-25 16:17:00 +00:00
|
|
|
use Joomla\Utilities\ArrayHelper;
|
|
|
|
|
2016-01-30 20:28:43 +00:00
|
|
|
/**
|
|
|
|
* General Controller of ###Component### component
|
|
|
|
*/
|
|
|
|
class ###Component###Controller extends JControllerLegacy
|
|
|
|
{
|
2018-03-09 03:26:44 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param array $config An optional associative array of configuration settings.
|
|
|
|
* Recognized key values include 'name', 'default_task', 'model_path', and
|
|
|
|
* 'view_path' (this list is not meant to be comprehensive).
|
|
|
|
*
|
|
|
|
* @since 3.0
|
|
|
|
*/
|
|
|
|
public function __construct($config = array())
|
|
|
|
{
|
|
|
|
// set the default view
|
|
|
|
$config['default_view'] = '###DASHBOARDVIEW###';
|
|
|
|
|
|
|
|
parent::__construct($config);
|
|
|
|
}
|
2018-03-11 17:03:31 +00:00
|
|
|
|
2016-01-30 20:28:43 +00:00
|
|
|
/**
|
|
|
|
* display task
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2017-12-14 23:10:47 +00:00
|
|
|
function display($cachable = false, $urlparams = false)
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
|
|
|
// set default view if not set
|
2018-03-09 03:26:44 +00:00
|
|
|
$view = $this->input->getCmd('view', '###DASHBOARDVIEW###');
|
2016-01-30 20:28:43 +00:00
|
|
|
$data = $this->getViewRelation($view);
|
|
|
|
$layout = $this->input->get('layout', null, 'WORD');
|
|
|
|
$id = $this->input->getInt('id');
|
|
|
|
|
|
|
|
// Check for edit form.
|
2017-12-14 23:10:47 +00:00
|
|
|
if(###Component###Helper::checkArray($data))
|
|
|
|
{
|
|
|
|
if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_###component###.edit.'.$data['view'], $id))
|
|
|
|
{
|
|
|
|
// Somehow the person just went to the form - we don't allow that.
|
|
|
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
|
|
|
|
$this->setMessage($this->getError(), 'error');
|
|
|
|
// check if item was opend from other then its own list view
|
|
|
|
$ref = $this->input->getCmd('ref', 0);
|
|
|
|
$refid = $this->input->getInt('refid', 0);
|
|
|
|
// set redirect
|
|
|
|
if ($refid > 0 && ###Component###Helper::checkString($ref))
|
|
|
|
{
|
|
|
|
// redirect to item of ref
|
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false));
|
|
|
|
}
|
|
|
|
elseif (###Component###Helper::checkString($ref))
|
|
|
|
{
|
2016-01-30 20:28:43 +00:00
|
|
|
|
2017-12-14 23:10:47 +00:00
|
|
|
// redirect to ref
|
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.(string)$ref, false));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// normal redirect back to the list view
|
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.$data['views'], false));
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
|
2017-12-14 23:10:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
|
|
|
|
return parent::display($cachable, $urlparams);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getViewRelation($view)
|
|
|
|
{
|
2018-03-05 00:13:42 +00:00
|
|
|
// check the we have a value
|
2017-12-14 23:10:47 +00:00
|
|
|
if (###Component###Helper::checkString($view))
|
|
|
|
{
|
2018-03-05 00:13:42 +00:00
|
|
|
// the view relationships
|
2017-12-14 23:10:47 +00:00
|
|
|
$views = array(###VIEWARRAY###
|
|
|
|
);
|
|
|
|
// check if this is a list view
|
2018-03-05 00:13:42 +00:00
|
|
|
if (in_array($view, $views))
|
2017-12-14 23:10:47 +00:00
|
|
|
{
|
2018-03-05 00:13:42 +00:00
|
|
|
// this is a list view
|
2017-12-14 23:10:47 +00:00
|
|
|
return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view);
|
|
|
|
}
|
|
|
|
// check if it is an edit view
|
2018-03-05 00:13:42 +00:00
|
|
|
elseif (array_key_exists($view, $views))
|
2017-12-14 23:10:47 +00:00
|
|
|
{
|
2018-03-05 00:13:42 +00:00
|
|
|
// this is a edit view
|
2017-12-14 23:10:47 +00:00
|
|
|
return array('edit' => true, 'view' => $view, 'views' => $views[$view]);
|
|
|
|
}
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|