|
|
@ -883,6 +883,13 @@ RDF; |
|
|
|
* |
|
|
|
* |
|
|
|
* First tries to treat the passed in value as a filename, tries using as contents second. |
|
|
|
* First tries to treat the passed in value as a filename, tries using as contents second. |
|
|
|
* Coerces the data into what is required, and passes it on to the relevant function. |
|
|
|
* Coerces the data into what is required, and passes it on to the relevant function. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param $filename_or_content Either a filename to add, or an string of content. |
|
|
|
|
|
|
|
* @param $dsid The DSID to update |
|
|
|
|
|
|
|
* @param $label A label to withwhich to update the datastream |
|
|
|
|
|
|
|
* @param $mime_type Mimetype for the data being pushed into the datastream |
|
|
|
|
|
|
|
* @param $force Dunno, refer to underlying functions/SOAP interface. We just pass it like a chump. |
|
|
|
|
|
|
|
* @param $logMessage A message for the audit log. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function modify_datastream($filename_or_content, $dsid, $label, $mime_type, $force = FALSE, $logMessage='Modified by Islandora API') { |
|
|
|
function modify_datastream($filename_or_content, $dsid, $label, $mime_type, $force = FALSE, $logMessage='Modified by Islandora API') { |
|
|
|
//Determine if it's inline xml; if it is, modify by value |
|
|
|
//Determine if it's inline xml; if it is, modify by value |
|
|
@ -902,25 +909,24 @@ RDF; |
|
|
|
$file = ''; |
|
|
|
$file = ''; |
|
|
|
$created_temp = FALSE; |
|
|
|
$created_temp = FALSE; |
|
|
|
if (is_file($filename_or_content) && is_readable($filename_or_content)) { |
|
|
|
if (is_file($filename_or_content) && is_readable($filename_or_content)) { |
|
|
|
$file = $filename_or_content; |
|
|
|
$file = $filename_or_content; |
|
|
|
|
|
|
|
$original_path = $file; |
|
|
|
|
|
|
|
// Temporarily move file to a web-accessible location. |
|
|
|
|
|
|
|
file_copy($file, file_directory_path()); |
|
|
|
|
|
|
|
$created_temp = ($original_path != $file); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
//Get Drupal temp file |
|
|
|
//Push contents to a web-accessible file |
|
|
|
$file = file_directory_path(); |
|
|
|
$file = file_save_data($filename_or_content, file_directory_path()); |
|
|
|
$file = tempnam($file, 'fedora_modification'); //Be careful... Does this return the full path to the file? |
|
|
|
|
|
|
|
//Push contents to file |
|
|
|
|
|
|
|
file_put_contents($file, $filename_or_content); |
|
|
|
|
|
|
|
$created_temp = TRUE; |
|
|
|
$created_temp = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$file_url = url($file, array( |
|
|
|
$file_url = file_create_url($file); |
|
|
|
'absolute' => TRUE, |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->modify_datastream_by_reference($file_url, $dsid, $label, $mime_type, $force, $logMessage); |
|
|
|
$this->modify_datastream_by_reference($file_url, $dsid, $label, $mime_type, $force, $logMessage); |
|
|
|
|
|
|
|
|
|
|
|
if ($created_temp && is_file($file) && is_writable($file)) { |
|
|
|
if ($created_temp && is_file($file) && is_writable($file)) { |
|
|
|
unlink($file); |
|
|
|
file_delete($file); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|