Browse Source

Add MIME type autocompletion to core.

pull/447/head
Jordan Dukart 11 years ago
parent
commit
7b7a74170d
  1. 27
      includes/mime_type.autocomplete.inc
  2. 10
      islandora.module

27
includes/mime_type.autocomplete.inc

@ -0,0 +1,27 @@
<?php
/**
* @file
* Autocomplete functionality for MIME types in Islandora.
*/
/**
* Autocomplete the MIME type name.
*
* @param string $string
* A search string.
*
* @return string
* The rendered JSON results.
*/
function islandora_mime_type_autocomplete($string) {
module_load_include('inc', 'islandora', 'includes/mime_detect');
$mime_detect = new MimeDetect();
$mime_types = $mime_detect->getMimeTypes();
$output = array();
foreach ($mime_types as $mime_type) {
if (preg_match("/{$string}/i", $mime_type) !== 0) {
$output[$mime_type] = $mime_type;
}
}
return drupal_json_output($output);
}

10
islandora.module

@ -62,6 +62,7 @@ define('ISLANDORA_DERVIATIVE_CREATION_HOOK', 'islandora_derivative');
// Autocomplete paths.
define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models');
define('ISLANDORA_MIME_TYPES_AUTOCOMPLETE', 'islandora/autocomplete/mime-types');
/**
* @deprecated Constants.
@ -358,6 +359,15 @@ function islandora_menu() {
'access arguments' => array('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items[ISLANDORA_MIME_TYPES_AUTOCOMPLETE] = array(
'title' => 'Autocomplete callback',
'description' => 'Autocomplete MIME Types.',
'file' => 'includes/mime_type.autocomplete.inc',
'page callback' => 'islandora_mime_type_autocomplete',
'page arguments' => array(3),
'access arguments' => array('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items['admin/islandora/restore/prep'] = array(
'description' => 'Restore or permanantly remove objects with Deleted status',
'title' => 'Manage Deleted Objects',

Loading…
Cancel
Save