~ubuntu-branches/ubuntu/wily/vdr-plugin-live/wily

« back to all changes in this revision

Viewing changes to .pc/themes-directory.patch/pages/setup.ecpp

  • Committer: Package Import Robot
  • Author(s): Tobias Grimm
  • Date: 2013-03-31 14:00:10 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130331140010-vkqbir6cp2o89nih
Tags: 0.2.0+git20130305-6
Build-depend on vdr-dev (>= 2.0.0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%pre>
 
2
#include <sys/stat.h>
 
3
#include <vdr/tools.h>
 
4
#include "setup.h"
 
5
#include "tools.h"
 
6
#include "users.h"
 
7
#include "i18n.h"
 
8
 
 
9
using namespace vdrlive;
 
10
using namespace std;
 
11
 
 
12
</%pre>
 
13
<%args>
 
14
        string lastchannel;
 
15
        bool useauth = false;
 
16
        string login;
 
17
        string pass;
 
18
        string times;
 
19
        string channelGroups;
 
20
        string scheduleDuration;
 
21
        string startscreen;
 
22
        string theme;
 
23
        string localnetmask;
 
24
        string showLogo;
 
25
        string useAjax;
 
26
        string showInfoBox;
 
27
        string useStreamdev;
 
28
        string showIMDb;
 
29
        string showChannelsWithoutEPG;
 
30
        string streamdevport;
 
31
        string streamdevtype;
 
32
        int authchanged = 0;
 
33
</%args>
 
34
<%session scope="global">
 
35
        bool logged_in(false);
 
36
</%session>
 
37
<%include>page_init.eh</%include>
 
38
<%cpp>
 
39
if (!logged_in && LiveSetup().UseAuth() ) return reply.redirect("login.html");
 
40
if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP))
 
41
                throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );
 
42
 
 
43
#define SELECTIF(x) reply.out() << ( (x) ? "selected=\"selected\"" : "" );
 
44
#define CHECKIF(x) reply.out() << ( (x) ? "checked=\"checked\"" : "" );
 
45
 
 
46
        std::string message;
 
47
 
 
48
        if ( request.getMethod() == "POST") {
 
49
                if (authchanged && useauth && (login.empty() || pass.empty()))
 
50
                        message = tr("Please set login and password!");
 
51
                else
 
52
                {
 
53
                        LiveSetup().SetLastChannel(lastchannel != "" ? lexical_cast< int >(lastchannel):0);
 
54
                        LiveSetup().SetUseAuth(useauth);
 
55
                        if (useauth) {
 
56
                                LiveSetup().SetAdminLogin(login);
 
57
                                if (pass != "")
 
58
                                        LiveSetup().SetAdminPassword(pass);
 
59
                                LiveSetup().SetLocalNetMask(localnetmask);
 
60
                                LiveSetup().CheckLocalNet(request.getPeerIp());
 
61
                        }
 
62
                        LiveSetup().SetTimes(times);
 
63
                        LiveSetup().SetChannelGroups(channelGroups);
 
64
                        LiveSetup().SetScheduleDuration(scheduleDuration);
 
65
                        LiveSetup().SetStartScreen(startscreen);
 
66
                        LiveSetup().SetTheme(theme);
 
67
                        LiveSetup().SetShowLogo(!showLogo.empty());
 
68
                        LiveSetup().SetUseAjax(!useAjax.empty());
 
69
                        if (LiveSetup().GetUseAjax()) {
 
70
                                LiveSetup().SetShowInfoBox(!showInfoBox.empty());
 
71
                        }
 
72
                        LiveSetup().SetUseStreamdev(!useStreamdev.empty());
 
73
                        LiveSetup().SetStreamdevPort(streamdevport.empty() ? 3000 : lexical_cast<int>(streamdevport));
 
74
                        LiveSetup().SetStreamdevType(streamdevtype.empty() ? "PES" : streamdevtype);
 
75
                        LiveSetup().SetShowIMDb(!showIMDb.empty());
 
76
                        LiveSetup().SetShowChannelsWithoutEPG(!showChannelsWithoutEPG.empty());
 
77
                        LiveSetup().SaveSetup();
 
78
 
 
79
                        message = tr("Setup saved.");
 
80
                }
 
81
        }
 
82
        pageTitle = tr("Setup");
 
83
        int ilastchannel = LiveSetup().GetLastChannel();
 
84
        if (ilastchannel == std::numeric_limits< int >::max())
 
85
                lastchannel = "";
 
86
        else
 
87
                lastchannel = lexical_cast<std::string, int>(ilastchannel);
 
