~ubuntu-branches/ubuntu/quantal/mythexport/quantal

« back to all changes in this revision

Viewing changes to usr/share/mythtv/mythexport/otg.cgi

  • Committer: Bazaar Package Importer
  • Author(s): John Baab
  • Date: 2009-03-11 09:22:55 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090311092255-rcoilu538y14if41
Tags: 1.99.3-0ubuntu1
* debian/rules:
  - Added missing dependency libhtml-template-perl 
* debian/mythexport.postinst,mythexport.postrm 
  - Moved configs
* Moved configs in daemon and cgi pages  
* Fixed issue where only the first userjob was updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
require includes;
10
10
my $connect = undef;
11
 
 
 
11
my $file = "/etc/mythtv/mythexport/mythexport_settings.cfg";
12
12
my $template = HTML::Template->new(filename => 'template/template.tmpl');
13
 
 
14
 
my $script = "<script type=\"text/javascript\">//<![CDATA[
15
 
function showBlocks(){
16
 
        document.getElementById(\"hidden\").style.display=\"block\";
17
 
}
18
 
function hideBlocks(){
19
 
        document.getElementById(\"hidden\").style.display=\"none\";
20
 
}//]]>
21
 
</script>";
22
 
 
23
 
my $myth = new MythTV();
24
 
# connect to database
25
 
$connect = $myth->{'dbh'};
26
 
 
27
 
my $cfg = new Config::Simple();
28
 
$cfg->read('/etc/mythtv/mythexport_settings.cfg'); 
29
 
 
30
 
my $block = param("block");
31
 
 
32
 
my $test = $cfg->as_string();
33
 
$test =~ s/\n//g;
34
 
$test =~ s/^(.*?)\[//;
35
 
$test =~ s/\](.*?)\[/,/g;
36
 
$test =~ s/\](.*?)$//;
37
 
 
38
 
my @blocks = split(",", $test);
39
 
# find all recordings
40
 
my $query = "SELECT title,subtitle,description,starttime,chanid
41
 
    FROM recorded order by title, subtitle, starttime";
42
 
my $query_handle = $connect->prepare($query);
43
 
$query_handle->execute()  || die "Unable to query mythexport table";
44
 
 
45
 
my $content = "<form id=\"form\" action=\"otg_job.cgi\" method=\"post\">
46
 
<p>Choose a Location: <input type=\"text\" id=\"location\" name=\"location\" value=\"\" /><br />
47
 
<input type=\"radio\" id=\"otgFull\" name=\"type\" value=\"otgFull\" onclick=\"javascript:hideBlocks();\" checked=\"checked\" />Full Featured
48
 
<input type=\"radio\" id=\"otgLight\" name=\"type\" value=\"otgLight\" onclick=\"javascript:showBlocks();\" />Lightweight<br />
49
 
<span id=\"hidden\" style=\"display:none\">Choose an export profile: <select id=\"block\" name=\"block\" onchange=\"javascript:changeBlock();\">";
50
 
 
51
 
foreach(@blocks){
52
 
        $content .= "<option value=\"$_\"";
53
 
        if ($_ eq $block){
54
 
                $content .= " selected=\"selected\"";
55
 
        }
56
 
        $content .= ">$_</option>";
57
 
}
58
 
$content .= "</select><br /></span>Choose recordings to take on the go:
59
 
<table border=\"1\"><th></th><th>Title</th><th>Description</th><th>Start Time</th>";
60
 
 
61
 
while ( my ($title,$subtitle,$description,$starttime,$chanid) = $query_handle->fetchrow_array() ) {
62
 
        $content .= "<tr><td><input type=\"checkbox\" name=\"recordings\" value=\"$chanid|$starttime\" /></td>
63
 
        <td>$title";
64
 
        if ($subtitle)
65
 
        {
66
 
                $content .= ": $subtitle";
67
 
        }
68
 
        $content .= "<td>$description</td><td>$starttime</td></tr>";
69
 
}
70
 
 
71
 
$content .= "</table><br />
72
 
<input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\" />
73
 
</p></form>";
 
13
my ($script,$content) = "";
 
14
 
 
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\";
 
20
    }
 
21
    function hideBlocks(){
 
22
            document.getElementById(\"hidden\").style.display=\"none\";
 
23
    }//]]>
 
24
    </script>";
 
25
 
 
26
    my $myth = new MythTV();
 
27
    # connect to database
 
28
    $connect = $myth->{'dbh'};
 
29
 
 
30
    my $cfg = new Config::Simple();
 
31
    $cfg->read($file) || die $cfg->error();
 
32
 
 
33
    my $block = param("block");
 
34
 
 
35
    my $test = $cfg->as_string();
 
36
    $test =~ s/\n//g;
 
37
    $test =~ s/^(.*?)\[//;
 
38
    $test =~ s/\](.*?)\[/,/g;
 
39
    $test =~ s/\](.*?)$//;
 
40
 
 
41
    my @blocks = split(",", $test);
 
42
    # find all recordings
 
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";
 
47
 
 
48
    $content = "<form id=\"form\" action=\"otg_job.cgi\" method=\"post\">
 
49
    <p>Choose a Location: <input type=\"text\" id=\"location\" name=\"location\" value=\"\" /><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();\">";
 
53
 
 
54
    foreach(@blocks){
 
55
            $content .= "<option value=\"$_\"";
 
56
            if ($_ eq $block){
 
57
                    $content .= " selected=\"selected\"";
 
58
            }
 
59
            $content .= ">$_</option>";
 
60
    }
 
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>";
 
63
 
 
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>
 
66
            <td>$title";
 
67
            if ($subtitle)
 
68
            {
 
69
                    $content .= ": $subtitle";
 
70
            }
 
71
            $content .= "<td>$description</td><td>$starttime</td></tr>";
 
72
    }
 
73
 
 
74
    $content .= "</table><br />
 
75
    <input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\" />
 
76
    </p></form>";
 
77
}
 
78
else{
 
79
    $content = "<p>Missing or Invalid configuration file, please create one.</p>";
 
80
}
74
81
 
75
82
$template->param(SCRIPT => $script);
76
83
$template->param(CONTENT => $content);
77
84
$template->param(LOCATION => "otg");
78
85
 
79
86
print generateContentType(), $template->output;
80
 
exit(0);
 
 
b'\\ No newline at end of file'
 
87
exit(0);