Skip to content

Commit

Permalink
LiveCmdiMetadata fixes
Browse files Browse the repository at this point in the history
* Support for val="OAIID" (and format being appended with
  "@Format={formatValue}") added
* val="OAIURI" renamed to val="OAIURL"
  • Loading branch information
zozlak committed May 28, 2021
1 parent e6b13c3 commit 91caef3
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/acdhOeaw/arche/oaipmh/metadata/LiveCmdiMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
* format configuration property (see above).
* Remark - when using the `ID&NMSP` syntax remember about proper XML entity
* escaping - ``ID&NMSP`.
* - `OAIURI` - resource's OAI-PMH ID
* - `OAIID` - resources's OAI-PMH identifier
* - `OAIURL` - URL of the OAI-PMH `GetRecord` request returning a given resource
* metadata in the currently requested metadata format
* - `IIIFURL` - resource's IIIF URL which is a concatenation of the metadata format's
* `iiifBaseUrl` parameter value and the path part of the repository resource ID in
* the `id` namespace.
Expand All @@ -113,10 +115,11 @@
* can be `Date` or `DateTime` which will automatically adjust date precision. Watch out
* as when present it will also naivly process any string values (cutting them or appending
* with a default time).
* - `format="FORMAT"` forces an URL value fetched according to the `val` attribute to be
* extended with a `?format=FORMAT`. Allows to provide links to particular serialization
* of repository objects when the default one (typically the repository GUI) is not the
* desired one. The `asXML` attribute takes a precedense.
* - `format="FORMAT"` extend the URL returned according to the `val` attribute with
* `?format=FORMAT` (when `val="ID"`) or `@format=FORMAT` (when `val="OAIID"`).
* This allows to provide URLs redirecting to particular dissemination services.
* It's worth noting that using `val="OAIID"` is faster.
* The `asXML` attribute takes a precedense.
* Doesn't work for special `val` attribute values of `NOW`, `URL` and `OAIURI`.
* - `valueMapProp="RDFpropertyURL"` causes value denoted by the `val` attribute to be
* mapped to another values using a given RDF property. The `val` attribute value must be
Expand Down Expand Up @@ -304,9 +307,15 @@ private function insertValue(DOMElement $el): bool {
} else if ($val === 'METAURL') {
$el->textContent = $this->res->getUri() . '/metadata';
$remove = false;
} else if ($val === 'OAIURI') {
$id = urlencode((string) $this->res->getGraph()->get($this->format->uriProp));
$prefix = urlencode($this->format->metadataPrefix);
} else if ($val === 'OAIID') {
$id = (string) $this->res->getGraph()->get($this->format->uriProp);
$format = $el->getAttribute('format');
$format = !empty($format) ? '@format=' . urlencode($format) : '';
$el->textContent = $id . $format;
$remove = false;
} else if ($val === 'OAIURL') {
$id = rawurlencode((string) $this->res->getGraph()->get($this->format->uriProp));
$prefix = rawurlencode($this->format->metadataPrefix);
$el->textContent = $this->format->info->baseURL . '?verb=GetRecord&metadataPrefix=' . $prefix . '&identifier=' . $id;
$remove = false;
} else if ($val === 'IIIFURL') {
Expand Down

0 comments on commit 91caef3

Please sign in to comment.