88
 
 
89
        login = LiveSetup().GetAdminLogin();
 
90
        useauth = LiveSetup().GetUseAuth();
 
91
        times = LiveSetup().GetTimes();
 
92
        channelGroups = LiveSetup().GetChannelGroups();
 
93
        scheduleDuration = LiveSetup().GetScheduleDuration();
 
94
        startscreen = LiveSetup().GetStartScreen();
 
95
        theme = LiveSetup().GetTheme();
 
96
        localnetmask = LiveSetup().GetLocalNetMask();
 
97
        showLogo = LiveSetup().GetShowLogo() ? "1" : "";
 
98
        useAjax = LiveSetup().GetUseAjax() ? "1" : "";
 
99
        showInfoBox = LiveSetup().GetShowInfoBox() ? "1" : "";
 
100
        useStreamdev = LiveSetup().GetUseStreamdev() ? "1" : "";
 
101
        streamdevport = lexical_cast<std::string, int>(LiveSetup().GetStreamdevPort());
 
102
        streamdevtype = LiveSetup().GetStreamdevType();
 
103
        showIMDb = LiveSetup().GetShowIMDb() ? "1" : "";
 
104
        showChannelsWithoutEPG = LiveSetup().GetShowChannelsWithoutEPG() ? "1" : "";
 
105
</%cpp>
 
106
<& pageelems.doc_type &>
 
107
<html>
 
108
        <head>
 
109
                <title>VDR-Live - <$ pageTitle $></title>
 
110
                <& pageelems.stylesheets &>
 
111
                <& pageelems.ajax_js &>
 
112
                <script type="text/javascript"><!--
 
113
                function initform()
 
114
                {
 
115
                        changeduseauth(document.getElementById("useauth"));
 
116
                        changeduseajax(document.getElementById("useAjax"));
 
117
                        changedusestreamdev(document.getElementById("useStreamdev"));
 
118
                        if (document.getElementById("message").value != "")
 
119
                                alert(document.getElementById("message").value);
 
120
                }
 
121
                function changeduseauth(selection)
 
122
                {
 
123
                        document.getElementById("authsection").style.display = (selection.checked ? "block" : "none");
 
124
                }
 
125
                function setauthchanged(selection)
 
126
                {
 
127
                        document.getElementById("authchanged").value = 1;
 
128
                }
 
129
                function changeduseajax(selection)
 
130
                {
 
131
                        document.getElementById("ajaxsection").style.display = (selection.checked ? "block" : "none");
 
132
                }
 
133
                function changedusestreamdev(selection)
 
134
                {
 
135
                        document.getElementById("streamdevsection").style.display = (selection.checked ? "block" : "none");
 
136
                }
 
137
                //--></script>
 
138
        </head>
 
139
        <body onload="initform()">
 
140
                <& pageelems.logo &>
 
141
                <& menu active=("setup") &>
 
142
                <div class="inhalt">
 
143
                        <form method="post" action="setup.html">
 
144
                                <input type="hidden" name="authchanged" value="<$ authchanged $>" id="authchanged"/>
 
145
                                <input type="hidden" name="message" value="<$ message $>" id="message"/>
 
146
                                <table class="formular" cellpadding="0" cellspacing="0">
 
147
                                        <tr class="head">
 
148
                                                <td  class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div><$ tr("Setup") $></div></div></div></td>
 
149
                                        </tr>
 
150
                                        <tr>
 
151
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Use authentication") $>:</div></td>
 
152
                                                <td class="rightcol">
 
153
                                                        <input type="checkbox" name="useauth" id="useauth" value="1" <%cpp> CHECKIF(useauth); </%cpp> onclick="changeduseauth(this)"/>
 
154
                                                        <div id="authsection" style="display: none">
 
155
                                                        <table border="0" cellpadding="0" cellspacing="0" class="dependent">
 
156
                                                        <tr>
 
157
                                                                <td class="label"><div class="withmargin"><$ tr("Admin login") $>:</div></td>
 
158
                                                                <td><input type="text" name="login" value="<$ login $>" id="login" onchange="setauthchanged(this)" /></td>
 
159
                                                        </tr>
 
160
                                                        <tr>
 
161
                                                                <td class="label"><div class="withmargin"><$ tr("Admin password") $>:</div></td>
 
162
                                                                <td><input  type="password" name="pass" value="<$ pass $>" id="pass" onchange="setauthchanged(this)" /></td>
 
163
                                                        </tr>
 
164
                                                        <tr>
 
165
                                                                <td class="label"><div class="withmargin"><a href="users.html"><$ tr("User management") $></a></div></td>
 
166
                                                                <td/>
 
