示例#1
0
/**
 * a shortcut to load_all_program_data's single-program query
/**/
function &load_one_program($start_time, $chanid, $manualid)
{
    if ($manualid) {
        $program =& load_all_program_data($start_time, $start_time, $chanid, true, 'program.manualid=' . intval($manualid));
    } else {
        $program =& load_all_program_data($start_time, $start_time, $chanid, true);
    }
    if (!is_object($program) || strcasecmp(get_class($program), 'program')) {
        return NULL;
    }
    return $program;
}
示例#2
0
        $query = "({$query})";
    }
    if (count($extra_query) > 0) {
        if ($query) {
            $query .= ' AND ';
        }
        $query .= '(' . implode(' AND ', $extra_query) . ')';
    }
    // Search!
    if (!empty($query)) {
        $tmpdate = strtotime($_SESSION['search']['starttime']);
    }
    if ($tmpdate == false) {
        $Results =& load_all_program_data(time(), strtotime('+1 month'), NULL, false, $query, $_SESSION['search']['distinctTitle']);
    } else {
        $Results =& load_all_program_data($tmpdate, strtotime('+1 month'), NULL, false, $query, $_SESSION['search']['distinctTitle']);
    }
}
// Only show unwatched shows?
if ($_SESSION['search']['unwatched'] && count($Results)) {
    foreach ($Results as $key => $show) {
        switch ($show->recstatus) {
            case 'PreviousRecording':
            case 'CurrentRecording':
            case 'Recorded':
            case 'NeverRecord':
                unset($Results[$key]);
                continue;
        }
    }
}
示例#3
0
 /** @deprecated FIXME:  this routine should get split out on its own, accepting
  *                      $channel as a parameter, and put into modules/tv/list.php
  */
 function display_programs($start_time, $end_time)
 {
     global $Page;
     // Keep track of each program this routine handles (for unique id generation)
     static $program_id_counter;
     if (empty($program_id_counter)) {
         $program_id_counter = 0;
     }
     ## we will eventually need to check for list vs "by channel" display
     #  for now, we only have the main list display
     if (defined('theme_num_time_slots')) {
         $timeslots_left = theme_num_time_slots;
         $timeslot_size = theme_timeslot_size;
     } else {
         $timeslots_left = num_time_slots;
         $timeslot_size = timeslot_size;
     }
     $programs =& load_all_program_data($start_time, $end_time, $this->chanid);
     foreach ($programs as &$program) {
         // Leave early?  just in case
         if ($timeslots_left < 1) {
             break;
         }
         // Make sure this program happens within the specified timeslot
         if ($program->starttime >= $end_time || $program->endtime <= $start_time) {
             continue;
         }
         // Get a modified start/end time for this program (in case it starts/ends outside of the aloted time
         $program_starts = $program->starttime;
         $program_ends = $program->endtime;
         if ($program->starttime < $start_time) {
             $program_starts = $start_time;
         }
         if ($program->endtime > $end_time) {
             $program_ends = $end_time;
         }
         // If there is a gap before the current program, put a NO DATA block in.
         if ($program_starts > $start_time) {
             $length = ($program_starts - $start_time) / $timeslot_size;
             if ($length >= 0.5) {
                 $timeslots_used = ceil($length);
                 require tmpl_dir . 'list_cell_nodata.php';
                 $start_time += $timeslots_used * timeslot_size;
                 if ($timeslots_left < $timeslots_used) {
                     $timeslots_used = $timeslots_left;
                 }
                 $timeslots_left -= $timeslots_used;
             }
         }
         // Calculate the number of time slots this program gets
         $length = ($program_ends - $program_starts) / $timeslot_size;
         if ($length < 0.5) {
             continue;
         }
         // ignore shows that don't take up at least half a timeslot
         $timeslots_used = ceil($length);
         // Increment $start_time so we avoid putting tiny shows (ones smaller than a timeslot) into their own timeslot
         $start_time += $timeslots_used * $timeslot_size;
         // Make sure this doesn't put us over
         if ($timeslots_left < $timeslots_used) {
             $timeslots_used = $timeslots_left;
         }
         $timeslots_left -= $timeslots_used;
         #if ($timeslots_left > 0)
         require tmpl_dir . 'list_cell_program.php';
         // Cleanup is good
         unset($program);
     }
     // Uh oh, there are leftover timeslots - display a no data message
     if ($timeslots_left > 0) {
         $timeslots_left = $timeslots_used;
         require tmpl_dir . 'list_cell_nodata.php';
     }
 }
示例#4
0
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  TV
 *
/**/
$recommend_enabled = setting('recommend_enabled', null);
$recommend_server = setting('recommend_server', null);
$recommend_key = setting('recommend_key', null);
$url = "{$recommend_server}/shows/recommended.json?auth_token={$recommend_key}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r = curl_exec($ch);
curl_close($ch);
$results = json_decode($r, true);
$shows = array();
$query = '';
foreach ($results as $result) {
    if (!strlen($result['tms_id'])) {
        continue;
    }
    if (strlen($query)) {
        $query .= ' OR ';
    }
    $query .= " program.seriesid = '{$result['tms_id']}'";
}
$shows =& load_all_program_data(time(), strtotime('+1 month'), NULL, false, strlen($query) ? "({$query})" : 'FALSE', true);
// Load the class for this page
require_once tmpl_dir . 'recommended.php';
// Exit
exit;
示例#5
0
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  TV
 *
/**/
$recommend_enabled = setting('recommend_enabled', null);
$recommend_server = setting('recommend_server', null);
$recommend_key = setting('recommend_key', null);
$url = "{$recommend_server}/shows/recommended.json?auth_token={$recommend_key}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r = curl_exec($ch);
curl_close($ch);
$results = json_decode($r, true);
$shows = array();
$query = '';
foreach ($results as $result) {
    if (!strlen($result['tms_id'])) {
        continue;
    }
    if (strlen($query)) {
        $query .= ' OR ';
    }
    $query .= " program.seriesid = '{$result['tms_id']}'";
}
$shows =& load_all_program_data(time(), strtotime('+1 month'), NULL, false, "({$query})", true);
// Load the class for this page
require_once tmpl_dir . 'recommended.php';
// Exit
exit;
示例#6
0
if ($_REQUEST['date']) {
    if (strlen($_REQUEST['date']) == 8) {
        $_REQUEST['date'] = unixtime(sprintf('%08d000000', $_REQUEST['date']));
    }
    $_SESSION['list_time'] = $_REQUEST['date'];
}
// No channel found
if (!$_REQUEST['chanid'] || !$this_channel->chanid) {
    redirect_browser(root_url . 'tv/list');
}
// Load the programs for today
$programs = load_all_program_data(mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']), date('Y', $_SESSION['list_time'])), mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']) + 1, date('Y', $_SESSION['list_time'])), $this_channel->chanid);
// No data?  Assume today.
if (count($programs) < 1) {
    $_SESSION['list_time'] = time();
    $programs = load_all_program_data(mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']), date('Y', $_SESSION['list_time'])), mktime(0, 0, 0, date('n', $_SESSION['list_time']), date('j', $_SESSION['list_time']) + 1, date('Y', $_SESSION['list_time'])), $this_channel->chanid);
    if (count($programs) < 1) {
        redirect_browser(root_url . 'tv/list');
    }
}
// Load the class for this page
require_once tmpl_dir . 'channel.php';
// Exit
exit;
/**
 * Prints a <select> of the available channels
/**/
function channel_select($params = '', $selected = '')
{
    $channels = Channel::getChannelList();
    echo "<select name=\"chanid\" {$params}>";