<?php

// wommcalendar.inc
// gives clickable calendar style interface to WOMM plays

// Pull in the calendar class
include __DIR__ . '/calendar.class.php';

?>
<!-- calendarstyle -->
<style>
<!--
table.calendar {border: 0}
table.calendar td, th {text-align: center; border: 1}
table.calendar th {height: 10px; font-size: 7pt;}
table.calendar td {width: 19px; height: 10px; font-size: 9pt;}
table.calendar .calendar-month {font-weight: bold; margin-top: 3px; font-size: 12pt; text-align: center}
table.calendar .calendar-month a{text-decoration: none}
table.calendar .calendar-prev, table.calendar .calendar-next {font-weight: normal;}
table.calendar th {color: green; text-align: center;}
table.calendar td.linked-day {font-size: 9pt}
table.prevnext {width: 100%; margin-top: .3em;}
table.prevnext td{font-size: smaller;}
table.prevnext td a{text-decoration: none}
-->
</style>

<?php
				$date = $_GET['date'];
				
				// Hacky - pull the passed date from the uri
				// $_SERVER["REQUEST_URI"]: /playlists-calendar?date=2013-12-11
				$req_uri = $_SERVER["REQUEST_URI"];
				$uri_bits = explode("playlists-calendar?date=",$req_uri);
				if ($uri_bits[1]) {
					$date = $uri_bits[1];
				}
				
				// no passed in date means now
				if (!$date) {$time = time();
			
					$month= date('m');
					$day	= date('d');
					$year	= date('y');
				}
				// Otherwise do a maketime from the passed data
				else {
				
					$crap = explode("-",$date);
					$month= $crap[1];
					$day	= $crap[2];
					$year	= $crap[0];
					$time = mktime(1,1,1,$month,$day,$year);
				}
				
				// make prev and nextlinks
				$prevlink = date("Y-m-d",mktime(1,1,1,$month-1,$day,$year));
				$nextlink = date("Y-m-d",mktime(1,1,1,$month+1,$day,$year));
			
				echo generate_calendar(date('Y', $time), date('n', $time), $days, 2, '','',$pn);

$url_to_hit = "http://wmxm.radioactivity.fm/feeds/daterss.html?date=" . $month . "-" . $day . "-" . $year;
require_once __DIR__ . '/magpie/rss_fetch.inc';

$rss = fetch_rss($url_to_hit);

?>
Playlists for <?=$month?>/<?=$day?>/<?=$year?>:
<table>
<tr>
	<td>Start time</td>
	<td>Show</td>
	<td>DJ/DJs</td>
	<td>Playlist</td>
</tr>

<?php

$size = sizeof($rss->items);
if ($size==0) {?>
	<tr><td colspan=4>No shows or play data are on file yet ...</td></tr>
<?php }

foreach ($rss->items as $item) {
  $show_starttime	= $item['ra']['starttime'];
  $show_dj 		= $item['ra']['dj'];
  $show_show 		= $item['ra']['show'];
  $show_playlist 	= $item['ra']['showplaylistlink'];
  ?>
  <tr>
  <td><?= $show_starttime?></td>
  <td><?= $show_show?></td>
  <td><?= $show_dj ?></td>
  <td><a target=_new href="<?= $show_playlist ?>">[playlist]</a></td>
  </tr>
  <?php
}
?>
</table>

More playlists and show information can be found at <a href="http://wmxm.radioactvity.fm" target=_new>wmxm.radioactivity.fm</a>
