Browse Source

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

pull/125/merge
Paul Pound 13 years ago
parent
commit
f19aa53095
  1. 13
      admin/islandora.admin.inc
  2. 50
      includes/utilities.inc
  3. 1
      islandora.info
  4. 8
      islandora_basic_collection/includes/change_content_models.inc
  5. 19
      islandora_basic_collection/includes/child_collection.inc
  6. 4
      islandora_basic_collection/includes/collection_management.inc
  7. 6
      islandora_basic_collection/includes/delete_collection.inc
  8. 4
      islandora_basic_collection/includes/manage_policies.inc
  9. 3
      islandora_basic_collection/includes/move_collection.inc
  10. 1
      islandora_basic_collection/islandora_basic_collection.info
  11. 1
      islandora_basic_image/islandora_basic_image.info

13
admin/islandora.admin.inc

@ -8,6 +8,7 @@
function islandora_repository_admin($form, &$form_state) { function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/tuque'); module_load_include('inc', 'islandora', 'includes/tuque');
module_load_include('inc', 'islandora', 'includes/utilities');
if (!IslandoraTuque::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'))); $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')));
@ -24,16 +25,10 @@ function islandora_repository_admin($form, &$form_state) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
} }
$connection = new IslandoraTuque(NULL, $url); // Connect to Fedora
try { $info = islandora_describe_repository($url);
$info = $connection->api->a->describeRepository();
$connected = TRUE;
}
catch (RepositoryException $e) {
$connected = FALSE;
}
if($connected) { if($info) {
$confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>' $confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
. t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion'])); . t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
} }

50
includes/utilities.inc

@ -46,3 +46,53 @@ function islandora_control_group_to_human_readable($control_group) {
return $control_group; return $control_group;
} }
} }
/**
* valid pid ??
* @param type $pid
* @return boolean
*/
function islandora_validate_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;
}
/**
* Valid Dsid ??
* @param type $dsid
* @return boolean
*/
function islandora_validate_dsid($dsid) {
$valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
$valid = TRUE;
}
return $valid;
}
/* Helper function to describe a Fedora repository.
*
* Can be used to check if Fedora is available.
*
* @param $url
* A url to a Fedora repository.
* @return
* Returns an array describing the repository. Returns FALSE if Fedora is down
* or if the url is incorrect.
*/
function islandora_describe_repository($url) {
$connection = new IslandoraTuque(NULL, $url);
try {
$info = $connection->api->a->describeRepository();
return $info;
}
catch (RepositoryException $e) {
return FALSE;
}
}

1
islandora.info

@ -3,5 +3,6 @@ description = "View and manage Fedora objects"
package = Islandora package = Islandora
version = 7.x-dev version = 7.x-dev
core = 7.x core = 7.x
configure = admin/islandora/configure
stylesheets[all][] = css/islandora.base.css stylesheets[all][] = css/islandora.base.css
stylesheets[all][] = css/islandora.theme.css stylesheets[all][] = css/islandora.theme.css

8
islandora_basic_collection/includes/change_content_models.inc

