[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_installer
   6   *
   7   * @copyright   (C) 2006 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\Language\Text;
  14  use Joomla\CMS\MVC\Controller\BaseController;
  15  use Joomla\CMS\Response\JsonResponse;
  16  use Joomla\CMS\Router\Route;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Installer Controller
  24   *
  25   * @since  1.5
  26   */
  27  class DisplayController extends BaseController
  28  {
  29      /**
  30       * Method to display a view.
  31       *
  32       * @param   boolean  $cachable   If true, the view output will be cached
  33       * @param   array    $urlparams  An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
  34       *
  35       * @return  static   This object to support chaining.
  36       *
  37       * @since   1.5
  38       */
  39      public function display($cachable = false, $urlparams = false)
  40      {
  41          // Get the document object.
  42          $document = $this->app->getDocument();
  43  
  44          // Set the default view name and format from the Request.
  45          $vName   = $this->input->get('view', 'install');
  46          $vFormat = $document->getType();
  47          $lName   = $this->input->get('layout', 'default', 'string');
  48          $id      = $this->input->getInt('update_site_id');
  49  
  50          // Check for edit form.
  51          if ($vName === 'updatesite' && $lName === 'edit' && !$this->checkEditId('com_installer.edit.updatesite', $id)) {
  52              // Somehow the person just went to the form - we don't allow that.
  53              if (!\count($this->app->getMessageQueue())) {
  54                  $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
  55              }
  56  
  57              $this->setRedirect(Route::_('index.php?option=com_installer&view=updatesites', false));
  58  
  59              $this->redirect();
  60          }
  61  
  62          // Get and render the view.
  63          if ($view = $this->getView($vName, $vFormat)) {
  64              // Get the model for the view.
  65              $model = $this->getModel($vName);
  66  
  67              // Push the model into the view (as default).
  68              $view->setModel($model, true);
  69              $view->setLayout($lName);
  70  
  71              // Push document object into the view.
  72              $view->document = $document;
  73  
  74              $view->display();
  75          }
  76  
  77          return $this;
  78      }
  79  
  80      /**
  81       * Provide the data for a badge in a menu item via JSON
  82       *
  83       * @return  void
  84       *
  85       * @since   4.0.0
  86       * @throws  \Exception
  87       */
  88      public function getMenuBadgeData()
  89      {
  90          if (!$this->app->getIdentity()->authorise('core.manage', 'com_installer')) {
  91              throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
  92          }
  93  
  94          $model = $this->getModel('Warnings');
  95  
  96          echo new JsonResponse(count($model->getItems()));
  97      }
  98  }


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