4
4
use CGI qw(:standard);
10
9
my $connect = undef;
11
my $file = "/etc/mythtv/mythexport/mythexport_settings.cfg";
12
10
my $template = HTML::Template->new(filename => 'template/template.tmpl');
13
11
my ($script,$content) = "";
15
# if we have a valid config
16
if(-e $file && -s $file > 207){
17
$script = "<script type=\"text/javascript\">//<![CDATA[
18
function showBlocks(){
19
document.getElementById(\"hidden\").style.display=\"block\";
21
function hideBlocks(){
22
document.getElementById(\"hidden\").style.display=\"none\";
26
my $myth = new MythTV();
28
$connect = $myth->{'dbh'};
30
my $cfg = new Config::Simple();
31
$cfg->read($file) || die $cfg->error();
33
my $block = param("block");
35
my $test = $cfg->as_string();
37
$test =~ s/^(.*?)\[//;
38
$test =~ s/\](.*?)\[/,/g;
39
$test =~ s/\](.*?)$//;
41
my @blocks = split(",", $test);
43
my $query = "SELECT title,subtitle,description,starttime,chanid
44
FROM recorded order by title, subtitle, starttime";
45
my $query_handle = $connect->prepare($query);
46
$query_handle->execute() || die "Unable to query mythexport table";
48
$content = "<form id=\"form\" action=\"otg_job.cgi\" method=\"post\">
49
<p>Choose a Location: <input type=\"text\" id=\"location\" name=\"location\" value=\"\" /> <span class=\"red\">*</span><br />
50
<input type=\"radio\" id=\"otgFull\" name=\"type\" value=\"otgFull\" onclick=\"javascript:hideBlocks();\" checked=\"checked\" />Full Featured
51
<input type=\"radio\" id=\"otgLight\" name=\"type\" value=\"otgLight\" onclick=\"javascript:showBlocks();\" />Lightweight<br />
52
<span id=\"hidden\" style=\"display:none\">Choose an export profile: <select id=\"block\" name=\"block\" onchange=\"javascript:changeBlock();\">";
55
$content .= "<option value=\"$_\"";
57
$content .= " selected=\"selected\"";
59
$content .= ">$_</option>";
61
$content .= "</select><br /></span>Choose recordings to take on the go:
62
<table border=\"1\"><th></th><th>Title</th><th>Description</th><th>Start Time</th>";
64
while ( my ($title,$subtitle,$description,$starttime,$chanid) = $query_handle->fetchrow_array() ) {
65
$content .= "<tr><td><input type=\"checkbox\" name=\"recordings\" value=\"$chanid|$starttime\" /></td>
69
$content .= ": $subtitle";
71
$content .= "<td>$description</td><td>$starttime</td></tr>";
74
$content .= "</table><br /><span class=\"red\">* Are required</span>
75
<br /><input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\" />
79
$content = "<p>Missing or Invalid configuration file, please create one.</p>";
13
my $dir = '/usr/share/mythexport/configs';
15
opendir(my $dh, $dir) || die "can't opendir $dir: $!";
16
my @modules = grep { /\.pm/ && -f "$dir/$_" } readdir($dh);
18
$script = "<script type=\"text/javascript\">//<![CDATA[
19
function showConfigs(){
20
document.getElementById(\"hidden\").style.display=\"block\";
22
function hideConfigs(){
23
document.getElementById(\"hidden\").style.display=\"none\";
27
my $myth = new MythTV();
29
$connect = $myth->{'dbh'};
32
my $query = "SELECT title,subtitle,description,starttime,chanid
33
FROM recorded order by title, subtitle, starttime";
34
my $query_handle = $connect->prepare($query);
35
$query_handle->execute() || die "Unable to query mythexport table";
37
$content = "<form id=\"form\" action=\"otg_job.cgi\" method=\"post\">
38
<p>Choose a Location: <input type=\"text\" id=\"location\" name=\"location\" value=\"\" /> <span class=\"red\">*</span><br />
39
<input type=\"radio\" id=\"otgFull\" name=\"type\" value=\"otgFull\" onclick=\"javascript:hideConfigs();\" checked=\"checked\" />Full Featured
40
<input type=\"radio\" id=\"otgLight\" name=\"type\" value=\"otgLight\" onclick=\"javascript:showConfigs();\" />Lightweight<br />
41
<span id=\"hidden\" style=\"display:none\">Choose an export profile: <select id=\"config\" name=\"config\" onchange=\"javascript:changeBlock();\">";
43
foreach my $config (@modules) {
44
next if $config eq "ExportBase.pm";
45
(my $class = $config) =~ s/.pm//;
47
$content .= "<option value=\"$class\">$class</option>";
50
$content .= "</select><br /></span>Choose recordings to take on the go:
51
<table border=\"1\"><th></th><th>Title</th><th>Description</th><th>Start Time</th>";
53
while ( my ($title,$subtitle,$description,$starttime,$chanid) = $query_handle->fetchrow_array() ) {
54
$content .= "<tr><td><input type=\"checkbox\" name=\"recordings\" value=\"$chanid|$starttime\" /></td>
58
$content .= ": $subtitle";
60
$content .= "<td>$description</td><td>$starttime</td></tr>";
63
$content .= "</table><br /><span class=\"red\">* Are required</span>
64
<br /><input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\" />
82
67
$template->param(SCRIPT => $script);
83
68
$template->param(CONTENT => $content);