Browse Source

fixed conflict in islandora.api

pull/125/merge
Paul Pound 13 years ago
parent
commit
1e90c5caec
  1. 7
      admin/islandora.admin.inc
  2. 6
      includes/breadcrumb.inc
  3. 165
      includes/datastream.inc
  4. 13
      includes/ingest-menu.inc
  5. 4
      includes/islandora.ingest.inc
  6. 2
      includes/mime.detect.inc
  7. 19
      includes/object_properties.inc
  8. 160
      includes/purge.form.inc
  9. 2
      includes/tuque.inc
  10. 4
      islandora.api.php
  11. 438
      islandora.module
  12. 17
      islandora_basic_collection/admin/islandora_basic_collection.admin.inc
  13. 4
      islandora_basic_collection/includes/CollectionPolicy.inc
  14. 17
      islandora_basic_collection/includes/change_content_models.inc
  15. 28
      islandora_basic_collection/includes/child_collection.inc
  16. 61
      islandora_basic_collection/includes/collection_management.inc
  17. 16
      islandora_basic_collection/includes/collection_manager_table.inc
  18. 28
      islandora_basic_collection/includes/delete_collection.inc
  19. 36
      islandora_basic_collection/includes/manage_policies.inc
  20. 14
      islandora_basic_collection/includes/move_collection.inc
  21. 10
      islandora_basic_collection/islandora_basic_collection.install
  22. 69
      islandora_basic_collection/islandora_basic_collection.module
  23. 6
      islandora_basic_collection/theme/islandora_basic_collection.theme.inc
  24. 4
      islandora_basic_image/includes/image.process.inc
  25. 9
      islandora_basic_image/islandora_basic_image.install
  26. 28
      islandora_basic_image/islandora_basic_image.module
  27. 0
      theme/islandora-object-edit.tpl.php
  28. 0
      theme/islandora-object.tpl.php
  29. 91
      theme/islandora.theme.inc

7
admin/islandora.admin.inc

