Browse Source

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

pull/120/head
jonathangreen 13 years ago
parent
commit
a90080cb59
  1. 4
      includes/islandora.ingest.inc
  2. 10
      islandora_basic_collection/admin/islandora_basic_collection.admin.inc
  3. 150
      islandora_basic_collection/includes/ChangeContentModels.inc
  4. 21
      islandora_basic_collection/includes/ChildCollection.inc
  5. 49
      islandora_basic_collection/includes/CollectionManagement.inc
  6. 14
      islandora_basic_collection/includes/CollectionManagerTable.inc
  7. 97
      islandora_basic_collection/includes/CollectionPolicy.inc
  8. 28
      islandora_basic_collection/includes/DeleteCollection.inc
  9. 45
      islandora_basic_collection/includes/ManagePolicies.inc
  10. 16
      islandora_basic_collection/includes/MoveCollection.inc
  11. 59
      islandora_basic_collection/islandora_basic_collection.install
  12. 10
      islandora_basic_collection/islandora_basic_collection.module

4
includes/islandora.ingest.inc

@ -13,9 +13,9 @@ function islandora_ingest_get_object($content_models, $collection_pid, $relation
$connection = new RestConnection($user); $connection = new RestConnection($user);
$object = $connection->repository->constructObject($namespace); $object = $connection->repository->constructObject($namespace);
foreach($content_models as $content_model) { foreach($content_models as $content_model) {
$object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model); $object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']);
} }
$object->relationships->add($relationship['uri'], $relationship['value'], $collection_pid); $object->relationships->add(FEDORA_RELS_EXT_URI, $relationship, $collection_pid);
module_invoke_all('islandora_ingest_pre_ingest', $object, $content_models, $collection_pid); module_invoke_all('islandora_ingest_pre_ingest', $object, $content_models, $collection_pid);
return $object; return $object;
} }

10
islandora_basic_collection/admin/islandora_basic_collection.admin.inc

