diff --git a/ObjectDetails.inc b/ObjectDetails.inc index 38409615..1dacf49f 100644 --- a/ObjectDetails.inc +++ b/ObjectDetails.inc @@ -72,6 +72,11 @@ function fedora_repository_object_details_XSLT($item) { } $xmlstr = $item->get_datastream_dissemination($dsid); + $default_to_dc = FALSE; + if (empty($xmlstr) && variable_get('islandora_object_details_xslt_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') { + $xmlstr = $item->get_datastream_dissemination('DC'); + $default_to_dc = TRUE; + } if (empty($xmlstr)) { return t('Error - could not find datastream @dsid on object @pid
Please contact the site administrator.', array('@dsid' => $dsid, '@pid' => $item->pid)); @@ -88,7 +93,13 @@ function fedora_repository_object_details_XSLT($item) { $proc->setParameter('', 'path', $path); $input = NULL; - $xsl_file = variable_get('islandora_object_details_xslt_sheet', 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl'); + if (!$default_to_dc) { + $xsl_file = variable_get('islandora_object_details_xslt_sheet', 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl'); + } + else { + $xsl_file = 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl'; + } + // set an error message in case xslt parsing fails $output = t("Failed to parse xslt file at @xsltFile", array('@xsltFile' => $xsl_file)); if (is_readable($xsl_file)) { @@ -191,6 +202,11 @@ function fedora_repository_object_details_XSLT_config() { '#default_value' => variable_get('islandora_object_details_xslt_datastream', 'DC'), '#required' => TRUE, ); + $form['config']['default_dc'] = array( + '#type' => 'checkbox', + '#title' => t("If the datastream to transform is unavailable, attempt to transform using the DC datastream"), + '#default_value' => variable_get('islandora_object_details_xslt_default_dc', FALSE), + ); $form['submit'] = array( '#type' => 'submit', '#value' => t("Submit"), @@ -210,6 +226,7 @@ function fedora_repository_object_details_XSLT_config_submit($form, &$form_state variable_set('islandora_object_details_display_table', 'xslt'); variable_set('islandora_object_details_xslt_sheet', $form_state['values']['xslt']); variable_set('islandora_object_details_xslt_datastream', $form_state['values']['dsid']); + variable_set('islandora_object_details_xslt_default_dc', $form_state['values']['default_dc']); drupal_set_message('Object Details view has been set to XSLT and your configuration has been saved'); }