Browse Source

Merge pull request #163 from willtp87/ISLANDORA-743

Islandora 743
pull/167/merge
Jonathan Green 12 years ago
parent
commit
25645330c1
  1. 6
      api/fedora_item.inc
  2. 66
      fedora_repository.solutionpacks.inc

6
api/fedora_item.inc

@ -274,10 +274,12 @@ class Fedora_Item {
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = RELS_TYPE_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = RELS_TYPE_URI) {
static $relsextxml = NULL; static $relsextxml = NULL;
if ($relsextxml === NULL) { if ($relsextxml === NULL) {
$relsextxml = new DOMDocument(); //Avoid new instantiations in long-running processes // Avoid new instantiations in long-running processes.
$relsextxml = new DOMDocument();
} }
$ds_list = $this->datastreams; $ds_list = $this->datastreams;
$f_prefix = 'info:fedora/'; $f_prefix = 'info:fedora/';
if (!array_key_exists('RELS-EXT', $ds_list)) { if (!array_key_exists('RELS-EXT', $ds_list)) {
$rdf_string = <<<RDF $rdf_string = <<<RDF
@ -978,6 +980,8 @@ RDF;
'force' => $force 'force' => $force
); );
$this->forget();
// Delete the object // Delete the object
return $this->soap_call('purgeObject', $params); return $this->soap_call('purgeObject', $params);
} }

66
fedora_repository.solutionpacks.inc

@ -2,24 +2,36 @@
/** /**
* @file * @file
* Invokes a hook to any dependent modules asking them if their installations require * Invokes a hook to any dependent modules asking them if their
* any fedora objects to be present. Modules implementing this hook should return an array * installations require any fedora objects to be present.
* Modules implementing this hook should return an array
* of arrays of the form: * 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 * where the last three options are optional.
* foxml file to install, or can specify a datastreamstream to check for, with a * A module can either point to a simple foxml file to install,
* path to load the datastream from if it isn't there. Optionally a version number * or can specify a datastreamstream to check for, with a
* can be included, to enable updating of content model or collection policy streams * path to load the datastream from if it isn't there.
* that may have been updated. THis is a simple whole number that should be incremented * Optionally a version number can be included,
* when changed. This value appears in as an attribute of the topmost element of the stream, * 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.,: * e.g.,:
* *
* <?xml version="1.0" encoding="utf-8"?> <content_model name="Collection" version="2" ... * <?xml version="1.0" encoding="utf-8"?>
* <content_model name="Collection" version="2" ...
* *
* Datastreams which don't have this element are assumed to be at version 0. * Datastreams which don't have this element are assumed to be at version 0.
*/ */
/**
* Builds the tab for the solution packs.
*/
function fedora_repository_solution_packs_page() { function fedora_repository_solution_packs_page() {
$enabled_solution_packs = module_invoke_all('required_fedora_objects'); $enabled_solution_packs = module_invoke_all('required_fedora_objects');
$output = ''; $output = '';
@ -42,7 +54,9 @@ function fedora_repository_solution_packs_page() {
} }
/** /**
* Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. * Check for installed objects and add a 'Update' or 'Install' button if
* some objects are missing.
*
* @param array $solution_pack * @param array $solution_pack
*/ */
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
@ -161,12 +175,18 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
return $form; 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) { function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$what = $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
//$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(
@ -180,9 +200,20 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
// Add this object to the batch job queue. // Add this object to the batch job queue.
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object));
} }
batch_set($batch); 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) { function solution_pack_add_form($form_name, $form_xml) {
$result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name)); $result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name));
if (!$result) { 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) { 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"', $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)); $content_model, $form_name));
@ -205,6 +241,6 @@ function solution_pack_add_form_association($content_model, $form_name) {
$object->title_field = "['titleInfo']['title']"; $object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl'; $object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object); $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)));
} }
} }

Loading…
Cancel
Save