You are here

mimedetect.install in MimeDetect 6

Same filename and directory in other branches
  1. 8 mimedetect.install
  2. 5 mimedetect.install
  3. 7 mimedetect.install

File

mimedetect.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function mimedetect_install() {
}

/**
 * Implementation of hook_uninstall().
 */
function mimedetect_uninstall() {
  variable_del('mimedetect_enable_file_binary');
  variable_del('mimedetect_file_binary');
}

/**
 * Implementation of hook_requirements().
 */
function mimedetect_requirements($phase) {
  $requirements = array();
  $t = get_t();
  $requirement = array(
    'title' => $t('Mime type detection'),
  );
  if (extension_loaded('fileinfo')) {
    $requirement['value'] = $t('PHP Fileinfo Extension');
    if (!($finfo = @finfo_open(FILEINFO_MIME, variable_get('mimedetect_magic', drupal_get_path('module', 'mimedetect') . '/magic')))) {
      $requirement['description'] = $t('Fileinfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.');
      $requirement['severity'] = REQUIREMENT_ERROR;
    }
  }
  else {
    if (variable_get('mimedetect_enable_file_binary', FALSE)) {
      $binary = variable_get('mimedetect_file_binary', '/usr/bin/file');
      $requirement['value'] = $t("UNIX 'file' Command");
      if (!is_executable($binary)) {
        if (!file_exists($binary)) {
          $requirement['description'] = $t("The file %path does not exist or is not readable by your webserver. ", array(
            '%path' => $binary,
          ));
        }
        else {
          $requirement['description'] = $t("The file %path is not executable by your webserver.", array(
            '%path' => $binary,
          ));
        }
        $requirement['severity'] = REQUIREMENT_ERROR;
      }
    }
    else {
      $requirement['value'] = $t('File Extension');
      $requirement['description'] = $t("MimeDetect is using the browser supplied filename for file extension lookups. It is strongly recommended that you install and configure the PHP Fileinfo Extension or the UNIX 'file' command to provide more accurate sever-side mime type detection.");
      $requirement['severity'] = REQUIREMENT_WARNING;
    }
  }
  return array(
    'mimedetect' => $requirement,
  );
}

Functions

Namesort descending Description
mimedetect_install Implementation of hook_install().
mimedetect_requirements Implementation of hook_requirements().
mimedetect_uninstall Implementation of hook_uninstall().