|
|
|
@ -211,34 +211,43 @@ function solution_pack_register_form($mods_form_name, $mods_form_file, $content_
|
|
|
|
|
{ |
|
|
|
|
// Load the form builder database |
|
|
|
|
module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); |
|
|
|
|
|
|
|
|
|
// Load the form |
|
|
|
|
$definition = new DOMDocument(); |
|
|
|
|
$definition->load($mods_form_file); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If it doesn't exist |
|
|
|
|
if (!XMLFormDatabase::Exists($mods_form_name) ) { |
|
|
|
|
|
|
|
|
|
// Load the form |
|
|
|
|
$definition = new DOMDocument(); |
|
|
|
|
$definition->load($mods_form_file); |
|
|
|
|
|
|
|
|
|
// Create the form |
|
|
|
|
XMLFormDatabase::Create($mods_form_name, $definition); |
|
|
|
|
|
|
|
|
|
// Force Update of an existing form |
|
|
|
|
} elseif ( $force == true ) { |
|
|
|
|
|
|
|
|
|
// Load the form |
|
|
|
|
$definition = new DOMDocument(); |
|
|
|
|
$definition->load($mods_form_file); |
|
|
|
|
|
|
|
|
|
// Update the form |
|
|
|
|
XMLFormDatabase::Update($mods_form_name, $definition); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Associates the form with the content model |
|
|
|
|
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); |
|
|
|
|
// Check to see if the form has already been registered |
|
|
|
|
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); |
|
|
|
|
|
|
|
|
|
// Check for results |
|
|
|
|
if (!$result) { |
|
|
|
|
|
|
|
|
|
// Create a model for the database |
|
|
|
|
$object = new stdClass(); |
|
|
|
|
$object->content_model = $content_model; |
|
|
|
|
$object->form_name = $mods_form_name; |
|
|
|
|
$object->dsid = 'MODS'; |
|
|
|
|
$object->title_field = "['titleInfo']['title']"; |
|
|
|
|
$object->transform = 'mods_to_dc.xsl'; |
|
|
|
|
|
|
|
|
|
// Write the association |
|
|
|
|
$result = drupal_write_record('islandora_content_model_forms', $object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -250,15 +259,23 @@ function solution_pack_register_form($mods_form_name, $mods_form_file, $content_
|
|
|
|
|
*/ |
|
|
|
|
function solution_pack_unregister_form($mods_form_name, $content_model) |
|
|
|
|
{ |
|
|
|
|
// Load the form builders xmlformdatabase |
|
|
|
|
module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); |
|
|
|
|
|
|
|
|
|
// Check to see if the form exists |
|
|
|
|
if (XMLFormDatabase::Exists($mods_form_name)) { |
|
|
|
|
|
|
|
|
|
// Delete the form |
|
|
|
|
XMLFormDatabase::Delete($mods_form_name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check to see if the form has already been registered |
|
|
|
|
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); |
|
|
|
|
|
|
|
|
|
if (!$result) { |
|
|
|
|
|
|
|
|
|
// Is there anything to delete |
|
|
|
|
if ($result) { |
|
|
|
|
|
|
|
|
|
// Delete the association |
|
|
|
|
db_query('DELETE FROM {islandora_content_model_forms} WHERE content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|