167
                                                        </tr>
 
168
                                                        <tr>
 
169
                                                                <td class="label"><div class="withmargin"><$ tr("Local net (no login required)") $>:</div></td>
 
170
                                                                <td><input  type="text" name="localnetmask" value="<$ localnetmask $>" id="localnetmask" /></td>
 
171
                                                        </tr>
 
172
                                                        </table>
 
173
                                                        </div>
 
174
                                                </td>
 
175
                                        </tr>
 
176
                                        <tr>
 
177
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Show live logo image") $>:</div></td>
 
178
                                                <td class="rightcol">
 
179
                                                        <input type="checkbox" name="showLogo" id="showLogo" value="1" <%cpp> CHECKIF(!showLogo.empty()); </%cpp>/>
 
180
                                                </td>
 
181
                                        </tr>
 
182
                                        <tr>
 
183
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Use ajax technology") $>:</div></td>
 
184
                                                <td class="rightcol">
 
185
                                                        <input type="checkbox" name="useAjax" id="useAjax" value="1" <%cpp> CHECKIF(!useAjax.empty()); </%cpp> onclick="changeduseajax(this)"/>
 
186
                                                        <div id="ajaxsection" style="display: none">
 
187
                                                        <table border="0" cellpadding="0" cellspacing="0" class="dependent">
 
188
                                                        <tr>
 
189
                                                                <td class="label"><div class="withmargin"><$ tr("Show dynamic VDR information box") $>:</div></td>
 
190
                                                                <td><input type="checkbox" name="showInfoBox" id="showInfoBox" value="1" <%cpp> CHECKIF(!showInfoBox.empty()); </%cpp>/></td>
 
191
                                                        </tr>
 
192
                                                        </table>
 
193
                                                        </div>
 
194
                                                </td>
 
195
                                        </tr>
 
196
                                        <tr>
 
197
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Allow video streaming") $>:</div></td>
 
198
                                                <td class="rightcol">
 
199
                                                        <input type="checkbox" name="useStreamdev" id="useStreamdev" value="1" <%cpp> CHECKIF(!useStreamdev.empty()); </%cpp> onclick="changedusestreamdev(this)"/>
 
200
                                                        <div id="streamdevsection" style="display: none">
 
201
                                                        <table border="0" cellpadding="0" cellspacing="0" class="dependent">
 
202
                                                        <tr>
 
203
                                                                <td class="label"><div class="withmargin"><$ tr("Streamdev server port") $>:</div></td>
 
204
                                                                <td><input type="text" name="streamdevport" id="streamdevport" value="<$ streamdevport $>" /></td>
 
205
                                                        </tr>
 
206
                                                        <tr>
 
207
                                                                <td class="label"><div class="withmargin"><$ tr("Streamdev stream type") $>:</div></td>
 
208
                                                                <td><select name="streamdevtype" size="1" id="streamdevtype">
 
209
                                                                        <option value="TS" <%cpp> SELECTIF(streamdevtype == "TS") </%cpp>>TS</option>
 
210
                                                                        <option value="PES" <%cpp> SELECTIF(streamdevtype == "PES") </%cpp>>PES</option>
 
211
                                                                        <option value="PS" <%cpp> SELECTIF(streamdevtype == "PS") </%cpp>>PS</option>
 
212
                                                                        <option value="ES" <%cpp> SELECTIF(streamdevtype == "ES") </%cpp>>ES</option>
 
213
                                                                        <option value="EXT" <%cpp> SELECTIF(streamdevtype == "EXT") </%cpp>>EXT</option>
 
214
                                                                </select></td>
 
215
                                                        </tr>
 
216
                                                        </table>
 
217
                                                        </div>
 
218
                                                </td>
 
219
                                        </tr>
 
220
                                        <tr>
 
221
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Add links to IMDb") $>:</div></td>
 
222
                                                <td class="rightcol">
 
223
                                                        <input type="checkbox" name="showIMDb" id="showIMDb" value="1" <%cpp> CHECKIF(!showIMDb.empty()); </%cpp>/>
 
224
                                                </td>
 
225
                                        </tr>
 
226
                                        <tr>
 
227
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Last channel to display") $>:</div></td>
 
228
                                                <td class="rightcol"><input type="text" name="lastchannel" value="<$ lastchannel $>" id="lastchannel" /></td>
 
229
                                        </tr>
 
230
                                        <tr>
 
231
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Additional fixed times in 'What's on?'") $>:</div></td>
 
232
                                                <td class="rightcol"><input type="text" name="times" value="<$ times $>" id="times" />
 
