Browse Source

basic object update. added items to datastreams array, added fieldset for file details, added table with datastream details to fieldset

pull/117/head
krisbulman 13 years ago
parent
commit
949c221c79
  1. 9
      css/islandora.theme.css
  2. 34
      islandora-object.tpl.php
  3. 51
      islandora.module

9
css/islandora.theme.css

@ -13,19 +13,24 @@ dl.islandora-object-tn {
float: left; float: left;
width: 20.8333%; width: 20.8333%;
padding: 0 10px 0 0; padding: 0 10px 0 0;
margin: 0; margin: 1.5em 0;
} }
dl.islandora-object-fields { dl.islandora-object-fields {
float: right; float: right;
width:79.1666%; width:79.1666%;
border-top:3px solid #ddd; border-top:0px solid #ddd;
margin: 1.5em 0;
} }
.islandora-object-fields dt { .islandora-object-fields dt {
font-weight: bold; font-weight: bold;
} }
.islandora-object-fields dt.first {
border-top:0;
}
.islandora-object-fields dt, .islandora-object-fields dt,
.islandora-object-fields dd { .islandora-object-fields dd {
padding:6px 2% 4px; padding:6px 2% 4px;

34
islandora-object.tpl.php

@ -57,7 +57,7 @@
* $ds->size - The size of the datastream * $ds->size - The size of the datastream
* $ds->checksum - The checksum of the datastream * $ds->checksum - The checksum of the datastream
* $ds->checksumType - The type of checksum for 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->content - The content of the datastream
* $ds->url - The URL. This is only valid for R and E datastreams. * $ds->url - The URL. This is only valid for R and E datastreams.
* *
@ -121,22 +121,28 @@ drupal_set_title($islandora_object->label);
<?php $row_field++; ?> <?php $row_field++; ?>
<?php endforeach; ?> <?php endforeach; ?>
</dl> </dl>
</div>
<fieldset class="collapsible collapsed" style="display: block; clear:both">
<legend><span class="fieldset-legend">File Details</span></legend>
<div class="fieldset-wrapper">
<table> <table>
<?php foreach($islandora_object as $ds): ?>
<tr> <tr>
<td> <th>ID</th>
<?php print $ds->id; ?> <th>Label</th>
</td> <th>Size</th>
<td> <th>Mimetype</th>
<?php print $ds->label; ?> <th>Created</th>
</td> </tr>
<td> <?php foreach($datastreams as $key => $value): ?>
<?php print $ds->controlGroup; ?> <tr>
</td> <td><?php print $value['id']; ?></td>
<td> <td><?php print $value['label_link']; ?></td>
<?php print $ds->mimetype; ?> <td><?php print $value['size']; ?></td>
</td> <td><?php print $value['mimetype']; ?></td>
<td><?php print $value['created_date']; ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
</div> </div>
</fieldset>

51
islandora.module

@ -595,6 +595,8 @@ function islandora_permission() {
* @param array $variables * @param array $variables
*/ */
function islandora_preprocess_islandora_default(&$variables) { function islandora_preprocess_islandora_default(&$variables) {
drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
$repository = $islandora_object->repository; $repository = $islandora_object->repository;
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); 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]['label'] = $object->label;
$variables['parent_collections'][$pid]['url'] = url('islandora/object/' . $object->id); $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 { try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc); //$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 * a helper function to get a connection and return an object
* @global object $user * @global object $user

Loading…
Cancel
Save