[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_installer 6 * 7 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Installer\Administrator\Controller; 12 13 use Joomla\CMS\Application\CMSApplication; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\MVC\Controller\BaseController; 16 use Joomla\CMS\MVC\Factory\MVCFactoryInterface; 17 use Joomla\CMS\Response\JsonResponse; 18 use Joomla\CMS\Router\Route; 19 use Joomla\Component\Installer\Administrator\Model\ManageModel; 20 use Joomla\Input\Input; 21 use Joomla\Utilities\ArrayHelper; 22 23 // phpcs:disable PSR1.Files.SideEffects 24 \defined('_JEXEC') or die; 25 // phpcs:enable PSR1.Files.SideEffects 26 27 /** 28 * Installer Manage Controller 29 * 30 * @since 1.6 31 */ 32 class ManageController extends BaseController 33 { 34 /** 35 * Constructor. 36 * 37 * @param array $config An optional associative array of configuration settings. 38 * @param MVCFactoryInterface $factory The factory. 39 * @param CMSApplication $app The Application for the dispatcher 40 * @param Input $input Input 41 * 42 * @since 1.6 43 */ 44 public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null) 45 { 46 parent::__construct($config, $factory, $app, $input); 47 48 $this->registerTask('unpublish', 'publish'); 49 $this->registerTask('publish', 'publish'); 50 } 51 52 /** 53 * Enable/Disable an extension (if supported). 54 * 55 * @return void 56 * 57 * @throws \Exception 58 * 59 * @since 1.6 60 */ 61 public function publish() 62 { 63 // Check for request forgeries. 64 $this->checkToken(); 65 66 $ids = (array) $this->input->get('cid', array(), 'int'); 67 $values = array('publish' => 1, 'unpublish' => 0); 68 $task = $this->getTask(); 69 $value = ArrayHelper::getValue($values, $task, 0, 'int'); 70 71 // Remove zero values resulting from input filter 72 $ids = array_filter($ids); 73 74 if (empty($ids)) { 75 $this->setMessage(Text::_('COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED'), 'warning'); 76 } else { 77 /** @var ManageModel $model */ 78 $model = $this->getModel('manage'); 79 80 // Change the state of the records. 81 if (!$model->publish($ids, $value)) { 82 $this->setMessage(implode('<br>', $model->getErrors()), 'warning'); 83 } else { 84 if ($value == 1) { 85 $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; 86 } else { 87 $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; 88 } 89 90 $this->setMessage(Text::plural($ntext, count($ids))); 91 } 92 } 93 94 $this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false)); 95 } 96 97 /** 98 * Remove an extension (Uninstall). 99 * 100 * @return void 101 * 102 * @throws \Exception 103 * 104 * @since 1.5 105 */ 106 public function remove() 107 { 108 // Check for request forgeries. 109 $this->checkToken(); 110 111 $eid = (array) $this->input->get('cid', array(), 'int'); 112 113 // Remove zero values resulting from input filter 114 $eid = array_filter($eid); 115 116 if (!empty($eid)) { 117 /** @var ManageModel $model */ 118 $model = $this->getModel('manage'); 119 120 $model->remove($eid); 121 } 122 123 $this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false)); 124 } 125 126 /** 127 * Refreshes the cached metadata about an extension. 128 * 129 * Useful for debugging and testing purposes when the XML file might change. 130 * 131 * @return void 132 * 133 * @since 1.6 134 */ 135 public function refresh() 136 { 137 // Check for request forgeries. 138 $this->checkToken(); 139 140 $uid = (array) $this->input->get('cid', array(), 'int'); 141 142 // Remove zero values resulting from input filter 143 $uid = array_filter($uid); 144 145 if (!empty($uid)) { 146 /** @var ManageModel $model */ 147 $model = $this->getModel('manage'); 148 149 $model->refresh($uid); 150 } 151 152 $this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false)); 153 } 154 155 /** 156 * Load the changelog for a given extension. 157 * 158 * @return void 159 * 160 * @since 4.0.0 161 */ 162 public function loadChangelog() 163 { 164 /** @var ManageModel $model */ 165 $model = $this->getModel('manage'); 166 167 $eid = $this->input->get('eid', 0, 'int'); 168 $source = $this->input->get('source', 'manage', 'string'); 169 170 if (!$eid) { 171 return; 172 } 173 174 $output = $model->loadChangelog($eid, $source); 175 176 echo (new JsonResponse($output)); 177 } 178 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |