Skip to content

Commit

Permalink
[BUGFIX] Allow OAI-PMH set names which are required for DINI
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Feb 8, 2025
1 parent 9cc612a commit cbac1b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,26 @@ private function addCollections(Document &$document, array $collections): void
$documentCollection = GeneralUtility::makeInstance(Collection::class);
$documentCollection->setIndexName($collection);
$documentCollection->setLabel($collection);
$documentCollection->setOaiName((!empty($this->extConf['general']['publishNewCollections']) ? Helper::getCleanString($collection) : ''));
$setSpec = '';
if (!empty($this->extConf['general']['publishNewCollections'])) {
// setSpec only allows unreserved characters (rfc2396).
// alnum | "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
// Here we are a little bit more restrictive because
// some more unreserved characters are not allowed.
// Convert whitespaces to dash.
$setSpec = $collection;
$setSpec = preg_replace('/[\s]/', '-', $setSpec);
// Remove multiple dashes.
$setSpec = preg_replace('/[-]{2,}/', '-', $setSpec);
// Remove undesired characters.
$setSpec = preg_replace('/[^\w:-]/', '', $setSpec);
// A hierarchical setSpec consists of two or more
// normal setSpec which are separated by colons.
// Remove colons which don't separate hierarchical setSpec entries.
$setSpec = trim($setSpec, ':');
$setSpec = preg_replace('/:{2,}/', ':', $setSpec);
}
$documentCollection->setOaiName($setSpec);
$documentCollection->setIndexSearch('');
$documentCollection->setDescription('');
// add to CollectionRepository
Expand Down
3 changes: 2 additions & 1 deletion Configuration/TCA/tx_dlf_collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
'type' => 'input',
'size' => 30,
'max' => 255,
'eval' => 'nospace,alphanum_x,uniqueInPid',
// TODO: Add own form evaluation (see OAI-PMH setSpec).
'eval' => 'nospace,uniqueInPid',
'default' => '',
],
],
Expand Down

0 comments on commit cbac1b9

Please sign in to comment.