<?php
header('Content-Type: application/xml; charset=utf-8');
$today = date('Y-m-d');
$base  = 'https://schlegel-ventures.com';
$pierres_data = json_decode(file_get_contents(__DIR__ . '/data/pierres.json'), true);

// Static pages: [de_url, cz_url, priority, changefreq]
$static_pages = [
    ['/', '/cz/', '1.00', 'weekly'],
    ['/edelsteine', '/cz/edelsteine', '0.90', 'weekly'],
    ['/vergleich', '/cz/vergleich', '0.80', 'monthly'],
    ['/kontakt', '/cz/kontakt', '0.85', 'monthly'],
    ['/gia-check', '/cz/gia-check', '0.80', 'monthly'],
];
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">

  <?php foreach ($static_pages as $pg): ?>
  <url>
    <loc><?= $base . htmlspecialchars($pg[0]) ?></loc>
    <xhtml:link rel="alternate" hreflang="de"        href="<?= $base . htmlspecialchars($pg[0]) ?>"/>
    <xhtml:link rel="alternate" hreflang="cs"        href="<?= $base . htmlspecialchars($pg[1]) ?>"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="<?= $base . htmlspecialchars($pg[0]) ?>"/>
    <lastmod><?= $today ?></lastmod>
    <changefreq><?= $pg[3] ?></changefreq>
    <priority><?= $pg[2] ?></priority>
  </url>
  <url>
    <loc><?= $base . htmlspecialchars($pg[1]) ?></loc>
    <xhtml:link rel="alternate" hreflang="de"        href="<?= $base . htmlspecialchars($pg[0]) ?>"/>
    <xhtml:link rel="alternate" hreflang="cs"        href="<?= $base . htmlspecialchars($pg[1]) ?>"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="<?= $base . htmlspecialchars($pg[0]) ?>"/>
    <lastmod><?= $today ?></lastmod>
    <changefreq><?= $pg[3] ?></changefreq>
    <priority><?= (float)$pg[2] - 0.05 ?></priority>
  </url>
  <?php endforeach; ?>

  <?php foreach ($pierres_data as $p):
    $de_url = '/edelstein/' . $p['slug'];
    $cz_url = '/cz/edelstein/' . $p['slug'];
  ?>
  <!-- DE: <?= htmlspecialchars($p['name']) ?> -->
  <url>
    <loc><?= $base . $de_url ?></loc>
    <xhtml:link rel="alternate" hreflang="de"        href="<?= $base . $de_url ?>"/>
    <xhtml:link rel="alternate" hreflang="cs"        href="<?= $base . $cz_url ?>"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="<?= $base . $de_url ?>"/>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.85</priority>
  </url>
  <!-- CZ: <?= htmlspecialchars($p['name']) ?> -->
  <url>
    <loc><?= $base . $cz_url ?></loc>
    <xhtml:link rel="alternate" hreflang="de"        href="<?= $base . $de_url ?>"/>
    <xhtml:link rel="alternate" hreflang="cs"        href="<?= $base . $cz_url ?>"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="<?= $base . $de_url ?>"/>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.80</priority>
  </url>
  <?php endforeach; ?>

</urlset>