Browse Source

Merge remote-tracking branch 'upstream/7.x' into 7.x

pull/118/head
krisbulman 13 years ago
parent
commit
8bab516f69
  1. 2
      includes/datastream.inc
  2. 15
      includes/utilities.inc
  3. 22
      islandora.module

2
includes/datastream.inc

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

15
includes/utilities.inc

@ -31,3 +31,18 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2)
return $bytes . ' B'; 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;
}
}

22
islandora.module

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

Loading…
Cancel
Save