<%pre> #include #ifdef HAVE_LIBPCRECPP #include #endif #include #include #include #include "exception.h" #include "epg_events.h" #include "setup.h" #include "tasks.h" #include "tools.h" #include "i18n.h" #include "users.h" #include "recman.h" #define MB_PER_MINUTE 25.75 // this is just an estimate! using namespace vdrlive; using namespace std; <%args> string sort; string todel; string diskinfo; string filter; string deletions[]; <%session scope="global"> bool logged_in(false); <%request scope="page"> string currentSort; string deleteResult; string currentFilter; <%include>page_init.eh <%cpp> if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); currentSort = LiveSetup().GetLastSortingMode(); if (!sort.empty()) { if (sort == "date") currentSort = (currentSort == "dateasc") ? "datedesc" : "dateasc"; else if (sort == "name") currentSort = (currentSort == "nameasc") ? "namedesc" : "nameasc"; LiveSetup().SetLastSortingMode(currentSort); } currentFilter = filter; pageTitle = tr("Recordings"); deleteResult = ""; if (!todel.empty()) { if (!cUser::CurrentUserHasRightTo(UR_DELRECS)) throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") ); deletions.push_back(todel); } for (deletions_type::const_iterator it = deletions.begin(); it != deletions.end(); ++it) { if (cUser::CurrentUserHasRightTo(UR_DELRECS)) { RemoveRecordingTask task(*it); LiveTaskManager().Execute(task); if (!task.Result()) deleteResult += string() + tr("ERROR:") + " " + task.Error() + "
"; else deleteResult += string() + tr("Deleted recording:") + " " + StringReplace(task.RecName(), "~", "/") + "
"; } else { throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") ); } } deletions.clear(); 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")); <& pageelems.doc_type &> VDR-Live - <$ pageTitle $> <& pageelems.stylesheets &> <& pageelems.ajax_js &> <& pageelems.logo &> <%cpp> if (!deleteResult.empty()) { <& menu active=("recordings") component=("recordings.delete_error") &> <%cpp> } else { <& menu active=("recordings") component=("recordings.sort_options") &> <%cpp> }
<$ string(tr("List of recordings")) + " (" + diskinfo + ")" $>
<%cpp> if (Recordings.Count() == 0) { // Access VDRs global cRecordings Recordings instance. <$ tr("No recordings found") $> <%cpp> } else {
    <& recordings.recordings_item filter=(currentFilter) &>
<%cpp> }
<%include>page_exit.eh <# ---------------------------------------------------------------------- #> <%def recordings_item> <%args> filter; path[]; int level = 0; <%cpp> RecordingsTreePtr recordingsTree(LiveRecordingsManager()->GetRecordingsTree()); RecordingsMap::iterator iter; RecordingsMap::iterator end = recordingsTree->end(path); list recItems; list::iterator recIter; for (iter = recordingsTree->begin(path); iter != end; ++iter) { RecordingsItemPtr recItem = iter->second; if (recItem->IsDir()) { recItems.push_back(recItem); } } if (currentSort == "namedesc") recItems.sort(RecordingsItemPtrCompare::ByDescendingName); else recItems.sort(RecordingsItemPtrCompare::ByAscendingName); for (recIter = recItems.begin(); recIter != recItems.end(); ++recIter) { RecordingsItemPtr recItem = *recIter;
  • <& rec_item_dir name=(recItem->Name()) level=(level) &> <%cpp> #if TNT_HAS_QUERYPARAMS #if TNT_QUERYPARAMS_NO_BOOL tnt::QueryParams recItemParams(qparam); #else tnt::QueryParams recItemParams(qparam, false); #endif #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(level + 1)); recItemParams.add("filter", filter);
  • <%cpp> } recItems.clear(); for (iter = recordingsTree->begin(path); iter != end; ++iter) { RecordingsItemPtr recItem = iter->second; if (!recItem->IsDir()) { recItems.push_back(recItem); } } if (currentSort == "dateasc") recItems.sort(RecordingsItemPtrCompare::ByAscendingDate); else if (currentSort == "datedesc") recItems.sort(RecordingsItemPtrCompare::ByDescendingDate); else if (currentSort == "namedesc") recItems.sort(RecordingsItemPtrCompare::ByDescendingName); else recItems.sort(RecordingsItemPtrCompare::ByAscendingName); for (recIter = recItems.begin(); recIter != recItems.end(); ++recIter) { RecordingsItemPtr recItem = *recIter; // xgettext:no-c-format string day(FormatDateTime(tr("%a,"), recItem->StartTime())); string dayLen(lexical_cast(day.length() - 1) + ".25em;"); // TRANSLATORS: recording duration format HH:MM string duration(recItem->Duration() < 0 ? "" : FormatDuration(tr("(%d:%02d)"), recItem->Duration() / 60, recItem->Duration() % 60)); string shortDescr(recItem->RecInfo()->ShortText() ? recItem->RecInfo()->ShortText() : ""); string description(recItem->RecInfo()->Description() ? recItem->RecInfo()->Description() : ""); string hint(tr("Click to view details.")); if (!shortDescr.empty()) hint = shortDescr + "
    " + hint; else if (!description.empty()) hint = description + "
    " + hint; #ifdef HAVE_LIBPCRECPP pcrecpp::RE re(filter.c_str(), pcrecpp::UTF8()); if (filter.empty() || re.PartialMatch(recItem->Name()) || re.PartialMatch(shortDescr) || re.PartialMatch(description)) #endif {
  • <& 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())) &>
  • <%cpp> } } <# ---------------------------------------------------------------------- #> <%def sort_options> <%cpp> { " alt="" /><$ tr("Sort by name") $> | " alt="" /><$ tr("Sort by date") $> <%cpp> #ifdef HAVE_LIBPCRECPP | <$ tr("Filter") $>:  <& tooltip.help text=(tr("Look in recordings titles and subtitles for the given string and display only the matching ones. You may also use perl compatible regular expressions (PCRE).")) &> <%cpp> #endif | " alt="" <& tooltip.hint text=(tr("Expand all folders")) &>/> " alt="" <& tooltip.hint text=(tr("Collapse all folders")) &>/>
    <%cpp> } <# ---------------------------------------------------------------------- #> <%def del_rec> <%args> string id; <%cpp> { >" alt="" /><%cpp> } <# ---------------------------------------------------------------------- #> <%def edit_rec> <%args> string id; <%cpp> { " alt="" <& tooltip.hint text=(tr("Edit recording")) &> /><%cpp> } <# ---------------------------------------------------------------------- #> <%def rec_tools> <%args> string id; string title; <& 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.edit_rec id=(id) &> <& recordings.del_rec id=(id) &> <# ---------------------------------------------------------------------- #> <%def archived_disc> <%args> string archived; string title; " alt="on_dvd" <& tooltip.hint text=(archived) &> /> <& pageelems.imdb_info_href title=(title) &> <# ---------------------------------------------------------------------- #> <%def rec_item_dir> <%args> string name; int level; string collapseimg = "plus.png"; string folderimg = "folder_closed.png";
    <%cpp> reply.out() << StringRepeat(level, "\"\""); " alt="" />" alt="" />
    <$ name $>
     
    <# ---------------------------------------------------------------------- #> <%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;
    <%cpp> reply.out() << StringRepeat(level + 1, "\"\""); <%cpp> if (!archived.empty()) { " alt="on_dvd" <& tooltip.hint text=(archived) &> /><%cpp> } else { <%cpp> }
    <$ FormatDateTime(tr("%a,"), startTime) + string(" ") + FormatDateTime(tr("%b %d %y"), startTime) + string(" ") + FormatDateTime(tr("%I:%M %p"), startTime) $>
    <$ duration $>
    <%cpp> if (archived.empty()) { <& recordings.rec_tools id=(id) title=(name)&> <%cpp> } else { <& pageelems.imdb_info_href title=(name) &> <%cpp> }
    <%cpp> if (! archived.empty()) {
    <$ archived $>
    <%cpp> }
    <# ---------------------------------------------------------------------- #> <%def delete_error> <& recordings.sort_options &> <%cpp> { reply.out() << deleteResult; }