Browse Source

Merge pull request #117 from krisbulman/7.x

basic object update.
pull/118/head
Jonathan Green 13 years ago
parent
commit
3434ff09ea
  1. 6
      css/islandora.base.css
  2. 9
      css/islandora.theme.css
  3. 46
      islandora-object.tpl.php
  4. 51
      islandora.module

6
css/islandora.base.css

@ -32,14 +32,14 @@ dl.islandora-inline-metadata {
.islandora-inline-metadata dt { .islandora-inline-metadata dt {
margin-right: -1px; margin-right: -1px;
width: 15.625%; width: 20.625%;
font-weight: normal;
font-weight: bold; font-weight: bold;
padding-right: 0; padding-right: 0;
word-wrap: normal;
} }
.islandora-inline-metadata dd { .islandora-inline-metadata dd {
width: 84.375%; width: 79.375%;
padding-left: 40px; padding-left: 40px;
} }

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;

46
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.
* *
@ -118,25 +118,31 @@ drupal_set_title($islandora_object->label);
<dd class="<?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>"> <dd class="<?php print $value['class']; ?><?php print $row_field == 0 ? ' first' : ''; ?>">
<?php print $value['value']; ?> <?php print $value['value']; ?>
</dd> </dd>
<?php $row_field++; ?> <?php $row_field++; ?>
<?php endforeach; ?> <?php endforeach; ?>
</dl> </dl>
<table>
<?php foreach($islandora_object as $ds): ?>
<tr>
<td>
<?php print $ds->id; ?>
</td>
<td>
<?php print $ds->label; ?>
</td>
<td>
<?php print $ds->controlGroup; ?>
</td>
<td>
<?php print $ds->mimetype; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div> </div>
<fieldset class="collapsible collapsed" style="display: block; clear:both">
<legend><span class="fieldset-legend">File Details</span></legend>
<div class="fieldset-wrapper">
<table>
<tr>
<th>ID</th>
<th>Label</th>
<th>Size</th>
<th>Mimetype</th>
<th>Created</th>
</tr>
<?php foreach($datastreams as $key => $value): ?>
<tr>
<td><?php print $value['id']; ?></td>
<td><?php print $value['label_link']; ?></td>
<td><?php print $value['size']; ?></td>
<td><?php print $value['mimetype']; ?></td>
<td><?php print $value['created_date']; ?></td>
</tr>
<?php endforeach; ?>
</table>
</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