From 01bce13b1cd15fdb6c7682009d92a423d77e6931 Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Wed, 2 Oct 2024 20:13:59 +0200 Subject: [PATCH] add missing properties to Festivity class --- php/index.php | 17 ++++------------- php/src/Festivity.php | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/php/index.php b/php/index.php index ae3923a..4b3889c 100644 --- a/php/index.php +++ b/php/index.php @@ -65,16 +65,7 @@ foreach ($LitCal as $key => $value) { // retransform each entry from an associative array to a Festivity class object - $LitCal[$key] = new Festivity( - $LitCal[$key]["name"], - $LitCal[$key]["date"], - $LitCal[$key]["color"], - $LitCal[$key]["type"], - $LitCal[$key]["grade"], - $LitCal[$key]["common"], - $LitCal[$key]["liturgical_year"] ?? '', - $LitCal[$key]["display_grade"] - ); + $LitCal[$key] = new Festivity($LitCal[$key]); } } @@ -120,19 +111,19 @@ echo _('You are requesting a year prior to 1970: it is not possible to request years prior to 1970.'); echo ''; } - $c = $litSettings->Locale === 'la' ? new Collator('en') : new Collator($litSettings->Locale); + $c = $litSettings->Locale === 'la' || $litSettings->Locale === 'la_VA' ? new Collator('en') : new Collator($litSettings->Locale); $AllAvailableLocales = array_filter(ResourceBundle::getLocales(''), function ($value) { return strpos($value, 'POSIX') === false; }); $AllAvailableLocales = array_reduce($AllAvailableLocales, function ($carry, $item) use ($litSettings) { - if ($litSettings->Locale === 'la') { + if ($litSettings->Locale === 'la' || $litSettings->Locale === 'la_VA') { $carry[$item] = [ Locale::getDisplayName($item, 'en'), Locale::getDisplayName($item, 'en') ]; } else { $carry[$item] = [ Locale::getDisplayName($item, $litSettings->Locale), Locale::getDisplayName($item, 'en') ]; } return $carry; }, []); - $AllAvailableLocales['la'] = [ 'Latin', 'Latin' ]; + $AllAvailableLocales['la_VA'] = [ 'Latin', 'Latin' ]; $c->asort($AllAvailableLocales); echo '
'; echo '
' . _('Customize options for generating the Roman Calendar') . ''; diff --git a/php/src/Festivity.php b/php/src/Festivity.php index cc56429..5036630 100644 --- a/php/src/Festivity.php +++ b/php/src/Festivity.php @@ -13,21 +13,27 @@ class Festivity public string $name; public \DateTime $date; public array $color; + public string $color_lcl; public string $type; public int $grade; + public string $grade_lcl; public string $displayGrade; public array $common; + public string $common_lcl; public string $liturgicalYear; - public function __construct(string $name, int $date, array $color, string $type, int $grade = 0, array $common = [], string $liturgicalYear = '', string $displayGrade = '') + public function __construct(array $LitEvent) { - $this->name = (string) $name; - $this->date = \DateTime::createFromFormat('U', $date, new \DateTimeZone('UTC')); - $this->color = $color; - $this->type = (string) $type; - $this->grade = (int) $grade; - $this->common = $common; - $this->liturgicalYear = (string) $liturgicalYear; - $this->displayGrade = (string) $displayGrade; + $this->name = $LitEvent['name']; + $this->date = \DateTime::createFromFormat('U', $LitEvent['date'], new \DateTimeZone('UTC')); + $this->color = $LitEvent['color']; + $this->color_lcl = $LitEvent['color_lcl']; + $this->type = $LitEvent['type']; + $this->grade = $LitEvent['grade']; + $this->grade_lcl = $LitEvent['grade_lcl']; + $this->common = $LitEvent['common']; + $this->common_lcl = $LitEvent['common_lcl']; + $this->liturgicalYear = $LitEvent['liturgical_year']; + $this->displayGrade = $LitEvent['display_grade']; } }