/
schedules.php
199 lines (183 loc) · 8.77 KB
/
schedules.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* This file defines a theme class for the all recordings section.
* It must define one method. documentation will be added someday.
*
*
* @package MythWeb
* @subpackage TV
*
**/
// Set the desired page title
$page_title = 'MythWeb - '.t('Recording Schedules');
// Custom headers
$headers[] = '<link rel="stylesheet" type="text/css" href="'.skin_url.'/tv_schedules.css">';
// Print the page header
require 'modules/_shared/tmpl/'.tmpl.'/header.php';
// No schedules defined?
if (!is_array($the_schedules) || !count($the_schedules)) {
echo '<div id="no_schedules">',
t('No recording schedules have been defined.').
'</div>';
return;
}
// Print the page contents
$group_field = $_GET['sortby'];
if ($group_field == 'title' || !in_array($group_field, array('title', 'callsign', 'channum', 'type', 'profile', 'recgroup')))
$group_field = '';
?>
<script type="text/javascript">
function load_tool_tip(element_id, recordid) {
var element = $(element_id);
if (Tips.hasTip(element) == false) {
ajax_add_request();
new Ajax.Request('<?php echo root_url; ?>tv/get_schedule_details',
{
parameters: {
recordid: recordid,
ajax: true
},
onSuccess: add_tool_tip,
method: 'get'
});
}
}
function add_tool_tip(content) {
ajax_remove_request();
var info = content.responseJSON;
if (Tips.hasTip($(info['id'])) == false) {
new Tip(info['id'], info['info'], { className: 'popup' });
attempt_to_show_tip(info['id']);
}
}
var currently_hovered_id = null;
var details_delay_timer_id = null;
function attempt_to_show_tip(element) {
if (element == currently_hovered_id)
Tips.showTip(element);
}
</script>
<table id="listings" border="0" cellpadding="4" cellspacing="2" class="list small" sortable="true">
<thead>
<tr class="menu">
<?php if ($group_field != '') echo "<th class=\"list\"> </th>\n"; ?>
<th class="x-title"><?php echo get_sort_link('title', t('Title' )); ?></th>
<th class="x-priority"><?php echo get_sort_link('recpriority', t('Recording Priority' )); ?></th>
<th class="x-channel"><?php echo get_sort_link($_SESSION["prefer_channum"] ? 'channum_with_type' : 'callsign_with_type', t('Channel' )); ?></th>
<th class="x-profile"><?php echo get_sort_link('profile', t('Profile' )); ?></th>
<th class="x-transcoder"><?php echo get_sort_link('transcoder', t('Transcoder')); ?></th>
<th class="x-group"><?php echo get_sort_link('recgroup', t('Recording Group')); ?></th>
<th class="x-type"><?php echo get_sort_link('type', t('Type')); ?></th>
<th class="x-sgroup"><?php echo get_sort_link('storagegroup', t('Storage Group')); ?></th>
<th class="x-startoffset"><?php echo get_sort_link('startoffset', t('Start Early')); ?></th>
<th class="x-endoffset"><?php echo get_sort_link('endoffset', t('End Late')); ?></th>
<th class="x-lastrec"><?php echo get_sort_link('last_record', t('Last Recorded')); ?></th>
</tr>
</thead>
<?php
$prev_group = '';
$cur_group = '';
foreach ($the_schedules as $schedule) {
// Ignore templates until full support can be added
if ($schedule->type == rectype_template)
continue;
// Reset the command variable to a default URL
$urlstr = 'recordid='.$schedule->recordid;
$css_class = ($schedule->type == rectype_dontrec ? 'deactivated' : 'scheduled');
// If this is an 'always on any channel' or 'find one' recording without the 'This Channel' filter, set the channel name to 'Any'
if (($schedule->type == rectype_always || $schedule->type == rectype_findone) && !($schedule->filter & (1 << 10))) {
$schedule->channel->name = '[ '.t('Any').' ]';
$schedule->channel->callsign = null;
$schedule->channel->channum = 0;
}
// A program id counter for popup info
if ($_SESSION["show_popup_info"]) {
static $program_id_counter = 0;
$program_id_counter++;
}
// Print a dividing row if grouping changes
if ($group_field == 'type')
$cur_group = $schedule->texttype;
elseif ($group_field == 'callsign')
$cur_group = ($schedule->channel->callsign ? $schedule->channel->callsign.' - ' : '').$schedule->channel->name;
elseif ($group_field == 'channum')
$cur_group = ($schedule->channel->channum ? $schedule->channel->channum.' - ' : '').$schedule->channel->name;
elseif ($group_field == 'profile')
$cur_group = $schedule->profile;
elseif ($group_field == 'recgroup')
$cur_group = $schedule->recgroup;
elseif ($group_field == 'storagegroup')
$cur_group = $schedule->storagegroup;
// "none"?
$cur_group or $cur_group = t('None');
$style_class = $schedule->css_class;
if ($schedule->type == rectype_override)
$style_class .= ' record_override_record';
elseif ($schedule->type == rectype_dontrec)
$style_class .= ' record_override_suppress';
if ( $cur_group != $prev_group && $group_field != '' ) {
?><tr class="list_separator">
<td colspan="6" class="list_separator"><?php echo $cur_group ?></td>
</tr><?php
}
// Print the content
?><tr class="<?php echo $css_class ?>">
<?php if ($group_field != '') echo "<td class=\"list\"> </td>\n" ?>
<td class="x-title <?php echo $style_class ?>"><?php
// Window status text, for the mouseover
$wstatus = "Details for $schedule->title";
// Print a link to the program detail for this schedule
echo '<a id="schedule-'.$schedule->recordid.'"';
if ($_SESSION["show_popup_info"]) {
echo ' onmouseover = "currently_hovered_id = this.id; details_delay_timer_id = setTimeout(function () {load_tool_tip(\'schedule-'.$schedule->recordid.'\',\''.$schedule->recordid.'\');}, 250);"';
echo ' onmouseout = "currently_hovered_id = null; clearTimeout( details_delay_timer_id ); details_delay_timer_id = null;"';
}
echo ' href="'.root_url.'tv/';
// Link to different places for different kinds of schedules
if ($schedule->search) {
echo 'schedules/',
($schedule->search == searchtype_manual) ? 'manual'
: 'custom',
'/', $schedule->recordid;
}
else
echo 'detail?recordid='.$schedule->recordid;
// Finish off the link
echo '">'.$schedule->title;
if (in_array($schedule->type, array(rectype_once, rectype_override, rectype_dontrec)) && preg_match('/\\w/', $schedule->subtitle))
echo ": $schedule->subtitle";
echo '</a>';
?></td>
<td class="x-priority"><?php
echo $schedule->recpriority
?></td>
<td class="x-channel"><?php
if ($_SESSION["prefer_channum"]) {
if ($schedule->channel->channum)
echo $schedule->channel->channum.' - ';
}
else {
if ($schedule->channel->callsign)
echo $schedule->channel->callsign.' - ';
}
echo $schedule->channel->name;
?></td>
<td class="x-profile"><?php echo _or($schedule->profile, ' ') ?></td>
<td class="x-transcoder"><?php
global $Transcoders;
echo _or($Transcoders[$schedule->transcoder], ' ')
?></td>
<td class="x-group"><?php echo _or($schedule->recgroup, ' ') ?></td>
<td class="x-type"><?php echo $schedule->texttype ?></td>
<td class="x-sgroup"><?php echo _or($schedule->storagegroup, ' ') ?></td>
<td class="x-startoffset"><?php echo _or($schedule->startoffset, ' ') ?></td>
<td class="x-endoffset"><?php echo _or($schedule->endoffset, ' ') ?></td>
<td class="x-lastrec"><?php echo _or($schedule->last_record, ' ') ?></td>
</tr><?php
$prev_group = $cur_group;
}
?>
</table>
<?php
// Print the page footer
require 'modules/_shared/tmpl/'.tmpl.'/footer.php';