@ -86,7 +86,7 @@ function islandora_change_content_models_form_submit($form, &$form_state) {
$collection_pid = $form_state['values']['collection_pid']; $collection_pid = $form_state['values']['collection_pid'];
$current_content_model_object = islandora_object_load($current_content_model); $current_content_model_object = islandora_object_load($current_content_model);
$collection_object = islandora_load_object($form_state['values']['collection_pid']); $collection_object = islandora_object_load($form_state['values']['collection_pid']);
$collection_policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); $collection_policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$policy = new CollectionPolicy($collection_policy_datastream->content); $policy = new CollectionPolicy($collection_policy_datastream->content);
@ -105,7 +105,7 @@ function islandora_change_content_models_form_submit($form, &$form_state) {
} }
} }
if ($add_to_policy) { if ($add_to_policy) {
$new_content_model_object = new FedoraObject($new_content_model, $rest_connection->repository); $new_content_model_object = islandora_object_load($new_content_model);
$new_content_model_datastream = $new_content_model_object->getDatastream(variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM')); $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_models_element = $collection_policy_xml->getElementsByTagName('content_models');
$content_model_element = $content_models_element->item(0)->getElementsByTagName('content_model'); $content_model_element = $content_models_element->item(0)->getElementsByTagName('content_model');
@ -129,14 +129,14 @@ function islandora_change_content_models_form_submit($form, &$form_state) {
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <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>)"; and \$object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)";
$objects = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $objects = $collection_object->repository->ri->itqlQuery($query, 'unlimited', '0');
$count = 0; $count = 0;
foreach ($objects as $object) { foreach ($objects as $object) {
if (!$object['object']['value']) { if (!$object['object']['value']) {
continue; continue;
} }
$fedora_item = new FedoraObject($object['object']['value'], $rest_connection->repository); $fedora_item = islandora_object_load($object['object']['value']);
$fedora_item->relationships->remove(FEDORA_MODEL_URI, 'hasModel', $current_content_model); $fedora_item->relationships->remove(FEDORA_MODEL_URI, 'hasModel', $current_content_model);
$fedora_item->relationships->add(FEDORA_MODEL_URI, 'hasModel', $new_content_model); $fedora_item->relationships->add(FEDORA_MODEL_URI, 'hasModel', $new_content_model);
$count++; $count++;

19
islandora_basic_collection/includes/child_collection.inc

@ -119,7 +119,20 @@ function islandora_create_child_collection_form($form, &$form_state, $collection
} }
function islandora_create_child_collection_form_validate($form, &$form_state) { function islandora_create_child_collection_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/utilities');
$new_collection_pid = $form_state['values']['new_collection_pid'];
if($new_collection_pid) {
$valid = islandora_validate_pid($new_collection_pid);
if(!$valid) {
form_set_error('new_collection_pid', 'Collection PID is Invalid.');
}
else {
$object = islandora_object_load($new_collection_pid);
if($object !== NULL) {
form_set_error('new_collection_pid', 'Collection PID already exists.');
}
}
}
} }
/** /**
@ -136,7 +149,7 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
$new_collection_pid = $form_state['values']['new_collection_pid']; $new_collection_pid = $form_state['values']['new_collection_pid'];
$this_collection_pid = $form_state['values']['current']; $this_collection_pid = $form_state['values']['current'];
if(empty($new_collection_pid)) { if(empty($new_collection_pid)) {
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":")); $new_collection_pid = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
} }
$new_collection_label = $form_state['values']['collection_name']; $new_collection_label = $form_state['values']['collection_name'];
$namespace = $form_state['values']['collection_namespace']; $namespace = $form_state['values']['collection_namespace'];
@ -185,5 +198,5 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
$fedora_object->ingestDatastream($policy_datastream); $fedora_object->ingestDatastream($policy_datastream);
$new_fedora_object = islandora_ingest_add_object($fedora_object); $new_fedora_object = islandora_ingest_add_object($fedora_object);
drupal_goto('/islandora/object/' . $new_collection_pid); drupal_goto('/islandora/object/' . $fedora_object->id);
} }

4
islandora_basic_collection/includes/collection_management.inc

@ -37,7 +37,7 @@ function get_child_collections($object) {
$query = <<<EOD $query = <<<EOD
select \$object from <#ri> select \$object from <#ri>
where \$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> 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> and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$object->id>
EOD; EOD;
$lines = $object->repository->ri->itqlQuery($query, 'unlimited', '0'); $lines = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
@ -49,7 +49,7 @@ function islandora_collections_get_collection_from_pid($object) {
$query = 'select $parent from <#ri> $query = 'select $parent from <#ri>
where ($object <fedora-rels-ext:isMemberOf> $parent where ($object <fedora-rels-ext:isMemberOf> $parent
or $object <fedora-rels-ext:isMemberOfCollection> $parent) or $object <fedora-rels-ext:isMemberOfCollection> $parent)
and $object <dc:identifier> \'' . $pid . '\' and $object <dc:identifier> \'' . $object->id . '\'
order by $object'; order by $object';
$object_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0'); $object_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0');

6
islandora_basic_collection/includes/delete_collection.inc

@ -67,7 +67,7 @@ function islandora_collection_deletion_form($form, &$form_state, $object) {
function islandora_collection_deletion_form_submit($form, &$form_state) { function islandora_collection_deletion_form_submit($form, &$form_state) {
$collection_pid = $form_state['values']['current']; $collection_pid = $form_state['values']['current'];
$fedora_object = islandora_object_load($collection_object); $fedora_object = islandora_object_load($collection_pid);
$parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection'); $parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection');
$parents = islandora_collections_get_collection_from_pid($fedora_object); $parents = islandora_collections_get_collection_from_pid($fedora_object);
@ -77,14 +77,14 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
drupal_goto("islandora/object/" . $parents[0]['parent']['value']); drupal_goto("islandora/object/" . $parents[0]['parent']['value']);
} }
$child_collections = get_child_collections($collection_pid); $child_collections = get_child_collections($fedora_object);
$populated_child_collections = array(); $populated_child_collections = array();
$pids = @array_filter($form_state['values']['table']); $pids = @array_filter($form_state['values']['table']);
if (!empty($child_collections)) { if (!empty($child_collections)) {
foreach ($child_collections as $child) { foreach ($child_collections as $child) {
$child_pids = get_related_items_as_array(islandora_object_load($child), 'isMemberOfCollection'); $child_pids = get_related_items_as_array(islandora_object_load($child['object']['value']), 'isMemberOfCollection');
if (!empty($child_pids)) { if (!empty($child_pids)) {
$populated_child_collections[] = $child; $populated_child_collections[] = $child;
} }

4
islandora_basic_collection/includes/manage_policies.inc

@ -137,6 +137,7 @@ function islandora_manage_policies_form_validate($form, &$form_state) {
* @param array $form_state * @param array $form_state
*/ */
function islandora_manage_policies_form_submit($form, &$form_state) { function islandora_manage_policies_form_submit($form, &$form_state) {
module_load_include('module', 'islandora', 'islandora');
$collection_pid = $form_state['values']['parent_collection']; $collection_pid = $form_state['values']['parent_collection'];
$collection_object = islandora_object_load($collection_pid); $collection_object = islandora_object_load($collection_pid);
@ -166,7 +167,8 @@ 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, $rest_connection->repository);
$content_model_object = islandora_object_load($cp_content_model);
$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');

3
islandora_basic_collection/includes/move_collection.inc

@ -64,7 +64,6 @@ function islandora_collection_migrate_form($form, &$form_state, $object) {
* @param array $form_state * @param array $form_state
*/ */
function islandora_collection_migrate_form_submit($form, &$form_state) { function islandora_collection_migrate_form_submit($form, &$form_state) {
$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'];
@ -73,4 +72,6 @@ function islandora_collection_migrate_form_submit($form, &$form_state) {
$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);
} }
drupal_set_message("@count objects successfully migrated!", array('@count' => count($pids)));
} }

1
islandora_basic_collection/islandora_basic_collection.info

@ -3,5 +3,6 @@ description = "A default Islandora Repository module to handle simple collection
dependencies[] = islandora dependencies[] = islandora
package = Islandora package = Islandora
core = 7.x core = 7.x
configure = admin/islandora/basic_collection
stylesheets[all][] = css/islandora_basic_collection.base.css stylesheets[all][] = css/islandora_basic_collection.base.css
stylesheets[all][] = css/islandora_basic_collection.theme.css stylesheets[all][] = css/islandora_basic_collection.theme.css

1
islandora_basic_image/islandora_basic_image.info

@ -3,5 +3,6 @@ description = "A default Islandora Repository module to handle images"
dependencies[] = islandora dependencies[] = islandora
package = Islandora package = Islandora
core = 7.x core = 7.x
configure = admin/islandora/basic_image
stylesheets[all][] = css/islandora_basic_image.base.css stylesheets[all][] = css/islandora_basic_image.base.css
stylesheets[all][] = css/islandora_basic_image.theme.css stylesheets[all][] = css/islandora_basic_image.theme.css
Loading…
Cancel
Save