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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
<%pre>
#include <vdr/plugin.h>
#include <vdr/channels.h>
#include <vdr/epg.h>
#include <vdr/config.h>
#include <vdr/i18n.h>
#include "livefeatures.h"
#include "setup.h"
#include "tools.h"
#include "epg_events.h"
#include "epgsearch.h"
using namespace std;
using namespace vdrlive;
static const size_t maximumDescriptionLength = 300;
static const size_t maximumTooltipHintLength = 150;
</%pre>
<%args>
type = "now";
string mode;
string attime;
string fixtime;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%request scope="page">
string current_type;
string current_mode;
string current_attime;
string current_fixtime;
string current_displaytime;
</%request>
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
cSchedulesLock schedulesLock;
const cSchedules* Schedules = cSchedules::Schedules(schedulesLock);
string head;
time_t seektime = 0;
string displaytime;
string headTime;
string headDate;
if (mode.empty())
mode = LiveSetup().GetLastWhatsOnListMode();
else
LiveSetup().SetLastWhatsOnListMode(mode);
current_type = type;
current_mode = mode;
current_attime = attime;
current_fixtime = fixtime;
char const * timeFormat = tr("%I:%M %p");
char const * dateFormat = tr("%A, %x");
if (mode == "detail") {
dateFormat = tr("%a, %x");
}
if (type == "now") {
headTime = FormatDateTime(timeFormat, time(0));
headDate = FormatDateTime(dateFormat, time(0));
head = string(tr("What's running on")) + " " + headDate + " " + tr("at") + " " + headTime;
} else if (type == "next") {
headTime = FormatDateTime(timeFormat, time(0) + 3600);
headDate = FormatDateTime(dateFormat, time(0) + 3600);
head = tr("What's on next?");
} else if (type == "at") {
if (attime != "")
displaytime = ExpandTimeString(attime);
else if (fixtime != "")
displaytime = ExpandTimeString(fixtime);
current_displaytime = displaytime;
seektime = GetTimeT(displaytime);
if (seektime - time(0) + 3600 < 0) // if wanted time is past more then 1h, then use tomorrow
seektime += SECSINDAY;
headTime = FormatDateTime(timeFormat, seektime);
headDate = FormatDateTime(dateFormat, seektime);
head = string(tr("What's running on")) + " " + headDate + " " + tr("at") + string(" ") + headTime;
} else if (type == "favs") {
head = tr("Favorites");
}
</%cpp>
<& pageelems.doc_type &>
<html>
<head>
<title>VDR-Live - <$ head $></title>
<& pageelems.stylesheets &>
<& pageelems.ajax_js &>
<script type="text/javascript"><!--
function showtime(selection)
{
if (selection.options[selection.selectedIndex].value != "")
window.location.href = "whats_on.html?type=at&mode=<$ current_mode $>&fixtime=" + selection.options[selection.selectedIndex].value;
}
function showspectime(selection)
{
if (selection.value != "")
window.location.href = "whats_on.html?type=at&mode=<$ current_mode $>&attime=" + selection.value;
}
//--></script>
</head>
<body>
<& pageelems.logo &>
<& menu active=("whats_on") component=("whats_on.whats_on_actions")>
<div class="inhalt">
% if (mode == "list") {
<table class="listing" cellspacing="0" cellpadding="0">
<tr class="head">
<td colspan="8"><div class="boxheader"><div><div><$ head $></div></div></div></td>
</tr>
% }
<%cpp>
std::list<EpgInfoPtr> eventList;
// collect the broadcasts
if (type != "favs")
{
ReadLock channelsLock( Channels );
if (channelsLock) {
// int evntNr = 0;
for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) {
if (Channel->GroupSep()) {
continue;
}
const cSchedule *Schedule = Schedules->GetSchedule(Channel);
if (!Schedule) {
continue;
}
const cEvent *Event = NULL;
if (type == "now")
Event = Schedule->GetPresentEvent();
else if (type == "next")
Event = Schedule->GetFollowingEvent();
else if (type == "at")
Event = Schedule->GetEventAround(seektime);
if (!Event && !LiveSetup().GetShowChannelsWithoutEPG()) continue;
EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event);
eventList.push_back(epgEvent);
}
}
}
else // get favorite broadcasts from epgsearch
{
SearchResults results;
SearchTimers timers;
for (SearchTimers::iterator timer = timers.begin(); timer != timers.end(); ++timer) {
if (!timer->UseInFavorites()) continue;
SearchResults curresults;
curresults.GetByID(timer->Id());
results.merge(curresults);
}
time_t now = time(NULL);
for (SearchResults::iterator result = results.begin(); result != results.end(); ++result) {
long diff = result->StartTime() - now;
if (labs(diff) >= 24*60*60) continue; // skip broadcasts more than a day away
EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(result->GetChannel(), result->GetEvent());
eventList.push_back(epgEvent);
}
}
// display broadcasts
for(std::list<EpgInfoPtr>::iterator i = eventList.begin(); i != eventList.end(); ++i ) {
EpgInfoPtr epgEvent = *i;
bool truncated = false;
string truncDescription = StringWordTruncate(epgEvent->LongDescr(), maximumTooltipHintLength, truncated);
string longDescription = StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), maximumDescriptionLength))
+ "<br/><br/>" + tr("Click to view details.");
const cChannel* Channel = epgEvent->Channel();
if (!Channel) continue;
int chNumber = Channel->Number();
string startTime(epgEvent->StartTime(tr("%I:%M %p")));
string endTime(epgEvent->EndTime(tr("%I:%M %p")));
string startDate(epgEvent->StartTime(tr("%a, %x")));
string timeSpan(startTime + " - " + endTime);
if (startTime.empty() && endTime.empty()) {
timeSpan = mode=="detail" ? headTime : string();
startDate = headDate;
}
if (mode == "detail") {
</%cpp>
<div class="event">
<div class="station">
<div><div><div><a href="schedule.html?channel=<$ chNumber $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ chNumber $><$ tr(" - ") $><$ (epgEvent->Caption()) $></a></div></div></div>
</div>
<div class="content">
<div class="tools">
<& pageelems.epg_tool_box detail=(1) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &>
</div>
<div>
<div class="info nowrap"><div class="date"><$ (startDate) $></div><div class="time"><$ (timeSpan) $></div></div>
<div class="progress"><div><& pageelems.progressbar progress=(epgEvent->Elapsed()) duration=(epgEvent->Duration()) &></div></div>
<div class="title withmargin"><$ (epgEvent->Title()) $></div>
<div class="short withmargin"><$ (epgEvent->ShortDescr()) $></div>
<div class="description withmargin"><$ truncDescription $></div>
% if (truncated) {
<div class="more withmargin"><a <& tooltip.hint text=(longDescription) &><& tooltip.display domId=(epgEvent->Id()) &>><$ tr("more") $> ...</a></div>
% }
</div>
</div>
</div>
<%cpp>
} else { // mode == "list"
std::list<EpgInfoPtr>::iterator last = i;
bool lastCurrentChanel = (++last == eventList.end());
tChannelID chanId;
tEventID eventId;
EpgEvents::DecodeDomId(epgEvent->Id(), chanId, eventId);
</%cpp>
<tr>
<& pageelems.epg_tool_box detail=(0) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) lastCurrentChanel=(lastCurrentChanel ? 1 : 0) &>
<td class="topaligned <? lastCurrentChanel ? "bottomrow"?>">
<div class="withmargin">
<div class="nomargin nowrap"><$ (timeSpan) $></div>
<div class="progress"><div><& pageelems.progressbar progress=(epgEvent->Elapsed()) duration=(epgEvent->Duration()) &></div></div>
</div>
</td>
<td class="topaligned <? lastCurrentChanel ? "bottomrow"?>">
<div class="more withmargin">
% if (eventId != 0) {
<a
% if (!longDescription.empty()) {
<& tooltip.hint text=(longDescription) &><& tooltip.display domId=(epgEvent->Id()) &>
% }
><span class="title"><$ (epgEvent->Title()) $></span><br /><span class="short"><$ (epgEvent->ShortDescr()) $></span></a>
% } else {
<span class="title"><$ (epgEvent->Title()) $></span>
% }
</div>
</td>
<td class="topaligned rightcol <? lastCurrentChanel ? "bottomrow"?>"><div class="station withmargin"><a href="schedule.html?channel=<$ chNumber $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ chNumber $><$ tr(" - ") $><$ (epgEvent->Caption()) $></a></div>
</td>
</tr>
% }
<%cpp>
}
</%cpp>
% if (mode == "list") {
</table>
% }
</div>
</body>
</html>
<%include>page_exit.eh</%include>
<# ------------------------------------------------------------------------- #>
<%def whats_on_actions>
<a class="<? current_type == "now" ? "active" ?>" href="whats_on.html?type=now&mode=<$ current_mode $>" id="nowhref"><$ tr("Now") $></a>
<span class="sep">|</span>
<a class="<? current_type == "next" ? "active" ?>" href="whats_on.html?type=next&mode=<$ current_mode $>" id="nexthref"><$ tr("Next") $></a>
<span class="sep">|</span>
<span class="<? current_type == "at" && current_fixtime != "" ? "active" ?>"><$ tr("What's on") $></span>
<select name="userdeftimes" size="1" id="userdeftimes" onchange="showtime(this)">
<option value="0"/>
<%cpp>
vector< string > parts = StringSplit( LiveSetup().GetTimes(), ';' );
vector< string >::const_iterator part = parts.begin();
for ( int i = 0; part != parts.end(); ++i, ++part ) {
</%cpp>
<option <%cpp> reply.out() << ( (current_fixtime != "" && *part == current_displaytime) ? "selected=\"selected\"" : "" ); </%cpp> value="<$ *part $>"> <$ tr("at") + string(" ") + *part $></option>
<%cpp>
}
</%cpp>
</select>
<span class="sep">|</span>
<span class="<? current_type == "at" && current_fixtime == "" ? "active" ?>"><$ tr("at") $></span>
<input type="text" size="6" name="spectime" id="spectime" value = "<? current_attime != "" ? current_displaytime ?>" onchange="showspectime(this)"/>
<span class="sep">|</span>
% if ( LiveFeatures< features::epgsearch >().Recent() ) {
<a class="<? current_type == "favs" ? "active" ?>" href="whats_on.html?type=favs&mode=<$ current_mode $>"><$ tr("Favorites") $></a>
<span class="sep">|</span>
% }
% if ( current_mode == "list" ) {
<a href="whats_on.html?mode=detail&type=<$ current_type $>&attime=<$ current_attime $>&fixtime=<$ current_fixtime $>"><$ tr("Details view") $></a>
% } else {
<a href="whats_on.html?mode=list&type=<$ current_type $>&attime=<$ current_attime $>&fixtime=<$ current_fixtime $>"><$ tr("List view") $></a>
% }
</%def>
|