You are here

function apachesolr_attachments_allowed_mime in Apache Solr Attachments 7

Same name and namespace in other branches
  1. 6.3 apachesolr_attachments.index.inc \apachesolr_attachments_allowed_mime()
  2. 6 apachesolr_attachments.admin.inc \apachesolr_attachments_allowed_mime()
  3. 6.2 apachesolr_attachments.admin.inc \apachesolr_attachments_allowed_mime()

Checks if a file is of a MIME type that is to be excluded from the index.

The MIME types of excluded files are built and cached each time the file attachments settings form is saved.

Parameters

$filename: A string, the MIME type of the file.

Return value

Boolean, TRUE if the $filemime is allowed, otherwise FALSE.

2 calls to apachesolr_attachments_allowed_mime()
apachesolr_attachments_node_solr_document in ./apachesolr_attachments.module
Builds the file-specific information for a Solr document.
apachesolr_attachments_status_callback in ./apachesolr_attachments.module
Status callback for the files. Files should never be removed from the table. See apachesolr_attachments_apachesolr_exclude() for exclusion of items

File

./apachesolr_attachments.index.inc, line 20
Indexing-related functions.

Code

function apachesolr_attachments_allowed_mime($filemime) {
  $excluded = variable_get('apachesolr_attachments_excluded_mime', FALSE);
  if ($excluded === FALSE) {

    // Build the list of excluded MIME types.
    $excluded = array();
    $extensions = variable_get('apachesolr_attachments_excluded_extensions', FALSE);
    if ($extensions !== FALSE) {
      $extensions = explode(' ', $extensions);
    }
    else {
      $extensions = apachesolr_attachments_default_excluded();
    }
    foreach ($extensions as $ext) {
      $ext = trim($ext);
      if ($ext) {
        $mime = file_get_mimetype('dummy.' . $ext);
        $excluded[$mime] = 1;
      }
    }
    variable_set('apachesolr_attachments_excluded_mime', $excluded);
  }
  return empty($excluded[$filemime]);
}