|
|
@ -989,6 +989,54 @@ RDF; |
|
|
|
return self::soap_call('modifyObject', $params, $quiet); |
|
|
|
return self::soap_call('modifyObject', $params, $quiet); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Work around function, due to file_create_url not URL encoding stuff. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Parses and reassembles the URL, exploding, rawurlencoding and imploding |
|
|
|
|
|
|
|
* the path components along the way. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param $url |
|
|
|
|
|
|
|
* A string containing an HTTP(S) URL to attempt. |
|
|
|
|
|
|
|
* @return string |
|
|
|
|
|
|
|
* The results of the HTTP request if successful; boolean FALSE otherwise. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected static function try_http_get_content($url) { |
|
|
|
|
|
|
|
//Can throw a warning prior to 5.3.3 |
|
|
|
|
|
|
|
$parsed_url = @parse_url($url); |
|
|
|
|
|
|
|
$supported_schemes = array( |
|
|
|
|
|
|
|
'http', |
|
|
|
|
|
|
|
'https' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$content = FALSE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($parsed_url && array_key_exists('scheme', $parsed_url) && in_array($parsed_url['scheme'], $supported_schemes)) { |
|
|
|
|
|
|
|
$components = explode('/', $parsed_url['path']); |
|
|
|
|
|
|
|
$components = array_map('rawurlencode', $components); |
|
|
|
|
|
|
|
$result = drupal_http_request( |
|
|
|
|
|
|
|
url( |
|
|
|
|
|
|
|
t('!scheme://!user:!pass@!host:!port/!path', array( |
|
|
|
|
|
|
|
'!scheme' => $parsed_url['scheme'], |
|
|
|
|
|
|
|
'!user' => rawurlencode($parsed_url['user']), |
|
|
|
|
|
|
|
'!pass' => rawurlencode($parsed_url['pass']), |
|
|
|
|
|
|
|
'!host' => $parsed_url['host'], |
|
|
|
|
|
|
|
'!path' => implode('/', $components), |
|
|
|
|
|
|
|
)), |
|
|
|
|
|
|
|
array( |
|
|
|
|
|
|
|
'query' => $parsed_url['query'], |
|
|
|
|
|
|
|
'fragment' => $parsed_url['fragment'], |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((int)($result->code / 100) === 2) { |
|
|
|
|
|
|
|
$content = $result->data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $content; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Wrap modify by value and reference |
|
|
|
* Wrap modify by value and reference |
|
|
|
* |
|
|
|
* |
|
|
@ -1022,7 +1070,15 @@ RDF; |
|
|
|
$content = file_get_contents($filename_or_content); |
|
|
|
$content = file_get_contents($filename_or_content); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
$content = $filename_or_content; |
|
|
|
//XXX: Get the contents to deal with fopen not being allowed for remote access |
|
|
|
|
|
|
|
// in some OSs |
|
|
|
|
|
|
|
$temp_content = self::try_http_get_content($filename_or_content); |
|
|
|
|
|
|
|
if ($temp_content !== FALSE) { |
|
|
|
|
|
|
|
$content = $temp_content; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$content = $filename_or_content; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage); |
|
|
|
$toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage); |
|
|
@ -1039,8 +1095,15 @@ RDF; |
|
|
|
$created_temp = ($original_path != $file); |
|
|
|
$created_temp = ($original_path != $file); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
|
|
|
|
//XXX: Get the contents to deal with fopen not being allowed for remote access |
|
|
|
|
|
|
|
// in some OSs |
|
|
|
|
|
|
|
$temp_content = self::try_http_get_content($filename_or_content); |
|
|
|
|
|
|
|
if ($temp_content !== FALSE) { |
|
|
|
|
|
|
|
$filename_or_content = $temp_content; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Push contents to a web-accessible file |
|
|
|
//Push contents to a web-accessible file |
|
|
|
$file = file_save_data($filename_or_content, file_directory_path()); |
|
|
|
$file = file_save_data($filename_or_content, file_create_filename($label, file_directory_path())); |
|
|
|
$created_temp = TRUE; |
|
|
|
$created_temp = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|