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
|
<%pre>
#include <livefeatures.h>
#include <setup.h>
#include <tools.h>
#include <epg_events.h>
#include <timers.h>
#include <recman.h>
#include <vdr/config.h>
using namespace vdrlive;
</%pre>
<%args>
int channel = -1;
std::string channelid;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<# scope="page" should be enough but does not work with tntnet 3.0 #>
<%request scope="global">
tChannelID channel_id = tChannelID();
int channel_number = 0;
cString prev;
cString next;
</%request>
<%include>page_init.eh</%include>
<%cpp>
reply.setHeader (tnt::httpheader::cacheControl, "no-store, no-cache, max-age=0, must-revalidate, proxy-revalidate", true);
if (!logged_in && LiveSetup().UseAuth()) {
cToSvConcat<0> targetUrl = "/login.html?redirect=";
targetUrl.appendUrlEscaped(request.getQuery());
return reply.redirect(targetUrl.data());
}
</%cpp>
<%cpp>
pageTitle = trVDR("Schedule");
bool display_pictures = !(LiveSetup().GetTvscraperImageDir().empty());
bool events_available = false;
{
// figure out channel_id & channel_number
const cChannel* Channel = nullptr;
LOCK_CHANNELS_READ;
if ( qparam.has("channelid") ) {
tChannelID cid = cid.FromString(channelid.c_str());
Channel = Channels->GetByChannelID( cid );
} else 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 )
throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") );
channel_id = Channel->GetChannelID();
channel_number = Channel->Number();
if (channel_number > 1)
prev = cString::sprintf("href=\"schedule.html?channel=%i\"", channel_number - 1);
if (channel_number < Channels->MaxNumber())
next = cString::sprintf("href=\"schedule.html?channel=%i\"", channel_number + 1);
LOCK_SCHEDULES_READ;
cSchedule const* Schedule = Schedules->GetSchedule(Channel);
events_available = Schedule && Schedule->Events()->First();
}
</%cpp>
<& pageelems.doc_type &>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>VDR Live - <$ pageTitle $></title>
<& pageelems.stylesheets &>
<& pageelems.ajax_js &>
<& pageelems.create_html_js &>
<script type="text/javascript"><!--
function KeyboardInput(ev) {
if (ev.ctrlKey)
switch (ev.which) {
case 37: // left
<?? *prev ? "window.location." << *prev ?>
return false;
case 39: // right
<?? *next ? "window.location." << *next ?>
return false;
}
switch (ev.key) {
case '<':
<?? *prev ? "window.location." << *prev ?>
return false;
case '>':
<?? *next ? "window.location." << *next ?>
return false;
}
return true;
}
//--></script>
</head>
<body onpagehide="saveScrollPosition('content')" onpageshow="restoreScrollPosition()" onkeydown="return KeyboardInput(event);">
<& pageelems.logo &>
<& menu active=("schedule") component=("schedule.channel_selection") &>
<div id="content">
<div class="spacebar"><# spacer with fade-out effect #></div>
<%cpp>
if (!events_available) {
</%cpp>
<$ tr("No schedules available for this channel") $>.
<%cpp>
}
else {
int col_span = 3;
if (display_pictures) col_span++;
std::string current_day = "";
time_t now = time(NULL) - ::Setup.EPGLinger * 60;
cToSvConcat<0> epg_item;
epg_item.reserve(10000);
epg_item.concat('[');
{
LOCK_TIMERS_READ;
LOCK_CHANNELS_READ;
LOCK_RECORDINGS_READ; // required because appendEpgItemWithRecItem needs also lock on recording
LOCK_SCHEDULES_READ;
const cChannel* Channel = Channels->GetByChannelID(channel_id);
cSchedule const* Schedule = Schedules->GetSchedule(Channel);
const cEvent* PresentEvent = Schedule->GetPresentEvent();
for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
if (Event->EndTime() <= now && Event != PresentEvent) continue;
current_day = appendEpgItemWithRecItem(epg_item, current_day, Event, Channel, false, Timers);
}
}
epg_item.concat("]]]");
if (current_day.empty() ) {
</%cpp>
<$ tr("No events available for this channel") $>.
% } else {
<script>
document.write(addEventListString(<$col_span$>, <$$ epg_item.c_str() $>))
</script>
<%cpp>
}
}
</%cpp>
<div class="spacebar"><# spacer with fade-out effect #></div>
</div>
<script>imgLoad()</script>
</body>
</html>
<%include>page_exit.eh</%include>
<%def channel_selection>
<form action="schedule.html" method="get" id="channels">
<span>
<label for="channel"><$ tr("Channel") $>: <span class="bold"><$ cToSvInt(channel_number) $></span></label>
<& channels_widget name=("channel") selected=(channel_id) onchange=("document.forms.channels.submit()") &>
</span>
</form>
<span class="tools">
% if (cDevice::PrimaryDevice() ) {
<& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel")) param=(channel_id) image="zap.png" className="icon" alt="" &>
% }
<& pageelems.hls_channel channelId=(channel_id) className="icon" &>
<& pageelems.m3u_playlist_channel channelId=(channel_id) className="icon" &>
</span>
<span class="sep">|</span>
<?? *prev ? "<a " << *prev << ">"?>« <$ tr("Prev. entry") $><?? *prev ? "</a>" ?>
<span class="sep">|</span>
<?? *next ? "<a " << *next << ">"?><$ tr("Next entry") $> »<?? *next ? "</a>" ?>
</%def>
|