You are here

function _search_log_normalize_keys in Search Log 8

Same name and namespace in other branches
  1. 7 search_log.module \_search_log_normalize_keys()

Internal function to normalize keys.

1 call to _search_log_normalize_keys()
search_log in ./search_log.module
Store search keys, module, language and day.

File

./search_log.module, line 211
This module holds functions of Search Log Module.

Code

function _search_log_normalize_keys($keys) {
  $keys = preg_replace('/\\s+/', ' ', trim($keys));
  switch (\Drupal::config('search_log.settings')
    ->get('search_log_terms')) {
    case SEARCH_LOG_TERMS_LOWERCASE:
      $keys = str_replace(' or ', ' OR ', mb_strtolower($keys));
      break;
    case SEARCH_LOG_TERMS_UPPERCASE_FIRST:
      $keys = str_replace(' or ', ' OR ', Unicode::ucfirst($keys));
      break;
    case SEARCH_LOG_TERMS_UPPERCASE_WORDS:
      $keys = str_replace(' Or ', ' OR ', ucwords(mb_strtolower($keys)));
      break;
  }
  return $keys;
}