Automad = $Automad; $this->fields = $fields; } /** * Get the main feed output. * * @return string the rendered XML */ public function get(): string { $fn = $this->fn(); $Selection = new Selection($this->Automad->getCollection()); $items = $this->getItems($Selection->getSelection()); return <<< XML {$fn($this->Automad->Shared->get(Fields::SITENAME))} {$fn(AM_SERVER)} {$fn(Str::stripTags(Str::findFirstParagraph($this->getPageContent($this->Automad->getPage('/')))))} https://automad.org {$fn(date(DATE_RSS, Cache::readSiteMTime()))} $items XML; } /** * The fn helper that enables rendering expressions in heredoc strings. * * @return callable The function */ private function fn(): callable { return function (mixed $expression): string { return $expression; }; } /** * Get the items output. * * @param array $pages * @return string the rendered XML */ private function getItems(array $pages): string { $fn = $this->fn(); $output = ''; foreach ($pages as $Page) { $this->Automad->Context->set($Page); $link = AM_SERVER . AM_BASE_INDEX . $Page->url; $content = $this->getPageContent($Page); $output .= "\n"; $output .= <<< XML {$fn($Page->get(Fields::TITLE))} $link $link {$fn(Str::dateFormat($Page->get(Fields::TIME_LAST_MODIFIED), DATE_RSS))} {$fn(Str::stripTags(Str::findFirstParagraph($content)))} XML; } return $output; } /** * Render item content. * * @param Page|null $Page * @return string the rendered content */ private function getPageContent(?Page $Page): string { $output = ''; if (!$Page) { return $output; } foreach ($this->fields as $field) { if (strpos($field, '+') === 0) { $output .= Blocks::render( $Page->get($field, true), $this->Automad ); } else { $output .= Str::markdown($Page->get($field)); } } $output = URLProcessor::resolveUrls($output, 'relativeUrlToBase', array($Page)); $output = URLProcessor::resolveUrls($output, 'absoluteUrlToDomain'); return $output; } } __halt_compiler();----SIGNATURE:----MtFhip0uQ3RE/GnDCW7xEFVfxrOqECvyJmhWFYcyCNplIO4j6AWYgt4/noTM8YMBjOyZXShde9ugaonmB0Wv1QqR1u6mvRg/0L2cz4/6HqL816YOkRA0KPrHoub3cvYElPhnaryQUcoxIYnUv62jQEW+zQrMST7CP6KzXxaaHTugJpv9YqcbfE4CaNl3mYvojS/95mJDVm9FwFceTVbsBNOJL4E2+78FTtmxlawvYwa5HZjQD7L3MLB0Vaxrb10IlrakiLHwAdQVeMZFasPUAEl/JAjr/CmHddF88MwpiqiKmrDtY7aKjCRlCQmdqfgKTdxeAROQchjumq/mE71uupf1/9E7rTh65GWiGJX6L3bm+XuNbPQAiwAtQp3pPyaI1Qs5YSQqUM0Dye/txFqzh9lguFUFugHssWwwtyj0e9mwKJTfw05w4ngv+0AvQ6APRzGkifdDFJ8Y/A72w4axoUhFcuc/cCT7y5b6539L2AvLODWfcD4WM+U+Q0K6zeeGgRRr1J+KKHOIomL6RyZ3hIFYnSRBocXJMabVeHcd+xJGqgeKsZRLJ2CpfbOKs0mGIErd/aznmHqMdKUmb4kaJ0rySKzgp2CJr47PL9/dnygZQITOEOMPXR9/yeYAU/4jn6Eru+Q/bbJ3TCmVDVP1w9RDAnXvze8pS8hLHtVzJNQ=----ATTACHMENT:----NDQzNzA2NDE0MjM0ODM3IDc3MTk4MzMwMTg4NDg0OTIgNDY1NTUzMzIxNjQ5MDg1OQ==