From 7f452454d5e58cf9bcad200beb6e1a5d6de5401b Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Thu, 24 Jan 2013 10:24:15 -0400 Subject: [PATCH] Change so that we can pass through and use URIs in additional to the original functionality. --- includes/utilities.inc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/includes/utilities.inc b/includes/utilities.inc index b2006722..fe1cf1d0 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -397,13 +397,26 @@ function islandora_prepare_new_object($namespace = NULL, $label = NULL, $datastr $mimetype = isset($ds['mimetype']) ? $ds['mimetype'] : 'text/xml'; // Default 'Managed' $control_group = (isset($ds['control_group']) && in_array($ds['control_group'], array('X', 'M', 'R', 'E'))) ? $ds['control_group'] : 'M'; - $datastream_file = url($ds['datastream_file'], array('absolute' => TRUE)); + + $ds_uri = FALSE; + if (file_valid_uri($ds['datastream_file'])) { + $datastream_file = $ds['datastream_file']; + $ds_uri = TRUE; + } + else { + $datastream_file = url($ds['datastream_file'], array('absolute' => TRUE)); + } $datastream = $object->constructDatastream($dsid, $control_group); $datastream->label = $label; $datastream->mimetype = $mimetype; switch ($control_group) { case 'M': - $datastream->setContentFromUrl($datastream_file); + if ($ds_uri) { + $datastream->setContentFromFile($datastream_file); + } + else { + $datastream->setContentFromUrl($datastream_file); + } break; case 'X': $datastream->setContentFromString(file_get_contents($datastream_file));