- md5
- 9c04624379290ce24f89323a33467985
- sha1
- fb59ab692bef5d9964803b6412f8050b0e4b9a2c
- sha256
- f39026cfdd77e2006d13e0e7cf5d1fff4779363354df72e216700a8003e2e062
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Installer\Administrator\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Router\Route;
use Joomla\Component\Installer\Administrator\Model\ManageModel;
use Joomla\Input\Input;
use Joomla\Utilities\ArrayHelper;
/**
* Installer Manage Controller
*
* @since 1.6
*/
class ManageController extends BaseController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param Input $input Input
*
* @since 1.6
* @see \JControllerLegacy
*/
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);
$this->registerTask('unpublish', 'publish');
$this->registerTask('publish', 'publish');
}
/**
* Enable/Disable an extension (if supported).
*
* @return void
*
* @throws \Exception
*
* @since 1.6
*/
public function publish()
{
// Check for request forgeries.
$this->checkToken();
$ids = $this->input->get('cid', array(), 'array');
$values = array('publish' => 1, 'unpublish' => 0);
$task = $this->getTask();
$value = ArrayHelper::getValue($values, $task, 0, 'int');
if (empty($ids))
{
$this->setMessage(Text::_('COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED'), 'warning');
}
else
{
/** @var ManageModel $model */
$model = $this->getModel('manage');
// Change the state of the records.
if (!$model->publish($ids, $value))
{
$this->setMessage(implode('<br>', $model->getErrors()), 'warning');
}
else
{
if ($value == 1)
{
$ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED';
}
else
{
$ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED';
}
$this->setMessage(Text::plural($ntext, count($ids)));
}
}
$this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false));
}
/**
* Remove an extension (Uninstall).
*
* @return void
*
* @throws \Exception
*
* @since 1.5
*/
public function remove()
{
// Check for request forgeries.
$this->checkToken();
/** @var ManageModel $model */
$model = $this->getModel('manage');
$eid = $this->input->get('cid', array(), 'array');
$eid = ArrayHelper::toInteger($eid, array());
$model->remove($eid);
$this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false));
}
/**
* Refreshes the cached metadata about an extension.
*
* Useful for debugging and testing purposes when the XML file might change.
*
* @return void
*
* @since 1.6
*/
public function refresh()
{
// Check for request forgeries.
$this->checkToken();
/** @var ManageModel $model */
$model = $this->getModel('manage');
$uid = $this->input->get('cid', array(), 'array');
$uid = ArrayHelper::toInteger($uid, array());
$model->refresh($uid);
$this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false));
}
/**
* Load the changelog for a given extension.
*
* @return void
*
* @since 4.0.0
*/
public function loadChangelog()
{
/** @var ManageModel $model */
$model = $this->getModel('manage');
$eid = $this->input->get('eid', 0, 'int');
$source = $this->input->get('source', 'manage', 'string');
if (!$eid)
{
return;
}
$output = $model->loadChangelog($eid, $source);
echo (new JsonResponse($output));
}
}
The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.