Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x

pull/120/merge
rwincewicz 13 years ago
parent
commit
aa0581cee7
  1. 6
      css/islandora.base.css
  2. 9
      css/islandora.theme.css
  3. 52
      includes/datastream.inc
  4. 58
      includes/object_properties.inc
  5. 48
      includes/utilities.inc
  6. 13
      islandora-object-edit.tpl.php
  7. 91
      islandora-object.tpl.php
  8. 112
      islandora.module
  9. 11
      islandora_basic_collection/admin/islandora_basic_collection.admin.inc
  10. 3
      islandora_basic_collection/css/islandora_basic_collection.admin.css
  11. 6
      islandora_basic_collection/css/islandora_basic_collection.theme.css
  12. 37
      islandora_basic_collection/islandora-basic-collection-grid.tpl.php
  13. 2
      islandora_basic_collection/islandora-basic-collection.tpl.php
  14. 49
      islandora_basic_collection/islandora_basic_collection.module
  15. 2
      islandora_basic_image/admin/islandora_basic_image.admin.inc
  16. 1
      islandora_basic_image/css/islandora_basic_image.theme.css
  17. 8
      islandora_basic_image/islandora-basic-image.tpl.php
  18. 4
      islandora_basic_image/islandora_basic_image.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;

52
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);
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"); header("Cache-control: private");
$method = arg(5); $method = arg(5);
if (isset($method) && $method == 'download') { if (isset($method) && $method == 'download') {
@ -34,6 +36,29 @@ function islandora_datastream_as_attachment($object_id, $dsid) {
exit(); exit();
} }
function islandora_get_datastream_parents($islandora_object) {
$parent_collections = array();
$repository = $islandora_object->repository;
$collections1 = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection');
$collections2 = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOf');
$collections = array_merge($collections1, $collections2);
foreach($collections as $collection) {
try {
$pid = $collection['object']['value'];
$object = $repository->getObject($collection['object']['value']);
$parent_collections[$pid] = array();
$parent_collections[$pid]['object'] = $object;
$parent_collections[$pid]['url'] = 'islandora/object/' . $object->id;
$parent_collections[$pid]['label'] = $object->label;
$parent_collections[$pid]['label_link'] = l($parent_collections[$pid]['label'], $parent_collections[$pid]['url']);
}
catch (RepositoryException $e) {}
}
return $parent_collections;
}
/** /**
* *
* @param array $arr * @param array $arr
@ -280,8 +305,8 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
$form['add_fieldset'] = array( $form['add_fieldset'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => 'Add a datastream', '#title' => 'Add a datastream',
'#collapsible' => TRUE, '#collapsible' => FALSE,
'#collapsed' => TRUE, '#collapsed' => FALSE,
); );
$form['add_fieldset']['add_datastream_label'] = array( $form['add_fieldset']['add_datastream_label'] = array(
'#value' => t('<br /><h3>Add Datastream:</h3>'), '#value' => t('<br /><h3>Add Datastream:</h3>'),
@ -339,3 +364,24 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
} }
return $form; return $form;
} }
function islandora_datastream_get_human_readable_size($ds) {
module_load_include('inc', 'islandora', 'includes/utilities');
// we return - if we don't have a size
if($ds->controlGroup == 'M' || $ds->controlGroup == 'X') {
return islandora_convert_bytes_to_human_readable($ds->size);
}
else {
return '-';
}
}
function islandora_datastream_get_url($ds, $type = 'download') {
if($ds->controlGroup == 'R') {
return $ds->url;
}
else {
return "islandora/object/{$ds->parent->id}/datastream/{$ds->id}/$type";
}
}

58
includes/object_properties.inc

@ -1,8 +1,17 @@
<?php <?php
function islandora_edit_properties_form_validate($form, &$form_state){ /**
* may want more validation here the only restrictions i see on
* the object label and owner is the foxml schema says they should be
* an xsd:string there maybe further restrictions such as length but they aren't
* defined in the schema.
* @param array $form
* @param array $form_state
* @return boolean
*/
function islandora_edit_properties_form_validate($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']); $islandora_object = islandora_get_object($form_state['values']['pid']);
if(!isset($islandora_object)){ if (!isset($islandora_object)) {
form_set_error('', t('Could not update properties object not found.')); form_set_error('', t('Could not update properties object not found.'));
return FALSE; return FALSE;
} }
@ -13,27 +22,34 @@ function islandora_edit_properties_form_validate($form, &$form_state){
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
*/ */
function islandora_edit_properties_form_submit($form, &$form_state){ function islandora_edit_properties_form_submit($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']); $islandora_object = islandora_get_object($form_state['values']['pid']);
$owner = $form_state['values']['object_owner']; $owner = $form_state['values']['object_owner'];
$state = $form_state['values']['object_state']; $state = $form_state['values']['object_state'];
$label = $form_state['values']['object_label']; $label = $form_state['values']['object_label'];
$submit = FALSE; if (isset($owner) && $owner != $islandora_object->owner) {
$params = array(); try {
if(isset($owner) && $owner != $islandora_object->owner){ $islandora_object->owner = $owner;
$params['ownerId'] = check_plain($owner); drupal_set_message(t('Successfully updated owner %s', array('%s' => $owner)));
$submit = TRUE; } catch (Exception $e) {
} form_set_error('object_owner',t('Error updating owner %s', array('%s'=> $e->getMessage())));
if(isset($state) && $state != $islandora_object->state){ }
$params['state'] = check_plain($state);
$submit = TRUE;
} }
if(isset($label) && $label != $islandora_object->label){ if (isset($state) && $state != $islandora_object->state) {
$params['label'] = check_plain($label); try {
$submit = TRUE; $islandora_object->state = $state;
drupal_set_message(t('Successfully updated state %s', array('%s' => $state)));
} catch (Exception $e) {
form_set_error('object_state',t('Error updating state %s', array('%s'=> $e->getMessage())));
}
} }
if($submit){ if (isset($label) && $label != $islandora_object->label) {
$islandora_object->modifyObject($params); try {
$islandora_object->label = $label;
drupal_set_message(t('Successfully updated label %s', array('%s' => check_plain($label))));
} catch (Exception $e) {
form_set_error(t('Error updating label %s', array('%s' => $e->getMessage())));
}
} }
} }
@ -45,10 +61,11 @@ function islandora_edit_properties_form_submit($form, &$form_state){
* an object id * an object id
* @return array * @return array
*/ */
function islandora_edit_properties_form ($form, &$form_state, $object_id){ function islandora_edit_properties_form($form, &$form_state, $object_id) {
$form = array(); $form = array();
$islandora_object = islandora_get_object($object_id); $islandora_object = islandora_get_object($object_id);
if(!isset($islandora_object)){ drupal_set_title($islandora_object->label);
if (!isset($islandora_object)) {
return NULL; return NULL;
} }
$form['pid'] = array( $form['pid'] = array(
@ -76,7 +93,7 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){
'#required' => TRUE, '#required' => TRUE,
'#description' => t('The items state one of active, inactive or deleted'), '#description' => t('The items state one of active, inactive or deleted'),
'#type' => 'select', '#type' => 'select',
'#options' => array ('A' => 'Active', 'I' => 'Inactive', 'D'=>'Deleted'), '#options' => array('A' => 'Active', 'I' => 'Inactive', 'D' => 'Deleted'),
); );
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
@ -84,4 +101,5 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){
); );
return $form; return $form;
} }
?> ?>

48
includes/utilities.inc

@ -0,0 +1,48 @@
<?php
/**
* Convert bytes to human readable format
*
* @param integer bytes Size in bytes to convert
* @return string
*/
function islandora_convert_bytes_to_human_readable($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';
}
}
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;
}
}

