From 0f34fcde21ec88b6df5422a1d1ee21e9cd3344ae Mon Sep 17 00:00:00 2001 From: William Panting Date: Mon, 10 Sep 2012 13:23:45 -0300 Subject: [PATCH] ISLANDORA-743 added the hook: postprocess_solution_pack and some style clean up --- fedora_repository.solutionpacks.inc | 72 +++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index b6c40412..10f5b3b5 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -2,24 +2,36 @@ /** * @file - * Invokes a hook to any dependent modules asking them if their installations require - * any fedora objects to be present. Modules implementing this hook should return an array + * Invokes a hook to any dependent modules asking them if their + * installations require any fedora objects to be present. + * Modules implementing this hook should return an array * of arrays of the form: * - * array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion) + * array( 'pid', 'path-to-foxml-file', + * 'dsid', + * 'path-to-datastream-file', + * int dsversion) * - * where the last three options are optional. A module can either point to a simple - * foxml file to install, or can specify a datastreamstream to check for, with a - * path to load the datastream from if it isn't there. Optionally a version number - * can be included, to enable updating of content model or collection policy streams - * that may have been updated. THis is a simple whole number that should be incremented - * when changed. This value appears in as an attribute of the topmost element of the stream, + * where the last three options are optional. + * A module can either point to a simple foxml file to install, + * or can specify a datastreamstream to check for, with a + * path to load the datastream from if it isn't there. + * Optionally a version number can be included, + * to enable updating of content model or collection policy streams + * that may have been updated. + * This is a simple whole number that should be incremented when changed. + * This value appears in as an attribute of the topmost element of the stream, * e.g.,: * - * + * 'hidden', '#value' => $solution_pack_module, @@ -161,14 +175,20 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul return $form; } +/** + * Submit handler for solution pack form. + * + * @param array $form + * The form submitted. + * @param array_reference $form_state + * The state of the form submited. + */ function fedora_repository_solution_pack_form_submit($form, &$form_state) { - $what = $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'); - + $batch = array( 'title' => t('Installing / updating solution pack objects'), 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', @@ -180,9 +200,20 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) { // Add this object to the batch job queue. $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); } + batch_set($batch); + + // Hook to let solution pack objects be modified. + // Not using module_invoke so solution packs can be expanded by other modules. + module_invoke_all('postprocess_solution_pack', $module_name); + } +/** + * + * @param unknown_type $form_name + * @param unknown_type $form_xml + */ function solution_pack_add_form($form_name, $form_xml) { $result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name)); if (!$result) { @@ -194,6 +225,11 @@ function solution_pack_add_form($form_name, $form_xml) { } } +/** + * + * @param unknown_type $content_model + * @param unknown_type $form_name + */ function solution_pack_add_form_association($content_model, $form_name) { $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $form_name)); @@ -205,6 +241,6 @@ function solution_pack_add_form_association($content_model, $form_name) { $object->title_field = "['titleInfo']['title']"; $object->transform = 'mods_to_dc.xsl'; $result = drupal_write_record('islandora_content_model_forms', $object); - drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name"=>$form_name))); + drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name" => $form_name))); } }