<?php
include_once './includes/news/ArticleLister.inc.php';
include_once './includes/news/ArticleFormatter.inc.php';
include_once './includes/utils/DateFormatter.inc.php';

include_once './includes/config/Configuration.inc.php';

$articles = ArticleLister::getAllArticles();

$buildDate = DateFormatter::formatRFC(time());
$pubDate = DateFormatter::formatRFC(time());

$title = Configuration::siteName;
$description = Configuration::feedName;
$link = Configuration::SiteURL;

$header = <<<HEADER
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
<title>$title</title>
<description>$description</description>
<link>$link</link>

<lastBuildDate>$buildDate</lastBuildDate>
<pubDate>$pubDate</pubDate>
HEADER;

$footer = <<<FOOTER
</channel>
</rss>
FOOTER;

echo $header;
foreach($articles as $article) {
    echo ArticleFormatter::getXML($article);
}
echo $footer;


?>