13
islandora-object-edit.tpl.php

@ -44,17 +44,8 @@
//dsm($object); //dsm($object);
drupal_set_title($islandora_object->label); drupal_set_title($islandora_object->label);
$islandora_datastreams = $variables['islandora_datastreams']; //print($islandora_object->label . ' ' . $islandora_object->id);
print($islandora_object->label . ' ' . $islandora_object->id);
print ('<h3>datastreams</h3>');
foreach ($islandora_datastreams as $dsid => $ds) {
print (l($ds['label'],$ds['view_url']));
print (' ' . l('download', $ds['download_url']));
print (' ' . l('delete', $ds['delete_url']));
print ('<br />');
} print ($variables['datastream_table']);
print (drupal_render($variables['add_datastream_form']));
print (l(t('Edit Metadata'),$variables['islandora_editmetadata_url']));
?> ?>

91
islandora-object.tpl.php

@ -27,15 +27,46 @@
* this is a template for objects that do not have a module to registered to build their display. * this is a template for objects that do not have a module to registered to build their display.
* *
* islandora_object is a fedora tuque Object * islandora_object is a fedora tuque Object
* $object->label * $object->label - The label for this object.
* $object->id * $object->id - The identifier of the object.
* $object->state - The state of this object.
* $object->createdDate - The date the object was ingested.
* $object->lastModifiedDate - The date teh object was last mofified.
*
* to get the contents of a datastream * to get the contents of a datastream
* $object['dsid']->content * $object['dsid']->content
*
* to test if a datastream exists isset($object['dsid'])
*
* to iterate over datastreams:
* foreach($object as $ds) {
* $ds->label, etc
* }
*
* each $ds in the above loop has the following properties:
* $ds->label - The label for this datastream.
* $ds->id - The identifier of the datastream.
* $ds->controlGroup - The control group of the datastream. This
* property is read-only. This will return one of: "X", "M", "R", or "E".
* $ds->versionable - This defines if the datastream will be versioned
* or not. This is boolean.
* $ds->state - The state of the datastream. This will be one
* of: "A", "I", "D".
* $ds->mimetype - The mimetype of the datastrem.
* $ds->format - The format of the datastream
* $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->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.
* *
* $dublin_core is a Dublin_Core object * $dublin_core is a Dublin_Core object
* which is an array of elements, such as dc.title * which is an array of elements, such as dc.title
* and each element has an array of values. dc.title can have none, one or many titles * and each element has an array of values. dc.title can have none, one or many titles
* this is the case for all dc elements. * this is the case for all dc elements.
*
*
* *
* we can get a list of datastreams by doing * we can get a list of datastreams by doing
* foreach ($object as $ds){ * foreach ($object as $ds){
@ -44,30 +75,7 @@
* *
*/ */
//dsm($object);
drupal_set_title($islandora_object->label); drupal_set_title($islandora_object->label);
// $dublin_core = $variables['islandora_dublin_core'];
// print($islandora_object->label . ' ' . $islandora_object->id);
// print ('<h3>datastreams</h3>');
// foreach ($islandora_object as $ds) {
// print $ds->label . '<br>';
// //do something
// }
// print('<h3>Dublin Core</h3>');
// foreach ($dublin_core as $element) {
// if (!empty($element)) {
// // print($element);
// foreach ($element as $key => $value) {
// foreach($value as $v){
// if(!empty($v)){
// print '<strong>'.($key).'</strong>: ';print($v).'<br />';
// }
// }
// }
// }
// }
?> ?>
<div class="islandora-object islandora"> <div class="islandora-object islandora">
<h2>Details</h2> <h2>Details</h2>
@ -87,7 +95,36 @@ 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; ?>
<dt>Collections</dt>
<dd>
<?php foreach($parent_collections as $key => $value): ?>
<div><?php print $value['label_link'] ?></div>
<?php endforeach; ?>
</dd>
</dl> </dl>
</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>

112
islandora.module

@ -108,16 +108,6 @@ function islandora_menu() {
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%/add'] = array(
'title' => 'Add to an object',
'file' => 'includes/datastream.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_add_datastream_form',2),
'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_ADD_DS)
);
$items['islandora/object/%/view'] = array( $items['islandora/object/%/view'] = array(
'title' => 'View', 'title' => 'View',
@ -146,9 +136,9 @@ function islandora_menu() {
$items['islandora/object/%/manage/datastreams'] = array( $items['islandora/object/%/manage/datastreams'] = array(
'title' => 'Datastreams', 'title' => 'Datastreams',
'page callback' => 'islandora_edit_object', //'page callback' => 'islandora_edit_object',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
'access arguments' => array(FEDORA_PURGE), 'access arguments' => array(FEDORA_PURGE),
'weight' => -10, 'weight' => -10,
); );
@ -157,13 +147,12 @@ function islandora_menu() {
'title' => 'Properties', 'title' => 'Properties',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'file' => 'includes/object_properties.inc', 'file' => 'includes/object_properties.inc',
'page arguments' => array('islandora_edit_properties_form',2), 'page arguments' => array('islandora_edit_properties_form', 2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_MODIFY_STATE), 'access arguments' => array(FEDORA_MODIFY_STATE),
'weight' => -5, 'weight' => -5,
); );
$items['islandora/object/%/delete'] = array( $items['islandora/object/%/delete'] = array(
'title' => 'Purge object', 'title' => 'Purge object',
'page callback' => 'islandora_purge_object', 'page callback' => 'islandora_purge_object',
@ -172,6 +161,26 @@ function islandora_menu() {
'access arguments' => array(FEDORA_PURGE), 'access arguments' => array(FEDORA_PURGE),
); );
$items['islandora/object/%/manage/datastreams/add'] = array(
'title' => 'Add a datastream',
'file' => 'includes/datastream.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_add_datastream_form', 2),
'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_ADD_DS)
);
// $items['islandora/object/%/add'] = array(
// 'title' => 'Add to an object',
// 'file' => 'includes/datastream.inc',
// 'page callback' => 'drupal_get_form',
// 'page arguments' => array('islandora_add_datastream_form',2),
// 'type' => MENU_NORMAL_ITEM,
// 'access arguments' => array(FEDORA_ADD_DS)
// );
$items['islandora/object/%/datastream/%'] = array( $items['islandora/object/%/datastream/%'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
@ -223,6 +232,23 @@ function islandora_admin_paths_alter(&$paths) {
$paths['*/manage*'] = TRUE; $paths['*/manage*'] = TRUE;
} }
/**
* Implements hook_menu_local_tasks_alter().
*/
function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) {
// Add action link 'islandora/object/%/manage/datastreams'.
if ($root_path == 'islandora/object/%/manage') {
$object_id = $router_item['page_arguments'][0];
$item = menu_get_item("islandora/object/$object_id/manage/datastreams/add");
if ($item['access']) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
}
/** /**
* determines whether we can see the object or not * determines whether we can see the object or not
* checks PID namespace permissions, and user permissions * checks PID namespace permissions, and user permissions
@ -353,7 +379,7 @@ function islandora_edit_object($object_id) {
function islandora_edit_properties($object_id) { function islandora_edit_properties($object_id) {
$object = islandora_get_object($object_id); $object = islandora_get_object($object_id);
if (isset($object)) { if (isset($object)) {
module_load_include('inc','islandora','includes/object_properties'); module_load_include('inc', 'islandora', 'includes/object_properties');
$form = drupal_get_form('islandora_edit_properties_form', $object); $form = drupal_get_form('islandora_edit_properties_form', $object);
drupal_set_title($object->label); drupal_set_title($object->label);
return drupal_render($form); return drupal_render($form);
@ -567,8 +593,31 @@ 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'];
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/datastream');
$variables['parent_collections'] = islandora_get_datastream_parents($islandora_object);
$datastreams = array();
foreach ($islandora_object as $ds) {
$pid = $islandora_object->id;
$id = $ds->id;
$label = $ds->label;
$download_path = islandora_datastream_get_url($ds, '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'] = islandora_datastream_get_human_readable_size($ds);
$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);
@ -615,13 +664,32 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
global $base_url; global $base_url;
$datastreams = array(); $datastreams = array();
$variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id;
module_load_include('inc','islandora','includes/datastream'); module_load_include('inc', 'islandora', 'includes/datastream');
$variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); module_load_include('inc', 'islandora', 'includes/utilities');
// $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('Size')),
array('data' => t('Operations'), 'colspan' => '2'),
//array('data' => t('Delete')),
);
$table_attributes = array('class' => array('manage-datastreams'));
$rows = array();
foreach ($islandora_object as $ds) { foreach ($islandora_object as $ds) {
$datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download'; $rows[] = array(
$datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view'; array('class' => 'datastream-id', 'data' => l($ds->id, islandora_datastream_get_url($ds, 'view'))),
$datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete'; array('class' => 'datastream-label', 'data' => $ds->label),
$datastreams['label'] = $ds->label; array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)),
$variables['islandora_datastreams'][$ds->id] = $datastreams; array('class' => 'datastream-mime', 'data' => $ds->mimeType),
array('class' => 'datastream-size', 'data' => islandora_datastream_get_human_readable_size($ds)),
array('class' => 'datastream-download', 'data' => l(t('download'), islandora_datastream_get_url($ds, 'download'))),
array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')),
);
} }
$caption = $islandora_object->label . ' - ' . $islandora_object->id;
$table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes);
$variables['datastream_table'] = theme_table($table);
} }

11
islandora_basic_collection/admin/islandora_basic_collection.admin.inc

@ -14,11 +14,18 @@ function islandora_basic_collection_admin() {
$form['islandora_basic_collection_use_for_default_tab'] = array( $form['islandora_basic_collection_use_for_default_tab'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Provide the view for the default tab'), '#title' => t('Provide the view for the default tab'),
'#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', 'TRUE'), '#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', TRUE),
'#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content
on a view tab you may have multiple modules configured to provide content for the default tab.'), on a view tab you may have multiple modules configured to provide content for the default tab.'),
'#weight' => -10 '#weight' => -10
); );
$form['islandora_basic_collection_page_size'] = array(
'#type' => 'textfield',
'#title' => t('The default number of objects to show for a collection'),
'#default_value' => variable_get('islandora_basic_collection_page_size', '10'),
'#description' => t('The default number of object to show in a collection view.'),
'#weight' => -10
);
return system_settings_form($form); return system_settings_form($form);
} }

3
islandora_basic_collection/css/islandora_basic_collection.admin.css

@ -4,6 +4,3 @@
Description: Description:
Purpose of the stylesheet follows. Purpose of the stylesheet follows.
*/ */

6
islandora_basic_collection/css/islandora_basic_collection.theme.css

@ -38,3 +38,9 @@ dl.islandora-basic-collection-object
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
/* to be moved to admin when it is added */
#islandora-collection-deletion-form table th.select-all,
#islandora-collection-migrate-form table th.select-all {
width: 20px;
}

37
islandora_basic_collection/islandora-basic-collection-grid.tpl.php

@ -0,0 +1,37 @@
<?php
/*
* islandora-basic-collection.tpl.php
*
*
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
?>
<?php drupal_set_title('grid_view'); ?>
<div class="islandora-basic-collection-wrapper">
<div class="islandora-basic-collection clearfix">
<?php print($variables['pager']); ?>
<?php foreach($associated_objects_array as $key => $value): ?>
<dl class="islandora-basic-collection-object <?php print $value['class']; ?>">
<dt class="islandora-basic-collection-thumb"><?php print $value['thumb_link']; ?></dt>
<dd class="islandora-basic-collection-caption"><?php print $value['title_link']; ?></dd>
</dl>
<?php endforeach; ?>
<?php print($variables['pager']); ?>
</div>
</div>

2
islandora_basic_collection/islandora-basic-collection.tpl.php

@ -25,11 +25,13 @@
<div class="islandora-basic-collection-wrapper"> <div class="islandora-basic-collection-wrapper">
<div class="islandora-basic-collection clearfix"> <div class="islandora-basic-collection clearfix">
<?php print($variables['pager']); ?>
<?php foreach($associated_objects_array as $key => $value): ?> <?php foreach($associated_objects_array as $key => $value): ?>
<dl class="islandora-basic-collection-object <?php print $value['class']; ?>"> <dl class="islandora-basic-collection-object <?php print $value['class']; ?>">
<dt class="islandora-basic-collection-thumb"><?php print $value['thumb_link']; ?></dt> <dt class="islandora-basic-collection-thumb"><?php print $value['thumb_link']; ?></dt>
<dd class="islandora-basic-collection-caption"><?php print $value['title_link']; ?></dd> <dd class="islandora-basic-collection-caption"><?php print $value['title_link']; ?></dd>
</dl> </dl>
<?php endforeach; ?> <?php endforeach; ?>
<?php print($variables['pager']); ?>
</div> </div>
</div> </div>

49
islandora_basic_collection/islandora_basic_collection.module

@ -176,6 +176,11 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) {
//an example template would be named islandora-basic-image--islandora-27.tpl.phps //an example template would be named islandora-basic-image--islandora-27.tpl.phps
'variables' => array('islandora_object' => NULL), 'variables' => array('islandora_object' => NULL),
), ),
'islandora_basic_collection_grid' => array(
'template' => 'islandora-basic-collection-grid',
'pattern' => 'islandora_basic_collection_grid__',
'variables' => array('islandora_object' => NULL),
),
'islandora_basic_collection_management_form_table' => array( 'islandora_basic_collection_management_form_table' => array(
'arguments' => array('element' => NULL), 'arguments' => array('element' => NULL),
'file' => 'includes/CollectionManagerTable.inc', 'file' => 'includes/CollectionManagerTable.inc',
@ -210,21 +215,35 @@ function islandora_basic_collection_islandora_get_types() {
* @return string * @return string
* themed html * themed html
*/ */
function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) { function islandora_basic_collection_islandora_view_object($object, $user) {
//global $user; //global $user;
$cmodel_list = islandora_basic_collection_islandora_get_types(); $cmodel_list = islandora_basic_collection_islandora_get_types();
$models = $object->models; $models = $object->models;
foreach ($object->models as $model) { foreach ($object->models as $model) {
if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
$output = theme('islandora_basic_collection', array('islandora_object' => $object)); $display = (empty($_GET['display'])) ? 'list' : $_GET['display'];
return array('' => $output); if($display == 'grid'){
$output = theme('islandora_basic_collection_grid', array('islandora_object' => $object));
} else {
$output = theme('islandora_basic_collection', array('islandora_object' => $object));
}
return array('Collection View' => $output);
} }
} }
return NULL; return NULL;
} }
/** /**
* * list view preprocess
* currently just calls normal view preprocess as variables are the same
* @param type $variables
*/
function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables){
islandora_basic_collection_preprocess_islandora_basic_collection($variables);
}
/**
*
* @global type $base_url * @global type $base_url
* @param array $variables * @param array $variables
* an array of variables that will be passed to the theme function * an array of variables that will be passed to the theme function
@ -242,7 +261,14 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error'); drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
} }
$variables['islandora_associated_objects'] = islandora_basic_collection_get_objects($islandora_object); $page_number = (empty($_GET['page'])) ? 0 : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize'];
$results = islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size);
$total_count = count($results);
pager_default_initialize($total_count, $page_size);
$pager = theme('pager', array('quantity' => $total_count));
$variables['pager'] = $pager;
$variables['islandora_dublin_core'] = $dc_object; $variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label; $variables['islandora_object_label'] = $islandora_object->label;
$variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id); $variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id);
@ -260,8 +286,11 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
} }
$associated_objects_array = array(); $associated_objects_array = array();
foreach ($variables['islandora_associated_objects'] as $key => $value) { $start = $page_size * ($page_number);
$pid = $variables['islandora_associated_objects'][$key]['object']['value']; $end = min($start + $page_size, $total_count);
for ($i = $start; $i < $end; $i++) {
$pid = $results[$i]['object']['value'];
$fc_object = islandora_basic_collection_get_object($pid); $fc_object = islandora_basic_collection_get_object($pid);
if (!isset($fc_object)) { if (!isset($fc_object)) {
continue; //null object so don't show in collection view; continue; //null object so don't show in collection view;
@ -276,7 +305,7 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
} }
$object_url = 'islandora/object/' . $pid; $object_url = 'islandora/object/' . $pid;
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>'; $thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
$title = $variables['islandora_associated_objects'][$key]['title']['value']; $title = $results[$i]['title']['value'];
$associated_objects_array[$pid]['pid'] = $pid; $associated_objects_array[$pid]['pid'] = $pid;
$associated_objects_array[$pid]['path'] = $object_url; $associated_objects_array[$pid]['path'] = $object_url;
$associated_objects_array[$pid]['title'] = $title; $associated_objects_array[$pid]['title'] = $title;
@ -307,7 +336,7 @@ function islandora_basic_collection_get_object($object_id) {
return $fedora_object; return $fedora_object;
} }
function islandora_basic_collection_get_objects($object) { function islandora_basic_collection_get_objects($object, $page_number = 1, $page_size = 5) {
$query = 'select $object $title $content from <#ri> $query = 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content and $object <fedora-model:hasModel> $content
@ -316,8 +345,6 @@ function islandora_basic_collection_get_objects($object) {
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title'; order by $title';
$page_number = (empty($_GET['page'])) ? '1' : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize'];
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number); $query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number);
drupal_alter('islandora_basic_collection_query', $query_array); drupal_alter('islandora_basic_collection_query', $query_array);

2
islandora_basic_image/admin/islandora_basic_image.admin.inc

@ -5,7 +5,7 @@ function islandora_basic_image_admin() {
$form['islandora_basic_image_use_for_default_tab'] = array( $form['islandora_basic_image_use_for_default_tab'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Provide the view for the default tab'), '#title' => t('Provide the view for the default tab'),
'#default_value' => variable_get('islandora_basic_image_use_for_default_tab', 'TRUE'), '#default_value' => variable_get('islandora_basic_image_use_for_default_tab', TRUE),
'#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content
on a view tab you may have multiple modules configured to provide content for the default tab.'), on a view tab you may have multiple modules configured to provide content for the default tab.'),
'#weight' => -10 '#weight' => -10

1
islandora_basic_image/css/islandora_basic_image.theme.css

@ -56,6 +56,7 @@ body.two-sidebars .islandora-basic-image-sidebar {
width: 60%; width: 60%;
padding: 0 20px 0 0; padding: 0 20px 0 0;
float: left; /* LTR */ float: left; /* LTR */
margin-top: 1em;
} }
body.no-sidebars .islandora-basic-image-sidebar { body.no-sidebars .islandora-basic-image-sidebar {

8
islandora_basic_image/islandora-basic-image.tpl.php

@ -31,6 +31,14 @@
<h1 class="title"><?php print $islandora_object_label; ?></h1> <h1 class="title"><?php print $islandora_object_label; ?></h1>
<h3><?php print $dc_array['dc:description']['label']; ?></h3> <h3><?php print $dc_array['dc:description']['label']; ?></h3>
<p><?php print $dc_array['dc:description']['value']; ?></p> <p><?php print $dc_array['dc:description']['value']; ?></p>
<div>
<h3>In Collections</h3>
<ul>
<?php foreach($parent_collections as $key => $value): ?>
<li><?php print $value['label_link'] ?></li>
<?php endforeach; ?>
</ul>
</div>
</div> </div>
<fieldset class="collapsible collapsed islandora-basic-image-metadata"> <fieldset class="collapsible collapsed islandora-basic-image-metadata">

4
islandora_basic_image/islandora_basic_image.module

@ -203,7 +203,10 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
drupal_add_js('misc/form.js'); drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js'); drupal_add_js('misc/collapse.js');
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
$repository = $islandora_object->repository;
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
module_load_include('inc', 'islandora', 'includes/datastream');
try { try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
$dc_object = Dublin_Core::import_from_xml_string($dc); $dc_object = Dublin_Core::import_from_xml_string($dc);
@ -214,6 +217,7 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
$variables['dc_array'] = $dc_object->as_formatted_array(); $variables['dc_array'] = $dc_object->as_formatted_array();
$variables['islandora_object_label'] = $islandora_object->label; $variables['islandora_object_label'] = $islandora_object->label;
$variables['theme_hook_suggestions'][] = 'islandora_basic_image__' . str_replace(':', '_', $islandora_object->id); $variables['theme_hook_suggestions'][] = 'islandora_basic_image__' . str_replace(':', '_', $islandora_object->id);
$variables['parent_collections'] = islandora_get_datastream_parents($islandora_object);
global $base_url; global $base_url;
if (isset($islandora_object['OBJ'])) { if (isset($islandora_object['OBJ'])) {
$full_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view'; $full_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';

Loading…
Cancel
Save