<?php
require_once('./system/core/Bootlegger.php');

$objects = Cms::factory()->getCmsPages();

$i=0;
foreach($objects as $obj)
{
	$pages[$i]['name'] = (string) $obj->name;
	$pages[$i]['sitemap'] = (int) $obj->sitemap;
	$pages[$i]['timestamp'] = (int) $obj->timestamp;
	$i++;
}

?>
<?php header('Content-type: text/xml'); ?>
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
	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">'; ?>

	
<?php
	foreach($pages as $page)
	{
		$str = '';
		if($page['sitemap'] == 1)
		{
			$str .= '<url>';
			$str .= '<loc>'.url::base().$page['name'].'</loc>';
			$str .= '<lastmod>'.date('Y-m-d', strtotime($page['timestamp'])).'</lastmod>';
			$str .= '<changefreq>monthly</changefreq>';
			$str .= '</url>';
			echo $str;
		}
	}

?>			
<?php echo '</urlset>';?>