Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] EDTF date sets in multivalued fields are rendered into human-readable text incorrectly. #95

Closed
rosiel opened this issue Apr 18, 2023 · 2 comments · Fixed by #96
Closed
Labels
bug Something isn't working

Comments

@rosiel
Copy link
Member

rosiel commented Apr 18, 2023

What steps does it take to reproduce the issue?

  • Enable date sets in an EDTF field (admittedly, this is "not recommended")

  • Enable multiple values in that field

  • Add multiple date sets to see how they render.

  • When does this issue occur?
    When looking at the node

  • Which page does it occur on?
    a node

  • What happens?
    the human-readable version of each date set includes data from other "deltas" (i.e. other values in the multivalued field)

In my example the first two values in the multivalued field are:

  • [1667,1668,1670..1672] which renders as "one of the dates: 1667, 1668, 1670 until 1672"

  • [..1760-12-03] which renders as "one of the dates: 1667, 1668, 1670 until 1672, 1760-12-03 or some earlier date"

  • To whom does it occur (anonymous visitor, editor, administrator)?
    Everyone can see it.

  • What did you expect to happen?
    the values to be rendered to text independently

Which version of Islandora are you using?
2
more meaningfully, the starter site

Any related open or closed issues to this bug report?

not that i know of

Screenshots:

Screenshot 2023-04-18 at 12 25 38 PM

@rosiel rosiel added the bug Something isn't working label Apr 18, 2023
@adam-vessey
Copy link
Contributor

adam-vessey commented Apr 19, 2023

Giving a quick look, thinking that $formatted_dates just needs to be (re)initialized to an empty array before it is populated with the values of the new set:

foreach (explode(',', trim($item->value, '{}[] ')) as $date) {
$date_range = explode('..', $date);
switch (count($date_range)) {
case 1:
$formatted_dates[] = $this->formatDate($date);
break;
case 2:
if (empty($date_range[0])) {
$formatted_dates[] = t('@date or some earlier date', [
'@date' => $this->formatDate($date_range[1]),
]);
}
elseif (empty($date_range[1])) {
$formatted_dates[] = t('@date or some later date', [
'@date' => $this->formatDate($date_range[0]),
]);
}
else {
$formatted_dates[] = t('@date_begin until @date_end', [
'@date_begin' => $this->formatDate($date_range[0]),
'@date_end' => $this->formatDate($date_range[1]),
]);
}
break;
}
}
$element[$delta] = [
'#markup' => t('@qualifier @list', [
'@qualifier' => $set_qualifier,
'@list' => implode(', ', $formatted_dates),
]),
];

... probably something like adding a

$formatted_dates = [];

just before that foreach, kind of thing?

@adam-vessey
Copy link
Contributor

Threw together #96 as a theoretical fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants