diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/whats_on.ecpp | 218 |
1 files changed, 142 insertions, 76 deletions
diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 7331adc..9944e21 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -8,6 +8,7 @@ #include "setup.h" #include "tools.h" #include "epg_events.h" +#include "epgsearch.h" using namespace std; using namespace vdrlive; @@ -69,6 +70,8 @@ if (type == "now") { if (seektime - time(0) + 3600 < 0) // if wanted time is past more then 1h, then use tomorrow seektime += SECSINDAY; head = tr("What's running at") + string(" ") + FormatDateTime(tr("%I:%M %p"), seektime) +string(" (") +FormatDateTime(tr("%a, %b %d"), seektime) + string(")"); +} else if (type == "favs") { + head = tr("Favorites"); } </%cpp> @@ -104,90 +107,151 @@ if (type == "now") { <%cpp> EpgEvents epgEvents; - 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) { - continue; - } - - EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event); - - bool truncated = false; - string truncDescription = StringWordTruncate(epgEvent->LongDescr(), maximumTooltipHintLength, truncated); - string longDescription = StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), maximumDescriptionLength)) - + "<br/><br/>" + tr("Click to view details."); - bool lastCurrentChanel = true; - - if (mode == "detail") { + 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) { + continue; + } + + EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event); + + bool truncated = false; + string truncDescription = StringWordTruncate(epgEvent->LongDescr(), maximumTooltipHintLength, truncated); + string longDescription = StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), maximumDescriptionLength)) + + "<br/><br/>" + tr("Click to view details."); + bool lastCurrentChanel = true; + + if (mode == "detail") { </%cpp> - <div class="event"> - <div class="station"> - <div><div><div><a href="schedule.html?channel=<$ Channel->Number() $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ (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 class="event"> + <div class="station"> + <div><div><div><a href="schedule.html?channel=<$ Channel->Number() $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ (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"><$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $></div> +% if (epgEvent->Elapsed() >= 0) { + <div class="progress"><div><& pageelems.progressbar progress=(epgEvent->Elapsed()) &></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> - <div class="info"><$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $></div> -% if (epgEvent->Elapsed() >= 0) { - <div class="progress"><div><& pageelems.progressbar progress=(epgEvent->Elapsed()) &></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" - lastCurrentChanel = ((Channel->Number() == LiveSetup().GetLastChannel()) - || (!Channels.Next(Channel))); + } + else { // mode == "list" + lastCurrentChanel = ((Channel->Number() == LiveSetup().GetLastChannel()) + || (!Channels.Next(Channel))); </%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"><$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $></div> -% if (epgEvent->Elapsed() >= 0) { - <div class="progress"><div><& pageelems.progressbar progress=(epgEvent->Elapsed()) &></div></div> -% } - </div> - </td> - <td class="topaligned <? lastCurrentChanel ? "bottomrow"?>"> - <div class="more withmargin"><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></div> - </td> - <td class="topaligned rightcol <? lastCurrentChanel ? "bottomrow"?>"><div class="station withmargin"><a href="schedule.html?channel=<$ Channel->Number() $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ (epgEvent->Caption()) $></a></div></td> - </tr> -% } + <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"><$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $></div> +% if (epgEvent->Elapsed() >= 0) { + <div class="progress"><div><& pageelems.progressbar progress=(epgEvent->Elapsed()) &></div></div> +% } + </div> + </td> + <td class="topaligned <? lastCurrentChanel ? "bottomrow"?>"> + <div class="more withmargin"><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></div> + </td> + <td class="topaligned rightcol <? lastCurrentChanel ? "bottomrow"?>"><div class="station withmargin"><a href="schedule.html?channel=<$ Channel->Number() $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ (epgEvent->Caption()) $></a></div></td> + </tr> +% } <%cpp> - } + } + } } + else { + 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); + } + for (SearchResults::iterator result = results.begin(); result != results.end(); ++result) { + string epgId = EpgEvents::EncodeDomId(result->Channel(), result->EventId()); + string channelname = Channels.GetByChannelID(result->Channel())->Name(); + int channelnr = Channels.GetByChannelID(result->Channel())->Number(); + bool truncated = false; + string truncDescription = StringWordTruncate(result->Description(), maximumTooltipHintLength, truncated); + string longDescription = StringEscapeAndBreak(StringWordTruncate(result->Description(), maximumDescriptionLength)) + + "<br/><br/>" + tr("Click to view details."); + + // last result? + bool bottom = false; + SearchResults::iterator nextres = result; + nextres++; + if (nextres == results.end()) bottom = true; + + time_t now = time(NULL); + long diff = result->StartTime() - now; + long absdiff = labs(diff); + if (absdiff >= 24*60*60) continue; // skip broadcasts more than a day away + string diffstring; + if (absdiff >= (60 * 60)) + diffstring = lexical_cast<std::string>(long(absdiff / (60*60))) + " hours"; + else + diffstring = lexical_cast<std::string>(long(absdiff / 60)) + " minutes"; + if (diff > 0) + diffstring = "in " + diffstring; + else + diffstring = "since " + diffstring; </%cpp> + <tr> + <& pageelems.epg_tool_box detail=(0) epgid=(epgId) title=(result->Title()) startTime=(result->StartTime()) endTime=(result->StopTime()) lastCurrentChanel=(bottom ? 1 : 0) &> + <td class="topaligned <? bottom ? "bottomrow"?>"> + <div class="withmargin"> + <div class="nomargin"><$ (FormatDateTime(tr("%I:%M %p"), result->StartTime())) $> - <$ (FormatDateTime(tr("%I:%M %p"), result->StopTime())) $></div> + <$ diffstring $> minutes + </div> + </td> + <td class="topaligned <? bottom ? "bottomrow"?>"> + <div class="more withmargin"><a +% if (!longDescription.empty()) { + <& tooltip.hint text=(longDescription) &><& tooltip.display domId=(epgId) &> +% } + ><span class="title"><$ (result->Title()) $></span><br /><span class="short"><$ (result->ShortText()) $></span></a></div> + </td> + <td class="topaligned rightcol <? bottom ? "bottomrow"?>"><div class="station withmargin"><a href="schedule.html?channel=<$ channelnr $>" <& tooltip.hint text=(tr("View the schedule of this channel")) &>><$ (channelname) $></a></div></td> + </tr> +% } +<%cpp> + } + </%cpp> % if (mode == "list") { </table> % } @@ -220,6 +284,8 @@ if (type == "now") { <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> +<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 { |