[ 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_modules 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\Modules\Administrator\Controller; 12 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\MVC\Controller\AdminController; 15 use Joomla\CMS\Response\JsonResponse; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Modules list controller class. 23 * 24 * @since 1.6 25 */ 26 class ModulesController extends AdminController 27 { 28 /** 29 * Method to clone an existing module. 30 * 31 * @return void 32 * 33 * @since 1.6 34 */ 35 public function duplicate() 36 { 37 // Check for request forgeries 38 $this->checkToken(); 39 40 $pks = (array) $this->input->post->get('cid', array(), 'int'); 41 42 // Remove zero values resulting from input filter 43 $pks = array_filter($pks); 44 45 try { 46 if (empty($pks)) { 47 throw new \Exception(Text::_('COM_MODULES_ERROR_NO_MODULES_SELECTED')); 48 } 49 50 $model = $this->getModel(); 51 $model->duplicate($pks); 52 $this->setMessage(Text::plural('COM_MODULES_N_MODULES_DUPLICATED', count($pks))); 53 } catch (\Exception $e) { 54 $this->app->enqueueMessage($e->getMessage(), 'warning'); 55 } 56 57 $this->setRedirect('index.php?option=com_modules&view=modules' . $this->getRedirectToListAppend()); 58 } 59 60 /** 61 * Method to get a model object, loading it if required. 62 * 63 * @param string $name The model name. Optional. 64 * @param string $prefix The class prefix. Optional. 65 * @param array $config Configuration array for model. Optional. 66 * 67 * @return object The model. 68 * 69 * @since 1.6 70 */ 71 public function getModel($name = 'Module', $prefix = 'Administrator', $config = array('ignore_request' => true)) 72 { 73 return parent::getModel($name, $prefix, $config); 74 } 75 76 /** 77 * Method to get the number of frontend modules 78 * 79 * @return void 80 * 81 * @since 4.0.0 82 */ 83 public function getQuickiconContent() 84 { 85 $model = $this->getModel('Modules'); 86 87 $model->setState('filter.state', 1); 88 $model->setState('filter.client_id', 0); 89 90 $amount = (int) $model->getTotal(); 91 92 $result = []; 93 94 $result['amount'] = $amount; 95 $result['sronly'] = Text::plural('COM_MODULES_N_QUICKICON_SRONLY', $amount); 96 $result['name'] = Text::plural('COM_MODULES_N_QUICKICON', $amount); 97 98 echo new JsonResponse($result); 99 } 100 101 /** 102 * Gets the URL arguments to append to a list redirect. 103 * 104 * @return string The arguments to append to the redirect URL. 105 * 106 * @since 4.0.0 107 */ 108 protected function getRedirectToListAppend() 109 { 110 $append = parent::getRedirectToListAppend(); 111 $append .= '&client_id=' . $this->input->getInt('client_id'); 112 113 return $append; 114 } 115 }
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 |