Skip to content

Commit

Permalink
Merge pull request #256 from Liturgical-Calendar/JohnRDOrazio/issue253
Browse files Browse the repository at this point in the history
refactor `display_grade` to `grade_display`
  • Loading branch information
JohnRDOrazio authored Nov 14, 2024
2 parents cc20908 + a87ab1d commit 88e103b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"event_key": "StAdalbert",
"name": "Sant'Adalberto, vescovo e martire",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Martyrs:For One Martyr",
"Pastors:For a Bishop"
Expand All @@ -29,7 +29,7 @@
"event_key": "StLouisGrignonMontfort",
"name": "San Luigi Grignon de Montfort",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Pastors:For One Pastor"
],
Expand All @@ -51,7 +51,7 @@
"event_key": "StPeterJulianEymard",
"name": "San Pietro Giuliani, sacerdote",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Pastors:For One Pastor",
"Holy Men and Women:For Religious"
Expand All @@ -74,7 +74,7 @@
"event_key": "StMaximilianKolbe",
"name": "San Massimiliano Kolbe, sacerdote e martire",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Proper"
],
Expand All @@ -97,7 +97,7 @@
"event_key": "StPeterClaver",
"name": "San Pietro Claver, sacerdote",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Pastors:For One Pastor",
"Holy Men and Women:For Those Who Practiced Works of Mercy"
Expand All @@ -120,7 +120,7 @@
"event_key": "StAndrewKimTaegon",
"name": "Santi Andrea Kim Taegon, sacerdote, Paolo Chong Hasang e compagni martiri",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Proper"
],
Expand All @@ -142,7 +142,7 @@
"event_key": "StsLawrenceRuiz",
"name": "Santi Lorenzo Ruiz e compagni martiri",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Martyrs:For Several Martyrs"
],
Expand All @@ -164,7 +164,7 @@
"event_key": "StAndrewDungLac",
"name": "Sant'Andrea Dung-Lac e compagni martiri",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Proper"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"event_key": "StElizabethSeton",
"name": "Saint Elizabeth Ann Seton, Religious",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Proper"
],
Expand All @@ -27,7 +27,7 @@
"event_key": "StJohnNeumann",
"name": "Saint John Neumann, Bishop",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Proper"
],
Expand All @@ -49,7 +49,7 @@
"event_key": "StAndreBessette",
"name": "Saint André Bessette, Religious",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Holy Men and Women:For Religious"
],
Expand All @@ -71,7 +71,7 @@
"event_key": "PrayerUnborn",
"name": "Day of Prayer for the Legal Protection of Unborn Children",
"grade": 3,
"display_grade": "National Day of Prayer",
"grade_display": "National Day of Prayer",
"common": [
"Masses and Prayers for Various Needs and Occasions:For Giving Thanks to God for the Gift of Human Life",
"Preservation of Peace and Justice"
Expand All @@ -95,7 +95,7 @@
"event_key": "StKatharineDrexel",
"name": "Saint Katharine Drexel, Virgin",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Virgins:For One Virgin"
],
Expand All @@ -117,7 +117,7 @@
"event_key": "StDamienVeuster",
"name": "Saint Damien de Veuster, Priest",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Pastors:For Missionaries"
],
Expand All @@ -139,7 +139,7 @@
"event_key": "StIsidore",
"name": "Saint Isidore",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Holy Men and Women:For One Saint"
],
Expand All @@ -161,7 +161,7 @@
"event_key": "JuniperoSerra",
"name": "Blessed Junípero Serra, Priest",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Pastors:For One Pastor",
"Pastors:For Missionaries"
Expand All @@ -184,7 +184,7 @@
"event_key": "IndependenceDay",
"name": "Independence Day",
"grade": 3,
"display_grade": "National Holiday",
"grade_display": "National Holiday",
"common": [
"Proper"
],
Expand All @@ -206,7 +206,7 @@
"event_key": "KateriTekakwitha",
"name": "Blessed Kateri Tekakwitha, Virgin",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Virgins:For One Virgin"
],
Expand All @@ -228,7 +228,7 @@
"event_key": "StPeterClaver",
"name": "Saint Peter Claver, Priest",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Pastors:For One Pastor",
"Holy Men and Women:For Those Who Practiced Works of Mercy"
Expand All @@ -251,7 +251,7 @@
"event_key": "MarieDurocher",
"name": "Blessed Marie Rose Durocher, Virgin",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Virgins:For One Virgin"
],
Expand All @@ -273,7 +273,7 @@
"event_key": "StFrancesXCabrini",
"name": "Saint Frances Xavier Cabrini, Virgin",
"grade": 3,
"display_grade": "",
"grade_display": "",
"common": [
"Virgins:For One Virgin",
"Holy Men and Women:For Those Who Practiced Works of Mercy"
Expand All @@ -296,7 +296,7 @@
"event_key": "StRoseDuchesne",
"name": "Saint Rose Philippine Duchesne, Virgin",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Virgins:For One Virgin"
],
Expand All @@ -318,7 +318,7 @@
"event_key": "MiguelPro",
"name": "Blessed Miguel Agustín Pro, Priest and Martyr",
"grade": 2,
"display_grade": "",
"grade_display": "",
"common": [
"Martyrs:For One Martyr",
"Pastors:For One Pastor"
Expand Down
12 changes: 6 additions & 6 deletions schemas/LitCal.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"type": "mobile",
"grade": 7,
"grade_lcl": "celebratio altioris ordinis quam sollemnitatis",
"display_grade": "",
"grade_display": "",
"common": [],
"common_lcl": "",
"day_of_the_week_iso8601": 6,
Expand Down Expand Up @@ -247,7 +247,7 @@
"type": "mobile",
"grade": 7,
"grade_lcl": "celebratio altioris ordinis quam sollemnitatis",
"display_grade": "",
"grade_display": "",
"common": [],
"common_lcl": "",
"day_of_the_week_iso8601": 7,
Expand Down Expand Up @@ -330,7 +330,7 @@
"grade_lcl": {
"type": "string"
},
"display_grade": {
"grade_display": {
"type": "string"
},
"common": {
Expand Down Expand Up @@ -403,7 +403,7 @@
"color_lcl",
"type",
"grade",
"display_grade",
"grade_display",
"common",
"common_lcl",
"day_of_the_week_iso8601",
Expand Down Expand Up @@ -452,7 +452,7 @@
"grade_lcl": {
"type": "string"
},
"display_grade": {
"grade_display": {
"type": "string"
},
"common": {
Expand Down Expand Up @@ -531,7 +531,7 @@
"color_lcl",
"type",
"grade",
"display_grade",
"grade_display",
"common",
"common_lcl",
"day_of_the_week_iso8601",
Expand Down
2 changes: 1 addition & 1 deletion schemas/LitCalEventsPath.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"grade_lcl": {
"type": "string"
},
"display_grade": {
"grade_display": {
"type": "string"
},
"common": {
Expand Down
2 changes: 1 addition & 1 deletion schemas/PropriumDeSanctis.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"grade": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitGrade"
},
"display_grade": {
"grade_display": {
"type": "string"
},
"common": {
Expand Down
8 changes: 4 additions & 4 deletions src/Festivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Festivity implements \JsonSerializable
public array $color = [];
public string $type;
public int $grade;
public string $display_grade;
public string $grade_display;
public array $common; //"Proper" or specified common(s) of saints...

/** The following properties are set externally, but may be optional and therefore may remain null */
Expand Down Expand Up @@ -73,7 +73,7 @@ public function __construct(
$_type = strtolower($type);
$this->type = LitFeastType::isValid($_type) ? $_type : '???';
$this->grade = $grade >= LitGrade::WEEKDAY && $grade <= LitGrade::HIGHER_SOLEMNITY ? $grade : -1;
$this->display_grade = $displayGrade;
$this->grade_display = $displayGrade;
$this->grade_lcl = self::$LitGrade->i18n($this->grade, false);
//Festivity::debugWrite( "*** Festivity.php *** common vartype = " . gettype( $common ) );
if (is_string($common)) {
Expand Down Expand Up @@ -126,7 +126,7 @@ public static function compDate(Festivity $a, Festivity $b)
* - type: the type of the festivity
* - grade: the grade of the festivity
* - grade_lcl: the grade of the festivity, translated according to the current locale
* - display_grade: a boolean indicating whether the grade of the festivity should be displayed
* - grade_display: a boolean indicating whether the grade of the festivity should be displayed
* - common: an array of common prayers associated with the festivity
* - common_lcl: an array of common prayers associated with the festivity, translated according to the current locale
* - day_of_the_week_iso8601: the day of the week of the festivity, in the ISO 8601 format (1 for Monday, 7 for Sunday)
Expand Down Expand Up @@ -159,7 +159,7 @@ public function jsonSerialize(): array
'type' => $this->type,
'grade' => $this->grade,
'grade_lcl' => $this->grade_lcl,
'display_grade' => $this->display_grade,
'grade_display' => $this->grade_display,
'common' => $this->common,
'common_lcl' => $this->common_lcl,
'day_of_the_week_iso8601' => (int) $this->date->format('N'), //1 for Monday, 7 for Sunday
Expand Down
2 changes: 1 addition & 1 deletion src/FestivityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function addFestivity(string $key, Festivity $festivity): void
{
$this->festivities[ $key ] = $festivity;
if ($festivity->grade === LitGrade::HIGHER_SOLEMNITY) {
$this->festivities[ $key ]->display_grade = "";
$this->festivities[ $key ]->grade_display = "";
}
if ($festivity->grade >= LitGrade::FEAST_LORD) {
$this->solemnities[ $key ] = $festivity->date;
Expand Down
22 changes: 11 additions & 11 deletions src/Paths/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ private function calculateFixedSolemnities(): void
}

//let's add a displayGrade property for AllSouls so applications don't have to worry about fixing it
$this->Cal->setProperty("AllSouls", 'display_grade', $this->LitGrade->i18n(LitGrade::COMMEMORATION, false));
$this->Cal->setProperty("AllSouls", 'grade_display', $this->LitGrade->i18n(LitGrade::COMMEMORATION, false));

$this->Cal->addSolemnitiesLordBVM([
"Easter",
Expand Down Expand Up @@ -1660,7 +1660,7 @@ private function calculateFeastsOfTheLord(): void
$currentFeastDate = DateTime::createFromFormat('!j-n-Y', $row->day . '-' . $row->month . '-' . $this->CalendarParams->Year, new \DateTimeZone('UTC'));
$festivity = new Festivity($row->name, $currentFeastDate, $row->color, LitFeastType::FIXED, $row->grade, $row->common);
if ($row->event_key === 'DedicationLateran') {
$festivity->display_grade = $this->LitGrade->i18n(LitGrade::FEAST, false);
$festivity->grade_display = $this->LitGrade->i18n(LitGrade::FEAST, false);
}
$this->Cal->addFestivity($row->event_key, $festivity);
}
Expand Down Expand Up @@ -3561,7 +3561,7 @@ private function applyNationalCalendar(): void
LitFeastType::FIXED,
$row->grade,
$row->common,
$row->display_grade
$row->grade_display
);
$this->Cal->addFestivity($row->event_key, $festivity);
} else {
Expand All @@ -3573,7 +3573,7 @@ private function applyNationalCalendar(): void
LitFeastType::FIXED,
$row->grade,
$row->common,
$row->display_grade
$row->grade_display
);
$this->Cal->addFestivity($row->event_key, $festivity);
$this->Messages[] = sprintf(
Expand All @@ -3593,7 +3593,7 @@ private function applyNationalCalendar(): void
* 7. Requested calendar year
*/
$this->NationalData->metadata->region . ": " . _('The %1$s \'%2$s\' (%3$s), added to the national calendar in the %4$s, is superseded by the %5$s \'%6$s\' in the year %7$d'),
$row->display_grade !== "" ? $row->display_grade : $this->LitGrade->i18n($row->grade, false),
$row->grade_display !== "" ? $row->grade_display : $this->LitGrade->i18n($row->grade, false),
'<i>' . $row->name . '</i>',
$this->dayAndMonth->format($currentFeastDate->format('U')),
RomanMissal::getName($missal),
Expand Down Expand Up @@ -4207,17 +4207,17 @@ private function produceIcal(\stdClass $SerializeableLitCal, \stdClass $GitHubRe
$displayGrade = $this->LitGrade->i18n(LitGrade::FEAST, false);
$displayGradeHTML = $this->LitGrade->i18n(LitGrade::FEAST, true);
} elseif ((int)$CalEvent->date->format('N') !== 7) {
if (property_exists($CalEvent, 'display_grade') && $CalEvent->display_grade !== "") {
$displayGrade = $CalEvent->display_grade;
$displayGradeHTML = '<B>' . $CalEvent->display_grade . '</B>';
if (property_exists($CalEvent, 'grade_display') && $CalEvent->grade_display !== "") {
$displayGrade = $CalEvent->grade_display;
$displayGradeHTML = '<B>' . $CalEvent->grade_display . '</B>';
} else {
$displayGrade = $this->LitGrade->i18n($CalEvent->grade, false);
$displayGradeHTML = $this->LitGrade->i18n($CalEvent->grade, true);
}
} elseif ((int)$CalEvent->grade > LitGrade::MEMORIAL) {
if (property_exists($CalEvent, 'display_grade') && $CalEvent->display_grade !== "") {
$displayGrade = $CalEvent->display_grade;
$displayGradeHTML = '<B>' . $CalEvent->display_grade . '</B>';
if (property_exists($CalEvent, 'grade_display') && $CalEvent->grade_display !== "") {
$displayGrade = $CalEvent->grade_display;
$displayGradeHTML = '<B>' . $CalEvent->grade_display . '</B>';
} else {
$displayGrade = $this->LitGrade->i18n($CalEvent->grade, false);
$displayGradeHTML = $this->LitGrade->i18n($CalEvent->grade, true);
Expand Down

0 comments on commit 88e103b

Please sign in to comment.