Browse Source

Updated the mimedetect and added a helper function to process dsids that are not in an objects content model, such as user added.

pull/502/head
MorganDawe 11 years ago
parent
commit
9c50193483
  1. 39
      includes/datastream.version.inc
  2. 2
      includes/mime_detect.inc

39
includes/datastream.version.inc

@ -231,6 +231,34 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo
$form_state['redirect'] = "islandora/object/{$islandora_object->id}/datastream/{$datastream_to_revert->id}/version";
}
/**
* Process available dsids, mime and extensions for a given object.
*
* @param AbstractObject $object
* The FedoraObject to process available extensions
*
* @return array()
* An associative array, merged from calls to
* islandora_get_datastreams_requirements_from_content_models()
* and an objects dsid's.
*/
function islandora_get_object_extensions(AbstractObject $object) {
$extensions = islandora_get_datastreams_requirements_from_models($object->models);
foreach($object as $datastream){
// Could be a datastream not associated in a content model,
// such as user added.
if (!isset($extensions[$datastream->id])) {
// Add the extensions manually.
$extensions[$datastream->id] = array(
'id' => $datastream->id,
'optional' => TRUE,
'mime' => array($datastream->mimeType),
);
}
}
return $extensions;
}
/**
* The admin replace datastream form.
*
@ -252,12 +280,15 @@ function islandora_datastream_version_replace_form($form, &$form_state, Abstract
$form_state['object_id'] = $object->id;
$form_state['dsid'] = $datastream->id;
$form_state['object'] = $object;
$extensions = islandora_get_datastreams_requirements_from_models($object->models);
$extensions = islandora_get_object_extensions($object);
$mime_detect = new MimeDetect();
$ext = array();
foreach ($extensions[$datastream->id]['mime'] as $key => $value) {
$str = $mime_detect->getExtension($value);
array_push($ext, $str);
if (isset($extensions[$datastream->id])) {
foreach ($extensions[$datastream->id]['mime'] as $key => $value) {
dsm($value, "getting value for");
$str = $mime_detect->getExtension($value);
array_push($ext, $str);
}
}
$comma = count($ext) > 1 ? "," : "";
$ext = array(implode($comma, $ext));

2
includes/mime_detect.inc

@ -144,7 +144,7 @@ class MimeDetect {
"ief" => "image/ief",
"jpeg" => "image/jpeg",
"jpe" => "image/jpeg",
"jpg" => "image/jpeg",
"jpg" => "image/jpg",
"jp2" => "image/jp2",
"png" => "image/png",
"tiff" => "image/tiff",

Loading…
Cancel
Save