1<?php 2/** 3 * Show the current lineup for a specific channel 4 * 5 * @license GPL 6 * 7 * @package MythWeb 8 * @subpackage TV 9 * 10 **/ 11 12// Path-based 13 if ($Path[2]) { 14 $_REQUEST['chanid'] = $Path[2]; 15 if (!$_REQUEST['date']) 16 $_REQUEST['date'] = $Path[3]; 17 } 18 19// Chanid? 20 $this_channel =& Channel::find($_REQUEST['chanid']); 21 22// New list date? 23 if ($_REQUEST['date']) { 24 if (strlen($_REQUEST['date']) == 8) 25 $_REQUEST['date'] = unixtime(sprintf('%08d000000', $_REQUEST['date'])); 26 $_SESSION['list_time'] = $_REQUEST['date']; 27 } 28 29// No channel found 30 if (!$_REQUEST['chanid'] || !$this_channel->chanid) { 31 redirect_browser(root_url.'tv/list'); 32 } 33 34// Load the programs for today 35 $programs = load_all_program_data(mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']), date('Y', $_SESSION['list_time'])), 36 mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']) + 1, date('Y', $_SESSION['list_time'])), 37 $this_channel->chanid); 38 39// No data? Assume today. 40 if (count($programs) < 1) { 41 $_SESSION['list_time'] = time(); 42 $programs = load_all_program_data(mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']), date('Y', $_SESSION['list_time'])), 43 mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']) + 1, date('Y', $_SESSION['list_time'])), 44 $this_channel->chanid); 45 if (count($programs) < 1) 46 redirect_browser(root_url.'tv/list'); 47 } 48 49// Load the class for this page 50 require_once tmpl_dir.'channel.php'; 51 52// Exit 53 exit; 54 55 56/** 57 * Prints a <select> of the available channels 58 **/ 59 function channel_select($params = '', $selected='') { 60 $channels = Channel::getChannelList(); 61 echo "<select name=\"chanid\" $params>"; 62 foreach ($channels as $chanid) { 63 $channel =& Channel::find($chanid); 64 // Not visible? 65 if (empty($channel->visible)) 66 continue; 67 // Print the option 68 echo '<option value="', $channel->chanid, '"', 69 ' title="', html_entities($channel->name), '"'; 70 // Selected? 71 if (($channel->chanid == $selected) || 72 ($channel->chanid == $_GET['chanid'])) 73 echo ' SELECTED'; 74 // Print the rest of the content 75 echo '>'; 76 if ($_SESSION["prefer_channum"]) 77 echo $channel->channum.' ('.html_entities($channel->callsign).')'; 78 else 79 echo html_entities($channel->callsign).' ('.$channel->channum.')'; 80 echo '</option>'; 81 } 82 echo '</select>'; 83 } 84 85/** 86 * Prints a <select> of the available date range 87 * Reused *almost* verbatim from modules/tv/list.php 88 **/ 89 function date_select($params = '') { 90 global $db; 91 // Get the available date range 92 $min_days = max(-7, $db->query_col('SELECT TO_DAYS(min(starttime)) - TO_DAYS(NOW()) FROM program')); 93 $max_days = min(30, $db->query_col('SELECT TO_DAYS(max(starttime)) - TO_DAYS(NOW()) FROM program')); 94 // Print out the list 95 echo "<select name=\"date\" $params>"; 96 for ($i=$min_days; $i<=$max_days; $i++) { 97 $time = mktime(0,0,0, date('m'), date('d') + $i, date('Y')); 98 $date = date('Ymd', $time); 99 echo "<option value=\"$date\""; 100 if ($date == date('Ymd', $_SESSION['list_time'])) 101 echo ' SELECTED'; 102 echo '>'.strftime($_SESSION['date_channel_jump'] , $time).'</option>'; 103 } 104 echo '</select>'; 105 } 106