Skip to content

Commit

Permalink
add missing properties to Festivity class
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Oct 2, 2024
1 parent 99d3123 commit 01bce13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
17 changes: 4 additions & 13 deletions php/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down Expand Up @@ -120,19 +111,19 @@
echo _('You are requesting a year prior to 1970: it is not possible to request years prior to 1970.');
echo '</div>';
}
$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 '<form method="GET">';
echo '<fieldset style="margin-bottom:6px;"><legend>' . _('Customize options for generating the Roman Calendar') . '</legend>';
Expand Down
24 changes: 15 additions & 9 deletions php/src/Festivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}

0 comments on commit 01bce13

Please sign in to comment.