@ -7,9 +7,9 @@
*/
function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/tuque');
if (!RestConnection::exists()) {
if (!IslandoraTuque::exists()) {
$message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque')));
drupal_set_message(check_plain($message));
return;
@ -24,8 +24,7 @@ function islandora_repository_admin($form, &$form_state) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
}
module_load_include('inc', 'islandora', 'RestConnection');
$connection = new RestConnection(NULL, $url);
$connection = new IslandoraTuque(NULL, $url);
try {
$info = $connection->api->a->describeRepository();
$connected = TRUE;

6
includes/Breadcrumbs.inc → includes/breadcrumb.inc

@ -1,11 +1,9 @@
<?php
function islandora_get_breadcrumbs($pid) {
module_load_include('inc', 'islandora', 'RestConnection');
function islandora_get_breadcrumbs($object) {
$breadcrumbs = array();
$connection = new RestConnection();
islandora_get_breadcrumbs_recursive($pid, $breadcrumbs, $connection->repository);
islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository);
if(isset($breadcrumbs[0])) {
unset($breadcrumbs[0]);

165
includes/datastream.inc

@ -13,33 +13,22 @@ define('DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
* @return stream
* prints datastream to browser
*/
function islandora_datastream_as_attachment($object_id, $dsid) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
// if the object exists but the datastream doesn't
if(!isset($fedora_object[$dsid])) {
return drupal_not_found();
}
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("Cache-control: private");
$method = arg(5);
if (isset($method) && $method == 'download') {
header("Content-Disposition: attachment; filename=\"" . $fedora_object[$dsid]->label);
}
print($fedora_object[$dsid]->content);
exit();
} catch (Exception $e) {
function islandora_view_datastream($object, $dsid, $method = 'view') {
// if the object exists but the datastream doesn't
if(!isset($object[$dsid])) {
return drupal_not_found();
}
header('Content-type: ' . $object[$dsid]->mimetype);
if($object[$dsid]->controlGroup == 'M' || $object[$dsid]->controlGroup == 'X') {
header('Content-length: ' . $object[$dsid]->size);
}
if ($method == 'download') {
header("Content-Disposition: attachment; filename=\"" . $object[$dsid]->label);
}
print($object[$dsid]->content);
exit();
}
function islandora_datastream_get_parents($islandora_object) {
@ -94,26 +83,19 @@ function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) {
* @param string $object_id
* @return string|array
*/
function islandora_get_unused_dsids($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s ', array('%s' => $object_id)), 'error');
return;
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not create add datastream form for %s'), array('%s' => $object_id));
return;
}
$models = $fedora_object->models;
function islandora_get_unused_dsids($object) {
$defined_dsids = array();
if(!$object) {
return $defined_dsids;
}
$models = $object->models;
if (isset($models)) {
foreach ($models as $model) {
try {
$model_object = new FedoraObject($model, $restConnection->repository);
$model_object = $object->repository->getObject($model);
if (isset($model_object[DS_COMP_STREAM])) {
$dscomposite_stream = $model_object[DS_COMP_STREAM]->content;
islandora_get_defined_dsids_array($defined_dsids, $dscomposite_stream);
@ -138,8 +120,8 @@ function islandora_get_unused_dsids($object_id) {
* @return array
* a form ready to be rendered with a call to Drupal render
*/
function islandora_get_add_datastream_form($object_id, &$form_state) {
$unused_dsids = islandora_get_unused_dsids($object_id); //$defined_dsids;
function islandora_get_add_datastream_form($object, &$form_state) {
$unused_dsids = islandora_get_unused_dsids($object);
$form = array();
$form['add_fieldset'] = array(
'#type' => 'fieldset',
@ -154,7 +136,7 @@ function islandora_get_add_datastream_form($object_id, &$form_state) {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$object_id"
'#value' => "$object->id"
);
$form['add_fieldset']['stream_label'] = array(
@ -172,7 +154,7 @@ function islandora_get_add_datastream_form($object_id, &$form_state) {
// '#required'=>'TRUE',
'#description' => t('The file to upload.')
);
$form['#redirect'] = "islandora/object/$object_id/";
$form['#redirect'] = "islandora/object/$object->id/";
$form['add_fieldset']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add Datastream')
@ -216,14 +198,13 @@ function islandora_get_add_datastream_form($object_id, &$form_state) {
*/
function islandora_add_datastream_form_submit($form, &$form_state) {
global $base_url;
module_load_include('inc', 'islandora', 'RestConnection');
if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') {
$form_state['rebuild'] = TRUE;
return;
}
module_load_include('inc', 'islandora', 'includes/MimeClass');
$mimetype = new MimeClass();
module_load_include('inc', 'islandora', 'includes/mime.detect');
$mimetype = new MimeDetect();
$file = $form_state['values']['add-stream-file-location'];
$file = drupal_realpath($file);
@ -235,8 +216,7 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
$controlGroup = "M";
try {
$restConnection = new RestConnection();
$fedora_object = $restConnection->repository->getObject($object_id);
$fedora_object = islandora_object_load($object_id);
$ds = $fedora_object->constructDatastream($dsid, $controlGroup);
$ds->label = $ds_label;
$ds->mimetype = $dformat;
@ -260,9 +240,8 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
* @return boolean
*/
function islandora_add_datastream_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/MimeClass');
module_load_include('inc', 'islandora', 'RestConnection');
$mimetype = new MimeClass();
module_load_include('inc', 'islandora', 'includes/mime.detect');
$mimetype = new MimeDetect();
if ($form_state['clicked_button']['#value'] == 'OK') {
$form_state['rebuild'] = TRUE;
return;
@ -287,16 +266,16 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
}
$object_id = $form_state['values']['pid'];
$restConnection = new RestConnection();
$fedora_object = $restConnection->repository->getObject($object_id);
$fedora_object = islandora_object_load($object_id);
if(isset($fedora_object[$dsid])) {
form_set_error('', t('Data stream ID already exists in object.'));
return FALSE;
}
$mimetype = new MimeClass();
$unused_dsids = islandora_get_unused_dsids($form_state['values']['pid']);
$mimetype = new MimeDetect();
$object = islandora_object_load($form_state['values']['pid']);
$unused_dsids = islandora_get_unused_dsids($object);
if(isset($unused_dsids[$dsid])) {
$types_allowed = $unused_dsids[$dsid];
$arr = array();
@ -329,8 +308,8 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
* @return array
* a form ready to be rendered with a call to Drupal render
*/
function islandora_add_datastream_form($form, &$form_state, $object_id) {
$unused_dsids = islandora_get_unused_dsids($object_id); //$defined_dsids;
function islandora_add_datastream_form($form, &$form_state, $object) {
$unused_dsids = islandora_get_unused_dsids($object); //$defined_dsids;
$form = array();
$form['add_fieldset'] = array(
'#type' => 'fieldset',
@ -345,7 +324,7 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$object_id"
'#value' => "$object->id"
);
$form['add_fieldset']['stream_label'] = array(
@ -363,13 +342,13 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
// '#required'=>'TRUE',
'#description' => t('The file to upload.')
);
$form['#redirect'] = "islandora/object/$object_id/";
$form['#redirect'] = "islandora/object/$object->id/";
$form['add_fieldset']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add Datastream')
);
$unused_dsids = islandora_get_unused_dsids($object_id);
$unused_dsids = islandora_get_unused_dsids($object);
$dsidsForForm = '';
$i = 0;
foreach ($unused_dsids as $key => $value) {
@ -385,13 +364,13 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
'#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: <b>' . $dsidsForForm . '</b>.'),
'#type' => 'textfield',
'#weight' => -1,
'#autocomplete_path' => "islandora/object/$object_id/manage/datastreams/add/autocomplete",
'#autocomplete_path' => "islandora/object/$object->id/manage/datastreams/add/autocomplete",
);
return $form;
}
function islandora_datastream_autocomplete_callback($object_id, $string = '') {
$dsids = islandora_get_unused_dsids($object_id);
function islandora_datastream_autocomplete_callback($object, $string = '') {
$dsids = islandora_get_unused_dsids($object);
$output = array();
foreach($dsids as $id => $ds) {
if(trim($string) == '') {
@ -428,6 +407,21 @@ function islandora_datastream_get_url($ds, $type = 'download') {
}
}
function islandora_datastream_get_delete_link($ds) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $ds->parent->models);
if(in_array($ds->id, $datastreams)) {
return '';
}
else {
return l(t('delete'), 'islandora/object/' . $ds->parent->id . '/datastream/' . $ds->id . '/delete');
}
}
function islandora_islandora_undeletable_datastreams($models) {
return array('DC');
}
function islandora_datastream_edit_get_link($object, $ds_id) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
if (count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT)) {
@ -438,34 +432,23 @@ function islandora_datastream_edit_get_link($object, $ds_id) {
}
}
function islandora_edit_datastream($object_id, $ds_id) {
global $user;
try {
module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection($user);
$object = new FedoraObject($object_id, $restConnection->repository);
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
$edit_count = count($edit_registry);
if ($edit_count == 0) {
// No edit implementations.
drupal_set_message(t('There are no edit methods specified for this datastream.'));
drupal_goto('islandora/object/' . $object->id . '/manage/datastreams');
}
elseif ($edit_count == 1) {
// One registry implementation, go there
drupal_goto($edit_registry[0]['url']);
}
else {
// Multiple edit routes registered
return islandora_edit_datastream_registry_render($edit_registry);
}
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora edit method for %s ', array('%s' => $object_id)), 'error');
return;
function islandora_edit_datastream($object, $ds_id) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
$edit_count = count($edit_registry);
if ($edit_count == 0) {
// No edit implementations.
drupal_set_message(t('There are no edit methods specified for this datastream.'));
drupal_goto('islandora/object/' . $object->id . '/manage/datastreams');
}
elseif ($edit_count == 1) {
// One registry implementation, go there
drupal_goto($edit_registry[0]['url']);
}
else {
// Multiple edit routes registered
return islandora_edit_datastream_registry_render($edit_registry);
}
}
//@TODO: theme / preprocess

13
includes/ingest-menu.inc

@ -10,15 +10,18 @@
* @TODO: validate?: pid, registry return
* @param string $pid
*/
function islandora_ingest_callback($collection_pid) {
$ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_pid);
function islandora_ingest_callback($collection_object) {
if(!$collection_object) {
return drupal_not_found();
}
$ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_object);
$registry_count = count($ingest_registry);
if ($registry_count == 0) {
// No ingest implementations.
drupal_set_message(t('There are no ingest methods specified for this collection.'));
drupal_goto('islandora/object/' . $collection_pid);
drupal_set_message(t('There are no ingest methods specified for @name.', array('@name', $collection_object->label)));
drupal_goto('islandora/object/' . $collection_object->id);
}
elseif ($registry_count == 1) {
// One registry implementation, go there

4
includes/islandora.ingest.inc

@ -8,9 +8,9 @@ function islandora_ingest_get_information(AbstractFedoraObject $collection_objec
}
function islandora_ingest_get_object($content_models, $collection_pid, $relationship, $namespace) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/tuque');
global $user;
$connection = new RestConnection($user);
$connection = new IslandoraTuque($user);
$object = $connection->repository->constructObject($namespace);
foreach($content_models as $content_model) {
$object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']);

2
includes/MimeClass.inc → includes/mime.detect.inc

@ -22,7 +22,7 @@
*
*/
class MimeClass {
class MimeDetect {
protected $protectedMimeTypes = array(
/*

19
includes/object_properties.inc

@ -10,7 +10,7 @@
* @return boolean
*/
function islandora_edit_properties_form_validate($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']);
$islandora_object = islandora_object_load($form_state['values']['pid']);
if (!isset($islandora_object)) {
form_set_error('', t('Could not update properties object not found.'));
return FALSE;
@ -23,7 +23,7 @@ function islandora_edit_properties_form_validate($form, &$form_state) {
* @param array $form_state
*/
function islandora_edit_properties_form_submit($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']);
$islandora_object = islandora_object_load($form_state['values']['pid']);
$owner = $form_state['values']['object_owner'];
$state = $form_state['values']['object_state'];
$label = $form_state['values']['object_label'];
@ -66,35 +66,34 @@ function islandora_edit_properties_form_delete($form, &$form_state) {
* an object id
* @return array
*/
function islandora_edit_properties_form($form, &$form_state, $object_id) {
function islandora_edit_properties_form($form, &$form_state, $object) {
$form = array();
$islandora_object = islandora_get_object($object_id);
drupal_set_title($islandora_object->label);
if (!isset($islandora_object)) {
if (!isset($object)) {
return NULL;
}
drupal_set_title($object->label);
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $object_id,
'#value' => $object->id,
);
$form['object_label'] = array(
'#title' => t('Item Label'),
'#default_value' => $islandora_object->label,
'#default_value' => $object->label,
'#required' => 'TRUE',
'#description' => t('A Human readable label'),
'#type' => 'textfield'
);
$form['object_owner'] = array(
'#title' => t('Owner'),
'#default_value' => $islandora_object->owner,
'#default_value' => $object->owner,
'#required' => FALSE,
'#description' => t('The owner id'),
'#type' => 'textfield',
);
$form['object_state'] = array(
'#title' => t('State'),
'#default_value' => $islandora_object->state,
'#default_value' => $object->state,
'#required' => TRUE,
'#description' => t('The items state one of active, inactive or deleted'),
'#type' => 'select',

160
includes/purge.form.inc

@ -0,0 +1,160 @@
<?php
/**
* Gives the option of deleting or purging and object.
*
* The default behaviour is to purge the object to reduce maintenance.
* If a solution pack wants to change this behaviour and have the object set to deleted then
* it can respond to the 'islandora_pre_purge_object' hook with an array containing the pair
* 'delete' => TRUE.
* Once the object has been deleted/purged then a second call lets the solution packs know that
* the object has been dealt with. In this call the object id and content models are sent out so
* that the solution packs can act on this news. There is no guarantee that the object still exists
* and so the object object isn't sent.
*
* @param string $object_id
* ID of the object
* @return type
*/
function islandora_purge_object_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$collection = $form_state['values']['col'];
if (!$object_id) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
$object = islandora_object_load($object_id);
if (!$object) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$content_models = $object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $object); //notify modules of pending deletion
if (isset($arr['delete']) && $arr['delete']) {
try {
$object->delete();
} catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
else {
try {
$object->repository->purgeObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
drupal_goto($collection);
}
function islandora_purge_object($form, &$form_state, $object) {
module_load_include('inc', 'islandora', 'includes/datastream');
$parent = islandora_datastream_get_parents($object);
$key = array_keys($parent);
if (count($key) > 0) {
$redirect = "islandora/object/$key[0]";
}
else {
$redirect = "islandora";
}
$form['pid'] = array('#type' => 'value', '#value' => $object->id);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $object->label)),
"islandora/object/$object->id",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
function islandora_purge_datastream($form, &$form_state, $object, $datastream_id) {
module_load_include('inc', 'islandora', 'includes/datastream');
$datastream = $object->getDatastream($datastream_id);
$redirect = "islandora/object/$object->id";
$form['pid'] = array('#type' => 'value', '#value' => $object->id);
$form['dsid'] = array('#type' => 'value', '#value' => $datastream_id);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)),
"islandora/object/$object->id",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
/**
* Gives the option of purging or deleting a datastream.
*
* The default behaviour is to purge the datastream but this can be overridden using the
* 'islandora_pre_purge_datastream' hook. The returned array can include a 'block' => TRUE
* pair which will prevent the datastream from being deleted if it particularly needed for
* a certain function. Returning 'delete' => TRUE will cause the datastream to be put into
* a deleted state.
*
* @param string $object_id
* ID of the object
* @param string $datastream_id
* ID of the datastream
*
*/
function islandora_purge_datastream_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$datastream_id = $form_state['values']['dsid'];
if (!isset($datastream_id)) {
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
return;
}
$object = islandora_object_load($object_id);
if (!isset($object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
//notify modules of pending deletion so we can update rels etc
$arr = module_invoke_all('islandora_pre_purge_datastream', $object[$datastream_id]);
if (isset($arr['block']) && $arr['block']) {
drupal_set_message(t('Purging of the %d datastream was blocked', array('%d' => $datastream_id)), 'warning');
return;
}
if (isset($arr['delete']) && $arr['delete']) {
try {
$object[$datastream_id]->state = 'D';
} catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object->id, '%e' => $e)), 'error');
return;
}
}
else {
try {
$object->purgeDatastream($datastream_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return;
}
}
//notify modules post deletion
module_invoke_all('islandora_post_purge_datastream', $object, $datastream_id);
drupal_set_message(t('%d datastream sucessfully purged from Islandora object %o', array('%d' => $datastream_id, '%o' => $object->label)));
drupal_goto('islandora/object/' . $object->id);
}

2
RestConnection.inc → includes/tuque.inc

@ -11,7 +11,7 @@ require_once 'sites/all/libraries/tuque/RepositoryException.php';
require_once 'sites/all/libraries/tuque/Repository.php';
require_once 'sites/all/libraries/tuque/FedoraRelationships.php';
class RestConnection {
class IslandoraTuque {
/**
* Connection to the repository

4
islandora.api.php

@ -25,7 +25,7 @@ function hook_islandora_datastream_edit($object, $dsid){}
* array('name' => t('Ingest Route Name'), 'url' => 'ingest_route/url', 'weight' => 0),
* );
*/
function hook_islandora_ingest_registry($collection_pid) {}
function hook_islandora_ingest_registry($collection_object) {}
/**
@ -41,4 +41,4 @@ function hook_islandora_object_alter ($fedora_object){}
* @param type $arr
* an arr of rendered views
*/
function hook_islandora_display_alter ($arr){}
function hook_islandora_display_alter ($arr){}

438
islandora.module

@ -59,13 +59,13 @@ function islandora_menu() {
'weight' => -1,
);
$items['islandora/ingest/%'] = array(
'title' => 'Ingest object',
$items['islandora/object/%islandora_object/manage/ingest'] = array(
'title' => 'Add an object',
'page callback' => 'islandora_ingest_callback',
'page arguments' => array(2),
'file' => 'includes/ingest-menu.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_access_callback',
'type' => MENU_LOCAL_ACTION,
'access callback' => 'islandora_ingest_access_callback',
'access arguments' => array(2, FEDORA_INGEST),
);
@ -76,7 +76,7 @@ function islandora_menu() {
'access arguments' => array(FEDORA_VIEW),
);
$items['islandora/object/%'] = array(
$items['islandora/object/%islandora_object'] = array(
'title' => 'Repository',
'page callback' => 'islandora_view_object',
'page arguments' => array(2),
@ -86,25 +86,19 @@ function islandora_menu() {
);
$items['islandora/object/%/view'] = array(
$items['islandora/object/%islandora_object/view'] = array(
'title' => 'View',
'page arguments' => array(2),
'type' => MENU_DEFAULT_LOCAL_TASK,
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
'weight' => -10
'weight' => -1,
);
$items['islandora/object/%/view/default'] = array(
$items['islandora/object/%islandora_object/view/default'] = array(
'title' => 'View',
'page callback' => 'islandora_view_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
'weight' => -10,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
);
$items['islandora/object/%/manage'] = array(
$items['islandora/object/%islandora_object/manage'] = array(
'title' => 'Manage',
'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
@ -113,17 +107,13 @@ function islandora_menu() {
'access arguments' => array(2, FEDORA_MODIFY_STATE),
);
$items['islandora/object/%/manage/datastreams'] = array(
$items['islandora/object/%islandora_object/manage/datastreams'] = array(
'title' => 'Datastreams',
//'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
'type' => MENU_DEFAULT_LOCAL_TASK,
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_PURGE),
'weight' => -10,
);
$items['islandora/object/%/manage/properties'] = array(
$items['islandora/object/%islandora_object/manage/properties'] = array(
'title' => 'Properties',
'page callback' => 'drupal_get_form',
'file' => 'includes/object_properties.inc',
@ -134,8 +124,9 @@ function islandora_menu() {
'weight' => -5,
);
$items['islandora/object/%/delete'] = array(
$items['islandora/object/%islandora_object/delete'] = array(
'title' => 'Delete object',
'file' => 'includes/purge.form.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_purge_object', 2),
'type' => MENU_CALLBACK,
@ -143,17 +134,17 @@ function islandora_menu() {
'access arguments' => array(2, FEDORA_PURGE),
);
$items['islandora/object/%/manage/datastreams/add'] = array(
$items['islandora/object/%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,
'type' => MENU_LOCAL_ACTION,
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_ADD_DS)
);
$items['islandora/object/%/manage/datastreams/add/autocomplete'] = array(
$items['islandora/object/%islandora_object/manage/datastreams/add/autocomplete'] = array(
'file' => 'includes/datastream.inc',
'page callback' => 'islandora_datastream_autocomplete_callback',
'page arguments' => array(2),
@ -162,9 +153,9 @@ function islandora_menu() {
'access arguments' => array(2, FEDORA_ADD_DS)
);
$items['islandora/object/%/datastream/%'] = array(
$items['islandora/object/%islandora_object/datastream/%'] = array(
'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment',
'page callback' => 'islandora_view_datastream',
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
@ -172,27 +163,22 @@ function islandora_menu() {
'access arguments' => array(2, FEDORA_VIEW),
);
$items['islandora/object/%/datastream/%/view'] = array(
$items['islandora/object/%islandora_object/datastream/%/view'] = array(
'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment',
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['islandora/object/%/datastream/%/download'] = array(
$items['islandora/object/%islandora_object/datastream/%/download'] = array(
'title' => 'Download datastream',
'page callback' => 'islandora_datastream_as_attachment',
'page arguments' => array(2, 4),
'page callback' => 'islandora_view_datastream',
'page arguments' => array(2, 4, 5),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
);
$items['islandora/object/%/datastream/%/edit'] = array(
$items['islandora/object/%islandora_object/datastream/%/edit'] = array(
'title' => 'Edit datastream',
'page callback' => 'islandora_edit_datastream',
'page arguments' => array(2, 4),
@ -202,10 +188,11 @@ function islandora_menu() {
'access arguments' => array(2, FEDORA_METADATA_EDIT),
);
$items['islandora/object/%/datastream/%/delete'] = array(
$items['islandora/object/%islandora_object/datastream/%/delete'] = array(
'title' => 'Purge data stream',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_purge_datastream', 2, 4),
'file' => 'includes/purge.form.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_PURGE),
@ -214,26 +201,10 @@ function islandora_menu() {
return $items;
}
function islandora_admin_paths_alter(&$paths) {
function islandora_admin_paths() {
$paths = array();
$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,
);
}
}
return $paths;
}
/**
@ -258,103 +229,12 @@ function islandora_access_callback($pid = NULL, $perm = NULL) {
else {
$pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon)
$allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$namespace_access = in_array($pid_namespace, $allowed_namespaces);
}
return ($namespace_access && user_access($perm));
}
/**
* Gives the option of deleting or purging and object.
*
* The default behaviour is to purge the object to reduce maintenance.
* If a solution pack wants to change this behaviour and have the object set to deleted then
* it can respond to the 'islandora_pre_purge_object' hook with an array containing the pair
* 'delete' => TRUE.
* Once the object has been deleted/purged then a second call lets the solution packs know that
* the object has been dealt with. In this call the object id and content models are sent out so
* that the solution packs can act on this news. There is no guarantee that the object still exists
* and so the object object isn't sent.
*
* @param string $object_id
* ID of the object
* @return type
*/
function islandora_purge_object_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$collection = $form_state['values']['col'];
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
if (!isset($object_id)) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$content_models = $fedora_object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion
if (isset($arr['delete']) && $arr['delete']) {
try {
$fedora_object->delete();
} catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
else {
try {
$restConnection->repository->purgeObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
drupal_goto($collection);
}
function islandora_purge_object($form, &$form_state, $pid) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/datastream');
$connection = new RestConnection();
$object = $connection->repository->getObject($pid);
$parent = islandora_datastream_get_parents($object);
$key = array_keys($parent);
if (count($key) > 0) {
$redirect = "islandora/object/$key[0]";
}
else {
$redirect = "islandora";
}
// Always provide entity id in the same form key as in the entity edit form.
$form['pid'] = array('#type' => 'value', '#value' => $pid);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $object->label)),
"islandora/object/$pid",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
/**
* returns an array listing object types provided by sub modules
* @return array
@ -376,18 +256,12 @@ function islandora_init() {
* @param string $object_id
* @return string
*/
function islandora_edit_object($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return"";
function islandora_edit_object($object) {
if(!$object) {
return drupal_not_found();
}
drupal_alter('islandora_edit_object', $fedora_object);
$arr = module_invoke_all('islandora_edit_object', $fedora_object);
drupal_alter('islandora_edit_object', $object);
$arr = module_invoke_all('islandora_edit_object', $object);
$output = "";
foreach ($arr as $key => $value) {
$output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
@ -402,7 +276,7 @@ function islandora_edit_object($object_id) {
* @return string
*/
function islandora_edit_properties($object_id) {
$object = islandora_get_object($object_id);
$object = islandora_object_load($object_id);
if (isset($object)) {
module_load_include('inc', 'islandora', 'includes/object_properties');
$form = drupal_get_form('islandora_edit_properties_form', $object);
@ -430,97 +304,6 @@ function islandora_islandora_edit_object($fedora_object) {
return array('Default Edit output' => $output);
}
function islandora_purge_datastream($form, &$form_state, $object_id, $datastream_id) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/datastream');
$connection = new RestConnection();
$object = $connection->repository->getObject($object_id);
$datastream = $object->getDatastream($datastream_id);
$redirect = "islandora/object/$object_id";
// Always provide entity id in the same form key as in the entity edit form.
$form['pid'] = array('#type' => 'value', '#value' => $object_id);
$form['dsid'] = array('#type' => 'value', '#value' => $datastream_id);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)),
"islandora/object/$object_id",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
/**
* Gives the option of purging or deleting a datastream.
*
* The default behaviour is to purge the datastream but this can be overridden using the
* 'islandora_pre_purge_datastream' hook. The returned array can include a 'block' => TRUE
* pair which will prevent the datastream from being deleted if it particularly needed for
* a certain function. Returning 'delete' => TRUE will cause the datastream to be put into
* a deleted state.
*
* @param string $object_id
* ID of the object
* @param string $datastream_id
* ID of the datastream
*
*/
function islandora_purge_datastream_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
$object_id = $form_state['values']['pid'];
$datastream_id = $form_state['values']['dsid'];
global $user;
if (!isset($datastream_id)) {
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
return;
}
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$arr = module_invoke_all('islandora_pre_purge_datastream', $fedora_object, $datastream_id); //notify modules of pending deletion so we can update rels etc
if (isset($arr['block']) && $arr['block']) {
drupal_set_message(t('Purging of the %d datastream was blocked', array('%d' => $datastream_id)), 'warning');
return;
}
if (isset($arr['delete']) && $arr['delete']) {
try {
$datastream = new FedoraDatastream($datastream_id, $fedora_object, $restConnection->repository);
$datastream->state = 'D';
} catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return;
}
}
else {
try {
$fedora_object->purgeDatastream($datastream_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return;
}
}
module_invoke_all('islandora_post_purge_datastream', $fedora_object, $datastream_id); //notify modules post deletion
drupal_set_message(t('%d datastream sucessfully purged from Islandora object %o', array('%d' => $datastream_id, '%o' => $object_id)));
drupal_goto('islandora/object/' . $object_id);
}
function islandora_view_default_object() {
$pid = variable_get('islandora_repository_pid', 'islandora:root');
drupal_goto("islandora/object/$pid");
@ -534,26 +317,19 @@ function islandora_view_default_object() {
*
* @return string
*/
function islandora_view_object($object_id = NULL) {
module_load_include('inc', 'islandora', 'includes/Breadcrumbs');
drupal_set_breadcrumb(islandora_get_breadcrumbs($object_id));
//return $object_id;
if (!isset($object_id)) {
$object_id = variable_get('islandora_repository_pid', 'islandora:root');
//return;
function islandora_view_object($fedora_object = NULL) {
module_load_include('inc', 'islandora', 'includes/breadcrumb');
global $user;
if(!$fedora_object) {
return drupal_not_found();
}
drupal_set_breadcrumb(islandora_get_breadcrumbs($fedora_object));
$page_number = (empty($_GET['page'])) ? '1' : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize'];
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return"";
}
drupal_alter('islandora_object', $fedora_object); //modify object if required before it is passed along
$arr = module_invoke_all('islandora_view_object', $fedora_object, $user, $page_number, $page_size); //allow submodules to decide how to handle content base on object type
if (empty($arr)) {
@ -595,11 +371,13 @@ function islandora_islandora_view_object($object) {
function islandora_theme() {
return array(
'islandora_default' => array(
'template' => 'islandora-object',
'file' => 'theme/islandora.theme.inc',
'template' => 'theme/islandora-object',
'variables' => array('islandora_object' => NULL),
),
'islandora_default_edit' => array(
'template' => 'islandora-object-edit',
'file' => 'theme/islandora.theme.inc',
'template' => 'theme/islandora-object-edit',
'variables' => array('islandora_object' => NULL),
),
);
@ -642,110 +420,40 @@ function islandora_permission() {
);
}
/**
* preprocess for the default view template
* @global string $base_url
* @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'];
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_datastream_get_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 {
$dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc);
$dc_object = Dublin_Core::import_from_xml_string($dc);
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$variables['dc_array'] = $dc_object->as_formatted_array();
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
global $base_url;
if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
}
}
/**
* a helper function to get a connection and return an object
* @global object $user
* @param string $object_id
* @return FedoraObject
*/
function islandora_get_object($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
function islandora_object_load($object_id) {
module_load_include('inc', 'islandora', 'includes/tuque');
static $islandora_tuque = NULL;
if(!$islandora_tuque) {
$islandora_tuque = new IslandoraTuque();
}
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
$fedora_object = $islandora_tuque->repository->getObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return NULL;
}
return $fedora_object;
}
/**
* preprocess the edit template
* @global string $base_url
* @param array $variables
* theme variables for the edit template
*/
function islandora_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object'];
global $base_url;
$datastreams = array();
$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/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' => '3'),
//array('data' => t('Delete')),
);
$table_attributes = array('class' => array('manage-datastreams'));
$rows = array();
foreach ($islandora_object as $ds) {
$rows[] = array(
array('class' => 'datastream-id', 'data' => l($ds->id, islandora_datastream_get_url($ds, 'view'))),
array('class' => 'datastream-label', 'data' => $ds->label),
array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)),
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' => 'datstream-edit', 'data' => islandora_datastream_edit_get_link($islandora_object, $ds->id)),
array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')),
);
function islandora_ingest_access_callback($object, $perm) {
if(islandora_access_callback($object, $perm) === FALSE) {
return FALSE;
}
$ingest_registry = module_invoke_all('islandora_ingest_registry', $object);
if(count($ingest_registry) > 0) {
return TRUE;
}
else {
return FALSE;
}
$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);
}

17
islandora_basic_collection/admin/islandora_basic_collection.admin.inc

@ -26,6 +26,23 @@ function islandora_basic_collection_admin() {
'#description' => t('The default number of object to show in a collection view.'),
'#weight' => -10
);
$form['islandora_basic_collection_disable_collection_policy_delete'] = array(
'#type' => 'checkbox',
'#title' => t('Disable deleting the collection policy'),
'#default_value' => variable_get('islandora_basic_collection_disable_collection_policy_delete', TRUE),
'#description' => t('This will disable the delete link for the COLLECTION_POLICY in the manage tab.'),
'#weight' => -10
);
$form['islandora_basic_collection_default_view'] = array(
'#type' => 'select',
'#title' => t('Select the default collection view style.'),
'#default_value' => variable_get('islandora_basic_collection_default_view', 'grid'),
'#options' => array(
'list' => t('List'),
'grid' => t('Grid'),
),
'#weight' => -10
);
return system_settings_form($form);
}

4
islandora_basic_collection/includes/CollectionPolicy.inc

@ -20,9 +20,9 @@ class CollectionPolicy {
* @return CollectionPolicy
* The parsed collection policy.
*/
public function __construct($xmlStr) {
public function __construct($xml_string) {
$this->xml = new DOMDocument();
$this->xml->loadXML($xmlStr);
$this->xml->loadXML($xml_string);
$this->name = 'Collection Policy';
}

17
islandora_basic_collection/includes/change_content_models.inc

@ -5,12 +5,10 @@
* ChangeContentModels.inc
*/
function islandora_change_content_models_form($form, &$form_state, $collection_pid) {
function islandora_change_content_models_form($form, &$form_state, $collection_object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$content_models = get_content_models_list($collection_pid);
$collection_pid = $collection_object->id;
$content_models = get_content_models_list($collection_object);
$cm_options = array();
$name_mappings = array();
foreach ($content_models as $content_model) {
@ -24,7 +22,6 @@ function islandora_change_content_models_form($form, &$form_state, $collection_p
$namespace = substr($collection_pid, 0, strpos($collection_pid, ":"));
$collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY');
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_policy_datastream = $collection_object->getDatastream($collection_policy_dsid);
$supported_collection_models = array();
@ -46,7 +43,7 @@ function islandora_change_content_models_form($form, &$form_state, $collection_p
$form['change_cmodel']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Change content models within @collection_pid", array('@collection_pid' => $collection_pid)),
'#title' => t("Change content models within @collection_name", array('@collection_name' => $collection_object->label)),
);
$form['change_cmodel']['current_content_model'] = array(
@ -83,16 +80,14 @@ function islandora_change_content_models_form_validate($form, &$form_state) {
function islandora_change_content_models_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$current_content_model = $form_state['values']['current_content_model'];
$new_content_model = $form_state['values']['new_content_model'];
$collection_pid = $form_state['values']['collection_pid'];
$current_content_model_object = new FedoraObject($current_content_model, $rest_connection->repository);
$current_content_model_object = islandora_object_load($current_content_model);
$collection_object = islandora_load_object($form_state['values']['collection_pid']);
$collection_object = new FedoraObject($form_state['values']['collection_pid'], $rest_connection->repository);
$collection_policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$policy = new CollectionPolicy($collection_policy_datastream->content);

28
islandora_basic_collection/includes/child_collection.inc

@ -13,13 +13,19 @@
* @param string $this_collection_pid
* @return array
*/
function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection');
function islandora_create_child_collection_form($form, &$form_state, $collection_object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
$rest_connection = new RestConnection();
$collection_object = new FedoraObject($this_collection_pid, $rest_connection->repository);
$policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
if (!$policy_datastream) {
$form['no_policy'] = array(
'#type' => 'item',
'#title' => t('No collection policy datastream found!'),
);
return $form;
}
$collection_policy = new CollectionPolicy($policy_datastream->content);
$current_content_models = $collection_policy->getContentModels();
$collection_content_model_exists = FALSE;
@ -48,14 +54,14 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
}
}
}
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
$collection_namespace = substr($collection_object->id, 0, strpos($collection_object->id, ":"));
$content_models = get_content_models_as_option_array();
unset($content_models['islandora:collectionCModel']);
$form['child_creation']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Create new child collection within @collection", array('@collection' => $this_collection_pid)),
'#title' => t("Create new child collection within @collection", array('@collection' => $collection_object->id)),
);
$form['child_creation']['collection_name'] = array(
@ -69,8 +75,8 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
'#title' => "Collection PID",
'#type' => 'textfield',
'#size' => 15,
'#default_value' => $rest_connection->repository->api->m->getNextPid($collection_namespace),
'#description' => t("Unique PID for this collection. <br />Pids take the general form of namespace:collection (eg. islandora:pamphlets)"),
'#default_value' => '',
'#description' => t("Unique PID for this collection. Leave blank for default. <br />Pids take the general form of namespace:collection (eg. islandora:pamphlets)"),
);
if (!$restricted) {
@ -94,7 +100,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
$form['current'] = array(
'#type' => 'hidden',
'#value' => $this_collection_pid,
'#value' => $collection_object->id,
);
$form['child_creation']['content_models'] = array(
@ -128,6 +134,10 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', '/includes/islandora.ingest');
$thumbnail = $base_url . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png';
$new_collection_pid = $form_state['values']['new_collection_pid'];
$this_collection_pid = $form_state['values']['current'];
if(empty($new_collection_pid)) {
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
}
$new_collection_label = $form_state['values']['collection_name'];
$namespace = $form_state['values']['collection_namespace'];
$all_cModels = get_content_models_as_option_array();

61
islandora_basic_collection/includes/collection_management.inc

@ -11,58 +11,48 @@
* @param string $pid
* @return array
*/
function get_represented_content_models($pid) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
function get_represented_content_models($object) {
$query = "select \$model \$title from <#ri>
where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$pid>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$pid>)
where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$object->id>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$object->id>)
and \$object <info:fedora/fedora-system:def/model#hasModel> \$model
and \$object <dc:title> \$title";
$model_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$model_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$represented_models = array();
foreach ($model_pids as $model_pid) {
if ($model_pid['model']['value'] && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') {
$fedora_object = new FedoraObject($model_pid['model']['value'], $rest_connection->repository);
$content_model_title = $fedora_object->label;
$represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $content_model_title;
try {
$fedora_object = $object->repository->getObject($model_pid['model']['value']);
$content_model_title = $fedora_object->label;
$represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $content_model_title;
}
catch (RepositoryException $e) {}
}
}
return $represented_models;
}
function get_child_collections($collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
function get_child_collections($object) {
$query = <<<EOD
select \$object from <#ri>
where \$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
EOD;
$lines = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$lines = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$collection_pids = array_values(array_filter($lines));
return $collection_pids;
}
function islandora_collections_get_collection_from_pid($pid) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
function islandora_collections_get_collection_from_pid($object) {
$query = 'select $parent from <#ri>
where ($object <fedora-rels-ext:isMemberOf> $parent
or $object <fedora-rels-ext:isMemberOfCollection> $parent)
and $object <dc:identifier> \'' . $pid . '\'
order by $object';
$object_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$object_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$object_pids = array_values(array_filter($object_pids));
return $object_pids;
}
@ -74,12 +64,9 @@ function islandora_collections_get_collection_from_pid($pid) {
* @param <type> $query
* @param <type> $query_format R
*/
function get_related_items_as_array($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
function get_related_items_as_array($collection_object, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') {
global $user;
$collection_pid = $collection_object->id;
// Not sure if this is necessary given that we should never be able to delete objects in a namespace that we don't have access to.
// if (!fedora_repository_access('view fedora repository', $collection_pid['object']['value'])) {
@ -118,7 +105,7 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by ' . $orderby;
$results = $rest_connection->repository->ri->itqlQuery($query_string, $limit, $offset);
$results = $collection_object->repository->ri->itqlQuery($query_string, $limit, $offset);
return $results;
}
@ -168,16 +155,13 @@ function fedora_repository_access($permission, $pid) {
* @param type $include_fedora_system_content_models
* @return array
*/
function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) {
function get_content_models_list($object, $include_fedora_system_content_models = FALSE) {
module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$rest_connection = new RestConnection();
$pids = array();
$query = 'select $object from <#ri>
where <info:fedora/' . $pid . '> <fedora-model:hasModel> $object
where <info:fedora/' . $object->id . '> <fedora-model:hasModel> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
$content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$content_models = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
if (empty($content_models)) {
return $pids;
@ -202,9 +186,8 @@ function get_content_models_list($pid, $include_fedora_system_content_models = F
* @return array
*/
function get_content_models_as_option_array() {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
module_load_include('inc', 'islandora', 'includes/tuque');
$rest_connection = new IslandoraTuque();
$restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');

16
islandora_basic_collection/includes/collection_manager_table.inc

@ -11,15 +11,12 @@
* @param string $collection_pid
* @return array
*/
function islandora_collection_table($collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$rest_connection = new RestConnection();
function islandora_collection_table($object) {
$query = 'select $object $title from <#ri>
where ($object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/' . $collection_pid . '>
or $object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/' . $collection_pid . '>)
where ($object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/' . $object->id . '>
or $object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/' . $object->id . '>)
and $object <dc:title> $title';
$results = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$results = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$keys = array();
$objects = array();
foreach ($results as $result) {
@ -87,14 +84,13 @@ function theme_islandora_basic_collection_management_form_table(array $element)
}
function get_collections_as_option_array() {
module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
module_load_include('inc', 'islandora', 'includes/tuque');
$restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
$rest_connection = new RestConnection();
$rest_connection = new IslandoraTuque();
$query = 'select $object $title from <#ri>
where ($object <fedora-model:label> $title
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>

28
islandora_basic_collection/includes/delete_collection.inc

@ -12,10 +12,11 @@
*
* @return string
*/
function islandora_collection_deletion_form($form, &$form_state, $pid) {
function islandora_collection_deletion_form($form, &$form_state, $object) {
module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table');
$pid = $object->id;
$potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid);
$table = islandora_collection_table($object);
$deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection";
$submit_text_message = ($table) ? "Delete selected objects" : "Delete collection";
@ -64,17 +65,15 @@ function islandora_collection_deletion_form($form, &$form_state, $pid) {
* @param array $form_state
*/
function islandora_collection_deletion_form_submit($form, &$form_state) {
global $user;
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$collection_pid = $form_state['values']['current'];
$fedora_object = new FedoraObject($collection_pid, $rest_connection->repository);
$fedora_object = islandora_object_load($collection_object);
$parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection');
$parents = Islandora_collections_get_collection_from_pid($collection_pid);
$parents = islandora_collections_get_collection_from_pid($fedora_object);
$collection_pid = $form_state['values']['current'];
if (isset($form_state['values']['delete_root']) && $form_state['values']['delete_root'] == 1) {
delete_root_collection($collection_pid);
delete_root_collection($fedora_object);
drupal_goto("islandora/object/" . $parents[0]['parent']['value']);
}
@ -85,7 +84,7 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
if (!empty($child_collections)) {
foreach ($child_collections as $child) {
$child_pids = get_related_items_as_array($child, 'isMemberOfCollection');
$child_pids = get_related_items_as_array(islandora_object_load($child), 'isMemberOfCollection');
if (!empty($child_pids)) {
$populated_child_collections[] = $child;
}
@ -103,7 +102,7 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
$pids_to_delete = array_diff($pids, $populated_child_collections);
foreach ($pids_to_delete as $pid_to_delete) {
$rest_connection->repository->purgeObject($pid_to_delete);
$fedora_object->repository->purgeObject($pid_to_delete);
}
drupal_goto("islandora/object/" . $collection_pid);
}
@ -113,12 +112,11 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
*
* @param string $pid
*/
function delete_root_collection($pid) {
module_load_include('inc', 'islandora', 'RestConnection');
function delete_root_collection($object) {
try {
$rest_connection = new RestConnection();
$rest_connection->repository->purgeObject($pid);
} catch (Exception $e) {
$object->repository->purgeObject($object->id);
} catch (RepositoryException $e) {
drupal_set_message(t("Collection '@pid' could not be deleted!", array('@pid' => $pid)), 'error');
return;
}

36
islandora_basic_collection/includes/manage_policies.inc

@ -13,26 +13,28 @@
* @param string $collection_pid
* @return type
*/
function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
function islandora_manage_policies_form($form, &$form_state, $collection_object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$content_models = get_content_models_list($collection_pid);
$repository = $collection_object->repository;
$content_models = get_content_models_list($collection_object);
$cm_options = array();
$name_mappings = array();
foreach ($content_models as $content_model) {
if ($content_model != "islandora:collectionCModel") {
$item = new FedoraObject($content_model, $rest_connection->repository);
$cm_name = $item->Label;
$cm_options[$content_model] = $cm_name;
try {
$item = $repository->getObject($content_model);
$cm_name = $item->Label;
$cm_options[$content_model] = $cm_name;
}
catch(RepositoryException $e) {}
}
}
$namespace = substr($collection_pid, 0, strpos($collection_pid, ":"));
$namespace = substr($collection_object->id, 0, strpos($collection_object->id, ":"));
$collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY');
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_policy_string = $collection_object->getDatastream($collection_policy_dsid);
$supported_collection_models = array();
@ -41,9 +43,9 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$supported_collection_models = $collection_policy->getContentModels();
}
$collection_namespace = substr($collection_pid, 0, strpos($collection_pid, ":"));
$collection_namespace = substr($collection_object->id, 0, strpos($collection_object->id, ":"));
$represented_content_models = get_represented_content_models($collection_pid);
$represented_content_models = get_represented_content_models($collection_object);
$collection_name = $collection_object->label;
$new_content_models = get_content_models_as_option_array();
$current_models_in_policy = array();
@ -66,7 +68,7 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$form['manage_collection_policy']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Manage collection policy for @collection_pid", array('@collection_pid' => $collection_pid)),
'#title' => t("Manage collection policy for @collection_title", array('@collection_title' => $collection_object->label)),
);
$form ['manage_collection_policy']['add']['content_model_to_add'] = array(
@ -86,12 +88,12 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$form['parent_collection'] = array(
'#type' => 'hidden',
'#value' => $collection_pid,
'#value' => $collection_object->id,
);
$form['collection_pid'] = array(
'#type' => 'hidden',
'#value' => $collection_pid,
'#value' => $collection_object->id,
);
$form['manage_collection_policy']['add']['submit'] = array(
@ -135,11 +137,9 @@ function islandora_manage_policies_form_validate($form, &$form_state) {
* @param array $form_state
*/
function islandora_manage_policies_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$collection_pid = $form_state['values']['parent_collection'];
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_object = islandora_object_load($collection_pid);
$policy = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$collection_policy = '<?xml version="1.0" encoding="UTF-8"?>
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd">

14
islandora_basic_collection/includes/move_collection.inc

@ -13,10 +13,10 @@
*
* @return string
*/
function islandora_collection_migrate_form($form, &$form_state, $pid) {
function islandora_collection_migrate_form($form, &$form_state, $object) {
module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table');
$potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid);
$table = islandora_collection_table($object);
if (!$table) {
$form['no_objects'] = array(
'#type' => 'item',
@ -28,12 +28,12 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
$form['migrate']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Move objects from @collection_pid", array('@collection_pid' => $pid)),
'#title' => t("Move objects from @collection_pid", array('@collection_pid' => $object->id)),
);
$form['migrate']['new_collection'] = array(
'#title' => t('New collection'),
'#description' => t("All content will be migrated from @pid to the selected collection", array('@pid' => $pid)),
'#description' => t("All content will be migrated from @pid to the selected collection", array('@pid' => $object->id)),
'#type' => 'select',
'#options' => $potential_collections,
);
@ -42,7 +42,7 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
$form['current'] = array(
'#type' => 'hidden',
'#value' => $pid,
'#value' => $object->id,
);
$form['migrate']['message'] = array(
@ -64,14 +64,12 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
* @param array $form_state
*/
function islandora_collection_migrate_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$pids = array_filter($form_state['values']['table']);
$new_collection = $form_state['values']['new_collection'];
$current = $form_state['values']['current'];
foreach ($pids as $pid) {
$fedora_object = new FedoraObject($pid, $rest_connection->repository);
$fedora_object = islandora_object_load($pid);
$fedora_object->relationships->remove(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $current);
$fedora_object->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $new_collection);
}

10
islandora_basic_collection/islandora_basic_collection.install

@ -5,12 +5,11 @@
* islandora_basic_collection.install
*/
function islandora_basic_collection_install() {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
module_load_include('inc', 'islandora', 'includes/tuque');
global $base_root;
try {
$rest_connection = new RestConnection($user);
$rest_connection = new IslandoraTuque();
} catch (Exception $e) {
drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return;
@ -55,10 +54,9 @@ function islandora_basic_collection_install() {
}
function islandora_basic_collection_uninstall() {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
module_load_include('inc', 'islandora', 'includes/tuque');
try {
$rest_connection = new RestConnection($user);
$rest_connection = new IslandoraTuque();
} catch (Exception $e) {
drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return;

69
islandora_basic_collection/islandora_basic_collection.module

@ -29,8 +29,8 @@
*/
function islandora_basic_collection_menu() {
$items = array();
$items['islandora/object/%/manage/collection'] = array(
'title' => 'Collection related',
$items['islandora/object/%islandora_object/manage/collection'] = array(
'title' => 'Collection',
'page callback' => 'islandora_basic_collection_manage_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
@ -67,30 +67,12 @@ function islandora_basic_collection_init() {
}
}
/**
* Implements hook_menu_local_tasks_alter().
*/
function islandora_basic_collection_menu_local_tasks_alter(&$data, $router_item, $root_path) {
// Add action link
if ($root_path == 'islandora/object/%/manage/collection') {
$object_id = $router_item['page_arguments'][0];
$item = menu_get_item("islandora/ingest/$object_id");
$item['title'] = 'Add a repository item';
if ($item['access']) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
}
/**
* This function is where we create the view for the related menu item
* @param type $object_id
* @return type
*/
function islandora_basic_collection_manage_object($object_id) {
function islandora_basic_collection_manage_object($object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/collection_management');
module_load_include('inc', 'islandora_basic_collection', 'includes/collection_manager_table');
@ -113,7 +95,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#type' => 'fieldset',
);
$form['collection_manager']['create_child_collection']['form'] = drupal_get_form('islandora_create_child_collection_form', $object_id);
$form['collection_manager']['create_child_collection']['form'] = drupal_get_form('islandora_create_child_collection_form', $object);
$form['collection_manager']['manage_policies'] = array(
'#type' => 'fieldset',
@ -122,7 +104,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE,
);
$form['collection_manager']['manage_policies']['form'] = drupal_get_form('islandora_manage_policies_form', $object_id);
$form['collection_manager']['manage_policies']['form'] = drupal_get_form('islandora_manage_policies_form', $object);
$form['collection_manager']['change_content_models'] = array(
'#type' => 'fieldset',
@ -131,7 +113,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE,
);
$form['collection_manager']['change_content_models']['form'] = drupal_get_form('islandora_change_content_models_form', $object_id);
$form['collection_manager']['change_content_models']['form'] = drupal_get_form('islandora_change_content_models_form', $object);
$form['collection_manager']['migrate_members'] = array(
'#type' => 'fieldset',
@ -140,7 +122,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE,
);
$form['collection_manager']['migrate_members']['form'] = drupal_get_form('islandora_collection_migrate_form', $object_id);
$form['collection_manager']['migrate_members']['form'] = drupal_get_form('islandora_collection_migrate_form', $object);
$form['collection_manager']['delete_members'] = array(
'#type' => 'fieldset',
@ -149,7 +131,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE,
);
$form['collection_manager']['delete_members']['form'] = drupal_get_form('islandora_collection_deletion_form', $object_id);
$form['collection_manager']['delete_members']['form'] = drupal_get_form('islandora_collection_deletion_form', $object);
// Pass the form around any modules that are interested so that they can add their own collection management functions.
module_invoke_all('islandora_collection_manager', $form);
@ -163,15 +145,7 @@ function islandora_basic_collection_manage_object($object_id) {
* @param string $object_id
* @return boolean
*/
function islandora_basic_collection_access($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
return FALSE;
}
function islandora_basic_collection_access($fedora_object) {
if (!isset($fedora_object)) {
return FALSE;
}
@ -268,16 +242,7 @@ function islandora_basic_collection_islandora_view_object($object, $user) {
* @return null|\FedoraObject
*/
function islandora_basic_collection_get_object($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
//drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return NULL;
}
return $fedora_object;
return islandora_object_load($object_id);
}
/**
@ -298,14 +263,10 @@ function islandora_basic_collection_get_objects($object, $page_number = 1, $page
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title';
module_load_include('inc', 'islandora', 'RestConnection');
$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);
global $user;
try {
$restConnection = new RestConnection($user);
$queryObject = new RepositoryQuery($restConnection->connection);
$results = $queryObject->query($query_array['query'], $query_array['type']);
$results = $object->repository->ri->query($query_array['query'], $query_array['type']);
} catch (Exception $e) {
drupal_set_message(t('Islandora Error getting related objects for %s', array('%s' => $object->id)), 'error');
return"";
@ -327,4 +288,12 @@ function islandora_basic_collection_islandora_ingest_get_information($models, $o
drupal_set_message(t('Islandora Error getting collection info for %s', array('%s' => $object->id)), 'error');
}
}
}
function islandora_basic_collection_islandora_undeletable_datastreams($models) {
if(in_array('islandora:collectionCModel', $models)) {
if(variable_get('islandora_basic_collection_disable_collection_policy_delete', TRUE)) {
return array('COLLECTION_POLICY');
}
}
}

6
islandora_basic_collection/theme/islandora_basic_collection.theme.inc

@ -17,19 +17,19 @@ function islandora_basic_collection_preprocess_islandora_basic_collection_wrappe
$total_count = count($results);
pager_default_initialize($total_count, $page_size);
$variables['collection_pager'] = theme('pager', array('quantity' => 10));
$display = (empty($_GET['display'])) ? 'list' : $_GET['display'];
$display = (empty($_GET['display'])) ? variable_get('islandora_basic_collection_default_view', 'grid') : $_GET['display'];
$link_text = (empty($_GET['display'])) ? 'grid' : $_GET['display'];
$query_params = drupal_get_query_parameters($_GET);
if ($display == 'grid') {
$query_params['display'] = 'list';
$link_text = 'list view';
$link_text = 'List View';
$link_class = 'islandora-view-default';
$collection_content = theme('islandora_basic_collection_grid', array('islandora_object' => $islandora_object, 'collection_results' => $results));
}
else {
$query_params['display'] = 'grid';
$link_text = 'grid view';
$link_text = 'Grid View';
$link_class = 'islandora-view-grid';
$collection_content = theme('islandora_basic_collection', array('islandora_object' => $islandora_object, 'collection_results' => $results));
}

4
islandora_basic_image/includes/image.process.inc

@ -7,9 +7,9 @@
*/
function islandora_basic_image_create_all_derivatives($object) {
module_load_include('inc', 'islandora', 'includes/MimeClass');
module_load_include('inc', 'islandora', 'includes/mime.detect');
module_load_include('inc', 'islandora_basic_image', 'includes/image_process');
$mime_class = new MimeClass();
$mime_class = new MimeDetect();
if (!isset($object['OBJ'])) {
drupal_set_message(t('Could not create image derivatives for %s. No image file was uploaded.', array('%s' => $object->id)),'error');
return "";

9
islandora_basic_image/islandora_basic_image.install

@ -9,12 +9,11 @@
* Implements hook_install
*/
function islandora_basic_image_install() {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
module_load_include('inc', 'islandora', 'includes/tuque');
global $base_root;
try {
$restConnection = new RestConnection($user);
$restConnection = new IslandoraTuque();
} catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return;
@ -64,10 +63,10 @@ function islandora_basic_image_install() {
* Implements hook_uninstall
*/
function islandora_basic_image_uninstall() {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/tuque');
global $user;
try {
$restConnection = new RestConnection($user);
$restConnection = new IslandoraTuque($user);
} catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return;

28
islandora_basic_image/islandora_basic_image.module

@ -104,34 +104,6 @@ function islandora_basic_image_menu() {
return 'Another view returned by the image cmodel';
} */
/**
* determines whether or not to show this modules manage tab
* @global object $user
* @param string $object_id
* @return boolean
*/
function islandora_basic_image_access($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
return FALSE;
}
if (!isset($fedora_object)) {
return FALSE;
}
$models = $fedora_object->models;
$cmodel_list = islandora_basic_image_islandora_get_types();
foreach ($fedora_object->models as $model) {
if (isset($cmodel_list[$model])) {
return user_access(FEDORA_MODIFY_STATE);
}
}
return FALSE;
}
function islandora_basic_image_init() {
if (path_is_admin(current_path())) {
drupal_add_css(drupal_get_path('module', 'islandora_basic_image') . '/css/islandora_basic_image.admin.css');

0
islandora-object-edit.tpl.php → theme/islandora-object-edit.tpl.php

0
islandora-object.tpl.php → theme/islandora-object.tpl.php

91
theme/islandora.theme.inc

@ -0,0 +1,91 @@
<?php
/**
* preprocess the edit template
* @global string $base_url
* @param array $variables
* theme variables for the edit template
*/
function islandora_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object'];
global $base_url;
$datastreams = array();
$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/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' => '3'),
//array('data' => t('Delete')),
);
$table_attributes = array('class' => array('manage-datastreams'));
$rows = array();
foreach ($islandora_object as $ds) {
$rows[] = array(
array('class' => 'datastream-id', 'data' => l($ds->id, islandora_datastream_get_url($ds, 'view'))),
array('class' => 'datastream-label', 'data' => $ds->label),
array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)),
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' => 'datstream-edit', 'data' => islandora_datastream_edit_get_link($islandora_object, $ds->id)),
array('class' => 'datastream-delete', 'data' => islandora_datastream_get_delete_link($ds)),
);
}
$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);
}
/**
* preprocess for the default view template
* @global string $base_url
* @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'];
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_datastream_get_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 {
$dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc);
$dc_object = Dublin_Core::import_from_xml_string($dc);
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$variables['dc_array'] = $dc_object->as_formatted_array();
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
global $base_url;
if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
}
}
Loading…
Cancel
Save