diff --git a/css/islandora.theme.css b/css/islandora.theme.css index e299b9db..29f14e66 100644 --- a/css/islandora.theme.css +++ b/css/islandora.theme.css @@ -13,19 +13,24 @@ dl.islandora-object-tn { float: left; width: 20.8333%; padding: 0 10px 0 0; - margin: 0; + margin: 1.5em 0; } dl.islandora-object-fields { float: right; width:79.1666%; - border-top:3px solid #ddd; + border-top:0px solid #ddd; + margin: 1.5em 0; } .islandora-object-fields dt { font-weight: bold; } +.islandora-object-fields dt.first { + border-top:0; +} + .islandora-object-fields dt, .islandora-object-fields dd { padding:6px 2% 4px; diff --git a/islandora-object.tpl.php b/islandora-object.tpl.php index 6a6680d3..614d72b1 100644 --- a/islandora-object.tpl.php +++ b/islandora-object.tpl.php @@ -57,7 +57,7 @@ * $ds->size - The size of the datastream * $ds->checksum - The checksum of the datastream * $ds->checksumType - The type of checksum for the datastream. - * $ds->createdDate - The created date + * $ds->createdDate->format("Y-m-d") - The created date with an option to use a format of your choice * $ds->content - The content of the datastream * $ds->url - The URL. This is only valid for R and E datastreams. * @@ -118,25 +118,31 @@ drupal_set_title($islandora_object->label);
- + - - - - - - - - - -
- id; ?> - - label; ?> - - controlGroup; ?> - - mimetype; ?> -
+ + diff --git a/islandora.module b/islandora.module index 0c621c95..2970cbf2 100644 --- a/islandora.module +++ b/islandora.module @@ -595,6 +595,8 @@ function islandora_permission() { * @param array $variables */ function islandora_preprocess_islandora_default(&$variables) { + drupal_add_js('misc/form.js'); + drupal_add_js('misc/collapse.js'); $islandora_object = $variables['islandora_object']; $repository = $islandora_object->repository; module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); @@ -609,7 +611,22 @@ function islandora_preprocess_islandora_default(&$variables) { $variables['parent_collections'][$pid]['label'] = $object->label; $variables['parent_collections'][$pid]['url'] = url('islandora/object/' . $object->id); } - + $datastreams = array(); + foreach ($islandora_object as $ds) { + $pid = $islandora_object->id; + $id = $ds->id; + $label = $ds->label; + $download_path = 'islandora/object/' . $pid . '/datastream/' . $id . '/download'; + $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'] = bytesToSize($ds->size); + $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); + $datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); + } + $variables['datastreams'] = $datastreams; try { $dc = $islandora_object['DC']->content; //$dc_xml = simplexml_load_string($dc); @@ -626,6 +643,38 @@ function islandora_preprocess_islandora_default(&$variables) { } } +/** + * Convert bytes to human readable format + * + * @param integer bytes Size in bytes to convert + * @return string + */ +function bytesToSize($bytes, $precision = 2) +{ + $kilobyte = 1024; + $megabyte = $kilobyte * 1024; + $gigabyte = $megabyte * 1024; + $terabyte = $gigabyte * 1024; + + if (($bytes >= 0) && ($bytes < $kilobyte)) { + return $bytes . ' B'; + + } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { + return round($bytes / $kilobyte, $precision) . ' KB'; + + } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { + return round($bytes / $megabyte, $precision) . ' MB'; + + } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { + return round($bytes / $gigabyte, $precision) . ' GB'; + + } elseif ($bytes >= $terabyte) { + return round($bytes / $terabyte, $precision) . ' TB'; + } else { + return $bytes . ' B'; + } +} + /** * a helper function to get a connection and return an object * @global object $user