[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_redirect/src/Helper/ -> RedirectHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_redirect
   6   *
   7   * @copyright   (C) 2017 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\Redirect\Administrator\Helper;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\HTML\HTMLHelper;
  15  use Joomla\CMS\Plugin\PluginHelper;
  16  use Joomla\Registry\Registry;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Redirect component helper.
  24   *
  25   * @since  1.6
  26   */
  27  class RedirectHelper
  28  {
  29      /**
  30       * Extension
  31       *
  32       * @var    string
  33       */
  34      public static $extension = 'com_redirect';
  35  
  36      /**
  37       * Returns an array of standard published state filter options.
  38       *
  39       * @return  array  An array containing the options
  40       *
  41       * @since   1.6
  42       */
  43      public static function publishedOptions()
  44      {
  45          // Build the active state filter options.
  46          $options   = array();
  47          $options[] = HTMLHelper::_('select.option', '*', 'JALL');
  48          $options[] = HTMLHelper::_('select.option', '1', 'JENABLED');
  49          $options[] = HTMLHelper::_('select.option', '0', 'JDISABLED');
  50          $options[] = HTMLHelper::_('select.option', '2', 'JARCHIVED');
  51          $options[] = HTMLHelper::_('select.option', '-2', 'JTRASHED');
  52  
  53          return $options;
  54      }
  55  
  56      /**
  57       * Gets the redirect system plugin extension id.
  58       *
  59       * @return  integer  The redirect system plugin extension id.
  60       *
  61       * @since   3.6.0
  62       */
  63      public static function getRedirectPluginId()
  64      {
  65          $db    = Factory::getDbo();
  66          $query = $db->getQuery(true)
  67              ->select($db->quoteName('extension_id'))
  68              ->from($db->quoteName('#__extensions'))
  69              ->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
  70              ->where($db->quoteName('element') . ' = ' . $db->quote('redirect'));
  71          $db->setQuery($query);
  72  
  73          try {
  74              $result = (int) $db->loadResult();
  75          } catch (\RuntimeException $e) {
  76              Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
  77          }
  78  
  79          return $result;
  80      }
  81  
  82      /**
  83       * Checks whether the option "Collect URLs" is enabled for the output message
  84       *
  85       * @return  boolean
  86       *
  87       * @since   3.4
  88       */
  89      public static function collectUrlsEnabled()
  90      {
  91          $collect_urls = false;
  92  
  93          if (PluginHelper::isEnabled('system', 'redirect')) {
  94              $params       = new Registry(PluginHelper::getPlugin('system', 'redirect')->params);
  95              $collect_urls = (bool) $params->get('collect_urls', 1);
  96          }
  97  
  98          return $collect_urls;
  99      }
 100  }


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