From 18c50f972aaab909dab5baf03eecb0c496dcd16f Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 15:39:32 -0300 Subject: [PATCH 1/8] Add support to default to DC transform for Object Details if desired datastream is missing --- ObjectDetails.inc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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'); } From bc708b1574dc7e9bced958e5f8d569b76c683ce7 Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 16:05:56 -0300 Subject: [PATCH 2/8] Add support to default to DC for Object Details on table view if datastream is missing --- ObjectDetails.inc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ObjectDetails.inc b/ObjectDetails.inc index 1dacf49f..16276cef 100644 --- a/ObjectDetails.inc +++ b/ObjectDetails.inc @@ -137,7 +137,10 @@ function fedora_repository_object_details_table($item) { $dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; } $xmlstr = $item->get_datastream_dissemination($dsid); - + + if (empty($xmlstr) && variable_get('islandora_object_details_table_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') { + $xmlstr = $item->get_datastream_dissemination('DC'); + } 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)); @@ -270,6 +273,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"), @@ -289,5 +297,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'); } From 61859a078b6ead731144955c0c0803873214b1f7 Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 17:26:13 -0300 Subject: [PATCH 3/8] Display dsid in table header for table Object Details view --- ObjectDetails.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ObjectDetails.inc b/ObjectDetails.inc index 16276cef..4bd46790 100644 --- a/ObjectDetails.inc +++ b/ObjectDetails.inc @@ -150,7 +150,7 @@ function fedora_repository_object_details_table($item) { $headers = array( array( - 'data' => t('Metadata'), + 'data' => t('@dsid Metadata', array('@dsid' => $dsid)), 'colspan' => 2, ), ); From 1c9da08e501434e15a98c54aa3ad7535aea8be15 Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 18:58:47 -0300 Subject: [PATCH 4/8] Modify title coming from DC XSLT: add 'DC' part and lower-case the D in metadata --- object_details_xslts/convertQDC.xsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/object_details_xslts/convertQDC.xsl b/object_details_xslts/convertQDC.xsl index 5d881e35..275d4c3f 100644 --- a/object_details_xslts/convertQDC.xsl +++ b/object_details_xslts/convertQDC.xsl @@ -9,7 +9,7 @@
- + @@ -30,4 +30,4 @@ - \ No newline at end of file + From 5ce9f4fa6d293a3478be159c7c3204bce693abe3 Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 19:05:24 -0300 Subject: [PATCH 5/8] Add title to the table coming from MODS XSLT for Object Details --- object_details_xslts/mods2html.xsl | 1 + 1 file changed, 1 insertion(+) diff --git a/object_details_xslts/mods2html.xsl b/object_details_xslts/mods2html.xsl index 3f794523..91ac74e5 100644 --- a/object_details_xslts/mods2html.xsl +++ b/object_details_xslts/mods2html.xsl @@ -51,6 +51,7 @@

MetaData

DC Metadata

+
From a9472691d46b80b3a30fe0c44edbc4e74dfcfd60 Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 19:07:13 -0300 Subject: [PATCH 6/8] Add class to

for styling --- object_details_xslts/convertQDC.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object_details_xslts/convertQDC.xsl b/object_details_xslts/convertQDC.xsl index 275d4c3f..9d0cf02b 100644 --- a/object_details_xslts/convertQDC.xsl +++ b/object_details_xslts/convertQDC.xsl @@ -9,7 +9,7 @@
- + From 9a23050b94c27d2e31c17b105052e2785b5a41fa Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 19:12:34 -0300 Subject: [PATCH 7/8] Add a span and class to the dsid portion of title for styling, not sure if it's exactly valid HTML but enables hiding via CSS --- object_details_xslts/convertQDC.xsl | 2 +- object_details_xslts/mods2html.xsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/object_details_xslts/convertQDC.xsl b/object_details_xslts/convertQDC.xsl index 9d0cf02b..036eb20a 100644 --- a/object_details_xslts/convertQDC.xsl +++ b/object_details_xslts/convertQDC.xsl @@ -9,7 +9,7 @@

DC Metadata

- + diff --git a/object_details_xslts/mods2html.xsl b/object_details_xslts/mods2html.xsl index 91ac74e5..59e13a50 100644 --- a/object_details_xslts/mods2html.xsl +++ b/object_details_xslts/mods2html.xsl @@ -51,7 +51,7 @@
- +
From 0e0aaec229d3f82b54a3f133f3b1b8086d7c36b0 Mon Sep 17 00:00:00 2001 From: Mitch MacKenzie Date: Wed, 17 Oct 2012 19:18:14 -0300 Subject: [PATCH 8/8] Make titles consistent between table and XSLT views --- ObjectDetails.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ObjectDetails.inc b/ObjectDetails.inc index 4bd46790..30121080 100644 --- a/ObjectDetails.inc +++ b/ObjectDetails.inc @@ -139,7 +139,8 @@ 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') { - $xmlstr = $item->get_datastream_dissemination('DC'); + $dsid = 'DC'; + $xmlstr = $item->get_datastream_dissemination($dsid); } if (empty($xmlstr)) { return t('Error - could not find datastream @dsid on object @pid
Please contact the site administrator.', @@ -150,7 +151,7 @@ function fedora_repository_object_details_table($item) { $headers = array( array( - 'data' => t('@dsid Metadata', array('@dsid' => $dsid)), + 'data' => t('Metadata (@dsid)', array('@dsid' => $dsid)), 'colspan' => 2, ), );