summaryrefslogtreecommitdiff
path: root/pages/recordings.ecpp
blob: 5789304b1645ed8801213f478d9260c7ed2515ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<%pre>
#include <string>

#include <vdr/plugin.h>
#include <vdr/config.h>
#include <vdr/videodir.h>

#include "exception.h"
#include "epg_events.h"

#include "setup.h"
#include "tasks.h"
#include "tools.h"
#include "i18n.h"

#include "recman.h"

#define MB_PER_MINUTE 25.75 // this is just an estimate!

using namespace vdrlive;
using namespace std;

</%pre>
<%args>
	string todel;
	string diskinfo;
</%args>
<%session scope="global">
	bool logged_in(false);
</%session>
<%request scope="page">
	string deleteResult;
</%request>
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");

pageTitle = tr("Recordings");

if (!todel.empty()) {
	RemoveRecordingTask task(todel);
	LiveTaskManager().Execute(task);
	if (!task.Result())
		deleteResult = string() + tr("ERROR:") + " " + task.Error();
	else
		deleteResult = string() + tr("Deleted recording:") + " " + StringReplace(task.RecName(), "~", "/");
}
int FreeMB, UsedMB;
int Percent = VideoDiskSpace(&FreeMB, &UsedMB);
int Minutes = int(double(FreeMB) / MB_PER_MINUTE);
int Hours = Minutes / 60;
Minutes %= 60;
diskinfo = cString::sprintf("%s %d%%  -  %2d:%02d %s", trVDR("Disk"), Percent, Hours, Minutes, trVDR("free"));
</%cpp>
<& pageelems.doc_type &>
<html>
	<head>
		<title>VDR-Live - <$ pageTitle $></title>
		<& pageelems.stylesheets &>
		<& pageelems.ajax_js &>
		<script type="text/javascript" src="treeview.js"></script>
	</head>
	<body>
		<& pageelems.logo &>
<%cpp>
if (! deleteResult.empty()) {
</%cpp>
		<& menu active=("recordings") component=("recordings.delete_error") &>
<%cpp>
} else {
</%cpp>
		<& menu active=("recordings") &>
<%cpp>
}
</%cpp>
		<div class="inhalt">
			<div class="boxheader"><div><div><$ string(tr("List of recordings")) + " (" + diskinfo + ")" $></div></div></div>
<%cpp>
			if (Recordings.Count() == 0) {
</%cpp>
			<$ tr("No recordings found") $>
<%cpp>
			} else {
</%cpp>
			<div class="recordings">
			<ul class="recordingslist" style="display: block;">
<& recordings.recordings_item &>
			</ul>
			</div>
<%cpp>
			}
</%cpp>
		</div>
	</body>
</html>
<%include>page_exit.eh</%include>

<# ---------------------------------------------------------------------- #>

<%def recordings_item>
<%args>
	path[];
	int level = 0;
</%args>
<%cpp>
RecordingsTreePtr recordingsTree(LiveRecordingsManager()->GetRecordingsTree());
RecordingsMap::iterator iter;
RecordingsMap::iterator end = recordingsTree->end(path);

for (iter = recordingsTree->begin(path); iter != end; ++iter) {
	RecordingsItemPtr recItem = iter->second;
	string folderimg("folder_closed.png");
	string collapseimg("plus.png");
	if (recItem->IsDir()) {
</%cpp>
	<li class="recording">
		<& rec_item_dir name=(recItem->Name()) level=(level) &>
<%cpp>
#if TNTVERSION >= 1606
		tnt::QueryParams recItemParams(qparam, false);
#else
		cxxtools::QueryParams recItemParams(qparam, false);
#endif
		for (path_type::const_iterator i = path.begin(); i != path.end(); ++i) {
			recItemParams.add("path", *i);
		}
		recItemParams.add("path", recItem->Name());
		recItemParams.add("level", lexical_cast<string, int>(level + 1));
</%cpp>
		<ul class="recordingslist" style="display: none;">
<%cpp>
		callComp("recordings.recordings_item", request, reply, recItemParams);
</%cpp>
    	</ul>
	</li>
<%cpp>
	}
}
for (iter = recordingsTree->begin(path); iter != end; ++iter) {
	RecordingsItemPtr recItem = iter->second;
    if (!recItem->IsDir()) {
		string day(FormatDateTime("%a,", recItem->StartTime()));
		string dayLen(lexical_cast<string, int>(day.length() - 1) + ".25em;");
		string duration(lexical_cast<string, int>(recItem->Duration()) + "'");
		string shortDescr(recItem->RecInfo()->ShortText() ? recItem->RecInfo()->ShortText() : "");
		string hint(tr("Click to view details.")); if (!shortDescr.empty()) hint = shortDescr + "<br />" + hint;
</%cpp>
	<li class="recording">
	   <& rec_item_file name=(recItem->Name()) level=(level) id=(recItem->Id()) day=(day) dayLen=(dayLen) startTime=(recItem->StartTime()) duration=(duration) hint=(hint) shortDescr=(shortDescr) archived=(RecordingsManager::GetArchiveDescr(recItem->Recording())) &>
    </li>
<%cpp>
	}
}
</%cpp>
</%def>

