<?php
header("Content-Type: application/xml; charset=utf-8");
require_once '../../inc/i.php';
require_once '../../inc/r.php';
if (isset($_GET['c']))
	$company = $_GET['c'];
else
	$company = '';
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
	<channel>
		<?php if (!isset($_GET['c'])) { ?>
		<title>Ledova.com - Job Reviews, Company Ratings, Career advice and more</title>
		<?php } else { ?>
		<title>Ledova.com - <?=$company?> Job Reviews</title>
		<?php } ?>
		<link>http://www.ledova.com/</link>
		<description>Discover the most up-to-date activities <?=($company=='')?'':"ragarding $company"?> at Levoda.com</description>
		<category>Career</category>
		<language>en-us</language>
		<atom:link href="http://<?=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>" rel="self" type="application/rss+xml" />
	
	<?php
	    // to do
	    // get a list of newest reviews
	    // reference: http://searchenginewatch.com/showPage.html?page=2175271

		if (!isset($_GET['c']))
			$cid = null;
		else
			$cid = intval(Lookup::cid($company));
		$reviews = Review::getReviews($cid,null,null,null,0,10,250);
		array_pop($reviews);
		foreach ($reviews as $r) {
			$metadata = Review::getInfo($r['cid'],$r['pid'],$r['lid']);
			$permlink = Links::getPermLinkReview($metadata['company'],$r['id'],$r['topic']);
			echo "\t<item>\n\t\t<title>{$r['topic']} - {$metadata['company']}";
			if (!empty($metadata['position']))
			    echo " / {$metadata['position']}";
			if (!empty($metadata['location']))
			    echo " / {$metadata['location']}";
			echo "</title>\n";
			echo "\t\t<description>{$r['review']}</description>\n";
			echo "\t\t<link>http://{$_SERVER['HTTP_HOST']}$permlink</link>\n";
			echo "\t\t<guid>http://{$_SERVER['HTTP_HOST']}$permlink</guid>\n\t</item>\n";
		}

	?></channel></rss>