Ticket #8075: mythweb_guide_channelgroups.diff

File mythweb_guide_channelgroups.diff, 12.3 KB (added by anonymous, 16 years ago)

(Uploading Tom's patch as anonymous to test Trac fix - mdean)

  • mythweb/includes/config.php

     
    4141         $_SESSION['recorded_pixmaps'] = (tmpl == 'default') ? true : false;
    4242
    4343// Guide settings
    44     if (!isset($_SESSION['guide_favonly']))
    45         $_SESSION['guide_favonly'] = false;
     44    if (!$_SESSION['guide_channelgroup'])
     45        $_SESSION['guide_channelgroup'] = 0;
    4646
    4747// The size of timeslots, in seconds (1800 = 30 minutes)
    4848    if ($_SESSION['timeslot_size'] < 300) {
  • mythweb/modules/tv/set_session.php

     
    2929        $_SESSION['recorded_pixmaps']   = $_POST['recorded_pixmaps']   ? true : false;
    3030        if (isset($_POST['file_url_override']))  $_SESSION['file_url_override']  = trim(preg_replace('#^file://#', '', $_POST['file_url_override']));
    3131    // Guide Settings
    32         $_SESSION['guide_favonly']    = $_POST['guide_favonly'] ? true : false;
     32        $_SESSION['guide_channelgroup'] = $_POST['guide_channelgroup'];
    3333        $_SESSION['timeslot_size']    = max(5, intVal($_POST['timeslot_size'])) * 60;
    3434        $_SESSION['num_time_slots']   = max(3, intVal($_POST['num_time_slots']));
    3535        $_SESSION['timeslot_blocks']  = max(1, intVal($_POST['timeslot_blocks']));
     
    3838        $_SESSION['star_character']   = $_POST['star_character'];
    3939        $_SESSION['recorded_paging']  = $_POST['recorded_paging'];
    4040    }
     41
     42/**
     43 * Prints a <select> of channel groups
     44/**/
     45    function channelgroup_select () {
     46        global $db;
     47        $sh = $db->query('SELECT grpid, name FROM channelgroupnames
     48            WHERE EXISTS (SELECT * FROM channelgroup
     49            WHERE channelgroup.grpid=channelgroupnames.grpid) ORDER BY name');
     50        echo "<select name=\"cgrp\">";
     51        echo '<option value="0"';
     52        if (!$_SESSION['guide_channelgroup']) echo ' SELECTED';
     53        echo '>'.t('All channels').'</option>';
     54        while ($grow = $sh->fetch_row()) {
     55            echo '<option value="'.$grow[0].'"';
     56            if ($_SESSION['guide_channelgroup']==$grow[0]) echo ' SELECTED';
     57            echo '>'.htmlspecialchars($grow[1]).'</option>';
     58        }
     59        $sh->finish();
     60        echo '</select>';
     61    }
     62
  • mythweb/modules/tv/list.php

     
    2323        $list_starttime = unixtime(sprintf('%08d%04d00', $_REQUEST['date'], $_REQUEST['daytime']));
    2424// Did we get passed a date (and probably an hour, too)?
    2525    elseif(isset($_REQUEST['date']))
    26         $list_starttime = unixtime(sprintf('%08d%02d0000', $_REQUEST['date'], $_REQUEST['hour']));
     26        $list_starttime = unixtime(sprintf('%08d%02d0000', date('Ymd',$_REQUEST['date']), $_REQUEST['hour']));
    2727// Default value - just use the current time
    2828    else
    2929        $list_starttime = time();
     
    4242// Set a session variable so other sections know how to get back to this particular page
    4343    $_SESSION['list_time'] = $list_starttime;
    4444
     45// Set channel group
     46    if (isset($_REQUEST['cgrp'])) $_SESSION['guide_channelgroup'] = $_REQUEST['cgrp'];
     47    $list_channelgroup = $_SESSION['guide_channelgroup'];
    4548// Populate the $Channels array
    4649    load_all_channels();
    4750
     
    5558        require_once tmpl_dir.'list.php';
    5659
    5760/**
     61 * Prints a <select> of channel groups
     62/**/
     63    function channelgroup_select ($params = '') {
     64        global $db;
     65        $sh = $db->query('SELECT grpid, name FROM channelgroupnames
     66            WHERE EXISTS (SELECT * FROM channelgroup
     67            WHERE channelgroup.grpid=channelgroupnames.grpid) ORDER BY name');
     68        echo "<select name=\"cgrp\" $params>";
     69        echo '<option value="0"';
     70        if (!$_SESSION['guide_channelgroup']) echo ' SELECTED';
     71        echo '>'.t('All channels').'</option>';
     72        while ($grow = $sh->fetch_row()) {
     73            echo '<option value="'.$grow[0].'"';
     74            if ($_SESSION['guide_channelgroup']==$grow[0]) echo ' SELECTED';
     75            echo '>'.htmlspecialchars($grow[1]).'</option>';
     76        }
     77        $sh->finish();
     78        echo '</select>';
     79    }
     80
     81/**
    5882 * Prints a <select> of the available hour range
    5983/**/
    6084    function hour_select($params = '') {
  • mythweb/modules/tv/includes/channels.php

     
    3333        global $Callsigns;
    3434        $Channels = array();
    3535    // Initialize the query
    36         if ($_SESSION['guide_favonly'])
    37             $sql = 'SELECT channel.* FROM channel, favorites WHERE channel.chanid = favorites.chanid AND';
    38         else
     36        if ($_SESSION['guide_channelgroup']) {
     37            $sql = 'SELECT channel.* FROM channel JOIN channelgroup ON channelgroup.chanid=channel.chanid ' .
     38                'WHERE channelgroup.grpid=? AND';
     39            $params = array($_SESSION['guide_channelgroup']);
     40        } else {
    3941            $sql = 'SELECT * FROM channel WHERE';
     42            $params = array();
     43        }
    4044        $sql .= ' channel.visible=1';
    4145        $sql .= ' GROUP BY channel.channum, channel.callsign';
    4246    // Sort
     
    4448                .($_SESSION["sortby_channum"] ? '' : 'channel.callsign, ')
    4549                .'(channel.channum + 0), channel.channum, channel.chanid';  // sort by channum as both int and string to grab subchannels
    4650    // Query
    47         $sh = $db->query($sql);
     51        $sh = $db->query($sql, $params);
    4852        while ($channel_data = $sh->fetch_assoc())  {
    4953            $Channels[$channel_data['chanid']] = new Channel($channel_data);
    5054            if (empty($Callsigns[$channel_data['channum'].':'.$channel_data['callsign']]))
     
    5357        $sh->finish();
    5458    // No channels returned?
    5559        if (empty($Channels)) {
    56             unset($_SESSION['guide_favonly']);
     60            $cgrp = $_SESSION['guide_channelgroup'];
     61            $_SESSION['guide_channelgroup'] = 0;
    5762            trigger_error('No channels were detected.  '
    58                          .($_SESSION['guide_favonly']
     63                         .($cgrp
    5964                            ? 'The "favorites only" option has now been turned off, please reload this page to try again.'
    6065                            : 'Are you sure that MythTV is properly configured?'),
    6166                          FATAL);
  • mythweb/modules/tv/tmpl/default/set_session.php

     
    4242</tr><tr class="x-sep">
    4343    <td colspan="2"><?php echo t('Guide Settings') ?>:</th>
    4444</tr><tr>
    45     <th><?php echo t('Only display favourite channels') ?>:</th>
    46     <td ><input class="radio" type="checkbox" title="In the program listing, only show channels marked as favourite channels" name="guide_favonly"<?php if ($_SESSION['guide_favonly']) echo ' CHECKED' ?>></td>
     45    <th><?php echo t('Channel group to display') ?>:</th>
     46    <td><?php channelgroup_select(); ?></td>
    4747</tr><tr>
    4848    <th><?php echo t('Max star rating for movies') ?>:</th>
    4949    <td><input type="text" size="5" name="max_stars" value="<?php echo intVal($_SESSION['max_stars']) ?>"></td>
  • mythweb/modules/tv/tmpl/default/list_data.php

     
    2525    <table id="x-jumpto" class="commandbox commands" border="0" cellspacing="0" cellpadding="0">
    2626    <tr>
    2727        <td class="x-jumpto"><?php echo t('Jump To') ?>:</td>
    28         <td class="x-hour"><?php hour_select('id="hour_select" onchange="list_update($(\'hour_select\')[$(\'hour_select\').selectedIndex].value);"') ?></td>
     28        <td class="x-cgrp"><?php channelgroup_select('id="cgrp_select" onchange="list_update('.$list_starttime.',$(\'cgrp_select\')[$(\'cgrp_select\').selectedIndex].value);"') ?></td>
     29        <td class="x-hour"><?php hour_select('id="hour_select" onchange="list_update($(\'hour_select\')[$(\'hour_select\').selectedIndex].value,'.$list_channelgroup.');"') ?></td>
    2930        <td class="x-day">
    30             <a class="link" onclick="list_update(<?php echo $list_starttime - (24 * 60 * 60); ?>);">
     31            <a class="link" onclick="list_update(<?php echo ($list_starttime - (24 * 60 * 60)).','.$list_channelgroup; ?>);">
    3132                <img src="<?php echo skin_url ?>img/left.gif" alt="<?php echo t('left'); ?>">
    3233            </a>
    33             <?php date_select('id="date_select" onchange="list_update($(\'date_select\')[$(\'date_select\').selectedIndex].value);"') ?>
    34             <a class="link" onclick="list_update(<?php echo $list_starttime + (24 * 60 * 60); ?>);">
     34            <?php date_select('id="date_select" onchange="list_update($(\'date_select\')[$(\'date_select\').selectedIndex].value,'.$list_channelgroup.');"') ?>
     35            <a class="link" onclick="list_update(<?php echo ($list_starttime + (24 * 60 * 60)).','.$list_channelgroup; ?>);">
    3536                <img src="<?php echo skin_url ?>img/right.gif" alt="<?php echo t('right'); ?>">
    3637            </a>
    3738        </td>
  • mythweb/modules/tv/tmpl/default/list.php

     
    2424?>
    2525
    2626<script type="text/javascript">
    27     function list_update(timestamp) {
     27    function list_update(timestamp, cgrp) {
    2828        ajax_add_request();
    2929        new Ajax.Updater($('list_content'),
    3030                         '<?php echo root_url ?>tv/list',
    3131                         {
    3232                            parameters: {
    3333                                            ajax: true,
    34                                             time: timestamp
     34                                            time: timestamp,
     35                                            cgrp: cgrp
    3536                                        },
    3637                            onComplete: ajax_remove_request
    3738                         }
  • mythweb/modules/tv/tmpl/lite/set_session.php

     
    2828</tr><tr>
    2929    <td colspan="2"><?php echo t('Guide Settings') ?>:</td>
    3030</tr><tr>
    31     <td align="right"><?php echo t('Only display favourite channels') ?>:</td>
    32     <td ><input class="radio" type="checkbox" title="In the program listing, only show channels marked as favourite channels" name="guide_favonly"<?php if ($_SESSION['guide_favonly']) echo ' CHECKED' ?>></td>
     31    <th><?php echo t('Channel group to display') ?>:</th>
     32    <td><?php channelgroup_select(); ?></td>
    3333</tr><tr>
    3434    <td align="right"><?php echo t('Max star rating for movies') ?>:</td>
    3535    <td><input type="text" size="5" name="max_stars" value="<?php echo intVal($_SESSION['max_stars']) ?>"></td>
  • mythweb/modules/tv/tmpl/lite/list.php

     
    3131        <tr>
    3232
    3333            <td nowrap align="center"><?php echo t('Jump To') ?>:&nbsp;&nbsp;</td>
     34            <td><?php channelgroup_select() ?></td>
    3435            <td align="right"><?php echo t('Hour') ?>:&nbsp;</td>
    3536            <td><select name="hour" style="text-align: right"><?php
    3637                for ($h=0;$h<24;$h++) {
     
    4142                }
    4243                ?></select></td>
    4344            <td align="right"><?php echo t('Date') ?>:&nbsp;</td>
    44             <tdnowrap><?php date_select() ?></td>
     45            <td nowrap><?php date_select() ?></td>
    4546            <td align="center"><input type="submit" class="submit" value="<?php echo t('Jump') ?>"></td>
    4647        </tr>
    4748        </table>