summaryrefslogtreecommitdiff
path: root/pages/schedule.ecpp
blob: 39942bbe33c6522df30ec5c7c751217008dbaa18 (plain)
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
<%pre>
#include <vdr/plugin.h>
#include <vdr/channels.h>
#include <vdr/epg.h>
#include <vdr/config.h>
#include <vdr/device.h>
#include "exception.h"
#include "livefeatures.h"
#include "setup.h"
#include "tools.h"
#include "epg_events.h"

using namespace std;
using namespace vdrlive;

</%pre>
<%args>
	int channel = -1;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%request scope="page">
	cChannel* Channel;
</%request>
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
</%cpp>
<%cpp>
	pageTitle = tr("Schedule");

	cSchedulesLock schedulesLock;
	cSchedules const* schedules = cSchedules::Schedules( schedulesLock );

	ReadLock channelsLock( Channels );
	if ( !channelsLock )
		throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );

	// cChannel* Channel; (see %request above)
	if ( channel > 0 ) {
		Channel = Channels.GetByNumber( channel );
	}
	else {
		if (cDevice::CurrentChannel()) {
			Channel = Channels.GetByNumber(cDevice::CurrentChannel());
		}
		else {
			Channel = Channels.Get( Channels.GetNextNormal( -1 ) );
		}
	}
	if ( Channel == 0 )
		throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") );

	cSchedule const* Schedule = schedules->GetSchedule( Channel );
</%cpp>
<& pageelems.doc_type &>
<html>
	<head>
		<title>VDR Live - <$ pageTitle $></title>
		<& pageelems.stylesheets &>
		<& tooltip.javascript var=("domTT_styleClass") value=("domTTepg") &>
		<& pageelems.ajax_js &>
	</head>
	<body>
		<& pageelems.logo &>
		<& menu active=("schedule") component=("schedule.channel_selection")>
		<div class="inhalt">
<%cpp>
	if ( Schedule == 0 ) {
</%cpp>
			<$ tr("No schedules available for this channel") $>.
<%cpp>
	}
	else {
</%cpp>
			<table class="listing" cellspacing="0" cellpadding="0">
<%cpp>
		EpgEvents epgEvents;

		string current_day = "";
		const cEvent* PresentEvent = Schedule->GetPresentEvent();
		time_t now = time(NULL) - ::Setup.EPGLinger * 60;
		tChannelID channel_id(Channel->GetChannelID());
		int evntNr = 0;
		for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
			if (Event->EndTime() <= now && Event != PresentEvent)
				continue;

			string evntId("eventId_");
			evntId += lexical_cast<std::string, int>(++evntNr);
			EpgEventPtr epgEvent(new EpgEvent(evntId, Event, Channel->Name()));
			epgEvents.push_back(epgEvent);

			string title(Event->Title() ? Event->Title() : "");
			string short_description(Event->ShortText() ? Event->ShortText() : "");
			string description(Event->Description() ? Event->Description() : "");
			string start(Event->StartTime() ? FormatDateTime(tr("%I:%M %p"), Event->StartTime()) : "");
			string end(Event->EndTime() ? FormatDateTime(tr("%I:%M %p"), Event->EndTime()) : "");
			string day(Event->StartTime() ? FormatDateTime(tr("%A, %b %d %Y"), Event->StartTime()) : "");
			tEventID event = Event->EventID();
			ostringstream os;
			os << Event->EventID();
			string strEventID = os.str();
			bool truncated = false;
			bool lastEventCurrentDay = false;
			{
				cEvent* NextEvent = Schedule->Events()->Next(Event);
				if (!NextEvent) {
					lastEventCurrentDay = true;
				}
				else {
					string nday(NextEvent->StartTime() ? FormatDateTime(tr("%A, %b %d %Y"), NextEvent->StartTime()) : "");
					lastEventCurrentDay = (day != nday);
				}
			}

			if (current_day != day) {
				if (current_day != "") {
</%cpp>
				<tr class="spacer">
					<td colspan="5"/>
				</tr>
<%cpp>
				}
</%cpp>
	   			<tr class="head">
	   				<td colspan="5"><div class="boxheader"><div><div><$ day $></div></div></div></td>
				</tr>
<%cpp>
	   			current_day = day;
			}
</%cpp>
				<tr>
					<td class="action leftcol <? lastEventCurrentDay ? "bottomrow" ?>"><& pageelems.event_timer channelid=(channel_id) eventid=(event) &></td>
					<td class="action <? lastEventCurrentDay ? "bottomrow" ?>"><%cpp>if (LiveFeatures<features::epgsearch>().Recent() ) { </%cpp><a href="searchresults.html?searchplain=<$ StringUrlEncode(title) $>"><img src="<$ LiveSetup().GetThemedLink("img", "search.png") $>" alt="" <& tooltip.hint text=(tr("Search for repeats.")) &>></img></a><%cpp> } else { </%cpp><img src="transparent.png" width="16" height="16"><%cpp> } </%cpp></td>
					<td class="action <? lastEventCurrentDay ? "bottomrow" ?>"><a href="http://akas.imdb.com/Tsearch?title=<$ StringUrlEncode(title) $>"><img src="<$ LiveSetup().GetThemedLink("img", "imdb.png") $>" border="0" alt="" <& tooltip.hint text=(tr("Find more at the Internet Movie Database.")) &>></img></a></td>
					<td class="topaligned <? lastEventCurrentDay ? "bottomrow" ?>"><div class="withmargin"><$ start $> - <$ end $></div></td>
					<td class="<? (Event == PresentEvent) ? "current" ?> topaligned rightcol <? lastEventCurrentDay ? "bottomrow" ?>"><div class="more withmargin" <& tooltip.hint text=(StringEscapeAndBreak(StringWordTruncate(description, 300, truncated)) + "<br />" + tr("Click to view details.")) &><& tooltip.display domId=(epgEvent->Id()) &>><span class="title"><$ title $></span><br /><span class="short"><%cpp>if (short_description.empty()) { </%cpp>&nbsp;<%cpp> } </%cpp><$ short_description $></span></div></td>
				</tr>
<%cpp>
		}
</%cpp>
			</table>
		</div>
		<div class="epg_data" style="display: none;">
<%cpp>
	   	// create hidden div for the tooltip hints.
	    for (vector<EpgEventPtr>::iterator i = epgEvents.begin(); i != epgEvents.end(); ++i) {
			EpgEventPtr epg = *i;
</%cpp>
		<& pageelems.epg_tt_box boxId=(epg->Id()) caption=(epg->Caption()) time=(epg->StartTime(tr("%I:%M %p")) + string(" - ") + epg->EndTime(tr("%I:%M %p"))) title=(epg->Title()) short_descr=(epg->ShortDescr()) long_descr=(epg->LongDescr()) elapsed=(epg->Elapsed()) &>
<%cpp>
	   	}
	}
</%cpp>
		</div>
	</body>
</html>
<%include>page_exit.eh</%include>

<%def channel_selection>
<form name="channels" id="channels"><span><$ tr("Show schedule of channel") $>: </span><& channels_widget name=("channel") selected=(Channel ? *Channel->GetChannelID().ToString() : "") onchange=("document.forms.channels.submit()") &></form>
</%def>