~ubuntu-branches/ubuntu/precise/mythexport/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): John Baab, John Baab, Angel Abad
  • Date: 2010-10-03 22:46:48 UTC
  • Revision ID: james.westby@ubuntu.com-20101003224648-8dq2plrex684wb52
Tags: 2.2.2-0ubuntu1
[ John Baab ]
* debian/mythexport.config and debian/mythexport.templates
  - Added warning about new configuration 
* usr/bin/mythexport-daemon
  - Fixed issue with OTG exports (LP #598439)
  - Added lockfile, to keep mythtv-backend informed of the job status (LP #596251)
  - Removed commented out code from past release
* usr/bin/mythexport_addjob
  - Added lockfile, to keep mythtv-backend informed of the job status (LP #596251)
* usr/share/mythtv/mythexport.sql
  - Changed param column to longtext (LP #647908)
* usr/share/mythtv/mythexport/otg.cgi
  - Fixed issue where old configuration file was still in use (LP #652322)
* usr/share/mythtv/mythexport/otg_job.cgi
  - Renamed variable, no longer using "block" from old configuration
* usr/share/mythtv/mythexport/setup.cgi
  - Fixed issue where form was submitting to the wrong page (LP #652322)
  - Changed configuration input to radio buttons
* usr/share/mythtv/mythexport/save_system_setup.cgi
  - Fixed typo
* usr/share/mythtv/mythexport/otg.cgi
  - Fixed issue where old configuration file was still in use
* usr/share/mythtv/mythexport/setupsave.cgi
  - Removed debugging line
* debial/rules:
  - Synced BZR_REVISION 

[ Angel Abad ]
* debian/rules: Fix typo in TARFILE rule (LP: #654088)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
use CGI qw(:standard);
5
5
use HTML::Template;
6
6
use MythTV;
7
 
use Config::Simple; 
8
7
 
9
8
require includes;
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) = "";
14
12
 
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=\"\" />&nbsp;<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();\">";
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 /><span class=\"red\">* Are required</span>
75
 
    <br /><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
 
}
 
13
my $dir = '/usr/share/mythexport/configs';
 
14
 
 
15
opendir(my $dh, $dir) || die "can't opendir $dir: $!";
 
16
my @modules = grep { /\.pm/ && -f "$dir/$_" } readdir($dh);
 
17
 
 
18
$script = "<script type=\"text/javascript\">//<![CDATA[
 
19
function showConfigs(){
 
20
    document.getElementById(\"hidden\").style.display=\"block\";
 
21
}
 
22
function hideConfigs(){
 
23
    document.getElementById(\"hidden\").style.display=\"none\";
 
24
}//]]>
 
25
</script>";
 
26
 
 
27
my $myth = new MythTV();
 
28
# connect to database
 
29
$connect = $myth->{'dbh'};
 
30
 
 
31
# find all recordings
 
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";
 
36
 
 
37
$content = "<form id=\"form\" action=\"otg_job.cgi\" method=\"post\">
 
38
<p>Choose a Location: <input type=\"text\" id=\"location\" name=\"location\" value=\"\" />&nbsp;<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();\">";
 
42
 
 
43
foreach my $config (@modules) {
 
44
    next if $config eq "ExportBase.pm";
 
45
    (my $class = $config) =~ s/.pm//;
 
46
 
 
47
    $content .= "<option value=\"$class\">$class</option>";
 
48
}
 
49
 
 
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>";
 
52
 
 
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>
 
55
    <td>$title";
 
56
    if ($subtitle)
 
57
    {
 
58
            $content .= ": $subtitle";
 
59
    }
 
60
    $content .= "<td>$description</td><td>$starttime</td></tr>";
 
61
}
 
62
 
 
63
$content .= "</table><br /><span class=\"red\">* Are required</span>
 
64
<br /><input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\" />
 
65
</p></form>";
81
66
 
82
67
$template->param(SCRIPT => $script);
83
68
$template->param(CONTENT => $content);