Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/search.php.tar
Назад
home/wuectly/www/administrator/components/com_search/search.php 0000604 00000001064 15245570254 0021150 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_search * * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; if (!JFactory::getUser()->authorise('core.manage', 'com_search')) { throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Search'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect(); home/wuectly/www/libraries/joomla/mediawiki/search.php 0000604 00000006121 15245570547 0017204 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage MediaWiki * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * MediaWiki API Search class for the Joomla Platform. * * @since 3.1.4 */ class JMediawikiSearch extends JMediawikiObject { /** * Method to perform a full text search. * * @param string $srsearch Search for all page titles (or content) that has this value. * @param array $srnamespace The namespace(s) to enumerate. * @param string $srwhat Search inside the text or titles. * @param array $srinfo What metadata to return. * @param array $srprop What properties to return. * @param boolean $srredirects Include redirect pages in the search. * @param integer $sroffest Use this value to continue paging. * @param integer $srlimit How many total pages to return. * * @return object * * @since 3.1.4 */ public function search($srsearch, array $srnamespace = null, $srwhat = null, array $srinfo = null, array $srprop = null, $srredirects = null, $sroffest = null, $srlimit = null) { // Build the request. $path = '?action=query&list=search'; if (isset($srsearch)) { $path .= '&srsearch=' . $srsearch; } if (isset($srnamespace)) { $path .= '&srnamespace=' . $this->buildParameter($srnamespace); } if (isset($srwhat)) { $path .= '&srwhat=' . $srwhat; } if (isset($srinfo)) { $path .= '&srinfo=' . $this->buildParameter($srinfo); } if (isset($srprop)) { $path .= '&srprop=' . $this->buildParameter($srprop); } if ($srredirects) { $path .= '&srredirects='; } if (isset($sroffest)) { $path .= '&sroffest=' . $sroffest; } if (isset($srlimit)) { $path .= '&srlimit=' . $srlimit; } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); } /** * Method to search the wiki using opensearch protocol. * * @param string $search Search string. * @param integer $limit Maximum amount of results to return. * @param array $namespace Namespaces to search. * @param string $suggest Do nothing if $wgEnableOpenSearchSuggest is false. * @param string $format Output format. * * @return object * * @since 3.1.4 */ public function openSearch($search, $limit = null, array $namespace = null, $suggest = null, $format = null) { // Build the request. $path = '?action=query&list=search'; if (isset($search)) { $path .= '&search=' . $search; } if (isset($limit)) { $path .= '&limit=' . $limit; } if (isset($namespace)) { $path .= '&namespace=' . $this->buildParameter($namespace); } if (isset($suggest)) { $path .= '&suggest=' . $suggest; } if (isset($format)) { $path .= '&format=' . $format; } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); } } home/wuectly/www/libraries/regularlabs/helpers/search.php 0000604 00000013547 15245570562 0017734 0 ustar 00 <?php /** * @package Regular Labs Library * @version 21.4.10972 * * @author Peter van Westen <info@regularlabs.com> * @link http://www.regularlabs.com * @copyright Copyright © 2021 Regular Labs All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ /** * BASE ON JOOMLA CORE FILE: * /components/com_search/models/search.php */ /** * @package Joomla.Site * @subpackage com_search * * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Factory as JFactory; use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel; use Joomla\CMS\Pagination\Pagination as JPagination; use Joomla\CMS\Plugin\PluginHelper as JPluginHelper; /** * Search Component Search Model * * @since 1.5 */ class SearchModelSearch extends JModel { /** * Search data array * * @var array */ protected $_data = null; /** * Search total * * @var integer */ protected $_total = null; /** * Search areas * * @var integer */ protected $_areas = null; /** * Pagination object * * @var object */ protected $_pagination = null; /** * Constructor * * @since 1.5 */ public function __construct() { parent::__construct(); // Get configuration $app = JFactory::getApplication(); $config = JFactory::getConfig(); // Get the pagination request variables $this->setState('limit', $app->getUserStateFromRequest('com_search.limit', 'limit', $config->get('list_limit'), 'uint')); $this->setState('limitstart', $app->input->get('limitstart', 0, 'uint')); // Get parameters. $params = $app->getParams(); if ($params->get('searchphrase') == 1) { $searchphrase = 'any'; } elseif ($params->get('searchphrase') == 2) { $searchphrase = 'exact'; } else { $searchphrase = 'all'; } // Set the search parameters $keyword = urldecode($app->input->getString('searchword')); $match = $app->input->get('searchphrase', $searchphrase, 'word'); $ordering = $app->input->get('ordering', $params->get('ordering', 'newest'), 'word'); $this->setSearch($keyword, $match, $ordering); // Set the search areas $areas = $app->input->get('areas', null, 'array'); $this->setAreas($areas); } /** * Method to set the search parameters * * @param string $keyword string search string * @param string $match matching option, exact|any|all * @param string $ordering option, newest|oldest|popular|alpha|category * * @return void * * @access public */ public function setSearch($keyword, $match = 'all', $ordering = 'newest') { if (isset($keyword)) { $this->setState('origkeyword', $keyword); if ($match !== 'exact') { $keyword = preg_replace('#\xE3\x80\x80#s', ' ', $keyword); } $this->setState('keyword', $keyword); } if (isset($match)) { $this->setState('match', $match); } if (isset($ordering)) { $this->setState('ordering', $ordering); } } /** * Method to get weblink item data for the category * * @access public * @return array */ public function getData() { // Lets load the content if it doesn't already exist if (empty($this->_data)) { $areas = $this->getAreas(); JPluginHelper::importPlugin('search'); $dispatcher = JEventDispatcher::getInstance(); $results = $dispatcher->trigger('onContentSearch', [ $this->getState('keyword'), $this->getState('match'), $this->getState('ordering'), $areas['active'], ] ); $rows = []; foreach ($results as $result) { $rows = array_merge((array) $rows, (array) $result); } $this->_total = count($rows); if ($this->getState('limit') > 0) { $this->_data = array_splice($rows, $this->getState('limitstart'), $this->getState('limit')); } else { $this->_data = $rows; } /* >>> ADDED: Run content plugins over results */ $params = JFactory::getApplication()->getParams('com_content'); $params->set('rl_search', 1); foreach ($this->_data as $item) { if (empty($item->text)) { continue; } $dispatcher->trigger('onContentPrepare', ['com_search.search.article', &$item, &$params, 0]); if (empty($item->title)) { continue; } // strip html tags from title $item->title = strip_tags($item->title); } /* <<< */ } return $this->_data; } /** * Method to get the total number of weblink items for the category * * @access public * * @return integer */ public function getTotal() { return $this->_total; } /** * Method to set the search areas * * @param array $active areas * @param array $search areas * * @return void * * @access public */ public function setAreas($active = [], $search = []) { $this->_areas['active'] = $active; $this->_areas['search'] = $search; } /** * Method to get a pagination object of the weblink items for the category * * @access public * @return integer */ public function getPagination() { // Lets load the content if it doesn't already exist if (empty($this->_pagination)) { $this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit')); } return $this->_pagination; } /** * Method to get the search areas * * @return int * * @since 1.5 */ public function getAreas() { // Load the Category data if (empty($this->_areas['search'])) { $areas = []; JPluginHelper::importPlugin('search'); $dispatcher = JEventDispatcher::getInstance(); $searchareas = $dispatcher->trigger('onContentSearchAreas'); foreach ($searchareas as $area) { if (is_array($area)) { $areas = array_merge($areas, $area); } } $this->_areas['search'] = $areas; } return $this->_areas; } } home/wuectly/www/components/com_search/search.php 0000604 00000000626 15245603227 0016270 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_search * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; $controller = JControllerLegacy::getInstance('Search'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect(); home/wuectly/www/components/com_finder/models/search.php 0000604 00000102615 15245617344 0017563 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_finder * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; // Register dependent classes. define('FINDER_PATH_INDEXER', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer'); JLoader::register('FinderIndexerHelper', FINDER_PATH_INDEXER . '/helper.php'); JLoader::register('FinderIndexerQuery', FINDER_PATH_INDEXER . '/query.php'); JLoader::register('FinderIndexerResult', FINDER_PATH_INDEXER . '/result.php'); JLoader::register('FinderIndexerStemmer', FINDER_PATH_INDEXER . '/stemmer.php'); /** * Search model class for the Finder package. * * @since 2.5 */ class FinderModelSearch extends JModelList { /** * Context string for the model type * * @var string * @since 2.5 */ protected $context = 'com_finder.search'; /** * The query object is an instance of FinderIndexerQuery which contains and * models the entire search query including the text input; static and * dynamic taxonomy filters; date filters; etc. * * @var FinderIndexerQuery * @since 2.5 */ protected $query; /** * An array of all excluded terms ids. * * @var array * @since 2.5 */ protected $excludedTerms = array(); /** * An array of all included terms ids. * * @var array * @since 2.5 */ protected $includedTerms = array(); /** * An array of all required terms ids. * * @var array * @since 2.5 */ protected $requiredTerms = array(); /** * Method to get the results of the query. * * @return array An array of FinderIndexerResult objects. * * @since 2.5 * @throws Exception on database error. */ public function getResults() { // Check if the search query is valid. if (empty($this->query->search)) { return null; } // Check if we should return results. if (empty($this->includedTerms) && (empty($this->query->filters) || !$this->query->empty)) { return null; } // Get the store id. $store = $this->getStoreId('getResults'); // Use the cached data if possible. if ($this->retrieve($store)) { return $this->retrieve($store); } // Get the row data. $items = $this->getResultsData(); // Check the data. if (empty($items)) { return null; } // Create the query to get the search results. $db = $this->getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('link_id') . ', ' . $db->quoteName('object')) ->from($db->quoteName('#__finder_links')) ->where($db->quoteName('link_id') . ' IN (' . implode(',', array_keys($items)) . ')'); // Load the results from the database. $db->setQuery($query); $rows = $db->loadObjectList('link_id'); // Set up our results container. $results = $items; // Convert the rows to result objects. foreach ($rows as $rk => $row) { // Build the result object. if (is_resource($row->object)) { $object = pg_unescape_bytea(stream_get_contents($row->object)); $result = unserialize(str_replace("''", "'", $object)); } else { $result = unserialize($row->object); } $result->weight = $results[$rk]; $result->link_id = $rk; // Add the result back to the stack. $results[$rk] = $result; } // Switch to a non-associative array. $results = array_values($results); // Push the results into cache. $this->store($store, $results); // Return the results. return $this->retrieve($store); } /** * Method to get the total number of results. * * @return integer The total number of results. * * @since 2.5 * @throws Exception on database error. */ public function getTotal() { // Check if the search query is valid. if (empty($this->query->search)) { return null; } // Check if we should return results. if (empty($this->includedTerms) && (empty($this->query->filters) || !$this->query->empty)) { return null; } // Get the store id. $store = $this->getStoreId('getTotal'); // Use the cached data if possible. if ($this->retrieve($store)) { return $this->retrieve($store); } // Get the results total. $total = $this->getResultsTotal(); // Push the total into cache. $this->store($store, $total); // Return the total. return $this->retrieve($store); } /** * Method to get the query object. * * @return FinderIndexerQuery A query object. * * @since 2.5 */ public function getQuery() { // Return the query object. return $this->query; } /** * Method to build a database query to load the list data. * * @return JDatabaseQuery A database query. * * @since 2.5 */ protected function getListQuery() { // Get the store id. $store = $this->getStoreId('getListQuery'); // Use the cached data if possible. if ($this->retrieve($store, false)) { return clone $this->retrieve($store, false); } // Set variables $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true) ->select('l.link_id') ->from($db->quoteName('#__finder_links') . ' AS l') ->where('l.access IN (' . $groups . ')') ->where('l.state = 1') ->where('l.published = 1'); // Get the null date and the current date, minus seconds. $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(substr_replace(JFactory::getDate()->toSql(), '00', -2)); // Add the publish up and publish down filters. $query->where('(l.publish_start_date = ' . $nullDate . ' OR l.publish_start_date <= ' . $nowDate . ')') ->where('(l.publish_end_date = ' . $nullDate . ' OR l.publish_end_date >= ' . $nowDate . ')'); /* * Add the taxonomy filters to the query. We have to join the taxonomy * map table for each group so that we can use AND clauses across * groups. Within each group there can be an array of values that will * use OR clauses. */ if (!empty($this->query->filters)) { // Convert the associative array to a numerically indexed array. $groups = array_values($this->query->filters); // Iterate through each taxonomy group and add the join and where. for ($i = 0, $c = count($groups); $i < $c; $i++) { // We use the offset because each join needs a unique alias. $query->join('INNER', $db->quoteName('#__finder_taxonomy_map') . ' AS t' . $i . ' ON t' . $i . '.link_id = l.link_id') ->where('t' . $i . '.node_id IN (' . implode(',', $groups[$i]) . ')'); } } // Add the start date filter to the query. if (!empty($this->query->date1)) { // Escape the date. $date1 = $db->quote($this->query->date1); // Add the appropriate WHERE condition. if ($this->query->when1 === 'before') { $query->where($db->quoteName('l.start_date') . ' <= ' . $date1); } elseif ($this->query->when1 === 'after') { $query->where($db->quoteName('l.start_date') . ' >= ' . $date1); } else { $query->where($db->quoteName('l.start_date') . ' = ' . $date1); } } // Add the end date filter to the query. if (!empty($this->query->date2)) { // Escape the date. $date2 = $db->quote($this->query->date2); // Add the appropriate WHERE condition. if ($this->query->when2 === 'before') { $query->where($db->quoteName('l.start_date') . ' <= ' . $date2); } elseif ($this->query->when2 === 'after') { $query->where($db->quoteName('l.start_date') . ' >= ' . $date2); } else { $query->where($db->quoteName('l.start_date') . ' = ' . $date2); } } // Filter by language if ($this->getState('filter.language')) { $query->where('l.language IN (' . $db->quote(JFactory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')'); } // Push the data into cache. $this->store($store, $query, false); // Return a copy of the query object. return clone $this->retrieve($store, false); } /** * Method to get the total number of results for the search query. * * @return integer The results total. * * @since 2.5 * @throws Exception on database error. */ protected function getResultsTotal() { // Get the store id. $store = $this->getStoreId('getResultsTotal', false); // Use the cached data if possible. if ($this->retrieve($store)) { return $this->retrieve($store); } // Get the base query and add the ordering information. $base = $this->getListQuery(); $base->select('0 AS ordering'); // Get the maximum number of results. $limit = (int) $this->getState('match.limit'); /* * If there are no optional or required search terms in the query, * we can get the result total in one relatively simple database query. */ if (empty($this->includedTerms)) { // Adjust the query to join on the appropriate mapping table. $query = clone $base; $query->clear('select') ->select('COUNT(DISTINCT l.link_id)'); // Get the total from the database. $this->_db->setQuery($query); $total = $this->_db->loadResult(); // Push the total into cache. $this->store($store, min($total, $limit)); // Return the total. return $this->retrieve($store); } /* * If there are optional or required search terms in the query, the * process of getting the result total is more complicated. */ $start = 0; $items = array(); $sorted = array(); $maps = array(); $excluded = $this->getExcludedLinkIds(); /* * Iterate through the included search terms and group them by mapping * table suffix. This ensures that we never have to do more than 16 * queries to get a batch. This may seem like a lot but it is rarely * anywhere near 16 because of the improved mapping algorithm. */ foreach ($this->includedTerms as $token => $ids) { // Get the mapping table suffix. $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); // Initialize the mapping group. if (!array_key_exists($suffix, $maps)) { $maps[$suffix] = array(); } // Add the terms to the mapping group. $maps[$suffix] = array_merge($maps[$suffix], $ids); } /* * When the query contains search terms we need to find and process the * result total iteratively using a do-while loop. */ do { // Create a container for the fetched results. $results = array(); $more = false; /* * Iterate through the mapping groups and load the total from each * mapping table. */ foreach ($maps as $suffix => $ids) { // Create a storage key for this set. $setId = $this->getStoreId('getResultsTotal:' . serialize(array_values($ids)) . ':' . $start . ':' . $limit); // Use the cached data if possible. if ($this->retrieve($setId)) { $temp = $this->retrieve($setId); } // Load the data from the database. else { // Adjust the query to join on the appropriate mapping table. $query = clone $base; $query->join('INNER', '#__finder_links_terms' . $suffix . ' AS m ON m.link_id = l.link_id') ->where('m.term_id IN (' . implode(',', $ids) . ')'); // Load the results from the database. $this->_db->setQuery($query, $start, $limit); $temp = $this->_db->loadObjectList(); // Set the more flag to true if any of the sets equal the limit. $more = count($temp) === $limit; // We loaded the data unkeyed but we need it to be keyed for later. $junk = $temp; $temp = array(); // Convert to an associative array. for ($i = 0, $c = count($junk); $i < $c; $i++) { $temp[$junk[$i]->link_id] = $junk[$i]; } // Store this set in cache. $this->store($setId, $temp); } // Merge the results. $results = array_merge($results, $temp); } // Check if there are any excluded terms to deal with. if (count($excluded)) { // Remove any results that match excluded terms. for ($i = 0, $c = count($results); $i < $c; $i++) { if (in_array($results[$i]->link_id, $excluded)) { unset($results[$i]); } } // Reset the array keys. $results = array_values($results); } // Iterate through the set to extract the unique items. for ($i = 0, $c = count($results); $i < $c; $i++) { if (!isset($sorted[$results[$i]->link_id])) { $sorted[$results[$i]->link_id] = $results[$i]->ordering; } } /* * If the query contains just optional search terms and we have * enough items for the page, we can stop here. */ if (empty($this->requiredTerms)) { // If we need more items and they're available, make another pass. if ($more && count($sorted) < $limit) { // Increment the batch starting point and continue. $start += $limit; continue; } // Push the total into cache. $this->store($store, min(count($sorted), $limit)); // Return the total. return $this->retrieve($store); } /* * The query contains required search terms so we have to iterate * over the items and remove any items that do not match all of the * required search terms. This is one of the most expensive steps * because a required token could theoretically eliminate all of * current terms which means we would have to loop through all of * the possibilities. */ foreach ($this->requiredTerms as $token => $required) { // Create a storage key for this set. $setId = $this->getStoreId('getResultsTotal:required:' . serialize(array_values($required)) . ':' . $start . ':' . $limit); // Use the cached data if possible. if ($this->retrieve($setId)) { $reqTemp = $this->retrieve($setId); } // Check if the token was matched. elseif (empty($required)) { return null; } // Load the data from the database. else { // Setup containers in case we have to make multiple passes. $reqStart = 0; $reqTemp = array(); do { // Get the map table suffix. $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); // Adjust the query to join on the appropriate mapping table. $query = clone $base; $query->join('INNER', '#__finder_links_terms' . $suffix . ' AS m ON m.link_id = l.link_id') ->where('m.term_id IN (' . implode(',', $required) . ')'); // Load the results from the database. $this->_db->setQuery($query, $reqStart, $limit); $temp = $this->_db->loadObjectList('link_id'); // Set the required token more flag to true if the set equal the limit. $reqMore = count($temp) === $limit; // Merge the matching set for this token. $reqTemp += $temp; // Increment the term offset. $reqStart += $limit; } while ($reqMore === true); // Store this set in cache. $this->store($setId, $reqTemp); } // Remove any items that do not match the required term. $sorted = array_intersect_key($sorted, $reqTemp); } // If we need more items and they're available, make another pass. if ($more && count($sorted) < $limit) { // Increment the batch starting point. $start += $limit; // Merge the found items. $items += $sorted; continue; } // Otherwise, end the loop. { // Merge the found items. $items += $sorted; $more = false; } // End do-while loop. } while ($more === true); // Set the total. $total = count($items); $total = min($total, $limit); // Push the total into cache. $this->store($store, $total); // Return the total. return $this->retrieve($store); } /** * Method to get the results for the search query. * * @return array An array of result data objects. * * @since 2.5 * @throws Exception on database error. */ protected function getResultsData() { // Get the store id. $store = $this->getStoreId('getResultsData', false); // Use the cached data if possible. if ($this->retrieve($store)) { return $this->retrieve($store); } // Get the result ordering and direction. $ordering = $this->getState('list.ordering', 'l.start_date'); $direction = $this->getState('list.direction', 'DESC'); // Get the base query and add the ordering information. $base = $this->getListQuery(); $base->select($this->_db->escape($ordering) . ' AS ordering'); $base->order($this->_db->escape($ordering) . ' ' . $this->_db->escape($direction)); /* * If there are no optional or required search terms in the query, we * can get the results in one relatively simple database query. */ if (empty($this->includedTerms)) { // Get the results from the database. $this->_db->setQuery($base, (int) $this->getState('list.start'), (int) $this->getState('list.limit')); $return = $this->_db->loadObjectList('link_id'); // Get a new store id because this data is page specific. $store = $this->getStoreId('getResultsData', true); // Push the results into cache. $this->store($store, $return); // Return the results. return $this->retrieve($store); } /* * If there are optional or required search terms in the query, the * process of getting the results is more complicated. */ $start = 0; $limit = (int) $this->getState('match.limit'); $items = array(); $sorted = array(); $maps = array(); $excluded = $this->getExcludedLinkIds(); /* * Iterate through the included search terms and group them by mapping * table suffix. This ensures that we never have to do more than 16 * queries to get a batch. This may seem like a lot but it is rarely * anywhere near 16 because of the improved mapping algorithm. */ foreach ($this->includedTerms as $token => $ids) { // Get the mapping table suffix. $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); // Initialize the mapping group. if (!array_key_exists($suffix, $maps)) { $maps[$suffix] = array(); } // Add the terms to the mapping group. $maps[$suffix] = array_merge($maps[$suffix], $ids); } /* * When the query contains search terms we need to find and process the * results iteratively using a do-while loop. */ do { // Create a container for the fetched results. $results = array(); $more = false; /* * Iterate through the mapping groups and load the results from each * mapping table. */ foreach ($maps as $suffix => $ids) { // Create a storage key for this set. $setId = $this->getStoreId('getResultsData:' . serialize(array_values($ids)) . ':' . $start . ':' . $limit); // Use the cached data if possible. if ($this->retrieve($setId)) { $temp = $this->retrieve($setId); } // Load the data from the database. else { // Adjust the query to join on the appropriate mapping table. $query = clone $base; $query->join('INNER', $this->_db->quoteName('#__finder_links_terms' . $suffix) . ' AS m ON m.link_id = l.link_id') ->where('m.term_id IN (' . implode(',', $ids) . ')'); // Load the results from the database. $this->_db->setQuery($query, $start, $limit); $temp = $this->_db->loadObjectList('link_id'); // Store this set in cache. $this->store($setId, $temp); // The data is keyed by link_id to ease caching, we don't need it till later. $temp = array_values($temp); } // Set the more flag to true if any of the sets equal the limit. $more = count($temp) === $limit; // Merge the results. $results = array_merge($results, $temp); } // Check if there are any excluded terms to deal with. if (count($excluded)) { // Remove any results that match excluded terms. for ($i = 0, $c = count($results); $i < $c; $i++) { if (in_array($results[$i]->link_id, $excluded)) { unset($results[$i]); } } // Reset the array keys. $results = array_values($results); } /* * If we are ordering by relevance we have to add up the relevance * scores that are contained in the ordering field. */ if ($ordering === 'm.weight') { // Iterate through the set to extract the unique items. for ($i = 0, $c = count($results); $i < $c; $i++) { // Add the total weights for all included search terms. if (isset($sorted[$results[$i]->link_id])) { $sorted[$results[$i]->link_id] += (float) $results[$i]->ordering; } else { $sorted[$results[$i]->link_id] = (float) $results[$i]->ordering; } } } /* * If we are ordering by start date we have to add convert the * dates to unix timestamps. */ elseif ($ordering === 'l.start_date') { // Iterate through the set to extract the unique items. for ($i = 0, $c = count($results); $i < $c; $i++) { if (!isset($sorted[$results[$i]->link_id])) { $sorted[$results[$i]->link_id] = strtotime($results[$i]->ordering); } } } /* * If we are not ordering by relevance or date, we just have to add * the unique items to the set. */ else { // Iterate through the set to extract the unique items. for ($i = 0, $c = count($results); $i < $c; $i++) { if (!isset($sorted[$results[$i]->link_id])) { $sorted[$results[$i]->link_id] = $results[$i]->ordering; } } } // Sort the results. natcasesort($items); if ($direction === 'DESC') { $items = array_reverse($items, true); } /* * If the query contains just optional search terms and we have * enough items for the page, we can stop here. */ if (empty($this->requiredTerms)) { // If we need more items and they're available, make another pass. if ($more && count($sorted) < ($this->getState('list.start') + $this->getState('list.limit'))) { // Increment the batch starting point and continue. $start += $limit; continue; } // Push the results into cache. $this->store($store, $sorted); // Return the requested set. return array_slice($this->retrieve($store), (int) $this->getState('list.start'), (int) $this->getState('list.limit'), true); } /* * The query contains required search terms so we have to iterate * over the items and remove any items that do not match all of the * required search terms. This is one of the most expensive steps * because a required token could theoretically eliminate all of * current terms which means we would have to loop through all of * the possibilities. */ foreach ($this->requiredTerms as $token => $required) { // Create a storage key for this set. $setId = $this->getStoreId('getResultsData:required:' . serialize(array_values($required)) . ':' . $start . ':' . $limit); // Use the cached data if possible. if ($this->retrieve($setId)) { $reqTemp = $this->retrieve($setId); } // Check if the token was matched. elseif (empty($required)) { return null; } // Load the data from the database. else { // Setup containers in case we have to make multiple passes. $reqStart = 0; $reqTemp = array(); do { // Get the map table suffix. $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); // Adjust the query to join on the appropriate mapping table. $query = clone $base; $query->join('INNER', $this->_db->quoteName('#__finder_links_terms' . $suffix) . ' AS m ON m.link_id = l.link_id') ->where('m.term_id IN (' . implode(',', $required) . ')'); // Load the results from the database. $this->_db->setQuery($query, $reqStart, $limit); $temp = $this->_db->loadObjectList('link_id'); // Set the required token more flag to true if the set equal the limit. $reqMore = count($temp) === $limit; // Merge the matching set for this token. $reqTemp += $temp; // Increment the term offset. $reqStart += $limit; } while ($reqMore === true); // Store this set in cache. $this->store($setId, $reqTemp); } // Remove any items that do not match the required term. $sorted = array_intersect_key($sorted, $reqTemp); } // If we need more items and they're available, make another pass. if ($more && count($sorted) < ($this->getState('list.start') + $this->getState('list.limit'))) { // Increment the batch starting point. $start += $limit; // Merge the found items. $items = array_merge($items, $sorted); continue; } // Otherwise, end the loop. else { // Set the found items. $items = $sorted; $more = false; } // End do-while loop. } while ($more === true); // Push the results into cache. $this->store($store, $items); // Return the requested set. return array_slice($this->retrieve($store), (int) $this->getState('list.start'), (int) $this->getState('list.limit'), true); } /** * Method to get an array of link ids that match excluded terms. * * @return array An array of links ids. * * @since 2.5 * @throws Exception on database error. */ protected function getExcludedLinkIds() { // Check if the search query has excluded terms. if (empty($this->excludedTerms)) { return array(); } // Get the store id. $store = $this->getStoreId('getExcludedLinkIds', false); // Use the cached data if possible. if ($this->retrieve($store)) { return $this->retrieve($store); } // Initialize containers. $links = array(); $maps = array(); /* * Iterate through the excluded search terms and group them by mapping * table suffix. This ensures that we never have to do more than 16 * queries to get a batch. This may seem like a lot but it is rarely * anywhere near 16 because of the improved mapping algorithm. */ foreach ($this->excludedTerms as $token => $id) { // Get the mapping table suffix. $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); // Initialize the mapping group. if (!array_key_exists($suffix, $maps)) { $maps[$suffix] = array(); } // Add the terms to the mapping group. $maps[$suffix][] = (int) $id; } /* * Iterate through the mapping groups and load the excluded links ids * from each mapping table. */ // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); foreach ($maps as $suffix => $ids) { // Create the query to get the links ids. $query->clear() ->select('link_id') ->from($db->quoteName('#__finder_links_terms' . $suffix)) ->where($db->quoteName('term_id') . ' IN (' . implode(',', $ids) . ')') ->group($db->quoteName('link_id')); // Load the link ids from the database. $db->setQuery($query); $temp = $db->loadColumn(); // Merge the link ids. $links = array_merge($links, $temp); } // Sanitize the link ids. $links = array_unique($links); $links = ArrayHelper::toInteger($links); // Push the link ids into cache. $this->store($store, $links); return $links; } /** * Method to get a store id based on model the configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id An identifier string to generate the store id. [optional] * @param boolean $page True to store the data paged, false to store all data. [optional] * * @return string A store id. * * @since 2.5 */ protected function getStoreId($id = '', $page = true) { // Get the query object. $query = $this->getQuery(); // Add the search query state. $id .= ':' . $query->input; $id .= ':' . $query->language; $id .= ':' . $query->filter; $id .= ':' . serialize($query->filters); $id .= ':' . $query->date1; $id .= ':' . $query->date2; $id .= ':' . $query->when1; $id .= ':' . $query->when2; if ($page) { // Add the list state for page specific data. $id .= ':' . $this->getState('list.start'); $id .= ':' . $this->getState('list.limit'); $id .= ':' . $this->getState('list.ordering'); $id .= ':' . $this->getState('list.direction'); } return parent::getStoreId($id); } /** * Method to auto-populate the model state. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. [optional] * @param string $direction An optional direction. [optional] * * @return void * * @since 2.5 */ protected function populateState($ordering = null, $direction = null) { // Get the configuration options. $app = JFactory::getApplication(); $input = $app->input; $params = $app->getParams(); $user = JFactory::getUser(); $this->setState('filter.language', JLanguageMultilang::isEnabled()); // Setup the stemmer. if ($params->get('stem', 1) && $params->get('stemmer', 'porter_en')) { FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance($params->get('stemmer', 'porter_en')); } $request = $input->request; $options = array(); // Get the empty query setting. $options['empty'] = $params->get('allow_empty_query', 0); // Get the static taxonomy filters. $options['filter'] = $request->getInt('f', $params->get('f', '')); // Get the dynamic taxonomy filters. $options['filters'] = $request->get('t', $params->get('t', array()), '', 'array'); // Get the query string. $options['input'] = $request->getString('q', $params->get('q', '')); // Get the query language. $options['language'] = $request->getCmd('l', $params->get('l', '')); // Get the start date and start date modifier filters. $options['date1'] = $request->getString('d1', $params->get('d1', '')); $options['when1'] = $request->getString('w1', $params->get('w1', '')); // Get the end date and end date modifier filters. $options['date2'] = $request->getString('d2', $params->get('d2', '')); $options['when2'] = $request->getString('w2', $params->get('w2', '')); // Load the query object. $this->query = new FinderIndexerQuery($options); // Load the query token data. $this->excludedTerms = $this->query->getExcludedTermIds(); $this->includedTerms = $this->query->getIncludedTermIds(); $this->requiredTerms = $this->query->getRequiredTermIds(); // Load the list state. $this->setState('list.start', $input->get('limitstart', 0, 'uint')); $this->setState('list.limit', $input->get('limit', $app->get('list_limit', 20), 'uint')); /** * Load the sort ordering. * Currently this is 'hard' coded via menu item parameter but may not satisfy a users need. * More flexibility was way more user friendly. So we allow the user to pass a custom value * from the pool of fields that are indexed like the 'title' field. * Also, we allow this parameter to be passed in either case (lower/upper). */ $order = $input->getWord('filter_order', $params->get('sort_order', 'relevance')); $order = StringHelper::strtolower($order); switch ($order) { case 'date': $this->setState('list.ordering', 'l.start_date'); break; case 'price': $this->setState('list.ordering', 'l.list_price'); break; case ($order === 'relevance' && !empty($this->includedTerms)) : $this->setState('list.ordering', 'm.weight'); break; // Custom field that is indexed and might be required for ordering case 'title': $this->setState('list.ordering', 'l.title'); break; default: $this->setState('list.ordering', 'l.link_id'); break; } /** * Load the sort direction. * Currently this is 'hard' coded via menu item parameter but may not satisfy a users need. * More flexibility was way more user friendly. So we allow to be inverted. * Also, we allow this parameter to be passed in either case (lower/upper). */ $dirn = $input->getWord('filter_order_Dir', $params->get('sort_direction', 'desc')); $dirn = StringHelper::strtolower($dirn); switch ($dirn) { case 'asc': $this->setState('list.direction', 'ASC'); break; default: case 'desc': $this->setState('list.direction', 'DESC'); break; } // Set the match limit. $this->setState('match.limit', 1000); // Load the parameters. $this->setState('params', $params); // Load the user state. $this->setState('user.id', (int) $user->get('id')); $this->setState('user.groups', $user->getAuthorisedViewLevels()); } /** * Method to retrieve data from cache. * * @param string $id The cache store id. * @param boolean $persistent Flag to enable the use of external cache. [optional] * * @return mixed The cached data if found, null otherwise. * * @since 2.5 */ protected function retrieve($id, $persistent = true) { $data = null; // Use the internal cache if possible. if (isset($this->cache[$id])) { return $this->cache[$id]; } // Use the external cache if data is persistent. if ($persistent) { $data = JFactory::getCache($this->context, 'output')->get($id); $data = $data ? unserialize($data) : null; } // Store the data in internal cache. if ($data) { $this->cache[$id] = $data; } return $data; } /** * Method to store data in cache. * * @param string $id The cache store id. * @param mixed $data The data to cache. * @param boolean $persistent Flag to enable the use of external cache. [optional] * * @return boolean True on success, false on failure. * * @since 2.5 */ protected function store($id, $data, $persistent = true) { // Store the data in internal cache. $this->cache[$id] = $data; // Store the data in external cache if data is persistent. if ($persistent) { return JFactory::getCache($this->context, 'output')->store(serialize($data), $id); } return true; } } home/wuectly/www/libraries/joomla/github/package/search.php 0000604 00000006503 15245635560 0020117 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage GitHub * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * GitHub API Search class for the Joomla Platform. * * @documentation https://developer.github.com/v3/search * * @since 3.1.4 * @deprecated 4.0 Use the `joomla/github` package via Composer instead */ class JGithubPackageSearch extends JGithubPackage { /** * Search issues. * * @param string $owner The name of the owner of the repository. * @param string $repo The name of the repository. * @param string $state The state - open or closed. * @param string $keyword The search term. * * @throws UnexpectedValueException * * @since 3.3 (CMS) * * @return object */ public function issues($owner, $repo, $state, $keyword) { if (false == in_array($state, array('open', 'close'))) { throw new UnexpectedValueException('State must be either "open" or "closed"'); } // Build the request path. $path = '/legacy/issues/search/' . $owner . '/' . $repo . '/' . $state . '/' . $keyword; // Send the request. return $this->processResponse( $this->client->get($this->fetchUrl($path)) ); } /** * Search repositories. * * Find repositories by keyword. Note, this legacy method does not follow * the v3 pagination pattern. * This method returns up to 100 results per page and pages can be fetched * using the start_page parameter. * * @param string $keyword The search term. * @param string $language Filter results by language https://github.com/languages * @param integer $startPage Page number to fetch * * @since 3.3 (CMS) * * @return object */ public function repositories($keyword, $language = '', $startPage = 0) { // Build the request path. $path = '/legacy/repos/search/' . $keyword . '?'; $path .= ($language) ? '&language=' . $language : ''; $path .= ($startPage) ? '&start_page=' . $startPage : ''; // Send the request. return $this->processResponse( $this->client->get($this->fetchUrl($path)) ); } /** * Search users. * * Find users by keyword. * * @param string $keyword The search term. * @param integer $startPage Page number to fetch * * @since 3.3 (CMS) * * @return object */ public function users($keyword, $startPage = 0) { // Build the request path. $path = '/legacy/user/search/' . $keyword . '?'; $path .= ($startPage) ? '&start_page=' . $startPage : ''; // Send the request. return $this->processResponse( $this->client->get($this->fetchUrl($path)) ); } /** * Email search. * * This API call is added for compatibility reasons only. There’s no guarantee * that full email searches will always be available. The @ character in the * address must be left unencoded. Searches only against public email addresses * (as configured on the user’s GitHub profile). * * @param string $email The email address(es). * * @since 3.3 (CMS) * * @return object */ public function email($email) { // Build the request path. $path = '/legacy/user/email/' . $email; // Send the request. return $this->processResponse( $this->client->get($this->fetchUrl($path)) ); } } home/wuectly/www/libraries/joomla/twitter/search.php 0000604 00000013055 15245657524 0016750 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Twitter * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); /** * Twitter API Search class for the Joomla Platform. * * @since 3.1.4 * @deprecated 4.0 Use the `joomla/twitter` package via Composer instead */ class JTwittersearch extends JTwitterObject { /** * Method to get tweets that match a specified query. * * @param string $query Search query. Should be URL encoded. Queries will be limited by complexity. * @param string $callback If supplied, the response will use the JSONP format with a callback of the given name * @param string $geocode Returns tweets by users located within a given radius of the given latitude/longitude. The parameter value is * specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). * @param string $lang Restricts tweets to the given language, given by an ISO 639-1 code. * @param string $locale Specify the language of the query you are sending (only ja is currently effective). This is intended for * language-specific clients and the default should work in the majority of cases. * @param string $resultType Specifies what type of search results you would prefer to receive. The current default is "mixed." * @param integer $count The number of tweets to return per page, up to a maximum of 100. Defaults to 15. * @param string $until Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. * @param integer $sinceId Returns results with an ID greater than (that is, more recent than) the specified ID. * @param integer $maxId Returns results with an ID less than (that is, older than) or equal to the specified ID. * @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a * variety of metadata about the tweet in a discrete structure, including: urls, media and hashtags. * * @return array The decoded JSON response * * @since 3.1.4 */ public function search($query, $callback = null, $geocode = null, $lang = null, $locale = null, $resultType = null, $count = 15, $until = null, $sinceId = 0, $maxId = 0, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('search', 'tweets'); // Set the API path $path = '/search/tweets.json'; // Set query parameter. $data['q'] = rawurlencode($query); // Check if callback is specified. if ($callback) { $data['callback'] = $callback; } // Check if geocode is specified. if ($geocode) { $data['geocode'] = $geocode; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Check if locale is specified. if ($locale) { $data['locale'] = $locale; } // Check if result_type is specified. if ($resultType) { $data['result_type'] = $resultType; } // Check if count is specified. if ($count != 15) { $data['count'] = $count; } // Check if until is specified. if ($until) { $data['until'] = $until; } // Check if since_id is specified. if ($sinceId > 0) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId > 0) { $data['max_id'] = $maxId; } // Check if entities is specified. if (!is_null($entities)) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); } /** * Method to get the authenticated user's saved search queries. * * @return array The decoded JSON response * * @since 3.1.4 */ public function getSavedSearches() { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'list'); // Set the API path $path = '/saved_searches/list.json'; // Send the request. return $this->sendRequest($path); } /** * Method to get the information for the saved search represented by the given id. * * @param integer $id The ID of the saved search. * * @return array The decoded JSON response * * @since 3.1.4 */ public function getSavedSearchesById($id) { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'show/:id'); // Set the API path $path = '/saved_searches/show/' . $id . '.json'; // Send the request. return $this->sendRequest($path); } /** * Method to create a new saved search for the authenticated user. * * @param string $query The query of the search the user would like to save. * * @return array The decoded JSON response * * @since 3.1.4 */ public function createSavedSearch($query) { // Set the API path $path = '/saved_searches/create.json'; // Set POST request data $data['query'] = rawurlencode($query); // Send the request. return $this->sendRequest($path, 'POST', $data); } /** * Method to delete a saved search for the authenticating user. * * @param integer $id The ID of the saved search. * * @return array The decoded JSON response * * @since 3.1.4 */ public function deleteSavedSearch($id) { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'destroy/:id'); // Set the API path $path = '/saved_searches/destroy/' . $id . '.json'; // Send the request. return $this->sendRequest($path, 'POST'); } } home/wuectly/www/administrator/components/com_search/helpers/search.php 0000604 00000021534 15245664044 0022617 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_search * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\String\StringHelper; /** * Search component helper. * * @since 1.5 */ class SearchHelper { /** * Configure the Linkbar. * * @param string $vName The name of the active view. * * @return void * * @since 1.6 */ public static function addSubmenu($vName) { // Not required. } /** * Gets a list of the actions that can be performed. * * @return JObject * * @deprecated 3.2 Use JHelperContent::getActions() instead. */ public static function getActions() { // Log usage of deprecated function. try { JLog::add( sprintf('%s() is deprecated. Use JHelperContent::getActions() with new arguments order instead.', __METHOD__), JLog::WARNING, 'deprecated' ); } catch (RuntimeException $exception) { // Informational log only } // Get list of actions. return JHelperContent::getActions('com_search'); } /** * Sanitise search word. * * @param string &$searchword Search word to be sanitised. * @param string $searchphrase Either 'all', 'any' or 'exact'. * * @return boolean True if search word needs to be sanitised. */ public static function santiseSearchWord(&$searchword, $searchphrase) { $ignored = false; $lang = JFactory::getLanguage(); $tag = $lang->getTag(); $search_ignore = $lang->getIgnoredSearchWords(); // Deprecated in 1.6 use $lang->getIgnoredSearchWords instead. $ignoreFile = JLanguageHelper::getLanguagePath() . '/' . $tag . '/' . $tag . '.ignore.php'; if (file_exists($ignoreFile)) { include $ignoreFile; } // Check for words to ignore. $aterms = explode(' ', StringHelper::strtolower($searchword)); // First case is single ignored word. if (count($aterms) == 1 && in_array(StringHelper::strtolower($searchword), $search_ignore)) { $ignored = true; } // Filter out search terms that are too small. $lower_limit = $lang->getLowerLimitSearchWord(); foreach ($aterms as $aterm) { if (StringHelper::strlen($aterm) < $lower_limit) { $search_ignore[] = $aterm; } } // Next is to remove ignored words from type 'all' or 'any' (not exact) searches with multiple words. if (count($aterms) > 1 && $searchphrase != 'exact') { $pruned = array_diff($aterms, $search_ignore); $searchword = implode(' ', $pruned); } return $ignored; } /** * Does search word need to be limited? * * @param string &$searchword Search word to be checked. * * @return boolean True if search word should be limited; false otherwise. * * @since 1.5 */ public static function limitSearchWord(&$searchword) { $restriction = false; $lang = JFactory::getLanguage(); // Limit searchword to a maximum of characters. $upper_limit = $lang->getUpperLimitSearchWord(); if (StringHelper::strlen($searchword) > $upper_limit) { $searchword = StringHelper::substr($searchword, 0, $upper_limit - 1); $restriction = true; } // Searchword must contain a minimum of characters. if ($searchword && StringHelper::strlen($searchword) < $lang->getLowerLimitSearchWord()) { $searchword = ''; $restriction = true; } return $restriction; } /** * Logs a search term. * * @param string $searchTerm The term being searched. * * @return void * * @since 1.5 * @deprecated 4.0 Use \Joomla\CMS\Helper\SearchHelper::logSearch() instead. */ public static function logSearch($searchTerm) { try { JLog::add( sprintf('%s() is deprecated. Use \Joomla\CMS\Helper\SearchHelper::logSearch() instead.', __METHOD__), JLog::WARNING, 'deprecated' ); } catch (RuntimeException $exception) { // Informational log only } \Joomla\CMS\Helper\SearchHelper::logSearch($searchTerm, 'com_search'); } /** * Prepares results from search for display. * * @param string $text The source string. * @param string $searchword The searchword to select around. * * @return string * * @since 1.5 */ public static function prepareSearchContent($text, $searchword) { // Strips tags won't remove the actual jscript. $text = preg_replace("'<script[^>]*>.*?</script>'si", '', $text); $text = preg_replace('/{.+?}/', '', $text); // $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2', $text); // Replace line breaking tags with whitespace. $text = preg_replace("'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text); return self::_smartSubstr(strip_tags($text), $searchword); } /** * Checks an object for search terms (after stripping fields of HTML). * * @param object $object The object to check. * @param string $searchTerm Search words to check for. * @param array $fields List of object variables to check against. * * @return boolean True if searchTerm is in object, false otherwise. */ public static function checkNoHtml($object, $searchTerm, $fields) { $searchRegex = array( '#<script[^>]*>.*?</script>#si', '#<style[^>]*>.*?</style>#si', '#<!.*?(--|]])>#si', '#<[^>]*>#i' ); $terms = explode(' ', $searchTerm); if (empty($fields)) { return false; } foreach ($fields as $field) { if (!isset($object->$field)) { continue; } $text = self::remove_accents($object->$field); foreach ($searchRegex as $regex) { $text = preg_replace($regex, '', $text); } foreach ($terms as $term) { $term = self::remove_accents($term); if (StringHelper::stristr($text, $term) !== false) { return true; } } } return false; } /** * Transliterates given text to ASCII. * * @param string $str String to remove accents from. * * @return string * * @since 3.2 */ public static function remove_accents($str) { $str = JLanguageTransliterate::utf8_latin_to_ascii($str); // @TODO: remove other prefixes as well? return preg_replace("/[\"'^]([a-z])/ui", '\1', $str); } /** * Returns substring of characters around a searchword. * * @param string $text The source string. * @param integer $searchword Number of chars to return. * * @return string * * @since 1.5 */ public static function _smartSubstr($text, $searchword) { $lang = JFactory::getLanguage(); $length = $lang->getSearchDisplayedCharactersNumber(); $ltext = self::remove_accents($text); $textlen = StringHelper::strlen($ltext); $lsearchword = StringHelper::strtolower(self::remove_accents($searchword)); $wordfound = false; $pos = 0; $length = $length > $textlen ? $textlen : $length; while ($wordfound === false && $pos + $length < $textlen) { if (($wordpos = @StringHelper::strpos($ltext, ' ', $pos + $length)) !== false) { $chunk_size = $wordpos - $pos; } else { $chunk_size = $length; } $chunk = StringHelper::substr($ltext, $pos, $chunk_size); $wordfound = StringHelper::strpos(StringHelper::strtolower($chunk), $lsearchword); if ($wordfound === false) { $pos += $chunk_size + 1; } } if ($wordfound !== false) { // Check if original text is different length than searched text (changed by function self::remove_accents) // Displayed text only, adjust $chunk_size if ($pos === 0) { $iOriLen = StringHelper::strlen(StringHelper::substr($text, 0, $pos + $chunk_size)); $iModLen = StringHelper::strlen(self::remove_accents(StringHelper::substr($text, 0, $pos + $chunk_size))); $chunk_size += $iOriLen - $iModLen; } else { $iOriSkippedLen = StringHelper::strlen(StringHelper::substr($text, 0, $pos)); $iModSkippedLen = StringHelper::strlen(self::remove_accents(StringHelper::substr($text, 0, $pos))); // Adjust starting position $pos if ($iOriSkippedLen !== $iModSkippedLen) { $pos += $iOriSkippedLen - $iModSkippedLen; } $iOriReturnLen = StringHelper::strlen(StringHelper::substr($text, $pos, $chunk_size)); $iModReturnLen = StringHelper::strlen(self::remove_accents(StringHelper::substr($text, $pos, $chunk_size))); if ($iOriReturnLen !== $iModReturnLen) { $chunk_size += $iOriReturnLen - $iModReturnLen; } } $sPre = $pos > 0 ? '... ' : ''; $sPost = ($pos + $chunk_size) >= StringHelper::strlen($text) ? '' : ' ...'; return $sPre . StringHelper::substr($text, $pos, $chunk_size) . $sPost; } else { if (($mbtextlen = StringHelper::strlen($text)) < $length) { $length = $mbtextlen; } if (($wordpos = StringHelper::strpos($text, ' ', $length)) !== false) { return StringHelper::substr($text, 0, $wordpos) . ' ...'; } else { return StringHelper::substr($text, 0, $length); } } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка