You are here

function facetapi_luceneapi_prefix_get in Facet API 6

Helper function to get the wildcard prefix.

Parameters

$text: A string containing the text prefix is being extracted from.

Return value

A string containing the prefix.

1 call to facetapi_luceneapi_prefix_get()
facetapi_luceneapi_wildcard_matches_get in contrib/facetapi_luceneapi/facetapi_luceneapi.cache.inc
Rewrites a wildcard query into primitive terms.

File

contrib/facetapi_luceneapi/facetapi_luceneapi.cache.inc, line 40
Term frequency cache functions.

Code

function facetapi_luceneapi_prefix_get($text) {
  $q_pos = strpos($text, '?');
  $a_pos = strpos($text, '*');
  if ($q_pos !== false) {
    if ($a_pos !== false) {
      return substr($text, 0, min($q_pos, $a_pos));
    }
    return substr($text, 0, $q_pos);
  }
  elseif ($a_pos !== false) {
    return substr($text, 0, $a_pos);
  }
  return $text;
}