Browse Source

Change so that we can pass through and use URIs in additional to the original functionality.

pull/244/head
Jordan Dukart 12 years ago
parent
commit
7f452454d5
  1. 17
      includes/utilities.inc

17
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'; $mimetype = isset($ds['mimetype']) ? $ds['mimetype'] : 'text/xml';
// Default 'Managed' // Default 'Managed'
$control_group = (isset($ds['control_group']) && in_array($ds['control_group'], array('X', 'M', 'R', 'E'))) ? $ds['control_group'] : 'M'; $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 = $object->constructDatastream($dsid, $control_group);
$datastream->label = $label; $datastream->label = $label;
$datastream->mimetype = $mimetype; $datastream->mimetype = $mimetype;
switch ($control_group) { switch ($control_group) {
case 'M': case 'M':
$datastream->setContentFromUrl($datastream_file); if ($ds_uri) {
$datastream->setContentFromFile($datastream_file);
}
else {
$datastream->setContentFromUrl($datastream_file);
}
break; break;
case 'X': case 'X':
$datastream->setContentFromString(file_get_contents($datastream_file)); $datastream->setContentFromString(file_get_contents($datastream_file));

Loading…
Cancel
Save