[Bio] / FigKernelPackages / HTML.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/HTML.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6, Sun Mar 21 02:20:55 2004 UTC revision 1.46, Wed Jun 29 04:33:02 2005 UTC
# Line 1  Line 1 
1  package HTML;  package HTML;
2    
3    use FIG;
4  use Carp;  use Carp;
5  use Data::Dumper;  use Data::Dumper;
6  use LWP::UserAgent;  use LWP::UserAgent;
7  use LWP::Simple;  use LWP::Simple;
8    use URI::Escape;  # uri_escape()
9  use URI::URL;  use URI::URL;
10  use HTTP::Request::Common;  use HTTP::Request::Common;
11    use POSIX;
12    
13    sub new
14    {
15        my($class) = @_;
16    
17        my $self = {};
18    
19        return bless $self, $class;
20    }
21    
22    sub compute_html_header
23    {
24        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
25        my($additional_insert, $user, %options ) = @_;
26    
27        my $header_name = $options{header_name} ? $options{header_name} : "html.hdr";
28        my $tail_name = $options{tail_name} ? $options{tail_name} : "html.tail";
29    
30        my $html_hdr_file = "./Html/$header_name";
31        if (! -f $html_hdr_file)
32        {
33            $html_hdr_file = "$FIG_Config::fig/CGI/Html/$header_name";
34        }
35        my @html_hdr = &FIG::file_read($html_hdr_file);
36    
37        $options{no_fig_search} or push( @html_hdr, "<br><a href=\"index.cgi?user=$user\">FIG search</a>\n" );
38    
39        if (@html_hdr)
40        {
41            my $insert_stuff;
42    
43            if (not $options{no_release_info})
44            {
45                my @ver = &FIG::file_head("$FIG_Config::fig_disk/CURRENT_RELEASE", 1);
46                my $ver = $ver[0];
47                chomp $ver;
48                if ($ver =~ /^cvs\.(\d+)$/)
49                {
50                    my $d = asctime(localtime($1));
51                    chomp($d);
52                    $ver .=  " ($d)";
53                }
54                my $host = &FIG::get_local_hostname();
55                $insert_stuff = "SEED version <b>$ver</b> on $host";
56            }
57    
58            if ($additional_insert)
59            {
60                $insert_stuff .= "<br>" . $additional_insert;
61            }
62    
63            for $_ (@html_hdr)
64            {
65                s,(href|img\s+src)="/FIG/,\1="$FIG_Config::cgi_base,g;
66                if ($_ eq "<!-- HEADER_INSERT -->\n")
67                {
68                    $_ = $insert_stuff;
69                }
70            }
71        }
72    
73        return @html_hdr;
74    }
75    
76  sub show_page {  sub show_page {
77      my($cgi,$html,$no_home) = @_;      #warn "SHOWPAGE: cgi=", Dumper(@_);
78        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
79        my($cgi,$html,$no_home, $alt_header, $css, $javasrc) = @_;
80      my $i;      my $i;
81    
82        # ARGUMENTS:
83        #     $cgi is the CGI method
84        #     $html is an array with all the html in it. It is just joined by "\n" (and not <br> or <p>
85        #     $no_home eliminates ONLY the bottom FIG search link in a page
86        #     $alt_header is a reference to an array for an alternate header banner that you can replace the standard one with
87        #     $css is a reference to a hash. The key is the name of the CSS sheet and the value is the URL of that sheet. Note the usual rules about relative css urls
88        #               the sheet named "Default" is considered to be the default style sheet, and if this is not set it points at $FIG_Config::HTML/css/default.css
89        #               the sheet named "Sans Serif" is considered to the the first alternate, and if this is not set it points at $FIG_Config::HTML/css/sanserif.css
90        #     $javasrc is a reference to an array of URLs to javascripts to be included (e.g. "/FIG/Html/css/styleswitcher.js")
91      #      #
92      # Find the HTML header      # Find the HTML header
93      #      #
94    
95      my $html_hdr_file = "./Html/html.hdr";      my $html_tail_file = "./Html/$tail_name";
96      if (! -f $html_hdr_file)      if (! -f $html_tail_file)
97      {      {
98          $html_hdr_file = "$FIG_Config::fig/CGI/Html/html.hdr";          $html_tail_file = "$FIG_Config::fig/CGI/Html/$tail_name";
99      }      }
100    
101      my $html_tail_file = "./Html/html.tail";      my $user = $cgi->param('user') || "";
102      if (! -f $html_tail_file)      my @html_hdr;
103        if ($alt_header && ref($alt_header) eq "ARRAY")
104      {      {
105          $html_tail_file = "$FIG_Config::fig/CGI/Html/html.tail";         @html_hdr = @$alt_header;
106        }
107        else
108        {
109            @html_hdr = compute_html_header(undef,$user);
110      }      }
111    
112    
# Line 145  Line 227 
227      #      #
228      #  <BODY> goes after last head line      #  <BODY> goes after last head line
229      #      #
230        #  RAE:
231        #  Added the javascript for the buttons immediately after body.
232        #  Note if no buttons are added we still (at the moment) add the script,
233        #  but it only adds a little text (495 characters) to the html and noone will notice!
234        #  RAE: This is now deprecated because everything is in an external file, FIG.js, included later
235    
236      if ( $body_line < 0 )      if ( $body_line < 0 )
237      {      {
# Line 156  Line 243 
243      #  Seed page header (if it exists) goes after <BODY>      #  Seed page header (if it exists) goes after <BODY>
244      #      #
245    
246      if ( -f $html_hdr_file )      if (@html_hdr)
247      {      {
248          splice( @$html, $body_line + 1, 0, `cat $html_hdr_file` );          splice( @$html, $body_line + 1, 0, @html_hdr );
249      }      }
250    
251      #      #
# Line 171  Line 258 
258          splice( @$html, $body_line, 0, "</HEAD>\n" );          splice( @$html, $body_line, 0, "</HEAD>\n" );
259      }      }
260    
261        # RAE:
262        # Add css here
263        # Note that at the moment I define these two sheets here. I think this should
264        # be moved out, but I want to try it and see what happens.  css has the format:
265        #
266        # <link rel='stylesheet' title='default' href='/css/default.css' type='text/css'>
267    
268        # convert the default key to the right case. and eliminate dups
269        foreach my $k (keys %$css) {if (lc($k) eq "default") {$css->{'Default'}=$css->{$k}}}
270    
271        if (!$css || !$css->{'Default'})
272        {
273           $css->{'Default'}="/FIG/Html/css/default.css";
274        }
275        if (!$css->{"Sans Serif"})
276        {
277           $css->{'Sans Serif'}="/FIG/Html/css/sanserif.css";
278        }
279        my $csstext = "<link rel='stylesheet' title='default' href='".$css->{'Default'}."' type='text/css'>\n";
280        $csstext   .= "<link rel='alternate stylesheet' title='Sans Serif' href='".$css->{'Sans Serif'}."' type='text/css'>\n";
281    
282        foreach my $k (keys %$css)
283        {
284           next if (lc($k) eq "default" || lc($k) eq "sans serif");
285           $csstext .= "<link rel='alternate stylesheet' title='$k' href='".$css->{$k}."' type='text/css'>\n";
286        }
287    
288    
289        # RAE: also added support for external javascripts here.
290        # we are cluttering the HTML code with all the javascripts when they could easily be in external files
291        # this solution allows us to source other files
292    
293        # the file FIG.js contains most of the java script we use routinely. Every browser will just cache this and so
294        # it will reduce our overhead.
295    
296        # $javasrc must be a ref to an array with urls (absolute or relative) to the javascripts
297        push @$javasrc, "/FIG/Html/css/FIG.js";
298        foreach my $script (@$javasrc) {
299         $csstext .= "<script src=\"$script\" type=\"text/javascript\"></script>\n";
300        }
301    
302    
303    
304        splice( @$html, $head_end_line, 1, "$csstext</HEAD>\n" );  # note here I am replacing the </head> line. Could be bad...? But it doesn't increment everything else.
305    
306      #      #
307      #  <BASE ...> goes before </HEAD>      #  <BASE ...> goes before </HEAD>
308      #      #
# Line 183  Line 315 
315          #  only, or every update?), I provide an alternative derivation          #  only, or every update?), I provide an alternative derivation
316          #  from $cgi_url. -- GJO          #  from $cgi_url. -- GJO
317          #          #
318            # BASE href needs to be absolute. RDO.
319          my $base_url = $FIG_Config::cgi_base;          #
320          if ( ! $base_url )                      # if cgi_base was not defined          #
321          {          $base_url = &FIG::cgi_url;
322              $base_url = $FIG_Config::cgi_url;   # get the full cgi url  #       my $base_url = $FIG_Config::cgi_base;
323              $base_url =~ s~^http://[^/]*~~;     # remove protocol and host  #       if ( ! $base_url )                      # if cgi_base was not defined
324              $base_url =~ m~/$~ || $base_url =~ s~$~/~; # check trailing slash  #       {
325          }  #           $base_url = $FIG_Config::cgi_url;   # get the full cgi url
326    #           $base_url =~ s~^http://[^/]*~~;     # remove protocol and host
327    #           $base_url =~ m~/$~ || $base_url =~ s~$~/~; # check trailing slash
328    #       }
329    
330          $base_line = $head_end_line;          $base_line = $head_end_line;
331          splice( @$html, $base_line, 0, "<BASE href=\"$base_url\">\n" );          splice( @$html, $base_line, 0, "<BASE href=\"$base_url/\">\n" );
332      }      }
333    
334      #      #
# Line 228  Line 363 
363      }      }
364    
365      #      #
366        # See if we have a site-specific tail (for disclaimers, etc).
367        #
368    
369        my $site_tail = "$FIG_Config::fig_disk/config/site_tail.html";
370        my $site_fh;
371        if (open($site_fh, "<$site_tail"))
372        {
373            push(@tail, <$site_fh>);
374            close($site_fh);
375        }
376    
377        #
378      #  Figure out where to insert The SEED tail.  Before </body>,      #  Figure out where to insert The SEED tail.  Before </body>,
379      #  or before </html>, or at end of page.      #  or before </html>, or at end of page.
380      #      #
# Line 255  Line 402 
402          splice( @$html, $i, 0, @tags );          splice( @$html, $i, 0, @tags );
403      }      }
404    
405      print @$html;      # RAE the chomp will return any new lines at the ends of elements in the array,
406        # and then we can join  with a "\n". This is because somethings put newlines in,
407        # and others don't. This should make nicer looking html
408        #
409        # chomp(@$html);
410        # print join "\n", @$html;
411        #
412        # Apparently the above still breaks things. This is the correct code:
413    
414        foreach $_ (@$html)
415        {
416            print $_;
417        }
418  }  }
419    
420  sub make_table {  sub make_table {
421      my($col_hdrs,$tab,$title,$instr) = @_;      my($col_hdrs,$tab,$title, %options ) = @_;
422      my(@tab);      my(@tab);
423    
424      push( @tab, "\n<table border>\n",      my $border = defined $options{border} ? "border=\"$options{border}\"" : "border";
425        push( @tab, "\n<table $border>\n",
426                  "\t<caption><b>$title</b></caption>\n",                  "\t<caption><b>$title</b></caption>\n",
427                  "\t<tr>\n\t\t<th>"                  "\t<tr>\n\t\t"
428                . join( "</th>\n\t\t<th>", @$col_hdrs )                . join( "\n", map { &expand($_, "th") } @$col_hdrs )
429                . "</th>\n\t</tr>\n"                . "\n\t</tr>\n"
430          );          );
431      my($i,$nowrap);      my($i);
   
     for ($i=0; ($i < @$instr) && ($instr->[$i] !~ /nowrap/); $i++) {}  
     $nowrap = ($i == @$instr) ? "" : " nowrap";  
432    
433      my $row;      my $row;
434      foreach $row (@$tab)      foreach $row (@$tab)
435      {      {
436          push( @tab, "\t<tr>\n"          push( @tab, "\t<tr>\n"
437                    . join( "\n", map { &expand($_,$nowrap) } @$row )                    . join( "\n", map { &expand($_) } @$row )
438                    . "\n\t</tr>\n"                    . "\n\t</tr>\n"
439              );              );
440      }      }
# Line 286  Line 443 
443  }  }
444    
445  sub expand {  sub expand {
446      my($x,$nowrap) = @_;      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
447        my( $x, $tag ) = @_;
448    
449      if ($x =~ /^\@([^:]+)\:([^:]+)\:(.*)$/)      $tag = "td" unless $tag;
450        my $endtag = $tag;
451    
452        # RAE modified this so that you can pass in a reference to an array where
453        # the first element is the data to display and the second element is optional
454        # things like colspan and align. Note that in this case you need to include the td
455        # use something like ["some data to appear", "td colspan=4 bgcolor=gray"]
456    
457        if ( ref($x) eq "ARRAY" ) { ($x, $tag) = @$x; if ($tag =~ /td/) { $endtag = "td" } }
458    
459        if ( $x =~ /^\@([^:]+)\:(.*)$/ )
460      {      {
461          return "\t\t<td$nowrap $1=\"$2\">$3</td>";          return "\t\t<$tag $1>$2</$endtag>";
462      }      }
463      else      else
464      {      {
465          return "\t\t<td$nowrap>$x</td>";          return "\t\t<$tag>$x</$endtag>";
466        }
467    }
468    
469    sub set_ec_links {
470        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
471        my($cgi,$x) = @_;
472        my($before,$match,$after);
473    
474        if ($x =~ /^(.*)(EC \d+\.\d+\.\d+\.\d+)(.*)/s)
475        {
476            $before = $1;
477            $match = $2;
478            $after = $3;
479            return &set_ec_links($cgi,$before) . &HTML::ec_link($match) . &set_ec_links($cgi,$after);
480      }      }
481        return $x;
482  }  }
483    
484  sub ec_link {  sub ec_link {
485        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
486      my($role) = @_;      my($role) = @_;
487    
488      if ($role =~ /(\d+\.\d+\.\d+\.\d+)/)      if ($role =~ /(\d+\.\d+\.\d+\.\d+)/)
# Line 312  Line 496 
496  }  }
497    
498  sub role_link {  sub role_link {
499        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
500      my($cgi,$role) = @_;      my($cgi,$role) = @_;
501    
502      my $roleR = ($role =~ /^(\d+\.\d+\.\d+\.\d+)\s+-\s+/) ? $1 : $role;      my $roleR = ($role =~ /^(\d+\.\d+\.\d+\.\d+)\s+-\s+/) ? $1 : $role;
# Line 322  Line 507 
507      return "<a href=$link>$role</a>";      return "<a href=$link>$role</a>";
508  }  }
509    
510    #
511    # Local means to eliminate the fig|org.peg from the
512    # text of the link.
513    #
514  sub fid_link {  sub fid_link {
515        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
516      my($cgi,$fid,$local,$just_url) = @_;      my($cgi,$fid,$local,$just_url) = @_;
517      my($n);      my($n);
518    
# Line 347  Line 537 
537          my $user = $cgi->param('user');          my $user = $cgi->param('user');
538          if (! $user) { $user = "" }          if (! $user) { $user = "" }
539          my $trans = $cgi->param('translate') ? "&translate=1" : "";          my $trans = $cgi->param('translate') ? "&translate=1" : "";
540          my $link = $cgi->url() . "?prot=$fid&user=$user$trans";          my $sprout = $cgi->param('SPROUT') ? "&SPROUT=1" : "";
541          $link =~ s/[a-z_A-Z]+\.cgi\?/protein.cgi?/;          my $link = &FIG::cgi_url . "/protein.cgi?prot=$fid&user=$user$trans$sprout";
542            $link =~ s/[a-z_A-Z0-9]+\.cgi\?/protein.cgi?/;
543            #
544            # Elimin the p2p part if we're in that subdir. Ugh.
545            #
546            $link =~ s,p2p/protein.cgi,protein.cgi,;
547    
548          if ($just_url)          if ($just_url)
549          {          {
550              return $link;              return $link;
# Line 362  Line 558 
558  }  }
559    
560  sub family_link {  sub family_link {
561        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
562      my($family,$user) = @_;      my($family,$user) = @_;
563    
564      return $family;      return $family;
565  }  }
566    
 use URI::Escape;  
567    
568  sub get_html {  sub get_html {
569        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
570      my( $url, $type, $kv_pairs) = @_;      my( $url, $type, $kv_pairs) = @_;
571      my( $encoded, $ua, $args, @args, $out, @output, $x );      my( $encoded, $ua, $args, @args, $out, @output, $x );
572    
573      $ua = new LWP::UserAgent;      $ua = new LWP::UserAgent;
574      $ua->timeout( 900 );      $ua->timeout( 900 );
   
575      if ($type =~/post/i)      if ($type =~/post/i)
576      {      {
577          $args = [];          $args = [];
# Line 435  Line 631 
631  }  }
632    
633  sub trim_output {  sub trim_output {
634        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
635      my($out) = @_;      my($out) = @_;
636      my $i;      my $i;
637    
# Line 472  Line 669 
669  }  }
670    
671  sub set_prot_links {  sub set_prot_links {
672        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
673      my($cgi,$x) = @_;      my($cgi,$x) = @_;
674      my($before,$match,$after);      my($before,$match,$after);
675    
676      if ($x =~ /^(.*)(fig\|\d+\.\d+\.peg\.\d+)(.*)$/)      if ($x =~ /^(.*)(fig\|\d+\.\d+\.peg\.\d+)(.*)/s)
677        {
678            $before = $1;
679            $match = $2;
680            $after = $3;
681            return &set_prot_links($cgi,$before) . &HTML::fid_link($cgi,$match) . &set_prot_links($cgi,$after);
682        }
683        elsif ($x =~ /^(.*)\b([NXYZA]P_[0-9\.]+)\b(.*)/s)
684        {
685            $before = $1;
686            $match = $2;
687            $after = $3;
688            return &set_prot_links($cgi,$before) . &HTML::refseq_link($cgi,$match) . &set_prot_links($cgi,$after);
689        }
690        elsif ($x =~ /^(.*)(gi\|\d+)(.*)/s)
691        {
692            $before = $1;
693            $match = $2;
694            $after = $3;
695            return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after);
696        }
697        elsif ($x =~ /^(.*)(tigr\|[0-9a-zA-Z]+)(.*)/s)
698        {
699            $before = $1;
700            $match = $2;
701            $after = $3;
702            return &set_prot_links($cgi,$before) . &HTML::tigr_link($cgi,$match) . &set_prot_links($cgi,$after);
703        }
704        elsif ($x =~  /^(.*)(uni\|[A-Z0-9]{6})(.*)/s)
705      {      {
706          $before = $1;          $before = $1;
707          $match = $2;          $match = $2;
708          $after = $3;          $after = $3;
709          return &set_prot_links($cgi,$before) . &HTML::fid_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::uni_link($cgi,$match) . &set_prot_links($cgi,$after);
710      }      }
711      elsif ($x =~ /^(.*)(gi\|\d+)(.*)$/)      elsif ($x =~ /^(.*)(sp\|[A-Z0-9]{6})(.*)/s)
712      {      {
713          $before = $1;          $before = $1;
714          $match = $2;          $match = $2;
715          $after = $3;          $after = $3;
716          return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::sp_link($cgi,$match) . &set_prot_links($cgi,$after);
717      }      }
718      elsif ($x =~ /^(.*)(sp\|[A-Z0-9]{6})(.*)$/)      elsif ($x =~ /^(.*)(pirnr\|NF\d+)(.*)/s)
719      {      {
720          $before = $1;          $before = $1;
721          $match = $2;          $match = $2;
722          $after = $3;          $after = $3;
723          return &set_prot_links($cgi,$before) . &HTML::sp_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::pir_link($cgi,$match) . &set_prot_links($cgi,$after);
724      }      }
725      elsif ($x =~ /^(.*)(pirnr\|NF\d+)(.*)$/)      elsif ($x =~ /^(.*)(kegg\|[a-z]{2,4}:[a-zA-Z_0-9]+)(.*)/s)
726      {      {
727          $before = $1;          $before = $1;
728          $match = $2;          $match = $2;
729          $after = $3;          $after = $3;
730          return &set_prot_links($cgi,$before) . &HTML::pir_link($cgi,$match) . &set_prot_links($cgi,$after) . "\n";          return &set_prot_links($cgi,$before) . &HTML::kegg_link($cgi,$match) . &set_prot_links($cgi,$after);
731      }      }
732      return $x;      return $x;
733  }  }
734    
735    sub refseq_link {
736        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
737        my($cgi,$id) = @_;
738    
739        if ($id =~ /^[NXYZA]P_/)
740        {
741            return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=protein&cmd=search&term=$id>$id</a>";
742        }
743    }
744    
745  sub gi_link {  sub gi_link {
746        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
747      my($cgi,$gi) = @_;      my($cgi,$gi) = @_;
748    
749      if ($gi =~ /^gi\|(\d+)$/)      if ($gi =~ /^gi\|(\d+)$/)
# Line 516  Line 753 
753      return $gi;      return $gi;
754  }  }
755    
756    sub tigr_link {
757        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
758        my($cgi,$tigr) = @_;
759    
760        if ($tigr =~ /^tigr\|([0-9a-zA-Z]+)$/)
761        {
762            return "<a href=\"http://pathema.tigr.org/tigr-scripts/CMR/GenePage.cgi?locus=$1\">$tigr</a>";
763        }
764        return $tigr;
765    }
766    
767    sub uni_link {
768        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
769        my($cgi,$uni) = @_;
770    
771        if ($uni =~ /^uni\|(\S+)$/)
772        {
773            return "<a href=http://www.pir.uniprot.org/cgi-bin/upEntry?id=$1>$uni</a>";
774        }
775        return $uni;
776    }
777    
778  sub sp_link {  sub sp_link {
779        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
780      my($cgi,$sp) = @_;      my($cgi,$sp) = @_;
781    
782      if ($sp =~ /^sp\|(\S+)$/)      if ($sp =~ /^sp\|(\S+)$/)
# Line 527  Line 787 
787  }  }
788    
789  sub pir_link {  sub pir_link {
790        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
791      my($cgi,$pir) = @_;      my($cgi,$pir) = @_;
792    
793      if ($pir =~ /^pirnr\|(NF\d+)$/)      if ($pir =~ /^pirnr\|(NF\d+)$/)
# Line 536  Line 797 
797      return $pir;      return $pir;
798  }  }
799    
800    sub kegg_link {
801        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
802        my($cgi,$kegg) = @_;
803    
804        if ($kegg =~ /^kegg\|([^:]+):(\S+)$/)
805        {
806            return "<a href=http://www.genome.ad.jp/dbget-bin/www_bget?$1+$2>$kegg</a>";
807        }
808        return $kegg;
809    }
810    
811    sub set_map_links {
812        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
813        my($cgi,$x) = @_;
814        my($before,$match,$after);
815    
816        my $org = ($cgi->param('org') || $cgi->param('genome') || "");
817    
818        if ($x =~ /^(.*)(MAP\d+)(.*)/s)
819        {
820            $before = $1;
821            $match = $2;
822            $after = $3;
823            return &set_map_links($cgi,$before) . &map_link($cgi,$match,$org) . &set_map_links($cgi,$after);
824        }
825        return $x;
826    }
827    
828    sub map_link {
829        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
830        my($cgi,$map,$org) = @_;
831    
832        $user = $cgi->param('user');
833        $user = $user ? $user : "";
834        $org = $org ? $org : "";
835        my $url = "$FIG_Config::cgi_url/show_kegg_map.cgi?user=$user&map=$map&org=$org";
836        my $link = "<a href=\"$url\">$map</a>";
837        return $link;
838    }
839    
840    sub java_buttons {
841        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
842      ## ADDED BY RAE
843      # Provides code to include check all/first half/second half/none for javascrspt
844      # this takes two variables - the form name provided in start_form with the
845      # -name => field and the checkbox name
846      my ($form, $button)=@_;
847    
848      $java_script="<input type=\"button\" name=\"CheckAll\" value=\"Check All\"\nonClick=\"checkAll(document.$form.$button)\">\n";
849      $java_script.="<input type=\"button\" name=\"CheckFirst\" value=\"Check First Half\"\nonClick=\"checkFirst(document.$form.$button)\">\n";
850      $java_script.="<input type=\"button\" name=\"CheckSecond\" value=\"Check Second Half\"\nonClick=\"checkSecond(document.$form.$button)\">\n";
851      $java_script.="<input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\"\nonClick=\"uncheckAll(document.$form.$button)\">\n";
852    
853      return $java_script;
854    }
855    
856    sub sub_link {
857        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
858        my($cgi,$sub) = @_;
859        my($sub_link);
860    
861        my $user = $cgi->param('user');
862        if ($user)
863        {
864            my $esc_sub = uri_escape( $sub );
865            $sub_link = "<a href=./subsys.cgi?ssa_name=$esc_sub&request=show_ssa&user=$user>$sub</a>";
866        }
867        else
868        {
869            $sub_link = $sub;
870        }
871        return $sub_link;
872    }
873    
874  1  1

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.46

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3