Ticket #5235: recorded_limit.patch

File recorded_limit.patch, 3.1 KB (added by jhoff@…, 16 years ago)

patch

  • modules/tv/recorded.php

     
    1313 *
    1414/**/
    1515
     16//Optional display limit for Recordings menu. The "limit" variable can also be passed as an option and will always override this setting. If commented out, all shows will be displayed unless specified otherwise.
     17// ( Note: this setting would probably have a better home somewhere else, but I'm not sure where that would be )
     18//    $Limit = 40;
     19
    1620// Populate the $Channels array
    1721    load_all_channels();
    1822
     
    182186    if (count($All_Shows))
    183187        sort_programs($All_Shows, 'recorded_sortby');
    184188
     189//Routines to handle display limits
     190    if ( !$Limit ) { $Limit = count($All_Shows); }
     191    if ( ( $Limit && $Limit > 0 ) || ( $_REQUEST['limit'] && $_REQUEST['limit'] > 0 ) ) {
     192        if ( $_REQUEST['limit'] ) { $Limit = $_REQUEST['limit']; }
     193        if ( $Limit > count($All_Shows) ) { $Limit = count($All_Shows); }
     194        if ( $Limit < count($All_Shows) ) {
     195            //New temp array
     196            $All_Shows_temp = array();
     197            //Copy first X elements from All_Shows array into temp array
     198            for ( $LimitCount = 0; $LimitCount < $Limit; $LimitCount ++) {
     199                $All_Shows_temp[$LimitCount] = $All_Shows[$LimitCount];
     200            }
     201            $All_Shows = $All_Shows_temp;
     202        }
     203    }
     204
    185205// How much free disk space on the backend machine?
    186206    list($size_high, $size_low, $used_high, $used_low) = explode(backend_sep, backend_command('QUERY_FREE_SPACE_SUMMARY'));
    187207    if (function_exists('gmp_add')) {
  • modules/tv/tmpl/default/recorded.php

     
    214214// -->
    215215</script>
    216216
     217<table id="title_choices" class="commandbox commands" border="0" cellspacing="0" cellpadding="4">
    217218<form id="change_title" action="<?php echo root ?>tv/recorded" method="get">
    218 <table id="title_choices" class="commandbox commands" border="0" cellspacing="0" cellpadding="4">
    219219<tr>
    220220<?php if (count($Groups) > 1) { ?>
    221221    <td class="x-group"><?php echo t('Show group') ?>:</td>
     
    248248        }
    249249?>
    250250    </select></td>
     251    </form>
     252    <form id="change_limit" action="<?php echo root ?>tv/recorded" method="get">
     253    <td>
     254    <?php
     255        echo 'Limit: ';
     256        echo '<input id="set_limit" type="text" name="limit" size="5" value="'.htmlspecialchars($Limit).'">'
     257    ?>
     258    <input type="submit" class="submit" value="Change">
     259    </td>
     260    </form>
    251261</tr>
    252262</table>
    253 </form>
    254263
    255264<table id="recorded_list" border="0" cellpadding="0" cellspacing="0" class="list small">
    256265<tr class="menu">
     
    421430
    422431<?php
    423432    echo '<p style="padding-right: 75px; text-align: right;">'
     433        .'Showing '.$Limit.' / '
    424434        .t('$1 programs, using $2 ($3) out of $4 ($5 free).',
    425435           '<span id="programcount">'.t($Total_Programs).'</span>',
    426436           '<span id="diskused">'.nice_filesize($Total_Used).'</span>',