textlab / glossa-foni-cgibin

0 stars 0 forks source link

Fix missing context for parallels in OMC4 in show_page_dev.cgi #15

Closed andrely closed 11 years ago

andrely commented 11 years ago

Click on a context in show_page_dev.cgi for a parallel.

andrely commented 11 years ago

In show_page the context link for the English parallel is set to the Norwegian (original) text_id:

text_id=BHH1N&s_id=BHH1TE.2.4.s37

In query_dev both is set to the parallel text_id:

s_id=BHH1TE.2.2.s32&text_id=BHH1TE

This is probably the cause of the bug.

Anders fixed this in another installation. Here is the diff:

diff --git a/cgi-bin/glossa/show_page_dev.cgi b/cgi-bin/glossa/show_page_dev.cgi
index 2669c3a..a76d37a 100755
--- a/cgi-bin/glossa/show_page_dev.cgi
+++ b/cgi-bin/glossa/show_page_dev.cgi
@@ -16,6 +16,13 @@ my $query_id = CGI::param('query_id');
 my $corpus=CGI::param('corpus');
 my $attribute_type=CGI::param('atttype');

+my $id_name;
+if($corpus eq 'empac') {
+   $id_name = 'subtitle';
+} else {
+   $id_name = 's';
+}
+
 # for multiple-attribute display
 my $multiple_attribute_display = 0;
 if($attribute_type eq 'x'){$multiple_attribute_display = 2; $attribute_type = 0;}
@@ -320,12 +327,18 @@ while (<DATA>) {

     my ($corp, $s_id, $sts_string, $res_l, $ord, $res_r) = split(/\t/, $source);

+#print "A" . $s_id . "B";
+
     my $sts_url = "?" . $corpus_string . "&subcorpus=" . $corp . "&cs=3";

     my @sts = split(/\|\|/, $sts_string);
     my %sts;
     foreach my $sts (@sts) {
    my ($k,$v) = split(/=/, $sts);
+# HACK for EMPAC
+   if($corp eq 'EMPAC_ES' and $k eq 'subtitle_id') {
+       $k =~ s/\-ENF_/\-ESF/;
+   }
    $sts{$k}=$v;
    $sts_url .= "&" . $k . "=" . $v;

@@ -339,7 +352,7 @@ while (<DATA>) {

    my $annotation_table = uc($corpus) . "annotations";

-   my $sth = $dbh->prepare(qq{ SELECT value_id FROM $annotation_table where s_id = '$s_id' and set_id = '$set_id';});
+   my $sth = $dbh->prepare(qq{ SELECT value_id FROM $annotation_table where $id_name = '$s_id' and set_id = '$set_id';});
    $sth->execute  || die "Error fetching data: $DBI::errstr";
    my ($stored_value) = $sth->fetchrow_array;

@@ -465,15 +478,21 @@ while (<DATA>) {
    my %sts;
    foreach my $sts (@sts) {
        my ($k,$v) = split(/=/, $sts);
+
+       # HACK for EMPAC
+            if($corp eq 'EMPAC_ES' and $k eq 'subtitle_id') {
+       $v =~ s/\-ENF_/\-ESF_/;
+       }
+
        $sts{$k}=$v;
-       next if ($k eq 's_id');
+       next if ($k eq $id_name);
        $sts_url .= "&" . $k . "=" . $v;
    }
    my $t_id = $sts{'text_id'};

    my @targets = split(/ /, $targets);

-   $sts_url .= "&s_id=" . $targets[0];
+   $sts_url .= "&$id_name=" . $targets[0];

    foreach my $target (@targets) {
noklesta commented 11 years ago

The relevant parts of the diff are those that do the substitution s/\-ENF_/\-ESF_/ (and by the way, there is a bug in the first one - the last underscore is missing...) The other changes are unrelated to this bug.

andrely commented 11 years ago

Fixed in e06daf71f5c43d68495122f3290b153a6b16424c.

The link generation in show_page_dev replaces the s_id for the parallels when aking show_context links, but not the text_id which was still the base_corpus text.