233
                                                        <& tooltip.help text=(tr("Format is HH:MM. Separate multiple times with a semicolon")) &></td>
 
234
                                        </tr>
 
235
                                        <tr>
 
236
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Channel groups for MultiSchedule") $>:</div></td>
 
237
                                                <td class="rightcol"><input type="text" name="channelGroups" value="<$ channelGroups $>" id="channelGroups" />
 
238
                                                        <& tooltip.help text=(tr("Separate channels with a comma ',', separate groups with a semi-colon ';'")) &></td>
 
239
                                        </tr>
 
240
                                        <tr>
 
241
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Duration of MultiSchedule in hours") $>:</div></td>
 
242
                                                <td class="rightcol"><input type="text" name="scheduleDuration" value="<$ scheduleDuration $>" id="scheduleDuration" />
 
243
                                                        </td>
 
244
                                        </tr>
 
245
                                        <tr>
 
246
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Show channels without EPG") $>:</div></td>
 
247
                                                <td class="rightcol">
 
248
                                                        <input type="checkbox" name="showChannelsWithoutEPG" id="showChannelsWithoutEPG" value="1" <%cpp> CHECKIF(!showChannelsWithoutEPG.empty()); </%cpp>/>
 
249
                                                </td>
 
250
                                        </tr>
 
251
 
 
252
                                        <tr>
 
253
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Start page") $>:</div></td>
 
254
                                                <td class="rightcol"><select name="startscreen" size="1" id="startscreen">
 
255
                                                        <option value="whatsonnow" <%cpp> SELECTIF(startscreen == "whatsonnow") </%cpp>><$ trVDR("What's on now?") $></option>
 
256
                                                        <option value="whatsonnext" <%cpp> SELECTIF(startscreen == "whatsonnext") </%cpp>><$ trVDR("What's on next?") $></option>
 
257
                                                        <option value="schedule" <%cpp> SELECTIF(startscreen == "schedule") </%cpp>><$ trVDR("Schedule") $></option>
 
258
                                                        <option value="multischedule" <%cpp> SELECTIF(startscreen == "multischedule") </%cpp>><$ tr("MultiSchedule") $></option>
 
259
                                                        <option value="recordings" <%cpp> SELECTIF(startscreen == "recordings") </%cpp>><$ trVDR("Recordings") $></option>
 
260
                                                        <option value="timers" <%cpp> SELECTIF(startscreen == "timers") </%cpp>><$ trVDR("Timers") $></option>
 
261
                                                </select></td>
 
262
                                        </tr>
 
263
                                        <tr>
 
264
                                                <td class="label leftcol"><div class="withmargin"><$ tr("Theme") $>:</div></td>
 
265
                                                <td class="rightcol"><select name="theme" size="1" id="theme">
 
266
<%cpp>
 
267
{
 
268
        const string dirPath(Plugin::GetConfigDirectory() + "/themes");
 
269
        cReadDir d(dirPath.c_str());
 
270
        struct dirent* e;
 
271
        string parent("..");
 
272
        string current(".");
 
273
        string cvsDir("CVS");
 
274
        while ((e = d.Next())) {
 
275
                if ((current == e->d_name) || (parent == e->d_name) || (cvsDir == e->d_name)) {
 
276
                        continue;
 
277
                }
 
278
                /* Check if entry is a directory: I do not rely on e->d_type
 
279
                   here because on some systems it is allways DT_UNKNOWN. Also
 
280
                   testing for DT_DIR does not take into account symbolic
 
281
                   links to directories.
 
282
                */
 
283
                struct stat buf;
 
284
                if ((stat((dirPath + "/" + e->d_name).c_str(), &buf) != 0) || (!S_ISDIR(buf.st_mode))) {
 
285
                        continue;
 
286
                }
 
287
</%cpp>
 
288
                                                        <option value="<$ e->d_name $>" <%cpp> SELECTIF(theme == e->d_name) </%cpp>><$ e->d_name $></option>
 
289
<%cpp>
 
290
        }
 
291
}
 
292
</%cpp>
 
293
                                                </select></td>
 
294
                                        </tr>
 
295
                                        <tr>
 
296
                                                <td class="buttonpanel leftcol rightcol bottomrow" colspan="2">
 
297
                                                        <div class="withmargin">
 
298
                                                        <button class="green" type="submit" name="save" ><$ tr("Save") $></button>
 
299
                                                        </div>
 
300
                                                </td>
 
301
                                        </tr>
 
302
                                </table>
 
303
                        </form>
 
304
                </div>
 
305
        </body>
 
306
</html>
 
307
 
 
308
<%include>page_exit.eh</%include>
 
309