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, diff --git a/includes/dublin_core.inc b/includes/dublin_core.inc index 53879623..14d25392 100644 --- a/includes/dublin_core.inc +++ b/includes/dublin_core.inc @@ -151,7 +151,7 @@ class DublinCore { */ public static function importFromXMLString($dc_xml) { $dc_doc = new DomDocument(); - if ($dc_doc->loadXML($dc_xml)) { + 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) { @@ -161,9 +161,7 @@ class DublinCore { } return $new_dc; } - else { - return NULL; - } + return NULL; } } diff --git a/theme/theme.inc b/theme/theme.inc index a37cda74..87e44fc1 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -107,20 +107,16 @@ function islandora_preprocess_islandora_default(&$variables) { } } $variables['datastreams'] = $datastreams; - try { - $dc = $islandora_object['DC']->content; - $dc_object = DublinCore::importFromXMLString($dc); + // 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(); } - catch (Exception $e) { - drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE); - } $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"); } }