Browse Source

Changed formClass to render the XML Based form if xml_forms is enabled.

pull/3/merge
Nigel Banks 13 years ago
parent
commit
192a15cd3f
  1. 34
      formClass.inc

34
formClass.inc

@ -241,8 +241,7 @@ class formClass {
$form['fedora_repository_url'] = array( $form['fedora_repository_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora RISearch URL'), '#title' => t('Fedora RISearch URL'),
'#default_value' => variable_get('fedora_repository_url', '#default_value' => variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'),
'http://localhost:8080/fedora/risearch'),
'#description' => t('The url of the Fedora server'), '#required' => TRUE, '#description' => t('The url of the Fedora server'), '#required' => TRUE,
'#weight' => 0 '#weight' => 0
); );
@ -500,6 +499,10 @@ class formClass {
$modelsForForm["$identifier"] = "$name"; $modelsForForm["$identifier"] = "$name";
} }
if (module_exists('islandora_content_model_forms') && isset($contentModels[0])) {
$form_names = islandora_content_model_get_form_names($contentModels[0]->pid);
}
switch ($form_state['storage']['step']) { switch ($form_state['storage']['step']) {
case 1: case 1:
$form['indicator'] = array( $form['indicator'] = array(
@ -514,14 +517,36 @@ class formClass {
//'#description' => t('Content models available in this collection. A content model defines what is allowed in a collection and what to do with a file when it is uploaded (An example may creating a thumbnail from an image.).') //'#description' => t('Content models available in this collection. A content model defines what is allowed in a collection and what to do with a file when it is uploaded (An example may creating a thumbnail from an image.).')
'#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> ') '#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> ')
); );
if (isset($form_names) && count($form_names) >= 1) {
$form['indicator']['forms'] = array(
'#type' => 'select',
'#title' => t('Forms'),
'#options' => $form_names,
'#description' => t('Select the form to populate the metadata of the new object.')
);
}
break; break;
case 2: case 2:
module_load_include('inc', 'fedora_repository', 'MimeClass'); // Why this include? --Zac, 2010-09-17 module_load_include('inc', 'fedora_repository', 'MimeClass'); // Why this include? --Zac, 2010-09-17
$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']);
if (isset($form_state['values']['forms'])) {
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state);
if (!$xml_form->isInitialized()) {
module_load_include('inc', 'xml_form_api', 'XMLFormDefinition');
module_load_include('inc', 'xml_form_builder', 'FormBuilder');
$form_name = $form_state['values']['forms'];
$definition = FormBuilder::GetFormDefinition($form_name);
$form = XMLFormDefinition::GetDrupalForm($definition);
$properties = XMLFormDefinition::GetFormProperties($definition);
$document = new XMLDocument($properties['document']['root'], $properties['document']['namespaces'], $properties['document']['schema']);
$xml_form->initialize($form, $document);
}
$form = $xml_form->toArray();
}
else 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) {
@ -577,7 +602,6 @@ class formClass {
if (!empty($newElements)) { if (!empty($newElements)) {
$available_dsids = array_merge($available_dsids, $newElements); $available_dsids = array_merge($available_dsids, $newElements);
} }
} }
} }

Loading…
Cancel
Save