function theme_apachesolr_search_snippets__file in Apache Solr Attachments 6.3
Same name and namespace in other branches
- 7 apachesolr_attachments.module \theme_apachesolr_search_snippets__file()
@todo Vastly improve this theming function
Parameters
type $vars:
Return value
type
File
- ./
apachesolr_attachments.module, line 554 - Provides a file attachment search implementation for use with the Apache Solr module
Code
function theme_apachesolr_search_snippets__file($vars) {
$doc = $vars['doc'];
$snippets = $vars['snippets'];
$parent_entity_links = array();
// Retrieve our parent entities. They have been saved as
// a small serialized entity
foreach ($doc->zm_parent_entity as $parent_entity_encoded) {
$parent_entity = (object) drupal_json_decode($parent_entity_encoded);
$parent_entity_uri = entity_uri($parent_entity->entity_type, $parent_entity);
$parent_entity_uri['options']['absolute'] = TRUE;
$parent_label = entity_label($parent_entity->entity_type, $parent_entity);
$parent_entity_links[] = l($parent_label, $parent_entity_uri['path'], $parent_entity_uri['options']);
}
if (module_exists('file')) {
$file_type = t('!icon @filemime', array(
'@filemime' => $doc->ss_filemime,
'!icon' => theme('file_icon', array(
'file' => (object) array(
'filemime' => $doc->ss_filemime,
),
)),
));
}
else {
$file_type = t('@filemime', array(
'@filemime' => $doc->ss_filemime,
));
}
return implode(' ... ', $snippets) . '<span>' . $file_type . ' <em>attached to:</em>' . implode(', ', $parent_entity_links) . '</span>';
}