function _search_log_preprocess_search_form in Search Log 8
Same name and namespace in other branches
- 7 search_log.module \_search_log_preprocess_search_form()
Preprocess search form results before writing to DB.
4 calls to _search_log_preprocess_search_form()
- search_log_custom_search_blocks_form_submit in ./
search_log.module - Process custom search form to capture keys.
- search_log_search_block_form_submit in ./
search_log.module - Process block search form to capture keys.
- search_log_search_form_submit in ./
search_log.module - Process search form to capture keys.
- search_log_search_theme_form_submit in ./
search_log.module - Process theme search form to capture keys.
File
- ./
search_log.module, line 136 - This module holds functions of Search Log Module.
Code
function _search_log_preprocess_search_form($submitted, $keys, $module = NULL) {
$language = \Drupal::languageManager()
->getCurrentLanguage();
//@todo To be changed later on.
// if (!$module) {
// $info = search_get_default_module_info();
// $module = $info['module'];
// }
$modules = \Drupal::config('search_log.settings')
->get('search_log_modules_enabled');
if (!empty($modules) && !in_array($module, $modules, TRUE)) {
return;
}
// Custom Search content filter integration.
if (\Drupal::moduleHandler()
->moduleExists('custom_search')) {
$types = isset($submitted['custom_search_types']) ? $submitted['custom_search_types'] : array();
if (!is_array($types)) {
$types = array(
$types,
);
}
$types = array_map('_custom_search_filter_keys', array_filter($types));
if (in_array('all', $types)) {
// do nothing to keys or module.
}
elseif (in_array('user', $types)) {
$module = 'user';
}
else {
$keys .= ' type:' . implode(',', $types);
}
}
search_log($keys, $module, $language
->getName());
}