function apachesolr_search_preprocess_apachesolr_search_snippets in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr_search.module \apachesolr_search_preprocess_apachesolr_search_snippets()
- 7 apachesolr_search.module \apachesolr_search_preprocess_apachesolr_search_snippets()
Pseudo preprocess function for theme_apachesolr_search_snippets().
1 call to apachesolr_search_preprocess_apachesolr_search_snippets()
- theme_apachesolr_search_snippets in ./
apachesolr_search.module - Theme the highlighted snippet text for a search entry.
File
- ./
apachesolr_search.module, line 1818 - Provides a content search implementation for node content for use with the Apache Solr search application.
Code
function apachesolr_search_preprocess_apachesolr_search_snippets($snippets) {
// Flatten the multidimensional array of snippets into a one-dimensional,
// ordered array.
$vars['flattened_snippets'] = array();
if (is_array($snippets)) {
// Prioritize the 'content' and 'teaser' keys if they are present.
foreach (array(
'content',
'teaser',
) as $key) {
if (isset($snippets[$key])) {
$vars['flattened_snippets'] = array_merge($vars['flattened_snippets'], is_array($snippets[$key]) ? $snippets[$key] : array(
$snippets[$key],
));
unset($snippets[$key]);
}
}
// Add any remaining snippets from the array. Each snippet can either be a
// string or an array itself; see apachesolr_search_process_response().
foreach ($snippets as $snippet) {
$vars['flattened_snippets'] = array_merge($vars['flattened_snippets'], is_array($snippet) ? $snippet : array(
$snippet,
));
}
}
// Ensure unique search snippets.
return array_unique($vars['flattened_snippets']);
}