| Current Path : /home/jeromecohp/www/administrator/components/com_emailbeautifier/controllers/ |
| Current File : /home/jeromecohp/www/administrator/components/com_emailbeautifier/controllers/templates.php |
<?php
/**
* @package EmailBeautifier
* @subpackage com_emailbeautifier
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access.
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Joomla\CMS\Log\Log;
/**
* Templates list controller class.
*
* @package EmailBeautifer
* @subpackage com_emailbeautifier
* @since 2.2
*/
class EmailbeautifierControllerTemplates extends AdminController
{
/**
* 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 JModelBase|JModelLegacy|boolean Model object on success; otherwise false on failure.
*
* @since 2.2.0
*/
public function getModel($name = 'Template', $prefix = 'EmailBeautifierModel', $config = array())
{
return parent::getModel($name, $prefix, array('ignore_request' => true));
}
/**
* Removes an item.
*
* @return void
*
* @since 12.2
*/
public function toggledefault()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// Get items to remove from the request.
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
// Get some variables from the request
if (!is_array($cid) || count($cid) < 1)
{
Log::add(Text::_('COM_EMAILBEAUTIFIER_NO_TEMPLATE_SELECTED'), Log::WARNING, 'jerror');
}
else
{
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
JArrayHelper::toInteger($cid);
// Publish the items.
try
{
$model->toggledefault($cid);
$ntext = 'COM_EMAILBEAUTIFIER_TEMPLATES_SET_DEFAULT';
$this->setMessage(Text::plural($ntext, count($cid)));
}
catch (Exception $e)
{
$this->setMessage($e->getMessage(), 'error');
}
}
// Invoke the postDelete method to allow for the child class to access the model.
// $this->postDeleteHook($model, $cid);
$this->setRedirect('index.php?option=com_emailbeautifier&view=templates');
}
}