|
|
@ -19,6 +19,18 @@ function islandora_token_info() { |
|
|
|
'name' => t('Islandora Tokens'), |
|
|
|
'name' => t('Islandora Tokens'), |
|
|
|
'description' => t('Tokens for Islandora objects.'), |
|
|
|
'description' => t('Tokens for Islandora objects.'), |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
$node['media-original-file:filename'] = [ |
|
|
|
|
|
|
|
'name' => t('Media: Original File filename without extension.'), |
|
|
|
|
|
|
|
'description' => t('File name without extension of original uploaded file associated with Islandora Object via Media.'), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
$node['media-original-file:basename'] = [ |
|
|
|
|
|
|
|
'name' => t('Media: Original File filename with extension.'), |
|
|
|
|
|
|
|
'description' => t('File name with extension of original uploaded file associated with Islandora Object via Media.'), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
$node['media-original-file:extension'] = [ |
|
|
|
|
|
|
|
'name' => t('Media: Original File extension.'), |
|
|
|
|
|
|
|
'description' => t('File extension of original uploaded file associated with Islandora Object via Media.'), |
|
|
|
|
|
|
|
]; |
|
|
|
$node['media-thumbnail-image:url'] = [ |
|
|
|
$node['media-thumbnail-image:url'] = [ |
|
|
|
'name' => t('Media: Thumbnail Image URL.'), |
|
|
|
'name' => t('Media: Thumbnail Image URL.'), |
|
|
|
'description' => t('URL of Thumbnail Image associated with Islandora Object via Media.'), |
|
|
|
'description' => t('URL of Thumbnail Image associated with Islandora Object via Media.'), |
|
|
@ -70,6 +82,23 @@ function islandora_tokens($type, $tokens, array $data, array $options, Bubbleabl |
|
|
|
$islandoraUtils = \Drupal::service('islandora.utils'); |
|
|
|
$islandoraUtils = \Drupal::service('islandora.utils'); |
|
|
|
foreach ($tokens as $name => $original) { |
|
|
|
foreach ($tokens as $name => $original) { |
|
|
|
switch ($name) { |
|
|
|
switch ($name) { |
|
|
|
|
|
|
|
case 'media-original-file:basename': |
|
|
|
|
|
|
|
case 'media-original-file:filename': |
|
|
|
|
|
|
|
case 'media-original-file:extension': |
|
|
|
|
|
|
|
$term = $islandoraUtils->getTermForUri('http://pcdm.org/use#OriginalFile'); |
|
|
|
|
|
|
|
$media = $islandoraUtils->getMediaWithTerm($data['node'], $term); |
|
|
|
|
|
|
|
// Is there media? |
|
|
|
|
|
|
|
if ($media) { |
|
|
|
|
|
|
|
$file = \Drupal::service('islandora.media_source_service')->getSourceFile($media); |
|
|
|
|
|
|
|
if (!empty($file)) { |
|
|
|
|
|
|
|
$path_info = pathinfo($file->createFileUrl()); |
|
|
|
|
|
|
|
$key = explode(':', $name)[1]; |
|
|
|
|
|
|
|
if (array_key_exists($key, $path_info)) { |
|
|
|
|
|
|
|
$replacements[$original] = $path_info[$key]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case 'media-thumbnail-image:url': |
|
|
|
case 'media-thumbnail-image:url': |
|
|
|
case 'media_thumbnail_image:url': |
|
|
|
case 'media_thumbnail_image:url': |
|
|
|
$term = $islandoraUtils->getTermForUri('http://pcdm.org/use#ThumbnailImage'); |
|
|
|
$term = $islandoraUtils->getTermForUri('http://pcdm.org/use#ThumbnailImage'); |
|
|
|