primo commit
This commit is contained in:
		| @ -0,0 +1,67 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package     Joomla.Administrator | ||||
|  * @subpackage  com_plugins | ||||
|  * | ||||
|  * @copyright   (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> | ||||
|  * @license     GNU General Public License version 2 or later; see LICENSE.txt | ||||
|  */ | ||||
|  | ||||
| namespace Joomla\Component\Plugins\Administrator\Controller; | ||||
|  | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\MVC\Controller\BaseController; | ||||
| use Joomla\CMS\Router\Route; | ||||
|  | ||||
| // phpcs:disable PSR1.Files.SideEffects | ||||
| \defined('_JEXEC') or die; | ||||
| // phpcs:enable PSR1.Files.SideEffects | ||||
|  | ||||
| /** | ||||
|  * Plugins display controller. | ||||
|  * | ||||
|  * @since  1.5 | ||||
|  */ | ||||
| class DisplayController extends BaseController | ||||
| { | ||||
|     /** | ||||
|      * The default view. | ||||
|      * | ||||
|      * @var    string | ||||
|      * @since  1.6 | ||||
|      */ | ||||
|     protected $default_view = 'plugins'; | ||||
|  | ||||
|     /** | ||||
|      * Method to display a view. | ||||
|      * | ||||
|      * @param   boolean  $cachable   If true, the view output will be cached | ||||
|      * @param   array    $urlparams  An array of safe URL parameters and their variable types. | ||||
|      *                   @see        \Joomla\CMS\Filter\InputFilter::clean() for valid values. | ||||
|      * | ||||
|      * @return  static|boolean   This object to support chaining or false on failure. | ||||
|      * | ||||
|      * @since   1.5 | ||||
|      */ | ||||
|     public function display($cachable = false, $urlparams = []) | ||||
|     { | ||||
|         $view   = $this->input->get('view', 'plugins'); | ||||
|         $layout = $this->input->get('layout', 'default'); | ||||
|         $id     = $this->input->getInt('extension_id'); | ||||
|  | ||||
|         // Check for edit form. | ||||
|         if ($view == 'plugin' && $layout == 'edit' && !$this->checkEditId('com_plugins.edit.plugin', $id)) { | ||||
|             // Somehow the person just went to the form - we don't allow that. | ||||
|             if (!\count($this->app->getMessageQueue())) { | ||||
|                 $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); | ||||
|             } | ||||
|  | ||||
|             $this->setRedirect(Route::_('index.php?option=com_plugins&view=plugins', false)); | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         return parent::display($cachable, $urlparams); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,77 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package     Joomla.Administrator | ||||
|  * @subpackage  com_plugins | ||||
|  * | ||||
|  * @copyright   (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> | ||||
|  * @license     GNU General Public License version 2 or later; see LICENSE.txt | ||||
|  */ | ||||
|  | ||||
| namespace Joomla\Component\Plugins\Administrator\Controller; | ||||
|  | ||||
| use Joomla\CMS\MVC\Controller\FormController; | ||||
| use Joomla\CMS\MVC\Model\BaseDatabaseModel; | ||||
| use Joomla\CMS\Router\Route; | ||||
|  | ||||
| // phpcs:disable PSR1.Files.SideEffects | ||||
| \defined('_JEXEC') or die; | ||||
| // phpcs:enable PSR1.Files.SideEffects | ||||
|  | ||||
| /** | ||||
|  * Plugin controller class. | ||||
|  * | ||||
|  * @since  1.6 | ||||
|  */ | ||||
| class PluginController extends FormController | ||||
| { | ||||
|     /** | ||||
|      * Method to cancel an edit. | ||||
|      * | ||||
|      * @param   string  $key  The name of the primary key of the URL variable. | ||||
|      * | ||||
|      * @return  boolean  True if access level checks pass, false otherwise. | ||||
|      * | ||||
|      * @since   5.1.0 | ||||
|      */ | ||||
|     public function cancel($key = null) | ||||
|     { | ||||
|         $result = parent::cancel($key); | ||||
|  | ||||
|         // When editing in modal then redirect to modalreturn layout | ||||
|         if ($result && $this->input->get('layout') === 'modal') { | ||||
|             $id     = $this->input->get('extension_id'); | ||||
|             $return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id, 'extension_id') | ||||
|                 . '&layout=modalreturn&from-task=cancel'; | ||||
|  | ||||
|             $this->setRedirect(Route::_($return, false)); | ||||
|         } | ||||
|  | ||||
|         return $result; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Function that allows child controller access to model data | ||||
|      * after the data has been saved. | ||||
|      * | ||||
|      * @param   BaseDatabaseModel  $model      The data model object. | ||||
|      * @param   array              $validData  The validated data. | ||||
|      * | ||||
|      * @return  void | ||||
|      * | ||||
|      * @since   5.1.0 | ||||
|      */ | ||||
|     protected function postSaveHook(BaseDatabaseModel $model, $validData = []) | ||||
|     { | ||||
|         parent::postSaveHook($model, $validData); | ||||
|  | ||||
|         // When editing in modal then redirect to modalreturn layout | ||||
|         if ($this->input->get('layout') === 'modal' && $this->task === 'save') { | ||||
|             $id     = $model->getState('plugin.id', ''); | ||||
|             $return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id, 'extension_id') | ||||
|                 . '&layout=modalreturn&from-task=save'; | ||||
|  | ||||
|             $this->setRedirect(Route::_($return, false)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,67 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package     Joomla.Administrator | ||||
|  * @subpackage  com_plugins | ||||
|  * | ||||
|  * @copyright   (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> | ||||
|  * @license     GNU General Public License version 2 or later; see LICENSE.txt | ||||
|  */ | ||||
|  | ||||
| namespace Joomla\Component\Plugins\Administrator\Controller; | ||||
|  | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\MVC\Controller\AdminController; | ||||
| use Joomla\CMS\Response\JsonResponse; | ||||
|  | ||||
| // phpcs:disable PSR1.Files.SideEffects | ||||
| \defined('_JEXEC') or die; | ||||
| // phpcs:enable PSR1.Files.SideEffects | ||||
|  | ||||
| /** | ||||
|  * Plugins list controller class. | ||||
|  * | ||||
|  * @since  1.6 | ||||
|  */ | ||||
| class PluginsController 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  object  The model. | ||||
|      * | ||||
|      * @since   1.6 | ||||
|      */ | ||||
|     public function getModel($name = 'Plugin', $prefix = 'Administrator', $config = ['ignore_request' => true]) | ||||
|     { | ||||
|         return parent::getModel($name, $prefix, $config); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Method to get the number of activated plugins | ||||
|      * | ||||
|      * @return  void | ||||
|      * | ||||
|      * @since   4.0.0 | ||||
|      */ | ||||
|     public function getQuickiconContent() | ||||
|     { | ||||
|         $model = $this->getModel('Plugins'); | ||||
|  | ||||
|         $model->setState('filter.enabled', 1); | ||||
|  | ||||
|         $amount = (int) $model->getTotal(); | ||||
|  | ||||
|         $result = []; | ||||
|  | ||||
|         $result['amount'] = $amount; | ||||
|         $result['sronly'] = Text::plural('COM_PLUGINS_N_QUICKICON_SRONLY', $amount); | ||||
|         $result['name']   = Text::plural('COM_PLUGINS_N_QUICKICON', $amount); | ||||
|  | ||||
|         echo new JsonResponse($result); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user