From 1c48ace3900b398b633ce27cb80de7904530f4f2 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 29 Mar 2012 11:24:30 -0300 Subject: [PATCH] Use hook mechanism and improve version acquisition --- fedora_repository.module | 19 +++++++------------ fedora_repository.solutionpacks.inc | 5 +++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index fa4d6e25..18e3bfb5 100644 --- a/fedora_repository.module +++ b/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); if ($new_item->exists()) { // 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) { $return = NULL; - if (isset($item)) { + if (!empty($item) && !empty($dsid)) { $doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); } - elseif (isset($datastream_file)) { + elseif (!empty($datastream_file)) { $doc = simplexml_load_file($datastream_file); } - - if (!empty($doc)) { - $attrs = $doc->attributes(); - foreach ($attrs as $name => $value) { - if ($name == 'version') { - $return = (int) $value; - break; - } - } + + if (!empty($doc) && $version = (int)$doc->attributes()->version) { + $return = $version; } + return $return; } diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index e9cc573e..b6c40412 100644 --- a/fedora_repository.solutionpacks.inc +++ b/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. $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); + if ($available_version > $installed_version) { $needs_update = TRUE; $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']; // This should be replaced with module_invoke - $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); - //$solution_pack_info = module_invoke($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'); $batch = array( 'title' => t('Installing / updating solution pack objects'),