[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/modules/mod_finder/src/Helper/ -> FinderHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  mod_finder
   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\Module\Finder\Site\Helper;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Filter\InputFilter;
  15  use Joomla\CMS\Router\Route;
  16  use Joomla\CMS\Uri\Uri;
  17  use Joomla\Component\Finder\Administrator\Indexer\Query;
  18  use Joomla\Database\DatabaseInterface;
  19  use Joomla\Utilities\ArrayHelper;
  20  
  21  // phpcs:disable PSR1.Files.SideEffects
  22  \defined('_JEXEC') or die;
  23  // phpcs:enable PSR1.Files.SideEffects
  24  
  25  /**
  26   * Finder module helper.
  27   *
  28   * @since  2.5
  29   */
  30  class FinderHelper
  31  {
  32      /**
  33       * Method to get hidden input fields for a get form so that control variables
  34       * are not lost upon form submission.
  35       *
  36       * @param   string   $route      The route to the page. [optional]
  37       * @param   integer  $paramItem  The menu item ID. (@since 3.1) [optional]
  38       *
  39       * @return  string  A string of hidden input form fields
  40       *
  41       * @since   2.5
  42       */
  43      public static function getGetFields($route = null, $paramItem = 0)
  44      {
  45          $fields = array();
  46          $uri = Uri::getInstance(Route::_($route));
  47          $uri->delVar('q');
  48  
  49          // Create hidden input elements for each part of the URI.
  50          foreach ($uri->getQuery(true) as $n => $v) {
  51              $fields[] = '<input type="hidden" name="' . $n . '" value="' . $v . '">';
  52          }
  53  
  54          return implode('', $fields);
  55      }
  56  
  57      /**
  58       * Get Smart Search query object.
  59       *
  60       * @param   \Joomla\Registry\Registry  $params  Module parameters.
  61       *
  62       * @return  Query object
  63       *
  64       * @since   2.5
  65       */
  66      public static function getQuery($params)
  67      {
  68          $request = Factory::getApplication()->input->request;
  69          $filter  = InputFilter::getInstance();
  70  
  71          // Get the static taxonomy filters.
  72          $options = array();
  73          $options['filter'] = ($request->get('f', 0, 'int') !== 0) ? $request->get('f', '', 'int') : $params->get('searchfilter');
  74          $options['filter'] = $filter->clean($options['filter'], 'int');
  75  
  76          // Get the dynamic taxonomy filters.
  77          $options['filters'] = $request->get('t', '', 'array');
  78          $options['filters'] = $filter->clean($options['filters'], 'array');
  79          $options['filters'] = ArrayHelper::toInteger($options['filters']);
  80  
  81          // Instantiate a query object.
  82          return new Query($options, Factory::getContainer()->get(DatabaseInterface::class));
  83      }
  84  }


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