@ -1,5 +1,14 @@
<?php <?php
/**
* @file
* islandora_basic_collection.admin.inc
*/
/**
*
* @return type
*/
function islandora_basic_collection_admin() { function islandora_basic_collection_admin() {
$form = array(); $form = array();
$form['islandora_basic_collection_use_for_default_tab'] = array( $form['islandora_basic_collection_use_for_default_tab'] = array(
@ -20,4 +29,3 @@ function islandora_basic_collection_admin() {
return system_settings_form($form); return system_settings_form($form);
} }

150
islandora_basic_collection/includes/ChangeContentModels.inc

@ -0,0 +1,150 @@
<?php
/**
* @file
* ChangeContentModels.inc
*/
function islandora_change_content_models_form($form, &$form_state, $collection_pid) {
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);
$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;
}
}
$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();
if ($collection_policy_datastream->content) {
$collection_policy = new CollectionPolicy($collection_policy_datastream->content);
$supported_collection_models = $collection_policy->getContentModels();
}
$collection_namespace = substr($collection_pid, 0, strpos($collection_pid, ":"));
$collection_name = $collection_object->label;
$new_content_models = get_content_models_as_option_array();
$current_models_in_policy = array();
if ($supported_collection_models) {
foreach ($supported_collection_models as $supported_model) {
$current_models_in_policy[$supported_model['pid']] = $supported_model['pid'];
}
}
$form['change_cmodel']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Change Content Models within @collection_pid", array('@collection_pid' => $collection_pid)),
);
$form['change_cmodel']['current_content_model'] = array(
'#title' => "Choose content model to be changed",
'#type' => 'select',
'#options' => $current_models_in_policy,
'#description' => t("All objects in this collection with the selected content model will be changed."),
);
$form['change_cmodel']['new_content_model'] = array(
'#title' => "Choose new content model",
'#type' => 'select',
'#options' => $new_content_models,
'#description' => t("The new content model to be assigned to selected objects."),
);
$form['change_cmodel']['collection_pid'] = array(
'#type' => 'hidden',
'#value' => $collection_pid,
);
$form['change_cmodel']['submit'] = array(
'#type' => 'submit',
'#value' => t('Change content model associations'),
'#id' => 'change_model',
);
return $form;
}
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);
$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);
$collection_policy_xml = new DOMDocument();
$collection_policy_xml->loadXML($collection_policy_datastream->content);
$add_to_policy = TRUE;
$policy_content_models = $policy->getContentModels();
foreach ($policy_content_models as $policy_content_model) {
if ($policy_content_model['pid'] == $current_content_model) {
$namespace = $policy_content_model['namespace'];
}
if ($policy_content_model['pid'] == $new_content_model) {
$add_to_policy = FALSE;
}
}
if ($add_to_policy) {
$new_content_model_object = new FedoraObject($new_content_model, $rest_connection->repository);
$new_content_model_datastream = $new_content_model_object->getDatastream(variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM'));
$content_models_element = $collection_policy_xml->getElementsByTagName('content_models');
$content_model_element = $content_models_element->item(0)->getElementsByTagName('content_model');
$content_model_element = $collection_policy_xml->createElement('content_model');
$content_model_element->setAttribute('name', $new_content_model_object->label);
$content_model_element->setAttribute('dsid', variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM'));
$content_model_element->setAttribute('namespace', $namespace);
$content_model_element->setAttribute('pid', $new_content_model_object->id);
$content_models_element->item(0)->appendChild($content_model_element);
$new_collection_policy_datastream = $collection_object->getDatastream('COLLECTION_POLICY');
$new_collection_policy_datastream->setContentFromString($collection_policy_xml->saveXML());
$new_collection_policy_datastream->label = 'COLLECTION_POLICY';
$collection_object->ingestDatastream($new_collection_policy_datastream);
}
$query = "select \$object from <#ri>
where (\$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/$current_content_model>
and (\$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$collection_pid>)
and \$object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)";
$objects = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$count = 0;
foreach ($objects as $object) {
if (!$object['object']['value']) {
continue;
}
$fedora_item = new FedoraObject($object['object']['value'], $rest_connection->repository);
$fedora_item->relationships->remove(FEDORA_MODEL_URI, 'hasModel', $current_content_model);
$fedora_item->relationships->add(FEDORA_MODEL_URI, 'hasModel', $new_content_model);
$count++;
}
drupal_set_message(t('@current_content_model changed to @new_content_model on @count objects', array('@current_content_model' => $current_content_model, '@new_content_model' => $new_content_model, '@count' => $count)));
}

21
islandora_basic_collection/includes/ChildCollection.inc

@ -1,8 +1,20 @@
<?php <?php
/**
* @file
* ChildCollection.inc
*/
/**
*
* @param type $form
* @param type $form_state
* @param type $this_collection_pid
* @return string
*/
function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) { function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$restricted = FALSE; $restricted = FALSE;
if (variable_get('fedora_namespace_restriction_enforced', TRUE)) { if (variable_get('fedora_namespace_restriction_enforced', TRUE)) {
@ -18,7 +30,8 @@ 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($this_collection_pid, 0, strpos($this_collection_pid, ":"));
$form['child_creation']['titlebox'] = array( $form['child_creation']['titlebox'] = array(
'#markup' => t("Create New Child Collection within @collection", array('@collection' => $this_collection_pid)), '#type' => 'item',
'#title' => t("Create New Child Collection within @collection", array('@collection' => $this_collection_pid)),
); );
$form['child_creation']['collection_name'] = array( $form['child_creation']['collection_name'] = array(
@ -32,7 +45,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
'#title' => "Collection PID", '#title' => "Collection PID",
'#type' => 'textfield', '#type' => 'textfield',
'#size' => 15, '#size' => 15,
'#default_value' => $restConnection->repository->api->m->getNextPid($collection_namespace), '#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)"), '#description' => t("Unique PID for this collection. <br />Pids take the general form of namespace:collection (eg. islandora:pamphlets)"),
); );
@ -62,7 +75,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
$form['child_creation']['submit'] = array( $form['child_creation']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Create Collection'), '#value' => t('Create collection'),
'#id' => 'create_child' '#id' => 'create_child'
); );
return $form; return $form;

49
islandora_basic_collection/includes/CollectionManagement.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* CollectionManagement.inc
*/
/** /**
* collection creation form * collection creation form
* @param array $form_state * @param array $form_state
@ -219,7 +224,7 @@ function collection_management_form($this_collection_pid, $content_models) {
'#id' => 'change_model', '#id' => 'change_model',
); );
return($form); return $form;
} }
/** /**
@ -409,9 +414,9 @@ function collection_management_form_submit($form, &$form_state) {
*/ */
function delete_objects_as_batch($pid) { function delete_objects_as_batch($pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$name = $user->name; $name = $user->name;
$restConnection->repository->purgeObject($pid); $rest_connection->repository->purgeObject($pid);
} }
/** /**
@ -420,8 +425,8 @@ function delete_objects_as_batch($pid) {
*/ */
function remove_collection_association($pid, $collection_pid) { function remove_collection_association($pid, $collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$fedora_object = new FedoraObject($pid, $restConnection->repository); $fedora_object = new FedoraObject($pid, $rest_connection->repository);
$fedora_object->relationships->remove(NULL, 'isMemberOfCollection', $collection_pid); $fedora_object->relationships->remove(NULL, 'isMemberOfCollection', $collection_pid);
} }
@ -432,7 +437,7 @@ function remove_collection_association($pid, $collection_pid) {
*/ */
function get_represented_content_models($pid) { function get_represented_content_models($pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$query = "select \$model \$title from <#ri> $query = "select \$model \$title from <#ri>
@ -441,12 +446,14 @@ where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <i
and \$object <info:fedora/fedora-system:def/model#hasModel> \$model and \$object <info:fedora/fedora-system:def/model#hasModel> \$model
and \$object <dc:title> \$title"; and \$object <dc:title> \$title";
$model_pids = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $model_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$represented_models = array(); $represented_models = array();
foreach ($model_pids as $model_pid) { foreach ($model_pids as $model_pid) {
if ($model_pid && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') {
$represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $model_pid['title']['value']; 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;
} }
} }
return $represented_models; return $represented_models;
@ -454,7 +461,7 @@ where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <i
function get_child_collections($collection_pid) { function get_child_collections($collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$query = <<<EOD $query = <<<EOD
@ -463,14 +470,14 @@ function get_child_collections($collection_pid) {
and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid> and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
EOD; EOD;
$lines = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $lines = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$collection_pids = array_values(array_filter($lines)); $collection_pids = array_values(array_filter($lines));
return $collection_pids; return $collection_pids;
} }
function Islandora_collections_get_collection_from_pid($pid) { function Islandora_collections_get_collection_from_pid($pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$query = 'select $parent from <#ri> $query = 'select $parent from <#ri>
@ -479,7 +486,7 @@ function Islandora_collections_get_collection_from_pid($pid) {
and $object <dc:identifier> \'' . $pid . '\' and $object <dc:identifier> \'' . $pid . '\'
order by $object'; order by $object';
$object_pids = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $object_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$object_pids = array_values(array_filter($object_pids)); $object_pids = array_values(array_filter($object_pids));
return $object_pids; return $object_pids;
} }
@ -494,7 +501,7 @@ function Islandora_collections_get_collection_from_pid($pid) {
*/ */
function get_related_items_as_array($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { 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'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
global $user; global $user;
@ -534,7 +541,7 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by ' . $orderby; order by ' . $orderby;
$results = $restConnection->repository->ri->itqlQuery($query_string, $limit, $offset); $results = $rest_connection->repository->ri->itqlQuery($query_string, $limit, $offset);
return $results; return $results;
} }
@ -568,13 +575,13 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
// $collectionHelper = new CollectionClass(); // $collectionHelper = new CollectionClass();
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$pids = array(); $pids = array();
$query = 'select $object from <#ri> $query = 'select $object from <#ri>
where <info:fedora/' . $pid . '> <fedora-model:hasModel> $object where <info:fedora/' . $pid . '> <fedora-model:hasModel> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>'; and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
// $content_models = $collectionHelper->getRelatedItems($pid, $query); // $content_models = $collectionHelper->getRelatedItems($pid, $query);
$content_models = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
if (empty($content_models)) { if (empty($content_models)) {
return $pids; return $pids;
@ -604,7 +611,7 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
*/ */
function get_content_models_as_option_array() { function get_content_models_as_option_array() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
@ -622,7 +629,7 @@ function get_content_models_as_option_array() {
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
$list = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $list = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$options = array(); $options = array();
foreach ($list as $item) { //removes blanks foreach ($list as $item) { //removes blanks
if ($item) { if ($item) {
@ -641,10 +648,10 @@ function get_content_models_as_option_array() {
function getContentModels($collection_pid, $showError = TRUE) { function getContentModels($collection_pid, $showError = TRUE) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
// module_load_include('inc', 'Fedora_Repository', 'ContentModel'); // module_load_include('inc', 'Fedora_Repository', 'ContentModel');
$collection_stream = $this->getCollectionPolicyStream($collection_pid); $collection_stream = $this->getCollectionPolicyStream($collection_pid);
$collection_object = new FedoraObject($collection_pid, $restConnection->repository); $collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_stream = $collection_object->getDatastream('COLLECTION_POLICY'); $collection_stream = $collection_object->getDatastream('COLLECTION_POLICY');
try { try {
$xml = new SimpleXMLElement($collection_stream); $xml = new SimpleXMLElement($collection_stream);

14
islandora_basic_collection/includes/CollectionManagerTable.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* CollectionManagerTable.inc
*/
/** /**
* Returns a formatted table listing all members of the collection * Returns a formatted table listing all members of the collection
* defined by the $collection_pid parameter * defined by the $collection_pid parameter
@ -9,12 +14,12 @@
function islandora_collection_table($collection_pid) { function islandora_collection_table($collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/' . $collection_pid . '> 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 . '>) or $object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/' . $collection_pid . '>)
and $object <dc:title> $title'; and $object <dc:title> $title';
$results = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $results = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$keys = array(); $keys = array();
$objects = array(); $objects = array();
foreach ($results as $result) { foreach ($results as $result) {
@ -89,19 +94,18 @@ function get_collections_as_option_array() {
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <fedora-model:label> $title where ($object <fedora-model:label> $title
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
$results = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); $results = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
foreach ($namespaces as $namespace) { foreach ($namespaces as $namespace) {
$trimmed_names[] = trim($namespace); $trimmed_names[] = trim($namespace);
} }
$options = array(); $options = array();
foreach ($results as $item) { //removes blanks foreach ($results as $item) { //removes blanks
// var_dump($item['object']['value']);
$namespace = explode(':', $item['object']['value']); $namespace = explode(':', $item['object']['value']);
$namespace = trim($namespace[0]); $namespace = trim($namespace[0]);
if (!$restricted || in_array($namespace, $trimmed_names)) { if (!$restricted || in_array($namespace, $trimmed_names)) {

97
islandora_basic_collection/includes/CollectionPolicy.inc

@ -151,101 +151,4 @@ class CollectionPolicy {
return $ret; return $ret;
} }
/**
* valid_pid
* Validates a fedora PID based on the regexp provided in the fedora
* 3.3 documentation.
* http://www.fedora-commons.org/confluence/display/FCR30/Fedora+Identifiers
*
* @param String $pid
* @return boolean $valid
*/
public static function valid_pid($pid) {
$valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE;
}
return $valid;
}
/**
* Validates the XMLDatastream against the schema location
* defined by the xmlns:schemaLocation attribute of the root
* element. If the xmlns:schemaLocation attribute does not exist,
* then it is assumed to be the old schema and it attempts to convert
* using the convertFromOldSchema method.
*
* TODO: Maybe change it so that it always validates against a known
* schema. This makes more sense because this class assumes the structure
* to be known after it has been validated.
*
* @return boolean $valid
*/
public function validate() {
global $user;
if ($this->valid === NULL) {
$ret = TRUE;
if ($this->xml == NULL) {
$this->fetchXml();
}
// figure out if we're dealing with a new or old schema
$rootEl = $this->xml->firstChild;
if (!$rootEl->hasAttributes() || $rootEl->attributes->getNamedItem('schemaLocation') === NULL) {
//$tmpname = substr($this->pid, strpos($this->pid, ':') + 1);
$tmpname = user_password(10);
$this->convertFromOldSchema();
drupal_add_js("fedora_repository_print_new_schema_$tmpname = function(tagID) {
var target = document.getElementById(tagID);
var content = target.innerHTML;
var text = '<html><head><title>Title' +
'</title><body>' + content +'</body></html>';
printerWindow = window.open('', '', 'toolbar=no,location=no,' + 'status=no,menu=no,scrollbars=yes,width=650,height=400');
printerWindow.document.open();
printerWindow.document.write(text);
}", 'inline');
if (user_access('administer site configuration')) {
drupal_set_message('<span id="new_schema_' . $tmpname . '" style="display: none;">' . htmlentities($this->xml->saveXML()) . '</span>Warning: XMLDatastream performed conversion of \'' . $this->getIdentifier() . '\' from old schema. Please update the datastream. The new datastream contents are <a href="javascript:fedora_repository_print_new_schema_' . $tmpname . '(\'new_schema_' . $tmpname . '\')">here.</a> ');
}
$rootEl = $this->xml->firstChild;
}
$schemaLocation = NULL;
if ($this->forceSchema) {
// hack because you cant easily get the static property value from
// a subclass.
$vars = get_class_vars(get_class($this));
$schemaLocation = $vars['SCHEMA_URI'];
}
elseif ($rootEl->attributes->getNamedItem('schemaLocation') !== NULL) {
//figure out where the schema is located and validate.
list(, $schemaLocation) = preg_split('/\s+/', $rootEl->attributes->getNamedItem('schemaLocation')->nodeValue);
}
$schemaLocation = NULL;
return TRUE;
if ($schemaLocation !== NULL) {
if (!$this->xml->schemaValidate($schemaLocation)) {
$ret = FALSE;
$errors = libxml_get_errors();
foreach ($errors as $err) {
self::$errors[] = 'XML Error: Line ' . $err->line . ': ' . $err->message;
}
}
else {
$this->name = $rootEl->attributes->getNamedItem('name')->nodeValue;
}
}
else {
$ret = FALSE;
self::$errors[] = 'Unable to load schema.';
}
$this->valid = $ret;
}
return $this->valid;
}
} }

28
islandora_basic_collection/includes/DeleteCollection.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* DeleteCollection.inc
*/
/** /**
* *
* @param array $form_state * @param array $form_state
@ -12,10 +17,15 @@ function islandora_collection_deletion_form($form, &$form_state, $pid) {
$potential_collections = get_collections_as_option_array(); $potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid); $table = islandora_collection_table($pid);
$deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection"; $deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection";
$submit_text_message = ($table) ? "Delete Selected Objects" : "Delete Collection"; $submit_text_message = ($table) ? "Delete selected objects" : "Delete collection";
$form = array(); $form = array();
$form['collection_delete']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Delete objects from @collection_pid", array('@collection_pid' => $pid)),
);
if ($table) { if ($table) {
$form['collection_delete']['table'] = array( $form['collection_delete']['table'] = array(
'table' => $table, 'table' => $table,
@ -49,10 +59,10 @@ function islandora_collection_deletion_form($form, &$form_state, $pid) {
function islandora_collection_deletion_form_submit($form, &$form_state) { function islandora_collection_deletion_form_submit($form, &$form_state) {
global $user; global $user;
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$collection_pid = $form_state['values']['current']; $collection_pid = $form_state['values']['current'];
$fedora_object = new FedoraObject($collection_pid, $restConnection->repository); $fedora_object = new FedoraObject($collection_pid, $rest_connection->repository);
$parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection'); $parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection');
$parents = Islandora_collections_get_collection_from_pid($collection_pid); $parents = Islandora_collections_get_collection_from_pid($collection_pid);
$collection_pid = $form_state['values']['current']; $collection_pid = $form_state['values']['current'];
@ -75,18 +85,18 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
} }
} }
if (!empty($populated_child_collections)) { if (!empty($populated_child_collections)) {
$conflict = false; $conflict = FALSE;
foreach ($populated_child_collections as $collection) { foreach ($populated_child_collections as $collection) {
if (in_array($collection, $pids)) { if (in_array($collection, $pids)) {
$conflict = true; $conflict = TRUE;
drupal_set_message("Populated child collections were not deleted."); drupal_set_message(t("Populated child collections were not deleted."));
} }
} }
} }
$pids_to_delete = array_diff($pids, $populated_child_collections); $pids_to_delete = array_diff($pids, $populated_child_collections);
foreach ($pids_to_delete as $pid_to_delete) { foreach ($pids_to_delete as $pid_to_delete) {
$restConnection->repository->purgeObject($pid_to_delete); $rest_connection->repository->purgeObject($pid_to_delete);
} }
drupal_goto("islandora/object/" . $collection_pid); drupal_goto("islandora/object/" . $collection_pid);
} }
@ -94,8 +104,8 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
function delete_root_collection($pid) { function delete_root_collection($pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
try { try {
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$restConnection->repository->purgeObject($pid); $rest_connection->repository->purgeObject($pid);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t("Collection '@pid' could not be deleted!", array('@pid' => $pid)), 'error'); drupal_set_message(t("Collection '@pid' could not be deleted!", array('@pid' => $pid)), 'error');
return; return;

45
islandora_basic_collection/includes/ManagePolicies.inc

@ -1,30 +1,37 @@
<?php <?php
/**
* @file
* ManagePolicies.inc
*/
/**
*
* @param type $form
* @param type $form_state
* @param type $collection_pid
* @return type
*/
function islandora_manage_policies_form($form, &$form_state, $collection_pid) { function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy'); module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$content_models = get_content_models_list($collection_pid); $content_models = get_content_models_list($collection_pid);
$cm_options = array(); $cm_options = array();
$name_mappings = array(); $name_mappings = array();
foreach ($content_models as $content_model) { foreach ($content_models as $content_model) {
if ($content_model != "islandora:collectionCModel") { if ($content_model != "islandora:collectionCModel") {
$item = new FedoraObject($content_model, $restConnection->repository); $item = new FedoraObject($content_model, $rest_connection->repository);
$cm_name = $item->Label; $cm_name = $item->Label;
$cm_options[$content_model] = $cm_name; $cm_options[$content_model] = $cm_name;
} }
} }
$new_options = array();
if (is_array($content_models) && is_array($cm_options)) {
$new_options = array_diff_key($content_models, $cm_options);
}
$namespace = substr($collection_pid, 0, strpos($collection_pid, ":")); $namespace = substr($collection_pid, 0, strpos($collection_pid, ":"));
$collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'); $collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY');
$collection_object = new FedoraObject($collection_pid, $restConnection->repository); $collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_policy_string = $collection_object->getDatastream($collection_policy_dsid); $collection_policy_string = $collection_object->getDatastream($collection_policy_dsid);
$supported_collection_models = array(); $supported_collection_models = array();
@ -50,6 +57,11 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$new_options = array_diff_key($new_content_models, $current_models_in_policy); $new_options = array_diff_key($new_content_models, $current_models_in_policy);
} }
$form['manage_collection_policy']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Manage collection policy for @collection_pid", array('@collection_pid' => $collection_pid)),
);
$form ['manage_collection_policy']['add']['content_model_to_add'] = array( $form ['manage_collection_policy']['add']['content_model_to_add'] = array(
'#title' => "Choose Content Model", '#title' => "Choose Content Model",
'#type' => 'select', '#type' => 'select',
@ -77,7 +89,7 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$form['manage_collection_policy']['add']['submit'] = array( $form['manage_collection_policy']['add']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Add Content Model to Collection Policy'), '#value' => t('Add content model to collection policy'),
'#id' => 'add_cm' '#id' => 'add_cm'
); );
@ -96,10 +108,9 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
'#description' => t("Choose content models to remove from this collection policy."), '#description' => t("Choose content models to remove from this collection policy."),
); );
$form['manage_collection_policy']['remove']['submit'] = array( $form['manage_collection_policy']['remove']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Remove Content Model From Collection Policy'), '#value' => t('Remove content model from collection policy'),
'#id' => 'remove_cm' '#id' => 'remove_cm'
); );
} }
@ -111,12 +122,11 @@ function islandora_manage_policies_form_validate($form, &$form_state) {
} }
function islandora_manage_policies_form_submit($form, &$form_state) { function islandora_manage_policies_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora_basic_collection', 'CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$collection_pid = $form_state['values']['parent_collection']; $collection_pid = $form_state['values']['parent_collection'];
$collection_object = new FedoraObject($collection_pid, $restConnection->repository); $collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$policy = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); $policy = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$collection_policy = '<?xml version="1.0" encoding="UTF-8"?> $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"> <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">
@ -143,7 +153,7 @@ function islandora_manage_policies_form_submit($form, &$form_state) {
$cp_namespace = $form_state['values']['new_cp_namespace']; $cp_namespace = $form_state['values']['new_cp_namespace'];
$cp_content_model = $form_state['values']['content_model_to_add']; $cp_content_model = $form_state['values']['content_model_to_add'];
$content_model_object = new FedoraObject($cp_content_model, $restConnection->repository); $content_model_object = new FedoraObject($cp_content_model, $rest_connection->repository);
$content_model_datastream = $content_model_object->getDatastream(variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM')); $content_model_datastream = $content_model_object->getDatastream(variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM'));
$content_models_element = $collection_policy_xml->getElementsByTagName('content_models'); $content_models_element = $collection_policy_xml->getElementsByTagName('content_models');
@ -160,7 +170,7 @@ function islandora_manage_policies_form_submit($form, &$form_state) {
$new_collection_policy_datastream->setContentFromString($collection_policy_xml->saveXML()); $new_collection_policy_datastream->setContentFromString($collection_policy_xml->saveXML());
$new_collection_policy_datastream->label = 'COLLECTION_POLICY'; $new_collection_policy_datastream->label = 'COLLECTION_POLICY';
$collection_object->ingestDatastream($new_collection_policy_datastream); $collection_object->ingestDatastream($new_collection_policy_datastream);
drupal_set_message("Collection model successfully added"); drupal_set_message(t("Collection model @model successfully added", array('@model' => $content_model_object->label)));
} }
//remove content model from collection policy //remove content model from collection policy
@ -170,7 +180,6 @@ function islandora_manage_policies_form_submit($form, &$form_state) {
$s = ''; $s = '';
foreach ($candidates as $candidate) { foreach ($candidates as $candidate) {
if (is_string($candidate)) { if (is_string($candidate)) {
$content_models_element = $collection_policy_xml->getElementsByTagName('content_models'); $content_models_element = $collection_policy_xml->getElementsByTagName('content_models');
$models = $content_models_element->item(0)->getElementsByTagName('content_model'); $models = $content_models_element->item(0)->getElementsByTagName('content_model');
$found = FALSE; $found = FALSE;
@ -195,7 +204,7 @@ function islandora_manage_policies_form_submit($form, &$form_state) {
if ($count > 1) { if ($count > 1) {
$s = 's'; $s = 's';
} }
drupal_set_message("$count collection model$s removed"); drupal_set_message(t("$count collection model@s removed", array('@s' => $s)));
} }
} }
} }

16
islandora_basic_collection/includes/MoveCollection.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
* MoveCollection.inc
*/
/** /**
* *
* @param array $form_state * @param array $form_state
@ -16,9 +21,14 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
} }
$form = array(); $form = array();
$form['migrate']['titlebox'] = array(
'#type' => 'item',
'#title' => t("Move objects from @collection_pid", array('@collection_pid' => $pid)),
);
$form['migrate']['new_collection'] = array( $form['migrate']['new_collection'] = array(
'#title' => t('New Collection'), '#title' => t('New Collection'),
'#description' => t("All content will be migrated from $pid to the selected collection"), '#description' => t("All content will be migrated from @pid to the selected collection", array('@pid' => $pid)),
'#type' => 'select', '#type' => 'select',
'#options' => $potential_collections, '#options' => $potential_collections,
); );
@ -44,13 +54,13 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
function islandora_collection_migrate_form_submit($form, &$form_state) { function islandora_collection_migrate_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection(); $rest_connection = new RestConnection();
$pids = array_filter($form_state['values']['table']); $pids = array_filter($form_state['values']['table']);
$new_collection = $form_state['values']['new_collection']; $new_collection = $form_state['values']['new_collection'];
$current = $form_state['values']['current']; $current = $form_state['values']['current'];
foreach ($pids as $pid) { foreach ($pids as $pid) {
$fedora_object = new FedoraObject($pid, $restConnection->repository); $fedora_object = new FedoraObject($pid, $rest_connection->repository);
$fedora_object->relationships->remove(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $current); $fedora_object->relationships->remove(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $current);
$fedora_object->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $new_collection); $fedora_object->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $new_collection);
} }

59
islandora_basic_collection/islandora_basic_collection.install

@ -1,95 +1,94 @@
<?php <?php
/** /**
* @file islandora_basic_collection.install * @file
* islandora_basic_collection.install
*/ */
function islandora_basic_collection_install() { function islandora_basic_collection_install() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; global $user;
global $base_root; global $base_root;
try { try {
$restConnection = new RestConnection($user); $rest_connection = new RestConnection($user);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return; return;
} }
$content_model_query = $restConnection->api->a->findObjects('query', 'pid=islandora:collectionCModel'); $content_model_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:collectionCModel');
if (empty($content_model_query['results'])) { if (empty($content_model_query['results'])) {
try { try {
$xml = file_get_contents(drupal_get_path('module', 'islandora_basic_collection') . '/xml/islandora_collection_CModel.xml'); $xml = file_get_contents(drupal_get_path('module', 'islandora_basic_collection') . '/xml/islandora_collection_CModel.xml');
$restConnection->api->m->ingest(array('string' => $xml)); $rest_connection->api->m->ingest(array('string' => $xml));
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to install content models %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to install content models %e', array('%e' => $e)), 'error');
return; return;
} }
drupal_set_message(t('Content models installed!')); drupal_set_message(st('Content models installed!'));
} }
else { else {
drupal_set_message(t('Content models already exist!'), 'warning'); drupal_set_message(st('Content models already exist!'), 'warning');
} }
$collection_query = $restConnection->api->a->findObjects('query', 'pid=islandora:root'); $collection_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:root');
if (empty($collection_query['results'])) { if (empty($collection_query['results'])) {
try { try {
$xml = file_get_contents(drupal_get_path('module', 'islandora_basic_collection') . '/xml/islandora_root_collection.xml'); $xml = file_get_contents(drupal_get_path('module', 'islandora_basic_collection') . '/xml/islandora_root_collection.xml');
$restConnection->api->m->ingest(array('string' => $xml)); $rest_connection->api->m->ingest(array('string' => $xml));
$fedora_object = new FedoraObject('islandora:root', $restConnection->repository); $fedora_object = new FedoraObject('islandora:root', $rest_connection->repository);
$datastream = new NewFedoraDatastream('TN', 'M', $fedora_object, $restConnection->repository); $datastream = new NewFedoraDatastream('TN', 'M', $fedora_object, $rest_connection->repository);
$file_path = $base_root . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png'; $file_path = $base_root . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png';
$datastream->label = 'Thumbnail'; $datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png'; $datastream->mimetype = 'image/png';
$datastream->setContentFromUrl($file_path); $datastream->setContentFromUrl($file_path);
$fedora_object->ingestDatastream($datastream); $fedora_object->ingestDatastream($datastream);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to install collections %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to install collections %e', array('%e' => $e)), 'error');
return; return;
} }
drupal_set_message(t('Collections installed!')); drupal_set_message(st('Collections installed!'));
} }
else { else {
drupal_set_message(t('Collections already exist!'), 'warning'); drupal_set_message(st('Collections already exist!'), 'warning');
} }
} }
function islandora_basic_collection_uninstall() { function islandora_basic_collection_uninstall() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; global $user;
try { try {
$restConnection = new RestConnection($user); $rest_connection = new RestConnection($user);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return; return;
} }
$content_model_query = $restConnection->api->a->findObjects('query', 'pid=islandora:collectionCModel'); $content_model_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:collectionCModel');
if (!empty($content_model_query['results'])) { if (!empty($content_model_query['results'])) {
try { try {
$restConnection->repository->purgeObject('islandora:collectionCModel'); $rest_connection->repository->purgeObject('islandora:collectionCModel');
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to purge content models %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to purge content models %e', array('%e' => $e)), 'error');
return; return;
} }
drupal_set_message(t('Content models purged!')); drupal_set_message(st('Content models purged!'));
} }
else { else {
drupal_set_message(t('Content models don\'t exist!'), 'warning'); drupal_set_message(st('Content models don\'t exist!'), 'warning');
} }
$collection_query = $restConnection->api->a->findObjects('query', 'pid=islandora:root'); $collection_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:root');
if (!empty($collection_query['results'])) { if (!empty($collection_query['results'])) {
try { try {
$restConnection->repository->purgeObject('islandora:root'); $rest_connection->repository->purgeObject('islandora:root');
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to purge collections %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to purge collections %e', array('%e' => $e)), 'error');
return; return;
} }
drupal_set_message(t('Collections purged!')); drupal_set_message(st('Collections purged!'));
} }
else { else {
drupal_set_message(t('Collections don\'t exist!'), 'warning'); drupal_set_message(st('Collections don\'t exist!'), 'warning');
} }
} }

10
islandora_basic_collection/islandora_basic_collection.module

@ -1,7 +1,8 @@
<?php <?php
/* /*
* @file islandora_basic_image.module * @file
* islandora_basic_collection.module
* *
* an Islandora module to handle basic image cmodels * an Islandora module to handle basic image cmodels
* *
@ -23,7 +24,7 @@
*/ */
/** /**
* Implementation of hook_menu. * Implements hook_menu().
* we need some standard entry points so we can have consistent urls for different Object actions * we need some standard entry points so we can have consistent urls for different Object actions
*/ */
function islandora_basic_collection_menu() { function islandora_basic_collection_menu() {
@ -73,6 +74,7 @@ function islandora_basic_collection_manage_object($object_id) {
module_load_include('inc', 'islandora_basic_collection', 'includes/MoveCollection'); module_load_include('inc', 'islandora_basic_collection', 'includes/MoveCollection');
module_load_include('inc', 'islandora_basic_collection', 'includes/ChildCollection'); module_load_include('inc', 'islandora_basic_collection', 'includes/ChildCollection');
module_load_include('inc', 'islandora_basic_collection', 'includes/ManagePolicies'); module_load_include('inc', 'islandora_basic_collection', 'includes/ManagePolicies');
module_load_include('inc', 'islandora_basic_collection', 'includes/ChangeContentModels');
$form = array(); $form = array();
@ -105,9 +107,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$form['collection_manager']['change_content_models']['form'] = array( $form['collection_manager']['change_content_models']['form'] = drupal_get_form('islandora_change_content_models_form', $object_id);
// '#content' => drupal_get_form($form_id),
);
$form['collection_manager']['migrate_members'] = array( $form['collection_manager']['migrate_members'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',

Loading…
Cancel
Save