Source for file query.php
Documentation is available at query.php
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Query HTML behavior class for Finder.
* Method to get the explained (human-readable) search query.
* @param FinderIndexerQuery $query A FinderIndexerQuery object to explain.
* @return mixed String if there is data to explain, null otherwise.
public static function explained(FinderIndexerQuery $query)
// Process the required tokens.
foreach ($query->included as $token)
if ($token->required &&
(!isset
($token->derived) ||
$token->derived ==
false))
$parts[] =
'<span class="query-required">' .
JText::sprintf('COM_FINDER_QUERY_TOKEN_REQUIRED', $token->term) .
'</span>';
// Process the optional tokens.
foreach ($query->included as $token)
if (!$token->required &&
(!isset
($token->derived) ||
$token->derived ==
false))
$parts[] =
'<span class="query-optional">' .
JText::sprintf('COM_FINDER_QUERY_TOKEN_OPTIONAL', $token->term) .
'</span>';
// Process the excluded tokens.
foreach ($query->excluded as $token)
if (!isset
($token->derived) ||
$token->derived ==
false)
$parts[] =
'<span class="query-excluded">' .
JText::sprintf('COM_FINDER_QUERY_TOKEN_EXCLUDED', $token->term) .
'</span>';
// Process the start date.
$parts[] =
'<span class="query-start-date">' .
JText::sprintf('COM_FINDER_QUERY_START_DATE', $query->when1, $date) .
'</span>';
$parts[] =
'<span class="query-end-date">' .
JText::sprintf('COM_FINDER_QUERY_END_DATE', $query->when2, $date) .
'</span>';
// Process the taxonomy filters.
if (!empty($query->filters))
// Get the filters in the request.
// Process the taxonomy branches.
foreach ($query->filters as $branch =>
$nodes)
// Process the taxonomy nodes.
foreach ($nodes as $title =>
$id)
// Translate the title for Types
// Don't include the node if it is not in the request.
// Add the node to the explanation.
$parts[] =
'<span class="query-taxonomy">'
// Build the interpreted query.
* Method to get the suggested search query.
* @param FinderIndexerQuery $query A FinderIndexerQuery object.
* @return mixed String if there is a suggestion, false otherwise.
public static function suggested(FinderIndexerQuery $query)
// Check if the query input is empty.
if (empty($query->input))
// Check if there were any ignored or included keywords.
if (count($query->ignored) ||
count($query->included))
$suggested =
$query->input;
// Replace the ignored keyword suggestions.
if (isset
($token->suggestion))
$suggested =
str_replace($token->term, $token->suggestion, $suggested);
// Replace the included keyword suggestions.
if (isset
($token->suggestion))
$suggested =
str_replace($token->term, $token->suggestion, $suggested);
// Check if we made any changes.
if ($suggested ==
$query->input)
Documentation generated on Tue, 19 Nov 2013 15:11:29 +0100 by phpDocumentor 1.4.3