[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_languages/src/Controller/ -> OverridesController.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_languages
   6   *
   7   * @copyright   (C) 2011 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\Languages\Administrator\Controller;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\MVC\Controller\AdminController;
  15  use Joomla\CMS\Router\Route;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Languages Overrides Controller.
  23   *
  24   * @since  2.5
  25   */
  26  class OverridesController extends AdminController
  27  {
  28      /**
  29       * The prefix to use with controller messages.
  30       *
  31       * @var     string
  32       * @since   2.5
  33       */
  34      protected $text_prefix = 'COM_LANGUAGES_VIEW_OVERRIDES';
  35  
  36      /**
  37       * Method for deleting one or more overrides.
  38       *
  39       * @return  void
  40       *
  41       * @since   2.5
  42       */
  43      public function delete()
  44      {
  45          // Check for request forgeries.
  46          $this->checkToken();
  47  
  48          // Get items to delete from the request.
  49          $cid = (array) $this->input->get('cid', array(), 'string');
  50  
  51          // Remove zero values resulting from input filter
  52          $cid = array_filter($cid);
  53  
  54          if (empty($cid)) {
  55              $this->setMessage(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning');
  56          } else {
  57              // Get the model.
  58              $model = $this->getModel('overrides');
  59  
  60              // Remove the items.
  61              if ($model->delete($cid)) {
  62                  $this->setMessage(Text::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
  63              } else {
  64                  $this->setMessage($model->getError(), 'error');
  65              }
  66          }
  67  
  68          $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
  69      }
  70  
  71      /**
  72       * Method to purge the overrider table.
  73       *
  74       * @return  void
  75       *
  76       * @since   3.4.2
  77       */
  78      public function purge()
  79      {
  80          // Check for request forgeries.
  81          $this->checkToken();
  82  
  83          /** @var \Joomla\Component\Languages\Administrator\Model\OverridesModel $model */
  84          $model = $this->getModel('overrides');
  85          $model->purge();
  86          $this->setRedirect(Route::_('index.php?option=com_languages&view=overrides', false));
  87      }
  88  }


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