From cd81a80bfc816976430f228a66d06ac699556341 Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Wed, 27 Feb 2013 09:42:10 -0400 Subject: [PATCH 1/6] added checks in theme preprocessor for missing dc --- theme/theme.inc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/theme/theme.inc b/theme/theme.inc index 1622d810..53546945 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -108,9 +108,16 @@ function islandora_preprocess_islandora_default(&$variables) { } $variables['datastreams'] = $datastreams; try { - $dc = $islandora_object['DC']->content; - $dc_object = DublinCore::importFromXMLString($dc); - $dc_array = $dc_object->asArray(); + //pp,jm added missing value checks for fcrepo4 + $datastream = $islandora_object['DC']; + if (isset($datastream)) { + $dc = $datastream->content; + $dc_object = DublinCore::importFromXMLString($dc); + + if (isset($dc_object)) { + $dc_array = $dc_object->asArray(); + } + } } catch (Exception $e) { drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE); From 3ce9015df02ae57d75571b7325d1e6447edc9d66 Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Wed, 27 Feb 2013 09:42:33 -0400 Subject: [PATCH 2/6] added checks for missing dc datastream --- includes/dublin_core.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/dublin_core.inc b/includes/dublin_core.inc index 53879623..a53cfcfb 100644 --- a/includes/dublin_core.inc +++ b/includes/dublin_core.inc @@ -151,7 +151,8 @@ class DublinCore { */ public static function importFromXMLString($dc_xml) { $dc_doc = new DomDocument(); - if ($dc_doc->loadXML($dc_xml)) { + // a fix for the potential error of a missing DC (patching a possible fcrepo4 error) + if (!empty($dc_xml) && $dc_doc->loadXML($dc_xml)) { $oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*'); $new_dc = new DublinCore(); foreach ($oai_dc as $child) { From 12b489d33ab27bcf78a5de70f28df4034c0ea0f5 Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Wed, 27 Feb 2013 09:42:59 -0400 Subject: [PATCH 3/6] fixed a fieldset name in add datastream form --- includes/add_datastream.form.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/add_datastream.form.inc b/includes/add_datastream.form.inc index 1a577fb8..fa94148f 100644 --- a/includes/add_datastream.form.inc +++ b/includes/add_datastream.form.inc @@ -32,7 +32,7 @@ function islandora_add_datastream_form(array $form, array &$form_state, FedoraOb '#attributes' => array( 'enctype' => 'multipart/form-data', ), - 'fieldset' => array( + 'dsid' => array( '#type' => 'fieldset', '#title' => 'Add a datastream', '#collapsible' => FALSE, From 56f4dd8df80017fa24183c7c03e2a09ec99f1c32 Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Wed, 27 Feb 2013 09:52:42 -0400 Subject: [PATCH 4/6] updated dc_array's default value --- theme/theme.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/theme/theme.inc b/theme/theme.inc index 53546945..a2f1b74f 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -117,6 +117,9 @@ function islandora_preprocess_islandora_default(&$variables) { if (isset($dc_object)) { $dc_array = $dc_object->asArray(); } + else { + $dc_array = array(); + } } } catch (Exception $e) { From adf8eecd94905edc41166b967ba45ae93b77cadc Mon Sep 17 00:00:00 2001 From: Nigel Banks Date: Tue, 12 Mar 2013 08:58:13 +0100 Subject: [PATCH 5/6] Code Review --- includes/dublin_core.inc | 5 +---- theme/theme.inc | 24 +++++------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/includes/dublin_core.inc b/includes/dublin_core.inc index a53cfcfb..14d25392 100644 --- a/includes/dublin_core.inc +++ b/includes/dublin_core.inc @@ -151,7 +151,6 @@ class DublinCore { */ public static function importFromXMLString($dc_xml) { $dc_doc = new DomDocument(); - // a fix for the potential error of a missing DC (patching a possible fcrepo4 error) if (!empty($dc_xml) && $dc_doc->loadXML($dc_xml)) { $oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*'); $new_dc = new DublinCore(); @@ -162,9 +161,7 @@ class DublinCore { } return $new_dc; } - else { - return NULL; - } + return NULL; } } diff --git a/theme/theme.inc b/theme/theme.inc index a2f1b74f..b1af50ab 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -107,29 +107,15 @@ function islandora_preprocess_islandora_default(&$variables) { } } $variables['datastreams'] = $datastreams; - try { - //pp,jm added missing value checks for fcrepo4 - $datastream = $islandora_object['DC']; - if (isset($datastream)) { - $dc = $datastream->content; - $dc_object = DublinCore::importFromXMLString($dc); - - if (isset($dc_object)) { - $dc_array = $dc_object->asArray(); - } - else { - $dc_array = array(); - } - } - } - catch (Exception $e) { - drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE); + // Objects in fcrepo4 don't always contain a DC datastream. + if (isset($islandora_object['DC'])) { + $dc_object = DublinCore::importFromXMLString($islandora_object['DC']->content); + $dc_array = $dc_object->asArray(); } $variables['dc_array'] = isset($dc_array) ? $dc_array : array(); $variables['islandora_dublin_core'] = isset($dc_object) ? $dc_object : NULL; $variables['islandora_object_label'] = $islandora_object->label; - global $base_url; if (isset($islandora_object['TN'])) { - $variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view'; + $variables['islandora_thumbnail_url'] = url("islandora/object/{$islandora_object->id}/datastream/TN/view"); } } From c57d2df00d44b64c716781b1a8bcea827706ac18 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 12 Mar 2013 12:43:09 -0300 Subject: [PATCH 6/6] Allow for altering of forms in the stepped ingest process. --- includes/ingest.form.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index e2e97d5f..9434e9e4 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -295,11 +295,15 @@ function islandora_ingest_form_execute_step(array $form, array &$form_state) { * @return array * The stepified drupal form definition for the given step. */ -function islandora_ingest_form_stepify(array $form, array &$form_state) { +function islandora_ingest_form_stepify(array $form, array &$form_state, $step) { $first_step = islandora_ingest_form_on_first_step($form_state); $last_step = islandora_ingest_form_on_last_step($form_state); $form['prev'] = $first_step ? NULL : islandora_ingest_form_previous_button($form_state); $form['next'] = $last_step ? islandora_ingest_form_ingest_button($form_state) : islandora_ingest_form_next_button($form_state); + + // Allow for a hook_form_FORM_ID_alter(). + drupal_alter(array('form_' . $step['form_id'], 'form'), $form, $form_state, $step['form_id']); + return $form; }