|
|
@ -465,20 +465,44 @@ function islandora_prepare_new_object($namespace = NULL, $label = NULL, $datastr |
|
|
|
if (isset($ds['control_group']) && in_array($ds['control_group'], $groups)) { |
|
|
|
if (isset($ds['control_group']) && in_array($ds['control_group'], $groups)) { |
|
|
|
$control_group = $ds['control_group']; |
|
|
|
$control_group = $ds['control_group']; |
|
|
|
} |
|
|
|
} |
|
|
|
$ds_uri = FALSE; |
|
|
|
|
|
|
|
|
|
|
|
$as_file = FALSE; |
|
|
|
if (file_valid_uri($ds['datastream_file'])) { |
|
|
|
if (file_valid_uri($ds['datastream_file'])) { |
|
|
|
|
|
|
|
// A local file with as a Drupal file/stream wrapper URI. |
|
|
|
|
|
|
|
$datastream_file = $ds['datastream_file']; |
|
|
|
|
|
|
|
$as_file = TRUE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
elseif (is_readable($ds['datastream_file'])) { |
|
|
|
|
|
|
|
// A local file as a filesystem path. |
|
|
|
|
|
|
|
$datastream_file = drupal_realpath($ds['datastream_file']); |
|
|
|
|
|
|
|
$as_file = TRUE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$scheme = parse_url($ds['datastream_file'], PHP_URL_SCHEME); |
|
|
|
|
|
|
|
if (in_array($scheme, stream_get_wrappers())) { |
|
|
|
|
|
|
|
// A URI which gets handled by one of the PHP-native stream wrappers. |
|
|
|
$datastream_file = $ds['datastream_file']; |
|
|
|
$datastream_file = $ds['datastream_file']; |
|
|
|
$ds_uri = TRUE; |
|
|
|
$as_file = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
|
|
|
|
// Schema does not match available php stream wrapper. Attempt to |
|
|
|
|
|
|
|
// set datastream_file by url for the given scheme. Https (SSL) can |
|
|
|
|
|
|
|
// cause this to fail, and trigger an output log in watchdog. |
|
|
|
$datastream_file = url($ds['datastream_file'], array('absolute' => TRUE)); |
|
|
|
$datastream_file = url($ds['datastream_file'], array('absolute' => TRUE)); |
|
|
|
|
|
|
|
watchdog('islandora', 'Attempting to ingest %file in islandora_prepare_new_object(), ' . |
|
|
|
|
|
|
|
' but it does not appear to be readable. We will pass the path through' . |
|
|
|
|
|
|
|
' url(), and pass along as such.', |
|
|
|
|
|
|
|
array('%file' => $datastream_file), |
|
|
|
|
|
|
|
WATCHDOG_WARNING); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$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': |
|
|
|
if ($ds_uri) { |
|
|
|
if ($as_file) { |
|
|
|
$datastream->setContentFromFile($datastream_file); |
|
|
|
$datastream->setContentFromFile($datastream_file); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
@ -490,8 +514,10 @@ function islandora_prepare_new_object($namespace = NULL, $label = NULL, $datastr |
|
|
|
$datastream->setContentFromString(file_get_contents($datastream_file)); |
|
|
|
$datastream->setContentFromString(file_get_contents($datastream_file)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$object->ingestDatastream($datastream); |
|
|
|
$object->ingestDatastream($datastream); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $object; |
|
|
|
return $object; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -506,7 +532,7 @@ function islandora_display_repository_inaccessible_message() { |
|
|
|
$link = l($text, 'admin/islandora/configure', array('attributes' => array('title' => $text))); |
|
|
|
$link = l($text, 'admin/islandora/configure', array('attributes' => array('title' => $text))); |
|
|
|
$message = t('Could not connect to the repository. Please check the settings on the !link page.', |
|
|
|
$message = t('Could not connect to the repository. Please check the settings on the !link page.', |
|
|
|
array('!link' => $link)); |
|
|
|
array('!link' => $link)); |
|
|
|
drupal_set_message($message, 'error', FALSE); |
|
|
|
drupal_set_message(check_plain($message), 'error', FALSE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|