[ 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) 2014 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\AdminController; 16 use Joomla\CMS\MVC\Factory\MVCFactoryInterface; 17 use Joomla\CMS\Router\Route; 18 use Joomla\Input\Input; 19 use Joomla\Utilities\ArrayHelper; 20 21 // phpcs:disable PSR1.Files.SideEffects 22 \defined('_JEXEC') or die; 23 // phpcs:enable PSR1.Files.SideEffects 24 25 /** 26 * Installer Update Sites Controller 27 * 28 * @package Joomla.Administrator 29 * @subpackage com_installer 30 * @since 3.4 31 */ 32 class UpdatesitesController extends AdminController 33 { 34 /** 35 * The prefix to use with controller messages. 36 * 37 * @var string 38 * @since 4.0.0 39 */ 40 protected $text_prefix = 'COM_INSTALLER_UPDATESITES'; 41 42 /** 43 * Constructor. 44 * 45 * @param array $config An optional associative array of configuration settings. 46 * @param MVCFactoryInterface $factory The factory. 47 * @param CMSApplication $app The Application for the dispatcher 48 * @param Input $input Input 49 * 50 * @since 1.6 51 */ 52 public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null) 53 { 54 parent::__construct($config, $factory, $app, $input); 55 56 $this->registerTask('unpublish', 'publish'); 57 $this->registerTask('publish', 'publish'); 58 $this->registerTask('delete', 'delete'); 59 $this->registerTask('rebuild', 'rebuild'); 60 } 61 62 /** 63 * Proxy for getModel. 64 * 65 * @param string $name The model name. Optional. 66 * @param string $prefix The class prefix. Optional. 67 * @param array $config The array of possible config values. Optional. 68 * 69 * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel 70 * 71 * @since 4.0.0 72 */ 73 public function getModel($name = 'Updatesite', $prefix = 'Administrator', $config = array('ignore_request' => true)) 74 { 75 return parent::getModel($name, $prefix, $config); 76 } 77 78 /** 79 * Enable/Disable an extension (if supported). 80 * 81 * @return void 82 * 83 * @since 3.4 84 * 85 * @throws \Exception on error 86 */ 87 public function publish() 88 { 89 // Check for request forgeries. 90 $this->checkToken(); 91 92 $ids = (array) $this->input->get('cid', array(), 'int'); 93 $values = array('publish' => 1, 'unpublish' => 0); 94 $task = $this->getTask(); 95 $value = ArrayHelper::getValue($values, $task, 0, 'int'); 96 97 // Remove zero values resulting from input filter 98 $ids = array_filter($ids); 99 100 if (empty($ids)) { 101 throw new \Exception(Text::_('COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED'), 500); 102 } 103 104 // Get the model. 105 /** @var \Joomla\Component\Installer\Administrator\Model\UpdatesitesModel $model */ 106 $model = $this->getModel('Updatesites'); 107 108 // Change the state of the records. 109 if (!$model->publish($ids, $value)) { 110 throw new \Exception(implode('<br>', $model->getErrors()), 500); 111 } 112 113 $ntext = ($value == 0) ? 'COM_INSTALLER_N_UPDATESITES_UNPUBLISHED' : 'COM_INSTALLER_N_UPDATESITES_PUBLISHED'; 114 115 $this->setMessage(Text::plural($ntext, count($ids))); 116 117 $this->setRedirect(Route::_('index.php?option=com_installer&view=updatesites', false)); 118 } 119 120 /** 121 * Deletes an update site (if supported). 122 * 123 * @return void 124 * 125 * @since 3.6 126 * 127 * @throws \Exception on error 128 */ 129 public function delete() 130 { 131 // Check for request forgeries. 132 $this->checkToken(); 133 134 $ids = (array) $this->input->get('cid', array(), 'int'); 135 136 // Remove zero values resulting from input filter 137 $ids = array_filter($ids); 138 139 if (empty($ids)) { 140 throw new \Exception(Text::_('COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED'), 500); 141 } 142 143 // Delete the records. 144 $this->getModel('Updatesites')->delete($ids); 145 146 $this->setRedirect(Route::_('index.php?option=com_installer&view=updatesites', false)); 147 } 148 149 /** 150 * Rebuild update sites tables. 151 * 152 * @return void 153 * 154 * @since 3.6 155 */ 156 public function rebuild() 157 { 158 // Check for request forgeries. 159 $this->checkToken(); 160 161 // Rebuild the update sites. 162 $this->getModel('Updatesites')->rebuild(); 163 164 $this->setRedirect(Route::_('index.php?option=com_installer&view=updatesites', false)); 165 } 166 }
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 |