|
|
@ -8,15 +8,13 @@ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* The POST callback for the TN service. |
|
|
|
* The POST callback for the TN service. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $type |
|
|
|
* @param array $args |
|
|
|
* Entity type to which the RDF mapping belongs. |
|
|
|
* JSON decoded function arguments. |
|
|
|
* @param string $bundle |
|
|
|
|
|
|
|
* Bundle to which the RDF mapping belongs. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
* @return string |
|
|
|
* The RDF mapping. |
|
|
|
* Message. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function islandora_tn_service_create($args) { |
|
|
|
function islandora_tn_service_create(array $args) { |
|
|
|
$uuid = $args['uuid']; |
|
|
|
$uuid = $args['uuid']; |
|
|
|
$tn_b64 = $args['file']; |
|
|
|
$tn_b64 = $args['file']; |
|
|
|
$mimetype = $args['mimetype']; |
|
|
|
$mimetype = $args['mimetype']; |
|
|
@ -24,15 +22,15 @@ function islandora_tn_service_create($args) { |
|
|
|
$extension = $exploded[1]; |
|
|
|
$extension = $exploded[1]; |
|
|
|
|
|
|
|
|
|
|
|
$entities = entity_uuid_load('node', array($uuid)); |
|
|
|
$entities = entity_uuid_load('node', array($uuid)); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($entities)) { |
|
|
|
if (empty($entities)) { |
|
|
|
return "Could not add thumbnail because there is no entity identified by $uuid"; |
|
|
|
return "Could not add thumbnail because there is no entity identified by $uuid"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$node = array_pop($entities); |
|
|
|
$node = array_pop($entities); |
|
|
|
|
|
|
|
|
|
|
|
$file = file_save_data(base64_decode($tn_b64), "public://" . $uuid . "_TN." . $extension, FILE_EXISTS_REPLACE); |
|
|
|
$file = file_save_data(base64_decode($tn_b64), "public://" . $uuid . "_TN." . $extension, FILE_EXISTS_REPLACE); |
|
|
|
|
|
|
|
|
|
|
|
$node->field_tn[LANGUAGE_NONE][] = array( |
|
|
|
$node->field_tn[LANGUAGE_NONE][] = array( |
|
|
|
'fid' => $file->fid, |
|
|
|
'fid' => $file->fid, |
|
|
|
'width' => 100, |
|
|
|
'width' => 100, |
|
|
@ -40,7 +38,7 @@ function islandora_tn_service_create($args) { |
|
|
|
'alt' => "Thumbnail for node $uuid", |
|
|
|
'alt' => "Thumbnail for node $uuid", |
|
|
|
'title' => "Thumbnail for node $uuid", |
|
|
|
'title' => "Thumbnail for node $uuid", |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
node_save($node); |
|
|
|
node_save($node); |
|
|
|
|
|
|
|
|
|
|
|
return "Successfully added thumbnail to node $uuid"; |
|
|
|
return "Successfully added thumbnail to node $uuid"; |
|
|
|