[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_modules/src/Controller/ -> DisplayController.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_modules
   6   *
   7   * @copyright   (C) 2007 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\BaseController;
  15  use Joomla\CMS\Router\Route;
  16  use Joomla\CMS\Uri\Uri;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Modules manager master display controller.
  24   *
  25   * @since  1.6
  26   */
  27  class DisplayController extends BaseController
  28  {
  29      /**
  30       * The default view.
  31       *
  32       * @var    string
  33       * @since  1.6
  34       */
  35      protected $default_view = 'modules';
  36  
  37      /**
  38       * Method to display a view.
  39       *
  40       * @param   boolean        $cachable   If true, the view output will be cached
  41       * @param   array|boolean  $urlparams  An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}
  42       *
  43       * @return  static|boolean   This object to support chaining or false on failure.
  44       *
  45       * @since   1.5
  46       */
  47      public function display($cachable = false, $urlparams = false)
  48      {
  49          $layout = $this->input->get('layout', 'edit');
  50          $id     = $this->input->getInt('id');
  51  
  52          // Verify client
  53          $clientId = $this->input->post->getInt('client_id');
  54  
  55          if (!is_null($clientId)) {
  56              $uri = Uri::getInstance();
  57  
  58              if ((int) $uri->getVar('client_id') !== (int) $clientId) {
  59                  $this->setRedirect(Route::_('index.php?option=com_modules&view=modules&client_id=' . $clientId, false));
  60  
  61                  return false;
  62              }
  63          }
  64  
  65          // Check for edit form.
  66          if ($layout == 'edit' && !$this->checkEditId('com_modules.edit.module', $id)) {
  67              // Somehow the person just went to the form - we don't allow that.
  68              if (!\count($this->app->getMessageQueue())) {
  69                  $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
  70              }
  71  
  72              $this->setRedirect(Route::_('index.php?option=com_modules&view=modules&client_id=' . $this->input->getInt('client_id'), false));
  73  
  74              return false;
  75          }
  76  
  77          // Check if we have a mod_menu module set to All languages or a mod_menu module for each admin language.
  78          $factory = $this->app->bootComponent('menus')->getMVCFactory();
  79  
  80          if ($langMissing = $factory->createModel('Menus', 'Administrator')->getMissingModuleLanguages()) {
  81              $this->app->enqueueMessage(Text::sprintf('JMENU_MULTILANG_WARNING_MISSING_MODULES', implode(', ', $langMissing)), 'warning');
  82          }
  83  
  84          return parent::display();
  85      }
  86  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer