<%pre> #include #include #include #include #include #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; <%args> type = "now"; string mode; string attime; string fixtime; <%session scope="global"> bool logged_in(false); <%request scope="page"> string current_type; string current_mode; string current_attime; string current_fixtime; string current_displaytime; <%include>page_init.eh <%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"); } <& pageelems.doc_type &> VDR-Live - <$ head $> <& pageelems.stylesheets &> <& pageelems.ajax_js &> <& pageelems.logo &> <& menu active=("whats_on") component=("whats_on.whats_on_actions")>
% if (mode == "list") { % } <%cpp> std::list 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::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)) + "

" + 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") {
<& pageelems.epg_tool_box detail=(1) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &>
<$ (startDate) $>
<$ (timeSpan) $>
<& pageelems.progressbar progress=(epgEvent->Elapsed()) duration=(epgEvent->Duration()) &>
<$ (epgEvent->Title()) $>
<$ (epgEvent->ShortDescr()) $>
<$ truncDescription $>
% if (truncated) { % }
<%cpp> } else { // mode == "list" std::list::iterator last = i; bool lastCurrentChanel = (++last == eventList.end()); tChannelID chanId; tEventID eventId; EpgEvents::DecodeDomId(epgEvent->Id(), chanId, eventId);
<& pageelems.epg_tool_box detail=(0) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) lastCurrentChanel=(lastCurrentChanel ? 1 : 0) &> % } <%cpp> } % if (mode == "list") {
<$ head $>
">
<$ (timeSpan) $>
<& pageelems.progressbar progress=(epgEvent->Elapsed()) duration=(epgEvent->Duration()) &>
"> ">
% }
<%include>page_exit.eh <# ------------------------------------------------------------------------- #> <%def whats_on_actions> " href="whats_on.html?type=now&mode=<$ current_mode $>" id="nowhref"><$ tr("Now") $> | " href="whats_on.html?type=next&mode=<$ current_mode $>" id="nexthref"><$ tr("Next") $> | "><$ tr("What's on") $> | "><$ tr("at") $> " onchange="showspectime(this)"/> | % if ( LiveFeatures< features::epgsearch >().Recent() ) { " href="whats_on.html?type=favs&mode=<$ current_mode $>"><$ tr("Favorites") $> | % } % if ( current_mode == "list" ) { <$ tr("Details view") $> % } else { <$ tr("List view") $> % }