You are here

function _top_searches_valid_phrase in Top Searches 6

Same name and namespace in other branches
  1. 7 top_searches.module \_top_searches_valid_phrase()

Verify the keys contain at least one valid word

Return value

True on valid phrase, FALSE on non-valid

2 calls to _top_searches_valid_phrase()
top_searches_catch_search_keys in ./top_searches.module
top_searches_update_6001 in ./top_searches.install

File

./top_searches.module, line 103

Code

function _top_searches_valid_phrase($keys) {

  // Check for minimum search word size, according to the site wide search configuration:
  $min = variable_get('minimum_word_size', 3);
  $words = explode(' ', $keys);
  $pass = FALSE;
  foreach ($words as $word) {
    _search_index_truncate($word);

    // We need at least one word with minimal length, for the whole search phrase to be valid.
    if (drupal_strlen($word) >= $min) {
      $pass = TRUE;
      break;
    }
  }
  return $pass;
}