Browse Source

Merge pull request #502 from MorganDawe/7.x.cwrcps-9

7.x.cwrcps 9
pull/508/head
Nick Ruest 11 years ago
parent
commit
d619fdb6bb
  1. 32
      includes/datastream.version.inc
  2. 2
      includes/mime_detect.inc

32
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,13 +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();
if (isset($extensions[$datastream->id])) {
foreach ($extensions[$datastream->id]['mime'] as $key => $value) {
$str = $mime_detect->getExtension($value);
array_push($ext, $str);
}
}
$comma = count($ext) > 1 ? "," : "";
$ext = array(implode($comma, $ext));
$upload_size = min((int) ini_get('post_max_size'), (int) ini_get('upload_max_filesize'));

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