Ticket #3651: recorded.php

File recorded.php, 16.3 KB (added by elkin@…, 17 years ago)

redesigned recorded.php from default theme

Line 
1<?php
2/**
3 * Show recorded programs.
4 *
5 * @url         $URL: http://svn.mythtv.org/svn/trunk/mythplugins/mythweb/modules/tv/tmpl/default/recorded.php $
6 * @date        $Date: 2007-05-28 20:00:47 +0200 (Mon, 28 May 2007) $
7 * @version     $Revision: 13529 $
8 * @author      $Author: kormoc $
9 * @license     GPL
10 *
11 * @package     MythWeb
12 * @subpackage  TV
13 *
14/**/
15
16// Set the desired page title
17    $page_title = 'MythWeb - '.t('Recorded Programs');
18
19// Custom headers
20    $headers[] = '<link rel="stylesheet" type="text/css" href="'.skin_url.'/tv_recorded.css" />';
21
22// Print the page header
23    require 'modules/_shared/tmpl/'.tmpl.'/header.php';
24
25// Global variables used here
26    global $All_Shows, $Total_Programs, $Total_Time, $Total_Used,
27           $Groups,    $Program_Titles;
28
29// Show the recgroup?
30    if (count($Groups) > 1) {
31        $recgroup_cols = 1;
32    }
33    else {
34        $recgroup_cols = 0;
35    }
36
37// Setup for grouping by various sort orders
38    $group_field = $_SESSION['recorded_sortby'][0]['field'];
39    if ($group_field == "") {
40        $group_field = "airdate";
41    } elseif ( ! (($group_field == "title") || ($group_field == "channum") || ($group_field == "airdate") || ($group_field == "recgroup")) ) {
42        $group_field = "";
43    }
44
45?>
46
47<script language="JavaScript" type="text/javascript">
48<!--
49
50// Some initial values for global counters
51    var diskused       = parseInt('<?php echo addslashes(disk_used) ?>');
52    var programcount   = parseInt('<?php echo addslashes($Total_Programs) ?>');
53    var programs_shown = parseInt('<?php echo count($All_Shows) ?>');
54    var totaltime      = parseInt('<?php echo addslashes($Total_Time) ?>');
55
56// Initialize some variables that will get set after the page table is printed
57    var rowcount     = new Array();
58    var rowsection   = new Array();
59    var titles       = new Object;
60    var groups       = new Object;
61
62// Load the known shows
63    var file  = null;
64    var files = new Array();
65
66<?php
67    foreach ($All_Shows as $show) {
68?>
69    file = new Object();
70    file.title      = '<?php echo addslashes($show->title)                  ?>';
71    file.subtitle   = '<?php echo addslashes($show->subtitle)               ?>';
72    file.chanid     = '<?php echo addslashes($show->chanid)                 ?>';
73    file.starttime  = '<?php echo addslashes($show->recstartts)             ?>';
74    file.recgroup   = '<?php echo addslashes(str_replace('%2F', '/', rawurlencode($show->recgroup)))    ?>';
75    file.filename   = '<?php echo addslashes(str_replace('%2F', '/', rawurlencode($show->filename)))    ?>';
76    file.size       = '<?php echo addslashes($show->filesize)               ?>';
77    file.length     = '<?php echo addslashes($show->recendts - $show->recstartts) ?>';
78    file.autoexpire = <?php echo $show->auto_expire ? 1 : 0                 ?>;
79    files.push(file);
80
81<?php
82    }
83?>
84
85// Set the autoexpire flag
86    function set_autoexpire(id) {
87        var file = files[id];
88        var r = new Ajax.Request('<?php echo root ?>tv/detail/' + file.chanid + '/' + file.starttime,
89                                 {
90                                    parameters: 'toggle_autoexpire='+(1 - file.autoexpire),
91                                  asynchronous: false
92                                 });
93        if (r.transport.responseText == 'success') {
94        // Update to the new value
95            file.autoexpire = 1 - file.autoexpire;
96        // Fix the images
97            $('autoexpire_'+id).src = '<?php echo skin_url, '/img/flags/' ?>'
98                                      + (file.autoexpire
99                                         ? ''
100                                         : 'no_')
101                                      + 'autoexpire.png';
102            if (file.autoexpire)
103                $('autoexpire_'+id).title = '<?php echo addslashes(t('Click to disable Auto Expire')) ?>';
104            else
105                $('autoexpire_'+id).title = '<?php echo addslashes(t('Click to enable Auto Expire')) ?>';
106        }
107        else if (r.transport.responseText) {
108            alert('Error: '+r.transport.responseText);
109        }
110    }
111
112    function confirm_delete(id, forget_old) {
113        var file = files[id];
114        if (confirm("<?php echo t('Are you sure you want to delete the following show?')
115                    ?>\n\n     "+file.title+": "+file.subtitle)) {
116            var url = '<?php echo root ?>tv/recorded?delete=yes&chanid='+file.chanid
117                      +'&starttime='+file.starttime
118                      +(forget_old
119                        ? '&forget_old=yes'
120                        : '');
121        // Do the actual deletion
122            if (programs_shown == 1)
123                location.href = url;
124            else {
125                ajax_add_request();
126                submit_url(url+'&ajax=yes', http_success, http_failure, id, file);
127            }
128        // Debug statements - uncomment to verify that the right file is being deleted
129            //alert('row number ' + id + ' belonged to section ' + section + ' which now has ' + rowcount[section] + ' elements');
130            //alert('just deleted an episode of "' + title + '" which now has ' + episode_count + ' episodes left');
131        }
132    }
133
134    function http_success(result, args) {
135        var id   = args.shift();
136        var file = args.shift();
137    // Hide the row from view
138        toggle_vis('inforow_' + id,   'display');
139        toggle_vis('statusrow_' + id, 'display');
140    // decrement the number of rows in a section
141        var section   = rowsection[id];
142        rowcount[section]--;
143    // Decrement the number of episodes for this title
144        titles[file.title]--;
145        var episode_count = titles[file.title]
146    // If we just hid the only row in a section, then hide the section break above it as well
147        if (rowcount[section] == 0) {
148            toggle_vis('breakrow_' + section, 'display');
149        }
150// UGLY! but works well enough...
151    <?php if (count($Groups) > 1) { ?>
152    // Change the recording groups dropdown on the fly.
153        if (file.recgroup) {
154        // Decrement the number of episodes for this group
155            groups[file.recgroup]--;
156            var group_count = groups[file.recgroup]
157        // Change the groups dropdown menu on the fly
158            if (group_count == 0) {
159                toggle_vis('Group ' + file.recgroup, 'display');
160            }
161            else {
162                var group_text;
163                group_text = (group_count > 1) ? ' (' + group_count + ' episodes)' : '';
164                $('Group ' + file.recgroup).innerHTML = file.recgroup + group_text;
165            }
166        }
167    <?php } ?>
168    // Change the recordings dropdown menu on the fly
169        if (episode_count == 0) {
170            toggle_vis('Title ' + file.title, 'display');
171        }
172        else {
173            var count_text;
174            count_text = (episode_count > 1) ? ' (' + episode_count + ' episodes)' : '';
175            $('Title ' + file.title).innerHTML = file.title + count_text;
176        }
177    // Decrement the total number of shows and update the page
178        programs_shown--;
179        programcount--;
180        $('programcount').innerHTML = programcount;
181    // Decrease the total amount of time by the amount of the show
182        totaltime -= file.length;
183        $('totaltime').innerHTML = nice_length(totaltime, <?php
184                                                         echo "'", addslashes(t('$1 hr')),   "', ",
185                                                              "'", addslashes(t('$1 hrs')),  "', ",
186                                                              "'", addslashes(t('$1 min')),  "', ",
187                                                              "'", addslashes(t('$1 mins')), "'";
188                                                         ?>);
189    // Decrease the disk usage indicator by the amount of the show
190        diskused -= file.size;
191        $('diskused').innerHTML = nice_filesize(diskused);
192    // Adjust the freespace shown
193        $('diskfree').innerHTML = nice_filesize(<?php echo disk_size ?> - diskused);
194        // Eventually, we should perform the removal-from-the-list here instead
195        // of in confirm_delete()
196        ajax_remove_request();
197    }
198
199    function http_failure(err, errstr, args) {
200        var file = args[0];
201        alert("Can't delete "+file.title+': '+file.subtitle+".\nHTTP Error:  " + errstr + ' (' + err + ')');
202        ajax_remove_request();
203    }
204
205// -->
206</script>
207
208<form id="change_title" action="<?php echo root ?>tv/recorded" method="get">
209<table id="title_choices" class="commandbox commands" border="0" cellspacing="0" cellpadding="4" align="center">
210<tr>
211<?php if (count($Groups) > 1) { ?>
212    <td class="-group"><?php echo t('Show group') ?>:</td>
213    <td colspan=3><select name="recgroup" onchange="$('change_title').submit()">
214        <option value=""><?php echo t('All groups') ?></option><?php
215        foreach($Groups as $recgroup => $count) {
216            echo '<option id="Group '.htmlspecialchars($recgroup).'" value="'.htmlspecialchars($recgroup).'"';
217            if ($_GET['recgroup'] == $recgroup)
218                echo ' SELECTED';
219            echo '>'.html_entities($recgroup)
220                .' ('.tn('$1 recording', '$1 recordings', $count)
221                .')</option>';
222        }
223        ?>
224    </select></td>
225<?php
226    }
227?>
228    <td class="-recordings"><?php echo t('Show recordings') ?>:</td>
229    <td colspan=3><select name="title" onchange="$('change_title').submit()">
230        <option id="All recordings" value=""><?php echo t('All recordings') ?></option>
231<?php
232        foreach($Program_Titles as $title => $count) {
233            echo '<option id="Title '.htmlspecialchars($title).'" value="'.htmlspecialchars($title).'"';
234            if ($_GET['title'] == $title)
235                echo ' SELECTED';
236            echo '>'.html_entities($title)
237                .($count > 1 ? ' ('.tn('$1 episode', '$1 episodes', $count).')' : "")
238                ."</option>\n";
239        }
240?>
241    </select></td>
242</tr>
243    <td class="-group"><?php echo t('Sort by') ?>:</td>
244    <td class="-title"><?php     echo get_sort_link('title',     t('Title'))      ?></td>
245    <td class="-subtitle"><?php  echo get_sort_link('subtitle',  t('Subtitle'))   ?></td>
246    <td class="-programid"><?php echo get_sort_link('programid', t('Program ID')) ?></td>
247    <td class="-airdate"><?php   echo get_sort_link('airdate',   t('Airdate'))    ?></td>
248    <td class="-channum"><?php   echo get_sort_link('channum',   t('Channel'))    ?></td>
249<?php
250    if ($recgroup_cols)
251        echo '    <td class="-recgroup">', get_sort_link('recgroup', t('Recording Group')), "</td>\n";
252?>
253    <td class="-length"><?php        echo get_sort_link('length',    t('Length')) ?></td>
254    <td class="-filesize"><?php echo get_sort_link('file_size', t('File Size')) ?></td>
255
256</table>
257</form>
258
259
260<TABLE id="recorded_list" border="0" cellpadding="0" cellspacing="0" class="list small">
261
262<?php
263    $row     = 0;
264    $section = -1;
265
266    $prev_group = '';
267    $cur_group  = '';
268
269    foreach ($All_Shows as $show) {
270
271?>
272
273<?php
274        echo "<tr id=\"inforow_$row\">\n";
275?>
276                <TD ROWSPAN=4 class="-pixmap<?php
277        if ($_SESSION['recorded_pixmaps']) { ?>">
278
279                        <a class="-pixmap" href="<?php echo root ?>tv/detail/<?php echo $show->chanid, '/', $show->recstartts ?>" title="<?php echo t('Recording Details') ?>"
280            ><img src="<?php echo $show->thumb_url(100,0) ?>"></a>
281<?php   }
282        else {
283            echo ' -noimg">';
284        }
285?>
286        <a class="-download"
287            href="<?php echo video_url($show, true) ?>" title="<?php echo t('ASX Stream') ?>"
288            ><img src="<?php echo skin_url ?>/img/play_sm.png"></a>
289        <a class="-download"
290            href="<?php echo $show->url ?>" title="<?php echo t('Direct Download') ?>"
291            ><img src="<?php echo skin_url ?>/img/video_sm.png"></a>
292                </TD>
293                <TD class="-title">
294<?php echo '<a href="', root, 'tv/detail/', $show->chanid, '/', $show->recstartts, '"'
295                    .($_SESSION['recorded_pixmaps'] ? '' : " name=\"$row\"")
296                    .' title="', t('Recording Details'), '"'
297                    .'>'.$show->title.'</a>' ?>
298                </TD>
299                <TD class="-subtitle"><?php echo '<a href="', root, 'tv/detail/', $show->chanid, '/', $show->recstartts, '"'
300                    .' title="', t('Recording Details'), '"'
301                    .'>'.$show->subtitle.'</a>' ?>
302                       
303                </TD>
304                <TD class="-commands commands" ROWSPAN=4>
305                        <?php
306        if ($show->is_recording) {
307            echo '<a href="', root, 'tv/detail/', $show->chanid, '/', $show->recstartts, '">',
308                 t('Still Recording: Edit'),
309                 "</a>\n        ";
310        }
311        if ($show->can_delete) {
312        ?><a onclick="javascript:confirm_delete(<?php echo $row ?>, false)"
313            title="<?php echo html_entities(t('Delete $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
314            ><?php echo t('Delete') ?></a>
315        <a onclick="javascript:confirm_delete(<?php echo $row ?>, true)"
316            title="<?php echo html_entities(t('Delete and allow rerecord: $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
317            ><?php echo t('Delete + Rerecord') ?></a>
318<?php   } ?>
319                </TD>
320        </TR>
321        <TR VALIGN=TOP>
322                <TD>
323                        <?php echo $show->programid ?>
324                </TD>
325                <TD>
326                        <?php echo nice_filesize($show->filesize) ?>
327                </TD>
328        </TR>
329        <TR VALIGN=TOP>
330                <TD>
331                        <?php echo strftime($_SESSION['date_recorded'], $show->starttime) ?>
332                </TD>
333                <TD>
334                        <?php echo nice_length($show->length) ?>
335                </TD>
336        </TR>
337        <TR VALIGN=TOP>
338                <TD>
339                        <?php echo $show->channel->channum, ' - ', $show->channel->name ?>
340                </TD>
341                <TD>
342                        <?php
343        // Auto expire is interactive
344            echo '<a onclick="set_autoexpire(', $row, ')" class="_autoexpire">',
345                 '<img id="autoexpire_', $row, '" src="', skin_url, '/img/flags/';
346            if ($show->auto_expire)
347                echo 'autoexpire.png" title="', t('Click to disable Auto Expire'), '"';
348            else
349                echo 'no_autoexpire.png" title="', t('Click to enable Auto Expire'), '"';
350            echo '></a>';
351        // The rest of the flags are just for display
352            if ($show->closecaptioned)
353                echo '<img src="'.skin_url.'/img/flags/cc.png" title="'.t('Closed Captioning').'">';
354            if ($show->stereo)
355                echo '<img src="'.skin_url.'/img/flags/stereo.png" title="'.t('Stereo').'">';
356            if ($show->hdtv)
357                echo '<img src="'.skin_url.'/img/flags/hd.png" title="'.t('HD').'">';
358            if ($show->has_commflag)
359                echo '<img src="'.skin_url.'/img/flags/commflagged.png" title="'.t('Commercials Flagged').'">';
360            if ($show->has_cutlist)
361                echo '<img src="'.skin_url.'/img/flags/cutlist.png" title="'.t('Has Cutlist').'">';
362            if ($show->bookmark)
363                echo '<img src="'.skin_url.'/img/flags/bookmark.png" title="'.t('has Bookmark').'">';
364            if ($show->is_watched)
365                echo '<img src="'.skin_url.'/img/flags/watched.png" title="'.t('Watched').'">';
366        ?>
367                </TD>
368        </TR>
369        <TR VALIGN=TOP>
370                <TD COLSPAN=4 class="recorded">
371                                <?php echo $show->description ?>
372                </TD>
373        </TR>
374<?php
375        $prev_group = $cur_group;
376    // Keep track of how many shows are visible in each section
377        $row_count[$section]++;
378    // Keep track of which shows are in which section
379        $row_section[$row] = $section;
380    // Increment row last
381        $row++;
382    }
383?>
384
385</TABLE>
386
387
388
389<script language="JavaScript" type="text/javascript">
390<?php
391    foreach ($row_count as $count) {
392        echo 'rowcount.push(['.escape($count)."]);\n";
393    }
394    foreach ($row_section as $section) {
395        echo 'rowsection.push(['.escape($section)."]);\n";
396    }
397    foreach($Program_Titles as $title => $count) {
398        echo 'titles['.escape($title).'] = '.escape($count).";\n";
399    }
400    foreach($Groups as $recgroup => $count) {
401        echo 'groups['.escape($recgroup).'] = '.escape($count).";\n";
402    }
403?>
404</script>
405
406<?php
407    echo '<p align="right" style="padding-right: 75px">'
408        .t('$1 programs, using $2 ($3) out of $4 ($5 free).',
409           '<span id="programcount">'.t($Total_Programs).'</span>',
410           '<span id="diskused">'.nice_filesize($Total_Used).'</span>',
411           '<span id="totaltime">'.nice_length($Total_Time).'</span>',
412           '<span id="disksize">'.nice_filesize(disk_size).'</span>',
413           '<span id="diskfree">'.nice_filesize(disk_size - disk_used).'</span>'
414          )
415        .'</p>';
416
417// Print the page footer
418    require 'modules/_shared/tmpl/'.tmpl.'/footer.php';
419
420