Browse Source

Merge pull request #185 from mitchmac/xslt-view-default-to-dc

Default to DC if preferred datastream isn't available for Object Details view
pull/182/merge
Jonathan Green 12 years ago
parent
commit
06783d8b78
  1. 31
      ObjectDetails.inc
  2. 2
      object_details_xslts/convertQDC.xsl
  3. 1
      object_details_xslts/mods2html.xsl

31
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<br/>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)) {
@ -127,6 +138,10 @@ function fedora_repository_object_details_table($item) {
}
$xmlstr = $item->get_datastream_dissemination($dsid);
if (empty($xmlstr) && variable_get('islandora_object_details_table_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') {
$dsid = 'DC';
$xmlstr = $item->get_datastream_dissemination($dsid);
}
if (empty($xmlstr)) {
return t('Error - could not find datastream @dsid on object @pid<br/>Please contact the site administrator.',
array('@dsid' => $dsid, '@pid' => $item->pid));
@ -136,7 +151,7 @@ function fedora_repository_object_details_table($item) {
$headers = array(
array(
'data' => t('Metadata'),
'data' => t('Metadata (@dsid)', array('@dsid' => $dsid)),
'colspan' => 2,
),
);
@ -191,6 +206,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 +230,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');
}
@ -253,6 +274,11 @@ function fedora_repository_object_details_table_config() {
'#default_value' => variable_get('islandora_object_details_table_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_table_default_dc', FALSE),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t("Submit"),
@ -272,5 +298,6 @@ function fedora_repository_object_details_table_config() {
function fedora_repository_object_details_table_config_submit($form, &$form_state) {
variable_set('islandora_object_details_display_table', 'table');
variable_set('islandora_object_details_table_datastream', $form_state['values']['dsid']);
variable_set('islandora_object_details_table_default_dc', $form_state['values']['default_dc']);
drupal_set_message('Object Details view has been set to Table and your configuration has been saved');
}

2
object_details_xslts/convertQDC.xsl

@ -9,7 +9,7 @@
<xsl:template match="/">
<div><table cellspacing="3" cellpadding="3"><tbody>
<tr><th colspan="3"><h3>MetaData</h3></th></tr>
<tr><th colspan="3"><h3 class="islandora-obj-details-metadata-title">Metadata <span class="islandora-obj-details-dsid">(DC)</span></h3></th></tr>
<xsl:for-each select="/*/*">
<xsl:variable name="FULLFIELD" select="name()"/>
<xsl:variable name="FIELD" select="local-name()"/>

1
object_details_xslts/mods2html.xsl

@ -51,6 +51,7 @@
<xsl:template match="mods:mods">
<table class="modsContainer">
<tr><th colspan="2"><h3 class="islandora-obj-details-metadata-title">Metadata <span class="islandora-obj-details-dsid">(MODS)</span></h3></th></tr>
<xsl:apply-templates/>
</table>
<!--hr/-->

Loading…
Cancel
Save