Browse Source

Use hook mechanism and improve version acquisition

pull/95/head
Adam Vessey 13 years ago
parent
commit
1c48ace390
  1. 17
      fedora_repository.module
  2. 5
      fedora_repository.solutionpacks.inc

17
fedora_repository.module

@ -2178,7 +2178,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file);
if ($new_item->exists()) { if ($new_item->exists()) {
// Batch operation was successful; can still add additional DSs, though // Batch operation was successful; can still add additional DSs, though
$context['message'][] = "{$new_item->pid} installed."; $context['message'][] = t('%pid installed.', array('%pid' => $new_item->pid));
} }
} }
@ -2238,22 +2238,17 @@ function fedora_repository_batch_reingest_object($object, &$context) {
*/ */
function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) {
$return = NULL; $return = NULL;
if (isset($item)) { if (!empty($item) && !empty($dsid)) {
$doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); $doc = simplexml_load_string($item->get_datastream_dissemination($dsid));
} }
elseif (isset($datastream_file)) { elseif (!empty($datastream_file)) {
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }
if (!empty($doc)) { if (!empty($doc) && $version = (int)$doc->attributes()->version) {
$attrs = $doc->attributes(); $return = $version;
foreach ($attrs as $name => $value) {
if ($name == 'version') {
$return = (int) $value;
break;
}
}
} }
return $return; return $return;
} }

5
fedora_repository.solutionpacks.inc

@ -114,6 +114,7 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
// Check if the datastream is versioned and needs updating. // Check if the datastream is versioned and needs updating.
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']);
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']);
if ($available_version > $installed_version) { if ($available_version > $installed_version) {
$needs_update = TRUE; $needs_update = TRUE;
$object_status = 'Out of date'; $object_status = 'Out of date';
@ -165,8 +166,8 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$module_name = $form_state['values']['solution_pack_module']; $module_name = $form_state['values']['solution_pack_module'];
// This should be replaced with module_invoke // This should be replaced with module_invoke
$solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); //$solution_pack_info = call_user_func($module_name . '_required_fedora_objects');
//$solution_pack_info = module_invoke($module_name, 'required_fedora_objects'); $solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array( $batch = array(
'title' => t('Installing / updating solution pack objects'), 'title' => t('Installing / updating solution pack objects'),

Loading…
Cancel
Save