From 213b98b4f18076c8b9e42b6868beaa3a640ae4e6 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sun, 22 Jul 2007 02:10:11 +0000 Subject: - Tool icons in epg popup windows. --- css/styles.css | 34 +++++++++++++++------- doc/ChangeLog | 7 +++++ epg_events.cpp | 72 +++++++++++++++++++++++++-------------------- epg_events.h | 76 ++++++++++++++++++++++++++---------------------- live/css/siteprefs.css | 5 +++- live/js/live/infowin.js | 2 +- pages/epginfo.ecpp | 55 +++++++++++++++++++++++++++++------ pages/pageelems.ecpp | 50 +++++++++++++++++++++++++++++-- pages/searchresults.ecpp | 2 +- pages/whats_on.ecpp | 29 ++---------------- 10 files changed, 215 insertions(+), 117 deletions(-) diff --git a/css/styles.css b/css/styles.css index d197816..516ef4f 100644 --- a/css/styles.css +++ b/css/styles.css @@ -569,6 +569,7 @@ div.content { height: 220px; padding: 0; margin: 0; + overflow: hidden; background: white url(bg_tools.png) top left repeat-y; border-left: 1px solid #000000; @@ -582,18 +583,23 @@ div.content div.tools { height: 220px; margin: 0; padding: 0; + padding-top: 3px; text-align: center; vertical-align: top; } div.content div.tools img { - margin: 5px 2px; - border: 0px; + margin: 2px 5px; } div.content div { - padding-left: 15px; + padding-left: 0px; + margin-left: 35px; +} + +div.content div div { + margin-left: 0px; } div.description { @@ -921,9 +927,14 @@ table.login tr td { .info-win div.epg_content { padding: 0px 0px 7px 0px; - margin: 0; + margin: 0px 0px 0px 0px; background: transparent url(bg_tools.png) top left repeat-y; border: 0px; + overflow: hidden; +} + +.info-win div.epg_content div { + margin-left: 35px; } .info-win div.epg_content div.epg_tools { @@ -931,21 +942,24 @@ table.login tr td { width: 26px; margin: 0; padding: 0; + padding-top: 3px; text-align: center; vertical-align: top; } -.info-win div.epg_content div div.progress div { +.info-win div.epg_content div div { margin-left: 0px; } -.info-win div.epg_content div div { - margin-left: 35px; +/* +.info-win div.epg_content div div.progress div { + margin-left: 0px; } +*/ .info-win div.epg_content div.epg_tools img { - margin-top: 5px; + margin: 2px 5px; } .info-win span.epg_images img.epg_image { @@ -1002,12 +1016,12 @@ div.about_box a:hover { } .info-win div.epg_content div.about_line { - padding-left: 10px; + padding-left: 0px; } .info-win div.epg_content div.about_head { font-weight: bold; - margin-left: 26px; + margin-left: -9px; padding-top: 6px; } diff --git a/doc/ChangeLog b/doc/ChangeLog index 289e7a1..452126c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,10 @@ +2007-07-22 Dieter Hametner + + Added toolbox buttons to epg info popup windows. + Some style fixes for this. + * pages/whats_on.ecpp: Use new pageelems.epg_tool_box component. + * pages/pageelems.ecpp: new epg_tool_box component. + 2007-07-21 Dieter Hametner * live/js/live/pageenhance.js: Enhance a normal web page with diff --git a/epg_events.cpp b/epg_events.cpp index 89c1347..83d067d 100644 --- a/epg_events.cpp +++ b/epg_events.cpp @@ -28,7 +28,7 @@ namespace vdrlive { } - const std::string EpgInfo::CurrentTime(const char* format) const + const string EpgInfo::CurrentTime(const char* format) const { return FormatDateTime(format, time(0)); } @@ -47,16 +47,7 @@ namespace vdrlive int EpgInfo::Elapsed() const { - time_t end_time = GetEndTime(); - time_t start_time = GetStartTime(); - - if (end_time > start_time) { - time_t now = time(0); - if ((start_time <= now) && (now <= end_time)) { - return 100 * (now - start_time) / (end_time - start_time); - } - } - return -1; + return EpgEvents::ElapsedTime(GetStartTime(), GetEndTime()); } /* @@ -217,7 +208,7 @@ namespace vdrlive { } - string EpgEvents::GetDomId(const tChannelID& chanId, const tEventID& eId) + string EpgEvents::EncodeDomId(tChannelID const &chanId, tEventID const &eId) { string channelId(chanId.ToString()); string eventId("event_"); @@ -231,9 +222,9 @@ namespace vdrlive return eventId; } - EpgInfoPtr EpgEvents::CreateEpgInfo(const std::string& epgid, const cSchedules* schedules) + void EpgEvents::DecodeDomId(string const &epgid, tChannelID& channelId, tEventID& eventId) { - const string eventStr("event_"); + string const eventStr("event_"); size_t delimPos = epgid.find_last_of('_'); string cIdStr = epgid.substr(eventStr.length(), delimPos - eventStr.length()); @@ -241,51 +232,60 @@ namespace vdrlive replace(cIdStr.begin(), cIdStr.end(), 'm', '-'); replace(cIdStr.begin(), cIdStr.end(), 'p', '.'); - const string eIdStr = epgid.substr(delimPos+1); - const string errorInfo(tr("Epg error")); + string const eIdStr = epgid.substr(delimPos+1); + + channelId = tChannelID::FromString(cIdStr.c_str()); + eventId = lexical_cast(eIdStr); + } + + EpgInfoPtr EpgEvents::CreateEpgInfo(string const &epgid, cSchedules const *schedules) + { + string const errorInfo(tr("Epg error")); + cSchedulesLock schedulesLock; + tEventID eventId = tEventID(); + tChannelID channelId = tChannelID(); - tEventID eventId = lexical_cast(eIdStr); - tChannelID channelId = tChannelID::FromString(cIdStr.c_str()); - const cChannel* channel = Channels.GetByChannelID(channelId); + DecodeDomId(epgid, channelId, eventId); + cChannel const *channel = Channels.GetByChannelID(channelId); if (!channel) { return CreateEpgInfo(epgid, errorInfo, tr("Wrong channel id")); } - const cSchedule* schedule = schedules->GetSchedule(channel); + cSchedule const *schedule = schedules->GetSchedule(channel); if (!schedule) { return CreateEpgInfo(epgid, errorInfo, tr("Channel has no schedule")); } - const cEvent* event = schedule->GetEvent(eventId); + cEvent const *event = schedule->GetEvent(eventId); if (!event) { - return CreateEpgInfo(epgid, errorInfo, tr("wrong event id")); + return CreateEpgInfo(epgid, errorInfo, tr("Wrong event id")); } return CreateEpgInfo(channel, event, epgid.c_str()); } - EpgInfoPtr EpgEvents::CreateEpgInfo(const cChannel* chan, const cEvent* event, const char* idOverride) + EpgInfoPtr EpgEvents::CreateEpgInfo(cChannel const *chan, cEvent const *event, char const *idOverride) { - string domId(idOverride ? idOverride : GetDomId(chan->GetChannelID(), event->EventID())); + string domId(idOverride ? idOverride : EncodeDomId(chan->GetChannelID(), event->EventID())); return EpgInfoPtr(new EpgEvent(domId, event, chan->Name())); } - EpgInfoPtr EpgEvents::CreateEpgInfo(const string& recid, const cRecording* recording, const char* caption) + EpgInfoPtr EpgEvents::CreateEpgInfo(string const &recid, cRecording const *recording, char const *caption) { return EpgInfoPtr(new EpgRecording(recid, recording, caption)); } - EpgInfoPtr EpgEvents::CreateEpgInfo(const std::string& id, const std::string& caption, const std::string& info) + EpgInfoPtr EpgEvents::CreateEpgInfo(string const &id, string const &caption, string const &info) { return EpgInfoPtr(new EpgString(id, caption, info)); } - list EpgEvents::EpgImages(const std::string& epgid) + list EpgEvents::EpgImages(string const &epgid) { list images; - + size_t delimPos = epgid.find_last_of('_'); string imageId = epgid.substr(delimPos+1); imageId = imageId.substr(0, imageId.size()-1); // tvm2vdr seems always to use one digit less - + const string filemask(LiveSetup().GetEpgImageDir() + "/" + imageId + "*.*"); glob_t globbuf; globbuf.gl_offs = 0; @@ -295,11 +295,21 @@ namespace vdrlive { const string imagefile(globbuf.gl_pathv[i]); size_t delimPos = imagefile.find_last_of('/'); - images.push_back(imagefile.substr(delimPos+1)); + images.push_back(imagefile.substr(delimPos+1)); } globfree(&globbuf); } return images; } - + + int EpgEvents::ElapsedTime(time_t const startTime, time_t const endTime) + { + if (endTime > startTime) { + time_t now = time(0); + if ((startTime <= now) && (now <= endTime)) { + return 100 * (now - startTime) / (endTime - startTime); + } + } + return -1; + } }; // namespace vdrlive diff --git a/epg_events.h b/epg_events.h index f055045..15e4b36 100644 --- a/epg_events.h +++ b/epg_events.h @@ -19,29 +19,29 @@ namespace vdrlive class EpgInfo { protected: - EpgInfo(const std::string& id, - const std::string& caption); + EpgInfo(std::string const &id, + std::string const &caption); public: virtual ~EpgInfo(); - virtual const std::string Id() const { return m_eventId; } + virtual std::string const Id() const { return m_eventId; } - virtual const std::string Caption() const { return m_caption; } + virtual std::string const Caption() const { return m_caption; } - virtual const std::string Title() const = 0; + virtual std::string const Title() const = 0; - virtual const std::string ShortDescr() const = 0; + virtual std::string const ShortDescr() const = 0; - virtual const std::string LongDescr() const = 0; + virtual std::string const LongDescr() const = 0; - virtual const std::string Archived() const { return ""; } + virtual std::string const Archived() const { return ""; } - virtual const std::string StartTime(const char* format) const; + virtual std::string const StartTime(const char* format) const; - virtual const std::string EndTime(const char* format) const; + virtual std::string const EndTime(const char* format) const; - virtual const std::string CurrentTime(const char* format) const; + virtual std::string const CurrentTime(const char* format) const; virtual int Elapsed() const; @@ -65,18 +65,18 @@ namespace vdrlive friend class EpgEvents; protected: - EpgString(const std::string& id, - const std::string& caption, - const std::string& info); + EpgString(std::string const &id, + std::string const &caption, + std::string const &info); public: virtual ~EpgString(); - virtual const std::string Title() const; + virtual std::string const Title() const; - virtual const std::string ShortDescr() const; + virtual std::string const ShortDescr() const; - virtual const std::string LongDescr() const; + virtual std::string const LongDescr() const; virtual time_t GetStartTime() const; @@ -93,18 +93,18 @@ namespace vdrlive friend class EpgEvents; protected: - EpgEvent(const std::string& id, - const cEvent* event, - const char* channelName = ""); + EpgEvent(std::string const &id, + cEvent const *event, + char const *channelName = ""); public: virtual ~EpgEvent(); - virtual const std::string Title() const { return std::string(m_event->Title() ? m_event->Title() : ""); } + virtual std::string const Title() const { return std::string(m_event->Title() ? m_event->Title() : ""); } - virtual const std::string ShortDescr() const { return std::string(m_event->ShortText() ? m_event->ShortText() : ""); } + virtual std::string const ShortDescr() const { return std::string(m_event->ShortText() ? m_event->ShortText() : ""); } - virtual const std::string LongDescr() const { return std::string(m_event->Description() ? m_event->Description() : ""); } + virtual std::string const LongDescr() const { return std::string(m_event->Description() ? m_event->Description() : ""); } virtual time_t GetStartTime() const { return m_event->StartTime(); } @@ -121,22 +121,24 @@ namespace vdrlive friend class EpgEvents; protected: - EpgRecording(const std::string& recid, const cRecording* recording, const char* caption); + EpgRecording(std::string const &recid, + cRecording const *recording, + char const *caption); const std::string Name() const; public: virtual ~EpgRecording(); - virtual const std::string Caption() const; + virtual std::string const Caption() const; - virtual const std::string Title() const; + virtual std::string const Title() const; - virtual const std::string ShortDescr() const; + virtual std::string const ShortDescr() const; - virtual const std::string LongDescr() const; + virtual std::string const LongDescr() const; - virtual const std::string Archived() const; + virtual std::string const Archived() const; virtual time_t GetStartTime() const; @@ -156,32 +158,36 @@ namespace vdrlive EpgEvents(); virtual ~EpgEvents(); - static std::string GetDomId(const tChannelID& chanId, const tEventID& eventId); + static std::string EncodeDomId(tChannelID const &chanId, tEventID const &eventId); + static void DecodeDomId(std::string const &epgid, tChannelID &chanId, tEventID &eventId); /** * Allocate and initalize an epgEvent instance with the * passed channel and event information. */ - static EpgInfoPtr CreateEpgInfo(const cChannel* chan, const cEvent* event, const char* idOverride = 0); + static EpgInfoPtr CreateEpgInfo(cChannel const *chan, cEvent const *event, char const *idOverride = 0); /** * This is the inverse creator for epgInfos to the creator above. */ - static EpgInfoPtr CreateEpgInfo(const std::string& epgid, const cSchedules* schedules); + static EpgInfoPtr CreateEpgInfo(std::string const &epgid, cSchedules const *schedules); /** * Allocate and initalize an epgEvent instance with the * passed recording information. */ - static EpgInfoPtr CreateEpgInfo(const std::string& recid, const cRecording* recording, const char* caption = 0); + static EpgInfoPtr CreateEpgInfo(std::string const &recid, cRecording const *recording, char const *caption = 0); /** * Allocate and initalize an epgEvent instance with the * passed string informations */ - static EpgInfoPtr CreateEpgInfo(const std::string& id, const std::string& caption, const std::string& info); + static EpgInfoPtr CreateEpgInfo(std::string const &id, std::string const &caption, std::string const &info); + + static std::list EpgImages(std::string const &epgid); + + static int ElapsedTime(time_t const startTime, time_t const endTime); - static std::list EpgImages(const std::string& epgid); private: }; }; // namespace vdrlive diff --git a/live/css/siteprefs.css b/live/css/siteprefs.css index 9fa03cc..2f440b4 100644 --- a/live/css/siteprefs.css +++ b/live/css/siteprefs.css @@ -16,7 +16,10 @@ table { } */ -/* comment this out, if you want epg images at their native size */ +/* comment this out, if you want epg images at their native size + * the popup windows. This here restricts their width to 120 px. + * You might also only change size. + */ .info-win span.epg_images { width: 120px; } diff --git a/live/js/live/infowin.js b/live/js/live/infowin.js index 393cd87..1e35438 100644 --- a/live/js/live/infowin.js +++ b/live/js/live/infowin.js @@ -254,7 +254,7 @@ InfoWin.Ajax = InfoWin.extend({ options: { loadingMsg: 'loading', errorMsg: 'an error occured!', - onError: Class.empty, + onError: Class.empty }, initialize: function(id, url, options){ diff --git a/pages/epginfo.ecpp b/pages/epginfo.ecpp index 9487040..c14d89d 100644 --- a/pages/epginfo.ecpp +++ b/pages/epginfo.ecpp @@ -1,12 +1,31 @@ <%pre> #include #include + +#include "stdext.h" #include "exception.h" #include "setup.h" #include "tools.h" #include "epg_events.h" #include "recordings.h" +namespace vdrlive { + class SchedulesLock + { + public: + SchedulesLock() : m_schedulesLock() {} + + operator cSchedulesLock& () { return m_schedulesLock; } + + private: + SchedulesLock(SchedulesLock const &schedulesLock) {} + + cSchedulesLock m_schedulesLock; + }; + + typedef std::tr1::shared_ptr SchedulesLockPtr; +} + using namespace vdrlive; using namespace std; @@ -16,24 +35,25 @@ using namespace std; string async; <%session scope="global"> -bool logged_in(false); + bool logged_in(false); +<%request scope="page"> + EpgInfoPtr epgEvent; + <%include>page_init.eh <%cpp> -if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); - -<%cpp> + if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); + pageTitle = tr("Electronic program guide information"); bool ajaxReq = !async.empty() && (lexical_cast(async) != 0); - EpgInfoPtr epgEvent; - bool aboutBox(false); + bool aboutBox = false; - // These get initialized when needed. When freed by getting out + // One of these get initialized when needed. When freed by getting // out of scope they will release (if initialized) important // Semaphores/Locks. - cSchedulesLock schedulesLock; + SchedulesLockPtr schedulesLockPtr; RecordingsManagerPtr recordings; if (!epgid.empty()) { @@ -53,7 +73,11 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); } // check for event: else if (epgid.compare(0, event.length(), event) == 0) { - const cSchedules* schedules = cSchedules::Schedules(schedulesLock); + schedulesLockPtr = SchedulesLockPtr(new SchedulesLock); + if (!schedulesLockPtr) { + throw HtmlError(tr("Error aquiring schedules lock")); + } + const cSchedules* schedules = cSchedules::Schedules(*schedulesLockPtr); if (!schedules) { throw HtmlError(tr("Error aquiring schedules")); } @@ -97,6 +121,9 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); if (recordings) { tools_component = epgEvent->Archived().empty() ? "recordings.rec_tools" : "recordings.archived_disc" ; } + if (schedulesLockPtr) { + tools_component = "epginfo.epgTools"; + } <& pageelems.epg_tt_box boxId=(epgEvent->Id()) caption=(epgEvent->Caption()) tools_comp=(tools_component) time=(start) title=(epgEvent->Title()) short_descr=(epgEvent->ShortDescr()) long_descr=(epgEvent->LongDescr()) archived=(epgEvent->Archived()) elapsed=(epgEvent->Elapsed()) &> <%cpp> @@ -112,3 +139,13 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); <%include>page_exit.eh + +<# ---------------------------------------------------------------------- #> + +<%def epgTools> +<%args> +string id; +int detail; + +<& pageelems.epg_tool_box detail=(detail) epgid=(id) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &> + diff --git a/pages/pageelems.ecpp b/pages/pageelems.ecpp index 799412b..2cff427 100644 --- a/pages/pageelems.ecpp +++ b/pages/pageelems.ecpp @@ -190,6 +190,52 @@ int update_status(1); <# ---------------------------------------------------------------------- #> +<%def epg_tool_box> +<%args> + int detail; + string epgid; + string title; + time_t startTime; + time_t endTime; + int lastCurrentChanel = int(); + +<%cpp> + int elapsed = EpgEvents::ElapsedTime(startTime, endTime); + tEventID eventId = tEventID(); + tChannelID channelId = tChannelID(); + + EpgEvents::DecodeDomId(epgid, channelId, eventId); + if (detail) { // output for vertical toolbox + + <& pageelems.event_timer channelid=(channelId) eventid=(eventId) &> +<%cpp> + if (elapsed > 0) { + + <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(channelId) image="zap.png" alt="" &> +<%cpp> + } + if (LiveFeatures().Recent()) { + + " alt="" <& tooltip.hint text=(tr("Search for repeats.")) &>> +<%cpp> + } + + " alt="" <& tooltip.hint text=(tr("Find more at the Internet Movie Database.")) &>> +<%cpp> + } + else { // table output + + "><& pageelems.event_timer channelid=(channelId) eventid=(eventId) &> + "><%cpp>if (elapsed > 0) { <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(channelId) image="zap.png" alt="" &><%cpp> } + "><%cpp>if (LiveFeatures().Recent()) { " alt="" <& tooltip.hint text=(tr("Search for repeats.")) &>><%cpp> } else { <%cpp> } + ">" border="0" alt="" <& tooltip.hint text=(tr("Find more at the Internet Movie Database.")) &>> +<%cpp> + } + + + +<# ---------------------------------------------------------------------- #> + <%def epg_tt_box> <%args> string boxId; @@ -208,9 +254,9 @@ int update_status(1);
- <& (tools_comp) id=(boxId) archived=(archived) &> + <& (tools_comp) id=(boxId) archived=(archived) detail=(1) &>
-
+
<%cpp> if (!archived.empty()) { <$ (archived + " ") $><%cpp> } <$ (time) $>
<%cpp> if (elapsed >= 0) { diff --git a/pages/searchresults.ecpp b/pages/searchresults.ecpp index 63226d5..dda0d12 100644 --- a/pages/searchresults.ecpp +++ b/pages/searchresults.ecpp @@ -69,7 +69,7 @@ bool logged_in(false); tEventID event = result->EventId(); tChannelID channel_id(result->Channel()); string description = result->Description(); - string epgDomId(EpgEvents::GetDomId(result->Channel(), event)); + string epgDomId(EpgEvents::EncodeDomId(result->Channel(), event)); bool truncated = false; diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index d149e55..dfba641 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -128,21 +128,6 @@ if (type == "now") { continue; } - tChannelID channel_id(Channel->GetChannelID()); - tEventID event = Event->EventID(); - - - // string evntId("event_"); - // - // string schanid(channel_id.ToString()); - // replace(schanid.begin(), schanid.end(), '.', 'p'); - // replace(schanid.begin(), schanid.end(), '-', 'm'); - // evntId += schanid; - // evntId += '_'; - // evntId += lexical_cast(event); - // // evntId += lexical_cast(++evntNr); - // EpgEventPtr epgEvent(new EpgEvent(evntId, Event, Channel->Name())); - // // epgEvents.push_back(epgEvent); EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event); bool truncated = false; @@ -159,14 +144,7 @@ if (type == "now") {
- <& pageelems.event_timer channelid=(channel_id) eventid=(event) &> -% if (type == "now") { - <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(channel_id) image="zap.png" alt="" &> -% } -% if ( LiveFeatures< features::epgsearch >().Recent() ) { - " alt="" <& tooltip.hint text=(tr("Search for repeats.")) &>> -% } - " alt="" <& tooltip.hint text=(tr("Find more at the Internet Movie Database.")) &>> + <& pageelems.epg_tool_box detail=(1) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &>
<$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $>
@@ -189,10 +167,7 @@ if (type == "now") { || (!Channels.Next(Channel))); - "><& pageelems.event_timer channelid=(channel_id) eventid=(event) &> - "><%cpp>if (type == "now") { <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(channel_id) image="zap.png" alt="" &><%cpp> } - "><%cpp>if (LiveFeatures().Recent() ) { " border="0" alt="" <& tooltip.hint text=(tr("Search for repeats.")) &>><%cpp> } else { <%cpp> } - ">" border="0" alt="" <& tooltip.hint text=(tr("Find more at the Internet Movie Database.")) &>> + <& pageelems.epg_tool_box detail=(0) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) lastCurrentChanel=(lastCurrentChanel ? 1 : 0) &> ">
<$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $>
-- cgit v1.2.3