<?php

/**
 * /rss2/designs.xml
 *
 * This generates RSS XML data the 10 most recent designs added to the workshop.
 */

require_once('core.inc');

////////////////////////////////////////////////////////////////////////////////

$cond = array();
$cond[] = "post_type = 'design'";
$cond[] = "post_status = 'queued'";
$cond = implode(' AND ', $cond);

////////////////////////////////////////////////////////////////////////////////

core_tool('rss2design');

$rss2cache = new RSS2Cache(5);
if ($rss2cache->dump())
  exit;

$chan = new RSS2Channel("Newest Workshop Designs at TeeVirus.com");
$chan->pubDate = DB::get_var("SELECT UNIX_TIMESTAMP(MAX(post_queued)) FROM `Posts` WHERE {$cond}");
$chan->ttl = 15;

core_class('url');
$url = URL::get_instance();
$chan->link = $url->get_www_queue();

////////////////////////////////////////////////////////////////////////////////

$feed = new RSS2DesignFeed($chan);

DB::query("SELECT post_id FROM `Posts` WHERE {$cond} ORDER BY post_queued DESC LIMIT 10");
$feed->populate(DB::get_result());

$xml_data = $feed->dump(TRUE);
$rss2cache->save($xml_data);
echo $xml_data;

?>
