summaryrefslogtreecommitdiff
path: root/pages/edit_timer.ecpp
diff options
context:
space:
mode:
Diffstat (limited to 'pages/edit_timer.ecpp')
-rw-r--r--pages/edit_timer.ecpp81
1 files changed, 33 insertions, 48 deletions
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index c1faede..1fa3e95 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -1,8 +1,6 @@
<%pre>
-#include <sstream>
#include <vdr/config.h>
#include <vdr/i18n.h>
-#include <tnt/savepoint.h>
#include "exception.h"
#include "tools.h"
#include "timers.h"
@@ -12,35 +10,34 @@ using namespace vdrlive;
</%pre>
<%args>
-timerid;
-bool active = true;
-channel = "";
-title = "";
-day = FormatDateTime( "%d", time( 0 ) );
-bool wday_mon = false;
-bool wday_tue = false;
-bool wday_wed = false;
-bool wday_thu = false;
-bool wday_fri = false;
-bool wday_sat = false;
-bool wday_sun = false;
-int start_h = StringToInt( FormatDateTime( "%H", time( 0 ) ) );
-int start_m = StringToInt( FormatDateTime( "%M", time( 0 ) ) );
-int end_h = StringToInt( FormatDateTime( "%H", time( 0 ) ) );
-int end_m = StringToInt( FormatDateTime( "%M", time( 0 ) ) );
-bool vps = ::Setup.UseVps;
-int priority = ::Setup.DefaultPriority;
-int lifetime = ::Setup.DefaultLifetime;
-aux = "";
+ timerid;
+ bool active = true;
+ channel = "";
+ title = "";
+ day = FormatDateTime( "%d", time( 0 ) );
+ bool wday_mon = false;
+ bool wday_tue = false;
+ bool wday_wed = false;
+ bool wday_thu = false;
+ bool wday_fri = false;
+ bool wday_sat = false;
+ bool wday_sun = false;
+ int start_h = StringToInt( FormatDateTime( "%H", time( 0 ) ) );
+ int start_m = StringToInt( FormatDateTime( "%M", time( 0 ) ) );
+ int end_h = StringToInt( FormatDateTime( "%H", time( 0 ) ) );
+ int end_m = StringToInt( FormatDateTime( "%M", time( 0 ) ) );
+ bool vps = ::Setup.UseVps;
+ int priority = ::Setup.DefaultPriority;
+ int lifetime = ::Setup.DefaultLifetime;
+ aux = "";
</%args>
-<%request scope="global">
-std::string pageTitle( tr("Edit timer") );
-</%request>
+<%include>page_init.ecpp</%include>
<%cpp>
-try {
+ pageTitle = tr("Edit timer");
+
ReadLock channelsLock( Channels );
if ( !channelsLock )
- throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") );
+ throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );
cMutexLock timersLock( &LiveTimerManager() );
SortedTimers& timers = LiveTimerManager().GetTimers();
@@ -49,7 +46,7 @@ try {
if ( !timerid.empty() ) {
timer = timers.GetByTimerId( timerid );
if ( timer == 0 )
- throw HtmlError( tr("Timers"), tr("Couldn't find channel. Maybe you mistyped your request?") );
+ throw HtmlError( tr("Couldn't find channel. Maybe you mistyped your request?") );
}
if ( request.getMethod() != "POST" && timer != 0 ) {
@@ -74,23 +71,19 @@ try {
aux = timer->Aux() ? timer->Aux() : "";
}
- std::string result;
+ string result;
if ( request.getMethod() == "POST" ) {
uint flags = ( active ? tfActive : 0 ) | ( vps ? tfVps : 0 );
string weekdays = string( wday_mon ? "M" : "-" ) + ( wday_tue ? "T" : "-" ) + ( wday_wed ? "W" : "-" )
+ ( wday_thu ? "T" : "-" ) + ( wday_fri ? "F" : "-" ) + ( wday_sat ? "S" : "-" )
+ ( wday_sun ? "S" : "-" );
- ostringstream builder;
- builder << flags << ":" << channel << ":" << ( weekdays != "-------" ? weekdays : "" )
- << ( weekdays == "-------" || day.empty() ? "" : "@" ) << day << ":" << ( start_h * 100 + start_m )
- << ":" << ( end_h * 100 + end_m ) << ":" << priority << ":" << lifetime << ":" << title << ":" << aux;
+ int start = start_h * 100 + start_m;
+ int stop = end_h * 100 + end_m;
- std::string error = LiveTimerManager().UpdateTimer( timer, builder.str() );
- if ( !error.empty() )
- throw HtmlError( tr("Timers"), error );
- }
+ LiveTimerManager().UpdateTimer( timer, flags, channel, weekdays, day, start, stop, priority, lifetime, title, aux );
- tnt::Savepoint spoint( reply );
+ return reply.redirect("timers.html");
+ }
</%cpp>
<html>
<head>
@@ -118,7 +111,7 @@ try {
<tr>
<td class="label"><$ tr("Channel") $>:</td>
<td>
-<& channels_widget name=("channel") channelId=(true) selected=(channel) &>
+<& channels_widget name=("channel") channelid=(true) selected=(channel) &>
</td>
</tr>
@@ -179,12 +172,4 @@ try {
</div>
</body>
</html>
-<%cpp>
- spoint.commit();
-} catch ( HtmlError const& ex ) {
- cxxtools::QueryParams param = qparam;
- param.add( "errorTitle", ex.GetTitle() );
- param.add( "errorMessage", ex.GetMessage() );
- callComp( "error", request, reply, param );
-}
-</%cpp>
+<%include>page_exit.ecpp</%include>