Skip to content

Commit e016f74

Browse files
[BUGFIX] Display author URI as an external link (kitodo#1568)
Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
1 parent f1dc74d commit e016f74

File tree

6 files changed

+37
-14
lines changed

6 files changed

+37
-14
lines changed

Classes/Command/BaseCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ protected function saveToDatabase(Document $document): bool
212212
$document->setPlace(implode('; ', $metadata['place']));
213213
$document->setYear(implode('; ', $metadata['year']));
214214

215-
// Remove appended "valueURI" from authors' names for storing in database.
215+
// Get only authors' names for storing in database.
216216
foreach ($metadata['author'] as $i => $author) {
217-
$splitName = explode(pack('C', 31), $author);
218-
$metadata['author'][$i] = $splitName[0];
217+
if (is_array($author)) {
218+
$metadata['author'][$i] = $author['name'];
219+
}
219220
}
220221
$document->setAuthor($this->getAuthors($metadata['author']));
221222
$document->setThumbnail($doc->thumbnail ? : '');

Classes/Controller/MetadataController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,14 @@ private function buildExternalUrlFromMetadata(array $metadata): array
323323

324324
foreach ($metadata as $i => $section) {
325325
foreach ($section as $name => $value) {
326-
if (($name == 'author' || $name == 'holder') && !empty($value) && !empty($value[0]['url'])) {
327-
$externalUrl[$i][$name]['externalUrl'] = $value[0];
326+
if (($name == 'author' || $name == 'holder') && !empty($value)) {
327+
foreach ($value as $entry) {
328+
if (!empty($entry['url'])) {
329+
$externalUrl[$i][$name][] = $entry;
330+
}
331+
}
328332
} elseif (($name == 'geonames' || $name == 'wikidata' || $name == 'wikipedia') && !empty($value)) {
329-
$externalUrl[$i][$name]['externalUrl'] = [
333+
$externalUrl[$i][$name][] = [
330334
'name' => $value[0],
331335
'url' => $value[0]
332336
];

Classes/Format/Mods.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,16 @@ private function getAuthorFromXml(array $authors, int $i): void
173173
$k++;
174174
}
175175
ksort($name);
176+
176177
$this->metadata['author'][$i] = trim(implode(', ', $name));
177178
}
178-
// Append "valueURI" to name using Unicode unit separator.
179+
179180
if (isset($authors[$i]['valueURI'])) {
180-
$this->metadata['author'][$i] .= pack('C', 31) . (string) $authors[$i]['valueURI'];
181+
$displayName = $this->metadata['author'][$i];
182+
$this->metadata['author'][$i] = [
183+
'name' => $displayName,
184+
'url' => (string) $authors[$i]['valueURI']
185+
];
181186
}
182187
}
183188

@@ -263,9 +268,13 @@ private function getHolderFromViafApi(string $viafId, array $holders, int $i): v
263268
private function getHolderFromXml(array $holders, int $i): void
264269
{
265270
$this->getHolderFromXmlDisplayForm($holders, $i);
266-
// Append "valueURI" to name using Unicode unit separator.
271+
272+
$displayName = $this->metadata['holder'][$i];
267273
if (isset($holders[$i]['valueURI'])) {
268-
$this->metadata['holder'][$i] .= pack('C', 31) . (string) $holders[$i]['valueURI'];
274+
$this->metadata['holder'][$i] = [
275+
'name' => $displayName,
276+
'url' => (string) $holders[$i]['valueURI']
277+
];
269278
}
270279
}
271280

Resources/Private/Data/MetadataDefaults.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
}
104104
],
105105
"default_value": "",
106-
"wrap": "key.wrap = <dt class=\"tx-dlf-metadata-author\">|</dt>\nvalue.required = 1\nvalue.split.token.char = 31\nvalue.split.cObjNum = 1\nvalue.split.1.1 = CASE\nvalue.split.1.1.key.data = register:SPLIT_COUNT\nvalue.split.1.1.0 = LOAD_REGISTER\nvalue.split.1.1.0.tx_dlf_metadata_author_name.current = 1\nvalue.split.1.1.1 = LOAD_REGISTER\nvalue.split.1.1.1.tx_dlf_metadata_author_uri.current = 1\nvalue.postCObject = TEXT\nvalue.postCObject.value = {register:tx_dlf_metadata_author_name}\nvalue.postCObject.value.insertData = 1\nvalue.postCObject.value.stdWrap.typolink.parameter = {register:tx_dlf_metadata_author_uri} _blank external\nvalue.postCObject.value.stdWrap.typolink.parameter.insertData = 1\nvalue.postCObject.value.stdWrap.typolink.title = {register:tx_dlf_metadata_author_name}\nvalue.postCObject.value.stdWrap.typolink.ifNotEmpty = 1\nvalue.wrap = <dd class=\"tx-dlf-metadata-author\">|</dd>",
106+
"wrap": "key.wrap = <dt class=\"tx-dlf-metadata-author\">|</dt>\nvalue.required = 1\nvalue.wrap = <dd class=\"tx-dlf-metadata-author\">|</dd>",
107107
"index_tokenized": 1,
108108
"index_stored": 1,
109109
"index_indexed": 1,

Resources/Private/Partials/Metadata/Entries.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<f:variable name="wrappedValues"><f:spaceless>
2020
<f:for each="{documentMetadataSection.{configObject.indexName}}" as="value" iteration="iterator">
2121
<f:variable name="buildUrlVariable" value="{buildUrl.{sectionIterator.index}}" />
22+
<f:variable name="externalUrlVariable" value="{externalUrl.{sectionIterator.index}}" />
2223
<f:if condition="{buildUrlVariable.{configObject.indexName}}">
2324
<f:then>
2425
<f:render partial="Metadata/LinkEntry" arguments="{_all}"/>

Resources/Private/Partials/Metadata/ExternalLinkEntry.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
xmlns:kitodo="http://typo3.org/ns/Kitodo/Dlf/ViewHelpers"
1414
data-namespace-typo3-fluid="true">
1515

16-
<f:variable name="url" value="{externalUrlVariable.{configObject.indexName}.externalUrl.url}" />
17-
<f:variable name="value" value="{externalUrlVariable.{configObject.indexName}.externalUrl.name}" />
16+
<f:variable name="externalUrls" value="{externalUrlVariable.{configObject.indexName}}" />
1817

19-
<f:link.external uri="{url}">{value}</f:link.external>
18+
<f:if condition="{configObject.indexName} == 'author'">
19+
<f:then>
20+
<kitodo:stdWrap wrap="{metadataWrap.value}" data="{metaSectionConfigObject}"><f:link.external uri="{value.url}">{value.name}</f:link.external></kitodo:stdWrap>
21+
</f:then>
22+
<f:else>
23+
<f:for each="{externalUrls}" as="entry">
24+
<kitodo:stdWrap wrap="{metadataWrap.value}" data="{metaSectionConfigObject}"><f:link.external uri="{entry.url}">{entry.name}</f:link.external></kitodo:stdWrap>
25+
</f:for>
26+
</f:else>
27+
</f:if>

0 commit comments

Comments
 (0)