Browse Source

Edit form correctly shows up in the right spot.

pull/3/merge
Nigel Banks 14 years ago
parent
commit
f6541b26c7
  1. 12
      fedora_repository.module
  2. 51
      formClass.inc
  3. 2
      plugins/fedoraObject.inc

12
fedora_repository.module

@ -612,13 +612,16 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
// There is no custom function, so just load the standard QDC form. // There is no custom function, so just load the standard QDC form.
$metaDataForm = new formClass(); $metaDataForm = new formClass();
//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. //currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now.
return $metaDataForm->createMetaDataForm($pid, $dsId, $client); return $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state);
} }
return $output; return $output;
} }
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) {
$form_state['storage']['step']++;
$form_state['rebuild'] = TRUE;
}
} }
/** /**
@ -631,6 +634,10 @@ 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) {
}
else {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
global $base_url; global $base_url;
if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) { if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) {
@ -655,6 +662,7 @@ function fedora_repository_edit_qdc_form_submit($form, &$form_state) {
return $return_value; return $return_value;
} }
} }
}
/** /**
* drupal hook * drupal hook

51
formClass.inc

@ -696,11 +696,57 @@ class formClass {
/** /**
* Creates a drupal form to edit either the QDC or DC datastream * Creates a drupal form to edit either the QDC or DC datastream
*/ */
function createMetaDataForm($pid, $dsId = NULL, $client) { function createMetaDataForm($pid, $dsId = NULL, $client, &$form_state) {
if (module_exists('islandora_content_model_forms')) {
// Get the content model.
$content_model = ContentModel::loadFromObject($pid);
$form_names = islandora_content_model_get_form_names($content_model->pid);
}
if (isset($form_state['storage']['step']) || (isset($form_names) && count($form_names) > 0)) {
// Form Exists...
$form_state['storage']['step'] = isset($form_state['storage']['step']) ? $form_state['storage']['step'] : 1;
switch ($form_state['storage']['step']) {
case 1:
$form['indicator'] = array(
'#type' => 'fieldset',
'#title' => t('Choose edit form.')
);
$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.')
);
$form['submit'] = array(
'#type' => 'submit',
'#submit' => array('fedora_repository_edit_qdc_form_submit'),
'#value' => 'Next'
);
return $form;
case 2:
// XML Forms
module_load_include('inc', 'xml_form_api', 'XMLForm');
$xml_form = new XMLForm($form_state);
if (isset($form_state['values']['forms']) || $xml_form->isInitialized()) {
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);
}
return $xml_form->toArray();
}
break;
}
}
else {
if (!isset($dsId)) { if (!isset($dsId)) {
$dsId = 'QDC'; $dsId = 'QDC';
} }
//$client = getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); //$client = getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
$params = array('pid' => "$pid", 'dsID' => "$dsId", 'asOfDateTime' => ""); $params = array('pid' => "$pid", 'dsID' => "$dsId", 'asOfDateTime' => "");
try { try {
@ -784,6 +830,7 @@ class formClass {
return $form; return $form;
} }
}
/** /**
* Creates a form for replacing datastream * Creates a form for replacing datastream

2
plugins/fedoraObject.inc

@ -15,6 +15,7 @@ class FedoraObject {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$tabset = array(); $tabset = array();
$show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form'); $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form');
$show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_edit_qdc_form');
$purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); $purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path()))));
$tabset['fedora_object_details'] = array( $tabset['fedora_object_details'] = array(
@ -41,6 +42,7 @@ class FedoraObject {
$tabset['fedora_object_details']['tabset']['edit'] = array( $tabset['fedora_object_details']['tabset']['edit'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Edit'), '#title' => t('Edit'),
'#selected' => $show_edit_tab,
'#content' => $editform, '#content' => $editform,
); );
} }

Loading…
Cancel
Save