summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Wieninger <cwieninger (at) gmx (dot) de>2007-05-25 16:58:56 +0000
committerChristian Wieninger <cwieninger (at) gmx (dot) de>2007-05-25 16:58:56 +0000
commit3a4d59c9ac7226432120633ad394464d37e5f497 (patch)
tree926d255db984d789a5e8f1768e4f5985735377b1
parent181c5487cc5abbd21b0a8352a507aae4504c683c (diff)
downloadvdr-plugin-live-3a4d59c9ac7226432120633ad394464d37e5f497.tar.gz
vdr-plugin-live-3a4d59c9ac7226432120633ad394464d37e5f497.tar.bz2
- first version of "userdef. times" in "What's on?"
-rw-r--r--i18n.cpp22
-rw-r--r--pages/setup.ecpp11
-rw-r--r--pages/whats_on.ecpp50
-rw-r--r--setup.cpp2
-rw-r--r--setup.h3
-rw-r--r--tools.cpp15
-rw-r--r--tools.h1
7 files changed, 97 insertions, 7 deletions
diff --git a/i18n.cpp b/i18n.cpp
index 2ca0b68..8400d6c 100644
--- a/i18n.cpp
+++ b/i18n.cpp
@@ -3483,6 +3483,28 @@ const tI18nPhrase Phrases[] = {
"", // Dansk
"", // Czech
},
+ { "additional fixed times in 'What's on?'",
+ "zusätzliche Zeitpunkte in 'Was läuft?'",
+ "", // Slovenski
+ "", // Italiono
+ "", // Nederlands
+ "", // Português
+ "", // Français
+ "", // Norsk
+ "", // Finnish
+ "", // Polski
+ "", // Español
+ "", // Greek
+ "", // Svenska
+ "", // Românã
+ "", // Magyar
+ "", // Català
+ "", // Russian
+ "", // Hrvatski
+ "", // Eesti
+ "", // Dansk
+ "", // Czech
+ },
/*
{ "", // English
"", // Deutsch
diff --git a/pages/setup.ecpp b/pages/setup.ecpp
index 012d798..97fc199 100644
--- a/pages/setup.ecpp
+++ b/pages/setup.ecpp
@@ -10,6 +10,7 @@ using namespace std;
bool useauth = 0;
string login;
string pass;
+ string times;
</%args>
<%session scope="global">
bool logged_in(false);
@@ -27,12 +28,14 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
if (pass != "")
LiveSetup().SetAdminPassword(pass);
}
- LiveSetup().SaveSetup();
+ LiveSetup().SetTimes(times);
+ LiveSetup().SaveSetup();
}
pageTitle = tr("Setup");
lastchannel = LiveSetup().GetLastChannel();
login = LiveSetup().GetAdminLogin();
useauth = LiveSetup().UseAuth();
+ times = LiveSetup().GetTimes();
</%cpp>
<& pageelems.doc_type &>
@@ -90,6 +93,12 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
</tr>
<tr>
<td class="border" style="border-left: 1px solid black"></td>
+ <td class="label"><$ tr("additional fixed times in 'What's on?'") $>:</td>
+ <td><input type="text" name="times" value="<$ times $>" id="times" /></td>
+ <td class="border" style="border-right: 1px solid black"></td>
+ </tr>
+ <tr>
+ <td class="border" style="border-left: 1px solid black"></td>
<td class="buttonpanel" colspan="2">
<button class="green" type="submit" name="save" onclick="return checksearch();"><$ tr("Save") $></button>
</td>
diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp
index bab6a57..ed7ff99 100644
--- a/pages/whats_on.ecpp
+++ b/pages/whats_on.ecpp
@@ -14,6 +14,8 @@ using namespace vdrlive;
</%pre>
<%args>
type = "now";
+string attime;
+time_t seektime = 0;
</%args>
<%session scope="global">
bool logged_in(false);
@@ -29,9 +31,13 @@ const cSchedules* Schedules = cSchedules::Schedules(schedulesLock);
string head;
if (type == "now") {
head = tr("What's running at")+string(" ")+FormatDateTime(tr("%I:%M %p"), time(0));
-} else {
- type="next";
+} else if (type == "next") {
head = tr("What's on next?");
+} else if (type == "at") {
+ seektime = GetTimeT(attime);
+ if (seektime - time(0) + 3600 < 0)
+ seektime += 24 * 60 * 60;
+ head = tr("What's running at")+string(" ")+FormatDateTime(tr("%a, %b %d"), seektime) + string(" ") + FormatDateTime(tr("%I:%M %p"), seektime);
}
}>
@@ -42,6 +48,13 @@ if (type == "now") {
<link rel="stylesheet" type="text/css" href="styles.css" />
<& tooltip.javascript var=("domTT_styleClass") value=("domTTepg") &>
<& pageelems.ajax_js &>
+ <script type="text/javascript"><!--
+ function showtime(selection)
+ {
+ if (selection.options[selection.selectedIndex].value != "")
+ window.location.href = "whats_on.html?type=at&attime=" + selection.options[selection.selectedIndex].value;
+ }
+ //--></script>
</head>
<body onload="<& pageelems.infobox_start_update &>">
<& pageelems.logo &>
@@ -49,15 +62,28 @@ if (type == "now") {
<div class="inhalt">
<{
EpgEvents epgEvents;
-
+ time_t seektime = 0;
+ if (type == "at")
+ {
+ seektime = GetTimeT(attime);
+ if (seektime - time(0) + 3600 < 0)
+ seektime += 24 * 60 * 60;
+ }
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()) {
const cSchedule *Schedule = Schedules->GetSchedule(Channel);
- if (Schedule) {
- const cEvent *Event = (type == "now" ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent());
+ if (Schedule) {
+ 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) {
string evntId("eventId_");
evntId += lexical_cast<std::string, int>(++evntNr);
@@ -121,5 +147,17 @@ if (type == "now") {
<%def whats_on_actions>
<a href="whats_on.html?type=now"><$ tr("Now") $></a>&nbsp;&nbsp;
-<a href="whats_on.html?type=next"><$ tr("Next") $></a>
+<a href="whats_on.html?type=next"><$ tr("Next") $></a>&nbsp;&nbsp;
+<select name="userdeftimes" size="1" id="userdeftimes" onchange="showtime(this)">
+ <option value="0"/>
+<{
+ vector< string > parts = StringSplit( LiveSetup().GetTimes(), ';' );
+ vector< string >::const_iterator part = parts.begin();
+ for ( int i = 0; part != parts.end(); ++i, ++part ) {
+}>
+ <option value="<$ *part $>"> <$ *part $></option>
+<{
+ }
+}>
+</select>
</%def>
diff --git a/setup.cpp b/setup.cpp
index 247b81f..0b5a5c8 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -73,6 +73,7 @@ bool Setup::ParseSetupEntry( char const* name, char const* value )
else if ( strcmp( name, "UseAuth" ) == 0 ) m_useAuth = atoi( value );
else if ( strcmp( name, "AdminLogin" ) == 0 ) m_adminLogin = value;
else if ( strcmp( name, "AdminPasswordMD5" ) == 0 ) m_adminPasswordMD5 = value;
+ else if ( strcmp( name, "UserdefTimes" ) == 0 ) m_times = value;
else return false;
return true;
}
@@ -141,6 +142,7 @@ bool Setup::SaveSetup()
liveplugin->SetupStore("AdminLogin", m_adminLogin.c_str());
liveplugin->SetupStore("AdminPasswordMD5", m_adminPasswordMD5.c_str());
}
+ liveplugin->SetupStore("UserdefTimes", m_times.c_str());
return true;
}
diff --git a/setup.h b/setup.h
index 85b19c0..e9e2aaa 100644
--- a/setup.h
+++ b/setup.h
@@ -32,12 +32,14 @@ public:
std::string GetMD5HashAdminPassword() const;
int GetAdminPasswordLength() const;
bool UseAuth() const { return m_useAuth; }
+ std::string GetTimes() const { return m_times; }
void SetLastChannel(int lastChannel) { m_lastChannel = lastChannel; }
void SetAdminLogin(std::string login) { m_adminLogin = login; }
std::string SetAdminPassword(std::string password);
void SetUseAuth(int auth) { m_useAuth = auth; }
void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; }
+ void SetTimes(std::string times) { m_times = times; }
bool SaveSetup();
@@ -64,6 +66,7 @@ private:
int m_useAuth;
std::string m_adminLogin;
std::string m_adminPasswordMD5;
+ std::string m_times;
bool CheckServerPort();
bool CheckServerIps();
diff --git a/tools.cpp b/tools.cpp
index da3956f..a75068f 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -144,4 +144,19 @@ std::string MD5Hash(std::string const& str)
return hashStr.str();
}
+#define HOURS(x) ((x)/100)
+#define MINUTES(x) ((x)%100)
+
+time_t GetTimeT(std::string timestring) // timestring in HH:MM
+{
+ timestring = StringReplace(timestring, ":", "");
+ int iTime = lexical_cast< int >( timestring );
+ struct tm tm_r;
+ time_t t = time(NULL);
+ tm* tmnow = localtime_r(&t, &tm_r);
+ tmnow->tm_hour = HOURS(iTime);
+ tmnow->tm_min = MINUTES(iTime);
+ return mktime(tmnow);
+}
+
} // namespace vdrlive
diff --git a/tools.h b/tools.h
index 1576377..525df7d 100644
--- a/tools.h
+++ b/tools.h
@@ -32,6 +32,7 @@ std::string StringFormatBreak(std::string const& input);
std::string StringTrim(const std::string& str);
std::string ZeroPad(int number);
std::string MD5Hash(std::string const& str);
+time_t GetTimeT(std::string timestring);
struct bad_lexical_cast: std::runtime_error
{