Monatsvorhersage mit vollständigen Mondphasen
This commit is contained in:
@@ -161,7 +161,10 @@ try {
|
||||
);
|
||||
$authorId = (int) $authorStmt->fetchColumn();
|
||||
if ($authorId <= 0) {
|
||||
throw new RuntimeException('Kein Joomla-Autor für die Monatsvorschau vorhanden.');
|
||||
// Kategorie 59 kann beim ersten Export noch leer sein.
|
||||
// Monatsvorschauen werden dann mit dem festgelegten Joomla-
|
||||
// Autor angelegt.
|
||||
$authorId = 217;
|
||||
}
|
||||
|
||||
$insertContentStmt = $pdo->prepare(
|
||||
|
||||
@@ -896,11 +896,10 @@ if (!function_exists('monthForecastBuildNarrativeText')) {
|
||||
}
|
||||
}
|
||||
|
||||
$moonEvents = $findEvents(
|
||||
$moonEvents = array_values(array_filter(
|
||||
$filteredEvents,
|
||||
static fn (array $event): bool => in_array((string) ($event['type'] ?? ''), ['moon_phase', 'golden_handle', 'moon_planet', 'moon_planet_approach', 'moon_deep_sky', 'moon_deep_sky_approach', 'moon_occultation', 'moon_apsis'], true),
|
||||
10
|
||||
);
|
||||
static fn (array $event): bool => in_array((string) ($event['type'] ?? ''), ['moon_phase', 'golden_handle', 'moon_planet', 'moon_planet_approach', 'moon_deep_sky', 'moon_deep_sky_approach', 'moon_occultation', 'moon_apsis'], true)
|
||||
));
|
||||
// Jahreszahl aus Datum entfernen (z. B. "19.04.2026" → "19.04.")
|
||||
$shortDate = static function (string $d): string {
|
||||
return (string) preg_replace('/\.\d{4}$/', '.', $d);
|
||||
@@ -914,7 +913,13 @@ if (!function_exists('monthForecastBuildNarrativeText')) {
|
||||
));
|
||||
|
||||
$phaseEvents = array_values(array_filter($sortedMoonEvents, static fn (array $e): bool => (string) ($e['type'] ?? '') === 'moon_phase'));
|
||||
$nonPhaseEvents = array_values(array_filter($sortedMoonEvents, static fn (array $e): bool => (string) ($e['type'] ?? '') !== 'moon_phase'));
|
||||
// Alle Mondphasen müssen erhalten bleiben. Die übrigen Mondereignisse
|
||||
// werden weiterhin begrenzt, damit der Übersichtstext kompakt bleibt.
|
||||
$nonPhaseEvents = array_slice(
|
||||
array_values(array_filter($sortedMoonEvents, static fn (array $e): bool => (string) ($e['type'] ?? '') !== 'moon_phase')),
|
||||
0,
|
||||
10
|
||||
);
|
||||
|
||||
$moonSentences = [];
|
||||
|
||||
@@ -952,12 +957,22 @@ if (!function_exists('monthForecastBuildNarrativeText')) {
|
||||
$apsis = null;
|
||||
$approaches = [];
|
||||
$goldenHandle = null;
|
||||
$occultationTargets = [];
|
||||
foreach ($dateEvents as $de) {
|
||||
$type = (string) ($de['type'] ?? '');
|
||||
if ($type === 'moon_apsis') {
|
||||
$apsis = $de;
|
||||
} elseif ($type === 'golden_handle') {
|
||||
$goldenHandle = $de;
|
||||
} elseif ($type === 'moon_occultation' && isset($de['event_kind'])) {
|
||||
$occultationLabel = trim((string) ($de['event'] ?? ''));
|
||||
if (str_starts_with($occultationLabel, 'Mond bedeckt ')) {
|
||||
$target = substr($occultationLabel, strlen('Mond bedeckt '));
|
||||
$target = trim(explode(' – ', $target, 2)[0]);
|
||||
if ($target !== '') {
|
||||
$occultationTargets[$target] = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$approaches[] = $de;
|
||||
}
|
||||
@@ -965,6 +980,10 @@ if (!function_exists('monthForecastBuildNarrativeText')) {
|
||||
|
||||
$sd = $shortDate($date);
|
||||
|
||||
foreach (array_keys($occultationTargets) as $target) {
|
||||
$moonSentences[] = 'Am ' . $sd . ' bedeckt der Mond ' . $target . '.';
|
||||
}
|
||||
|
||||
if ($goldenHandle !== null) {
|
||||
$moonSentences[] = 'Am ' . $sd . ' zeigt der Mond den Goldenen Henkel: Ein Gebirgskamm am Mondrand leuchtet bereits im Sonnenlicht, während das Tal dahinter noch im Schatten liegt – ein lohnender Anblick schon im kleinen Teleskop.';
|
||||
}
|
||||
@@ -2474,6 +2493,7 @@ foreach ($moonPlanetApproaches as $approachEvent) {
|
||||
'date' => (string) ($approachEvent['local_date'] ?? ''),
|
||||
'time' => (string) ($approachEvent['local_time'] ?? ''),
|
||||
'local_iso' => (string) ($approachEvent['local_iso'] ?? ''),
|
||||
'event_kind' => $eventKind,
|
||||
'type' => $eventKind !== '' ? 'moon_occultation' : 'moon_planet',
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user