Browse Source

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

pull/122/head
Danny Joris 12 years ago
parent
commit
b04a0a0aad
  1. 7
      admin/islandora.admin.inc
  2. 1
      includes/breadcrumb.inc
  3. 12
      includes/datastream.inc
  4. 4
      includes/islandora.ingest.inc
  5. 13
      includes/purge.form.inc
  6. 2
      includes/tuque.inc
  7. 16
      islandora.module
  8. 17
      islandora_basic_collection/includes/change_content_models.inc
  9. 12
      islandora_basic_collection/includes/child_collection.inc
  10. 53
      islandora_basic_collection/includes/collection_management.inc
  11. 16
      islandora_basic_collection/includes/collection_manager_table.inc
  12. 28
      islandora_basic_collection/includes/delete_collection.inc
  13. 32
      islandora_basic_collection/includes/manage_policies.inc
  14. 14
      islandora_basic_collection/includes/move_collection.inc
  15. 10
      islandora_basic_collection/islandora_basic_collection.install
  16. 41
      islandora_basic_collection/islandora_basic_collection.module
  17. 9
      islandora_basic_image/islandora_basic_image.install
  18. 28
      islandora_basic_image/islandora_basic_image.module

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;

1
includes/breadcrumb.inc

@ -3,7 +3,6 @@
function islandora_get_breadcrumbs($object) {
$breadcrumbs = array();
$connection = new RestConnection();
islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository);
if(isset($breadcrumbs[0])) {

12
includes/datastream.inc

@ -136,7 +136,7 @@ function islandora_get_add_datastream_form($object, &$form_state) {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$object_id"
'#value' => "$object->id"
);
$form['add_fieldset']['stream_label'] = array(
@ -154,7 +154,7 @@ function islandora_get_add_datastream_form($object, &$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')
@ -198,7 +198,6 @@ function islandora_get_add_datastream_form($object, &$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;
@ -217,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;
@ -243,7 +241,6 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
*/
function islandora_add_datastream_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/mime.detect');
module_load_include('inc', 'islandora', 'RestConnection');
$mimetype = new MimeDetect();
if ($form_state['clicked_button']['#value'] == 'OK') {
$form_state['rebuild'] = TRUE;
@ -269,8 +266,7 @@ 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.'));

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']);

13
includes/purge.form.inc

@ -17,25 +17,26 @@
* @return type
*/
function islandora_purge_object_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$collection = $form_state['values']['col'];
if (!isset($object_id)) {
if (!$object_id) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
$object = islandora_object_load($object_id);
if (!isset($fedora_object)) {
if (!$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
$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 {
$fedora_object->delete();
$object->delete();
} catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
@ -43,7 +44,7 @@ function islandora_purge_object_submit($form, &$form_state) {
}
else {
try {
$restConnection->repository->purgeObject($object_id);
$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 "";

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

16
islandora.module

@ -216,8 +216,8 @@ function islandora_admin_paths() {
*
* @return boolean
*/
function islandora_access_callback($pid = NULL, $perm = NULL) {
if(!$pid || !$perm) {
function islandora_access_callback($object = NULL, $perm = NULL) {
if(!$object || !$perm) {
return FALSE;
}
@ -227,7 +227,7 @@ function islandora_access_callback($pid = NULL, $perm = NULL) {
$namespace_access = TRUE;
}
else {
$pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon)
$pid_namespace = substr($object->id, 0, strpos($object->id, ':') + 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);
}
@ -427,15 +427,15 @@ function islandora_permission() {
* @return FedoraObject
*/
function islandora_object_load($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
static $restConnection = NULL;
module_load_include('inc', 'islandora', 'includes/tuque');
static $islandora_tuque = NULL;
if(!$restConnection) {
$restConnection = new RestConnection();
if(!$islandora_tuque) {
$islandora_tuque = new IslandoraTuque();
}
try {
$fedora_object = $restConnection->repository->getObject($object_id);
$fedora_object = $islandora_tuque->repository->getObject($object_id);
} catch (Exception $e) {
return NULL;
}

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);

12
islandora_basic_collection/includes/child_collection.inc

@ -13,11 +13,9 @@
* @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(
@ -56,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(
@ -102,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(

53
islandora_basic_collection/includes/collection_management.inc

@ -11,23 +11,19 @@
* @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') {
try {
$fedora_object = new FedoraObject($model_pid['model']['value'], $rest_connection->repository);
$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;
}
@ -37,34 +33,26 @@ where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <i
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;
}
@ -76,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'])) {
@ -120,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;
}
@ -170,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;
@ -204,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;
}

32
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);
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;

41
islandora_basic_collection/islandora_basic_collection.module

@ -29,7 +29,7 @@
*/
function islandora_basic_collection_menu() {
$items = array();
$items['islandora/object/%/manage/collection'] = array(
$items['islandora/object/%islandora_object/manage/collection'] = array(
'title' => 'Collection',
'page callback' => 'islandora_basic_collection_manage_object',
'page arguments' => array(2),
@ -72,7 +72,7 @@ function islandora_basic_collection_init() {
* @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');
@ -95,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',
@ -104,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',
@ -113,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',
@ -122,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',
@ -131,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);
@ -145,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;
}
@ -250,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);
}
/**
@ -280,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"";

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');

Loading…
Cancel
Save