require_once 'MDB2.php';
	$db = MDB2::factory(DSN);
    $db->setFetchMode(MDB2_FETCHMODE_ASSOC); 
    $db->setOption('portability', MDB2_PORTABILITY_NONE);
    $db->loadModule('Extended');
	
	$CID = 276;
	$CollectionTableName = 'Collection_'.$CID;
	//get the rotator name and nav browser info
	$SQL = "SELECT $CollectionTableName.*  FROM  $CollectionTableName WHERE 1 ";
	$Pages = $db->queryAll($SQL);
	foreach ($Pages as $k => $v)
	{
		foreach ($v as $kk => $vv)
		{
			$Pages[$k][$kk] = utf8_encode(htmlspecialchars ($vv));
		}
	}
	
	//we need to get news pages
	$News[]['Link'] = '/news/';
	$News[]['Link'] = '/news/archives/';
	
	$SQL = "SELECT Collection_273.*  FROM  Collection_273 WHERE 1 ";
	$NewsCategories = $db->queryAll($SQL);
	if ($NewsCategories)
	{
		foreach ($NewsCategories as $k => $v)
		{
			$News[]['Link'] = '/news/'.$v['Collection_273_ID']."/";
		}
	}
	
	$SQL = "SELECT Collection_275.* , Collection_274.*  FROM  Collection_274 INNER JOIN Collection_275 ON Collection_275_1 = Collection_274_ID WHERE 1  Group By Collection_274_ID ";
	$NewsArticles = $db->queryAll($SQL);
	if ($NewsArticles)
	{
		foreach ($NewsArticles as $k => $v)
		{
			$News[]['Link'] = '/news/'.$v['Collection_275_2']."/".$v['Collection_274_ID']."/";
		}
	}
	
	//we get the events
	$SQL = "SELECT Collection_236.*  FROM  Collection_236 WHERE 1 ";
	$Events = $db->queryAll($SQL);
	
	//we get the events
	$SQL = "SELECT Collection_303.*  FROM  Collection_303 WHERE 1 ";
	$Extra = $db->queryAll($SQL);
	
	
		$filename = 'sitemap.xml';
		header("Content-type: text/xml");
        header("Content-Disposition: attachment; filename=\"$filename\"");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
        header("Pragma: public");
	
	$smarty->assign("Extra", $Extra);
	$smarty->assign("Events", $Events);
	$smarty->assign("News", $News);
	$smarty->assign("Pages", $Pages);
	$smarty->display('pagesXML.html');
