Source for file search.php
Documentation is available at search.php
* @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Search component helper.
* @package Joomla.Administrator
* @param string The name of the active view.
* Gets a list of the actions that can be performed.
$assetName =
'com_search';
foreach ($actions as $action)
$result->set($action->name, $user->authorise($action->name, $assetName));
$search_ignore =
$lang->getIgnoredSearchWords();
// Deprecated in 1.6 use $lang->getIgnoredSearchWords instead
$ignoreFile =
$lang->getLanguagePath() .
'/' .
$tag .
'/' .
$tag .
'.ignore.php';
// Check for words to ignore
// First case is single ignored word
// Filter out search terms that are too small
$lower_limit =
$lang->getLowerLimitSearchWord();
foreach ($aterms as $aterm)
$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')
$searchword =
implode(' ', $pruned);
// Limit searchword to a maximum of characters
$upper_limit =
$lang->getUpperLimitSearchWord();
// Searchword must contain a minimum of characters
if ($searchword &&
JString::strlen($searchword) <
$lang->getLowerLimitSearchWord())
* @param string $search_term The term being searched
* @deprecated 4.0 Use JSearchHelper::logSearch() instead
public static function logSearch($search_term)
JLog::add(__METHOD__ .
'() is deprecated, use JSearchHelper::logSearch() instead.', JLog::WARNING, 'deprecated');
* Prepares results from search for display
* @param string $text The source string
* @param string $searchword The searchword to select around
// Strips tags won't remove the actual jscript
$text =
preg_replace("'<script[^>]*>.*?</script>'si", "", $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)
'#<script[^>]*>.*?</script>#si',
'#<style[^>]*>.*?</style>#si',
$terms =
explode(' ', $searchTerm);
foreach ($fields as $field)
if (!isset
($object->$field))
$text =
self::remove_accents($object->$field);
foreach ($searchRegex as $regex)
foreach ($terms as $term)
$term =
self::remove_accents($term);
* Transliterates given text to ASCII//TRANSLIT.
* Simulates glibc transliteration style even if libiconv is used by PHP
* @param string $str String to remove accents from
$str =
iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $str);
//TODO: remove other prefixes as well?
* returns substring of characters around a searchword
* @param string $text The source string
* @param integer $searchword Number of chars to return
$length =
$lang->getSearchDisplayedCharactersNumber();
$ltext =
self::remove_accents($text);
while ($wordfound ===
false &&
$pos <
$textlen)
if (($wordpos =
@JString::strpos($ltext, ' ', $pos +
$length)) !==
false)
$chunk_size =
$wordpos -
$pos;
if ($wordfound ===
false)
if ($wordfound !==
false)
return (($pos >
0) ?
'... ' :
'') .
JString::substr($text, $pos, $chunk_size) .
' ...';
if (($wordpos =
@JString::strpos($text, ' ', $length)) !==
false)
Documentation generated on Tue, 19 Nov 2013 15:12:44 +0100 by phpDocumentor 1.4.3