You are here

function apachesolr_attachments_get_indexable_files in Apache Solr Attachments 6

Same name and namespace in other branches
  1. 6.2 apachesolr_attachments.admin.inc \apachesolr_attachments_get_indexable_files()

Return all non-excluded file attachments for a particular node

1 call to apachesolr_attachments_get_indexable_files()
apachesolr_attachments_add_documents in ./apachesolr_attachments.admin.inc
Callback for apachesolr_index_nodes().

File

./apachesolr_attachments.admin.inc, line 325
Provides a file attachment search implementation for use with the Apache Solr module

Code

function apachesolr_attachments_get_indexable_files($node) {
  $files = array();
  if (!empty($node->files)) {
    $files = $node->files;
  }
  $fields = apachesolr_attachments_get_cck_file_fields();
  foreach ($fields as $field) {
    if (!empty($node->{$field})) {
      $files = array_merge($files, $node->{$field});
    }
  }
  $file_list = array();
  foreach ($files as $file) {

    // Some are arrays others are objects, treat them all as objects
    $file = (object) $file;

    // Some filefield-enabled nodes show up with an emtpy file array.
    if (!empty($file->fid) && apachesolr_attachments_allowed_mime($file->filemime)) {
      if (isset($file->data['description']) && !isset($file->description)) {
        $file->description = $file->data['description'];
      }
      $file_list[$file->fid] = $file;
    }
  }
  return $file_list;
}