<?php

include_once dirname(__FILE__).'/common.php';


function addURL($relURL) {

    echo("<url><loc>".URL_ROOT.$relURL."</loc></url>\n");
}

function get_archive_path($root, $path) {
    $res = array();

    include("$root/$path/config.php");

    if(isset($config['event_list']) && !empty($config['event_list']) ) {
        array_push($res, "$path/select.php");
        foreach($config['event_list'] as $event) {
            $event_array = explode("/", $event);
            array_shift($event_array);
            $event_str = implode("/",$event_array);
            array_push($res, "$path/$event_str/polemicaltimeline.php");
        }
    } else {
        array_push($res, "$path/polemicaltimeline.php");
    }

    return $res;
}

header('Content-Type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";

?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
addURL("");
addURL("about.php");
addURL("archives.php");

$archives=array ();

for($i=0;$i<count($archives_list);$i++) {
    
    $archive_ref = $archives_list[$i];
    $archive_name = $archive_ref;
    if(is_array($archive_ref)) {
        $archive_name = $archive_ref[0];
    }
    $archives = array_merge($archives,get_archive_path(dirname(__FILE__), $archive_name));
}

foreach ($archives as $archPath) {
    addURL($archPath);
}

?>
</urlset>

