Browse Source

Added hooks for processing XMLBased form's during ingestion

pull/3/merge
Nigel Banks 14 years ago
parent
commit
3c4de73302
  1. 36
      fedora_repository.module
  2. 5
      formClass.inc

36
fedora_repository.module

@ -22,8 +22,6 @@ function fedora_repository_admin() {
return $adminForm->createAdminForm(); return $adminForm->createAdminForm();
} }
/** /**
* drupal hook * drupal hook
* calls the fedora_repositorys_admin form * calls the fedora_repositorys_admin form
@ -55,8 +53,7 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); drupal_set_message(t('You must specify an object pid to purge an object.'), 'error');
return ''; return '';
} }
$output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', array(
array(
'%name' => $name, '%name' => $name,
'%pid' => $pid) '%pid' => $pid)
); );
@ -122,6 +119,15 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
function fedora_repository_ingest_form_submit($form, &$form_state) { function fedora_repository_ingest_form_submit($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
if (module_exists('xml_form_api')) {
module_load_include('inc', 'xml_form_api', 'XMLForm');
$form = new XMLForm($form_state);
$doc = $form->submit($drupal_form, $form_state);
$document = $doc->document;
dom_document_pretty_print($document);
exit();
}
else {
if ($form_state['clicked_button']['#id'] == 'edit-submit') { if ($form_state['clicked_button']['#id'] == 'edit-submit') {
global $base_url; global $base_url;
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
@ -161,6 +167,7 @@ function fedora_repository_ingest_form_submit($form, &$form_state) {
} }
} }
} }
}
function fedora_repository_ingest_form_validate($form, &$form_state) { function fedora_repository_ingest_form_validate($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
@ -172,7 +179,12 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
break; break;
case 2: case 2:
// XML based form.
if (module_exists('xml_form_api')) {
module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state);
$xml_form->validate($form, $form_state);
}
// Get the uploaded file. // Get the uploaded file.
$validators = array(); $validators = array();
@ -394,8 +406,7 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL)
return ' '; return ' ';
} }
$output = t('Are you sure you wish to purge this datastream %name<br />', $output = t('Are you sure you wish to purge this datastream %name<br />', array(
array(
'%name' => $name) '%name' => $name)
); );
$output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId);
@ -550,7 +561,6 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat);
$form_state['redirect'] = 'fedora/repository/' . $pid; $form_state['redirect'] = 'fedora/repository/' . $pid;
} }
function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
@ -1180,7 +1190,6 @@ function fedora_repository_theme() {
'arguments' => array( 'arguments' => array(
'element' => NULL 'element' => NULL
), ),
'fedora_repository_solution_packs_list' => array( 'fedora_repository_solution_packs_list' => array(
'arguments' => array( 'arguments' => array(
'solution_packs' => NULL, 'solution_packs' => NULL,
@ -1454,7 +1463,6 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
} }
} }
function fedora_repository_required_fedora_objects() { function fedora_repository_required_fedora_objects() {
// array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required)
$module_path = drupal_get_path('module', 'fedora_repository'); $module_path = drupal_get_path('module', 'fedora_repository');
@ -1939,9 +1947,7 @@ function theme_add_to_basket_link($pid, $type = 'object') {
*/ */
if (!_is_added_to_basket($pid)) { if (!_is_added_to_basket($pid)) {
return l( return l(
theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), "fedora/repository/addToBasket/" . $path, array('html' => TRUE)
"fedora/repository/addToBasket/" . $path,
array('html' => TRUE)
); );
} }
@ -1964,7 +1970,6 @@ function fedora_repository_display_schema($file) {
return; return;
} }
function fedora_repository_batch_reingest_object($object, &$context) { function fedora_repository_batch_reingest_object($object, &$context) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -2037,7 +2042,8 @@ function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid
$return = NULL; $return = NULL;
if (isset($item)) { if (isset($item)) {
$doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); $doc = simplexml_load_string($item->get_datastream_dissemination($dsid));
} elseif (isset($datastream_file)) { }
elseif (isset($datastream_file)) {
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }

5
formClass.inc

@ -531,6 +531,7 @@ class formClass {
$contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']);
$contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']);
// XML Forms // XML Forms
if (module_exists('xml_form_api')) {
module_load_include('inc', 'xml_form_api', 'XMLForm'); module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state); $xml_form = new XMLForm($form_state);
if (isset($form_state['values']['forms']) || $xml_form->isInitialized()) { if (isset($form_state['values']['forms']) || $xml_form->isInitialized()) {
@ -545,9 +546,11 @@ class formClass {
$xml_form->initialize($form, $document); $xml_form->initialize($form, $document);
} }
$form = $xml_form->toArray(); $form = $xml_form->toArray();
break;
}
} }
// End XML forms // End XML forms
else if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) {
$form = $cm->buildIngestForm($form, $form_state); $form = $cm->buildIngestForm($form, $form_state);
if ($form === FALSE) { if ($form === FALSE) {

Loading…
Cancel
Save