[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_checkin
   6   *
   7   * @copyright   (C) 2008 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\Checkin\Administrator\Controller;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\MVC\Controller\BaseController;
  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   * Checkin Controller
  23   *
  24   * @since  1.6
  25   */
  26  class DisplayController extends BaseController
  27  {
  28      /**
  29       * The default view.
  30       *
  31       * @var    string
  32       * @since  1.6
  33       */
  34      protected $default_view = 'checkin';
  35  
  36      /**
  37       * Method to display a view.
  38       *
  39       * @param   boolean  $cachable   If true, the view output will be cached
  40       * @param   array    $urlparams  An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
  41       *
  42       * @return  static  A \JControllerLegacy object to support chaining.
  43       */
  44      public function display($cachable = false, $urlparams = array())
  45      {
  46          return parent::display();
  47      }
  48  
  49      /**
  50       * Check in a list of items.
  51       *
  52       * @return  void
  53       */
  54      public function checkin()
  55      {
  56          // Check for request forgeries
  57          $this->checkToken();
  58  
  59          $ids = (array) $this->input->get('cid', array(), 'string');
  60  
  61          if (empty($ids)) {
  62              $this->app->enqueueMessage(Text::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'), 'warning');
  63          } else {
  64              // Get the model.
  65              /** @var \Joomla\Component\Checkin\Administrator\Model\CheckinModel $model */
  66              $model = $this->getModel('Checkin');
  67  
  68              // Checked in the items.
  69              $this->setMessage(Text::plural('COM_CHECKIN_N_ITEMS_CHECKED_IN', $model->checkin($ids)));
  70          }
  71  
  72          $this->setRedirect('index.php?option=com_checkin');
  73      }
  74  
  75      /**
  76       * Provide the data for a badge in a menu item via JSON
  77       *
  78       * @return  void
  79       *
  80       * @since   4.0.0
  81       * @throws  \Exception
  82       */
  83      public function getMenuBadgeData()
  84      {
  85          if (!$this->app->getIdentity()->authorise('core.manage', 'com_checkin')) {
  86              throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
  87          }
  88  
  89          $model = $this->getModel('Checkin');
  90  
  91          $amount = (int) count($model->getItems());
  92  
  93          echo new JsonResponse($amount);
  94      }
  95  
  96      /**
  97       * Method to get the number of locked icons
  98       *
  99       * @return  void
 100       *
 101       * @since   4.0.0
 102       * @throws  \Exception
 103       */
 104      public function getQuickiconContent()
 105      {
 106          if (!$this->app->getIdentity()->authorise('core.manage', 'com_checkin')) {
 107              throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
 108          }
 109  
 110          $model = $this->getModel('Checkin');
 111  
 112          $amount = (int) count($model->getItems());
 113  
 114          $result = [];
 115  
 116          $result['amount'] = $amount;
 117          $result['sronly'] = Text::plural('COM_CHECKIN_N_QUICKICON_SRONLY', $amount);
 118  
 119          echo new JsonResponse($result);
 120      }
 121  }


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