Skip to content

Commit

Permalink
create handleNationalCalendarRows method
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Feb 9, 2022
1 parent ccff730 commit 15f16c3
Showing 1 changed file with 32 additions and 51 deletions.
83 changes: 32 additions & 51 deletions includes/LitCalAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1785,67 +1785,48 @@ private function createNewRegionalFestivity( object $row ) : void {
$this->elaborateDecreeSource( $row ),
$this->LitSettings->Year
);
} else {
}// else {
//$this->handleCoincidenceDecree( $row );
//}
}

private function handleNationalCalendarRows( array $rows ) : void {
foreach( $this->WiderRegionData->LitCal as $row ) {
if( $this->LitSettings->Year >= $row->Metadata->sinceYear ) {
if( property_exists( $row->Metadata, "untilYear" ) && $this->LitSettings->Year >= $row->Metadata->untilYear ) {
continue;
} else {
//if either the property doesn't exist (so no limit is set)
//or there is a limit but we are within those limits
switch( $row->Metadata->action ) {
case "makePatron":
$festivity = $this->Cal->getFestivity( $row->Festivity->tag );
if( $festivity !== null ) {
if( $festivity->grade !== $row->Festivity->grade ) {
$this->Cal->setProperty( $row->Festivity->tag, "grade", $row->Festivity->grade );
}
$this->Cal->setProperty( $row->Festivity->tag, "name", $row->Festivity->name );
} else {
$this->handleMissingFestivity( $row );
}
break;
case "createNew":
$this->createNewRegionalFestivity( $row );
break;
}
}
}
}
}

private function applyNationalCalendar() : void {
//first thing is apply any wider region festivities, such as Patron Saints of the Wider Region (example: Europe)
if( $this->WiderRegionData !== null && property_exists( $this->WiderRegionData, "LitCal" ) ) {
foreach( $this->WiderRegionData->LitCal as $row ) {
if( $this->LitSettings->Year >= $row->Metadata->sinceYear ) {
if( property_exists( $row->Metadata, "untilYear" ) && $this->LitSettings->Year >= $row->Metadata->untilYear ) {
continue;
} else {
//if either the property doesn't exist (so no limit is set)
//or there is a limit but we are within those limits
switch( $row->Metadata->action ) {
case "makePatron":
$festivity = $this->Cal->getFestivity( $row->Festivity->tag );
if( $festivity !== null ) {
if( $festivity->grade !== $row->Festivity->grade ) {
$this->Cal->setProperty( $row->Festivity->tag, "grade", $row->Festivity->grade );
}
$this->Cal->setProperty( $row->Festivity->tag, "name", $row->Festivity->name );
} else {
$this->handleMissingFestivity( $row );
}
break;
case "createNew":
$this->createNewRegionalFestivity( $row );
break;
}
}
}
}
$this->handleNationalCalendarRow( $this->WiderRegionData->LitCal );
}

if( $this->NationalData !== null && property_exists( $this->NationalData, "LitCal" ) ) {
foreach( $this->NationalData->LitCal as $row ) {
if( $this->LitSettings->Year >= $row->Metadata->sinceYear ) {
if( property_exists( $row->Metadata, "untilYear" ) && $this->LitSettings->Year >= $row->Metadata->untilYear ) {
continue;
} else {
switch( $row->Metadata->action ) {
case "makePatron":
$festivity = $this->Cal->getFestivity( $row->Festivity->tag );
if( $festivity !== null ) {
if( $festivity->grade !== $row->Festivity->grade ) {
$this->Cal->setProperty( $row->Festivity->tag, "grade", $row->Festivity->grade );
}
$this->Cal->setProperty( $row->Festivity->tag, "name", $row->Festivity->name );
} else {
$this->handleMissingFestivity( $row );
}
break;
case "createNew":
$this->createNewRegionalFestivity( $row );
break;
}
}
}
}
$this->handleNationalCalendarRow( $this->NationalData->LitCal );
}

if( $this->NationalData !== null && property_exists( $this->NationalData, "Metadata" ) && property_exists( $this->NationalData->Metadata, "Missals" ) ) {
Expand Down

0 comments on commit 15f16c3

Please sign in to comment.