Browse Source

broken?

pull/3/merge
Nigel Banks 14 years ago
parent
commit
4e6dad81a4
  1. 108
      fedora_repository.module
  2. 4
      formClass.inc

108
fedora_repository.module

@ -119,52 +119,52 @@ 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')) { if ($form_state['storage']['xml']) {
module_load_include('inc', 'xml_form_api', 'XMLForm'); module_load_include('inc', 'xml_form_api', 'XMLForm');
$form = new XMLForm($form_state); $xml_form = new XMLForm($form_state);
$doc = $form->submit($drupal_form, $form_state); if ($xml_form->isInitialized()) {
$document = $doc->document; $doc = $form->submit($drupal_form, $form_state);
dom_document_pretty_print($document); $document = $doc->document;
exit(); dom_document_pretty_print($document);
exit();
}
} }
else { 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'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'ContentModel');
$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']); $err = TRUE;
$err = TRUE; $redirect = TRUE;
$redirect = TRUE; if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) {
if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) { $relationship = $cp->getRelationship();
$relationship = $cp->getRelationship();
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) {
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { $pid = $cp->getNextPid($contentModelDsid);
$pid = $cp->getNextPid($contentModelDsid); global $user;
global $user; $form_state['values']['user_id'] = $user->name;
$form_state['values']['user_id'] = $user->name; $form_state['values']['pid'] = $pid;
$form_state['values']['pid'] = $pid; $form_state['values']['content_model_pid'] = $contentModelPid;
$form_state['values']['content_model_pid'] = $contentModelPid; $form_state['values']['relationship'] = $relationship;
$form_state['values']['relationship'] = $relationship;
$err = (!$cm->execFormHandler($form_state['values'], $form_state));
$err = (!$cm->execFormHandler($form_state['values'], $form_state));
$_SESSION['fedora_ingest_files'] = ''; //empty this variable
$_SESSION['fedora_ingest_files'] = ''; //empty this variable
$attr = $cm->getIngestFormAttributes();
$attr = $cm->getIngestFormAttributes(); $redirect = $attr['redirect'];
$redirect = $attr['redirect'];
if ($redirect) {
if ($redirect) { $form_state['storage'] = NULL;
$form_state['storage'] = NULL;
}
} }
} }
}
if ($redirect) { if ($redirect) {
$form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; $form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}";
}
} }
} }
} }
@ -180,7 +180,7 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
case 2: case 2:
// XML based form. // XML based form.
if (module_exists('xml_form_api')) { if ($form_state['storage']['xml']) {
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);
$xml_form->validate($form, $form_state); $xml_form->validate($form, $form_state);
@ -618,9 +618,16 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
} }
function fedora_repository_edit_qdc_form_validate($form, &$form_state) { function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
if (isset($form_state['storage']['step']) && $form_state['storage']['step'] == 1) { if (isset($form_state['storage']['step'])) {
$form_state['storage']['step']++; if ($form_state['storage']['step'] == 1) {
$form_state['rebuild'] = TRUE; $form_state['storage']['step']++;
$form_state['rebuild'] = TRUE;
}
else {
module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state);
$xml_form->validate($form, $form_state);
}
} }
} }
@ -634,8 +641,15 @@ function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
* @return * @return
*/ */
function fedora_repository_edit_qdc_form_submit($form, &$form_state) { function fedora_repository_edit_qdc_form_submit($form, &$form_state) {
if (true) { if ($form_state['storage']['xml']) {
module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state);
if ($xml_form->isInitialized()) {
$doc = $form->submit($drupal_form, $form_state);
$document = $doc->document;
dom_document_pretty_print($document);
exit();
}
} }
else { else {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');

4
formClass.inc

@ -502,6 +502,8 @@ class formClass {
$form_names = islandora_content_model_get_form_names($contentModels[0]->pid); $form_names = islandora_content_model_get_form_names($contentModels[0]->pid);
} }
$form_state['storage']['xml'] = false;
switch ($form_state['storage']['step']) { switch ($form_state['storage']['step']) {
case 1: case 1:
$form['indicator'] = array( $form['indicator'] = array(
@ -535,6 +537,7 @@ class formClass {
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()) {
$form_state['storage']['xml'] = true;
if (!$xml_form->isInitialized()) { if (!$xml_form->isInitialized()) {
module_load_include('inc', 'xml_form_api', 'XMLFormDefinition'); module_load_include('inc', 'xml_form_api', 'XMLFormDefinition');
module_load_include('inc', 'xml_form_builder', 'FormBuilder'); module_load_include('inc', 'xml_form_builder', 'FormBuilder');
@ -749,6 +752,7 @@ class formClass {
$document = new XMLDocument($properties['document']['root'], $properties['document']['namespaces'], $properties['document']['schema'], $xml); $document = new XMLDocument($properties['document']['root'], $properties['document']['namespaces'], $properties['document']['schema'], $xml);
$xml_form->initialize($form, $document); $xml_form->initialize($form, $document);
} }
$form_state['storage']['xml'] = true;
return $xml_form->toArray(); return $xml_form->toArray();
} }
break; break;

Loading…
Cancel
Save