From 7b7a74170d8b3b457f57806c6781c527cfea50bd Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 17 Jan 2014 19:05:44 +0000 Subject: [PATCH] Add MIME type autocompletion to core. --- includes/mime_type.autocomplete.inc | 27 +++++++++++++++++++++++++++ islandora.module | 10 ++++++++++ 2 files changed, 37 insertions(+) create mode 100644 includes/mime_type.autocomplete.inc diff --git a/includes/mime_type.autocomplete.inc b/includes/mime_type.autocomplete.inc new file mode 100644 index 00000000..3ac31079 --- /dev/null +++ b/includes/mime_type.autocomplete.inc @@ -0,0 +1,27 @@ +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); +} diff --git a/islandora.module b/islandora.module index 8e480baa..99a5740b 100644 --- a/islandora.module +++ b/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',