<# ---------------------------------------------------------------------- #>

<%def del_rec>
<%args>
	string id;
</%args>
<%cpp> { </%cpp><a href="recordings.html?todel=<$ id $>" <& tooltip.hint text=(tr("Delete this recording from hard disc!")) &>><img src="<$ LiveSetup().GetThemedLink("img", "del.png") $>" alt="" /></a><%cpp> } </%cpp>
</%def>

<# ---------------------------------------------------------------------- #>

<%def rec_tools>
<%args>
	string id;
	string title;
</%args>
<& pageelems.ajax_action_href action="play_recording" param=(id) tip=(tr("play this recording.")) image="play.png" alt="" &>
<& pageelems.vlc_stream_recording recid=(id) &>
<& pageelems.imdb_info_href title=(title) &>
<& recordings.del_rec id=(id) &>
</%def>

<# ---------------------------------------------------------------------- #>

<%def archived_disc>
<%args>
	string archived;
	string title;
</%args>
<img src="<$ LiveSetup().GetThemedLink("img", "on_dvd.png") $>" alt="on_dvd" <& tooltip.hint text=(archived) &> />
<& pageelems.imdb_info_href title=(title) &>
</%def>

<# ---------------------------------------------------------------------- #>

<%def rec_item_dir>
<%args>
	string name;
	int level;
	string collapseimg = "plus.png";
	string folderimg = "folder_closed.png";
</%args>
	<div class="recording_item" onclick="Toggle(this)">
		<div class="recording_imgs"><%cpp> reply.out() << StringRepeat(level, "<img src=\"img/transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />"); </%cpp><img class="recording_expander" src="<$ LiveSetup().GetThemedLink("img", collapseimg) $>" alt="" /><img class="recording_folder" src="<$ LiveSetup().GetThemedLink("img", folderimg) $>" alt="" /></div>
		<div class="recording_spec">
			<div class="recording_name"><$ name $></div>
	    </div>
		<div class="recording_actions">&nbsp;</div>
	</div>
</%def>

<# ---------------------------------------------------------------------- #>

<%def rec_item_file>
<%args>
	string name;
	int level;
	string id;
	string day;
	string dayLen;
	time_t startTime;
	string duration;
	string hint;
	string shortDescr;
	string archived;
</%args>
	<div class="recording_item">
	<div class="recording_imgs"><%cpp> reply.out() << StringRepeat(level + 1, "<img src=\"img/transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />"); </%cpp><%cpp> if (!archived.empty()) { </%cpp><img src="<$ LiveSetup().GetThemedLink("img", "on_dvd.png") $>" alt="on_dvd" <& tooltip.hint text=(archived) &> /><%cpp> } else { </%cpp><img src="<$ LiveSetup().GetThemedLink("img", "movie.png") $>" alt="movie" /><%cpp> } </%cpp></div>
	<div class="recording_spec">
		<div class="recording_day" style="width: <$ dayLen $>"><$ day $></div>
		<div class="recording_date nowrap"><$ FormatDateTime(tr("%b %d %y"), startTime) $></div>
		<div class="recording_time nowrap"><$ FormatDateTime(tr("%I:%M %p"), startTime) $></div>
		<div class="recording_duration"><$ duration $></div>
		<div class="recording_name"><a <& tooltip.hint text=(hint) &><& tooltip.display domId=(id) &>><$ name $><br /><%cpp>if ((name != shortDescr) && (!shortDescr.empty())) {</%cpp><span><$ shortDescr $></span><%cpp> } else { </%cpp><span>&nbsp;</span><%cpp> } </%cpp></a></div>
	</div>
	<div class="recording_actions">
<%cpp>
		if (archived.empty()) {
</%cpp>
		<& recordings.rec_tools id=(id) title=(name)&>
<%cpp>
	    }
		else {
</%cpp>
		<img src="img/transparent.png" alt="" width="16px" height="16px" />
		<& pageelems.imdb_info_href title=(name) &>
<%cpp>
		}
</%cpp>
		<!-- not supported yet ...
		<img src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" />
        -->
	</div>
<%cpp>
	if (! archived.empty()) {
</%cpp>
	<div class="recording_arch"><$ archived $></div>
<%cpp>
	}
</%cpp>
	</div>
</%def>

<# ---------------------------------------------------------------------- #>

<%def delete_error>
<%cpp> { </%cpp><$ deleteResult $><%cpp> } </%cpp>
</%def>