Browse Source

Changed some things with datastreams so redirect and managed work okay.

pull/118/merge
jonathangreen 13 years ago
parent
commit
fe5c54a390
  1. 4
      includes/datastream.inc
  2. 15
      includes/utilities.inc
  3. 26
      islandora.module

4
includes/datastream.inc

@ -24,7 +24,9 @@ function islandora_datastream_as_attachment($object_id, $dsid) {
return"";
}
header('Content-type: ' . $fedora_object[$dsid]->mimetype);
header('Content-length: ' . $fedora_object[$dsid]->size);
if($fedora_object[$dsid]->controlGroup == 'M' || $fedora_object[$dsid]->controlGroup == 'X') {
header('Content-length: ' . $fedora_object[$dsid]->size);
}
header("Cache-control: private");
$method = arg(5);
if (isset($method) && $method == 'download') {

15
includes/utilities.inc

@ -30,4 +30,19 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2)
} else {
return $bytes . ' B';
}
}
function islandora_control_group_to_human_readable($control_group) {
switch($control_group) {
case 'M':
return '<b>M</b>anaged';
case 'X':
return 'Inline <b>X</b>ML';
case 'R':
return '<b>R</b>edirect';
case 'E':
return '<b>E</b>xternally Referenced';
default:
return $control_group;
}
}

26
islandora.module

@ -109,7 +109,6 @@ function islandora_menu() {
);
$items['islandora/object/%/view'] = array(
'title' => 'View',
//'page callback' => 'islandora_view_object',
@ -144,7 +143,6 @@ function islandora_menu() {
'weight' => -10,
);
$items['islandora/object/%/manage/properties'] = array(
'title' => 'Properties',
'page callback' => 'drupal_get_form',
@ -617,13 +615,23 @@ function islandora_preprocess_islandora_default(&$variables) {
$pid = $islandora_object->id;
$id = $ds->id;
$label = $ds->label;
$download_path = 'islandora/object/' . $pid . '/datastream/' . $id . '/download';
if($ds->controlGroup != 'R') {
$download_path = 'islandora/object/' . $pid . '/datastream/' . $id . '/download';
}
else {
$download_path = $ds->url;
}
$datastreams[$id]['id'] = $id;
$datastreams[$id]['label'] = $label;
$datastreams[$id]['label_link'] = l($label, $download_path);
$datastreams[$id]['download_url'] = $download_path;
$datastreams[$id]['mimetype'] = $ds->mimetype;
$datastreams[$id]['size'] = islandora_convert_bytes_to_human_readable($ds->size);
if($ds->controlGroup == 'M' || $ds->controlGroup == 'X') {
$datastreams[$id]['size'] = islandora_convert_bytes_to_human_readable($ds->size);
}
else {
$datastreams[$id]['size'] = '-';
}
$datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d");
$datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id));
}
@ -679,9 +687,9 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
// $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id);
$header = array(
array('data' => t('ID')),
array('data' => t('Label')),
array('data' => t('Type')),
array('data' => t('Mime type')),
array('data' => t('Label')),
array('data' => t('Size')),
array('data' => t('Operations'), 'colspan' => '2'),
//array('data' => t('Delete')),
@ -690,11 +698,11 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
$rows = array();
foreach ($islandora_object as $ds) {
$rows[] = array(
array('class' => 'datastream-id', 'data' => l($ds->id, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')),
array('class' => 'datastream-control', 'data' => $ds->controlGroup),
array('class' => 'datastream-id', 'data' => $ds->id),
array('class' => 'datastream-label', 'data' => l($ds->label, $ds->controlGroup != 'R' ? $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view' : $ds->url)),
array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)),
array('class' => 'datastream-mime', 'data' => $ds->mimeType),
array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')),
array('class' => 'datastream-size', 'data' => islandora_convert_bytes_to_human_readable($ds->size)),
array('class' => 'datastream-size', 'data' => $ds->controlGroup == 'M' || $ds->controlGroup == 'X' ? islandora_convert_bytes_to_human_readable($ds->size) : '-'),
array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')),
array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')),
);

Loading…
Cancel
Save