[Bio] / Sprout / SearchHelper.pm Repository:
ViewVC logotype

Diff of /Sprout/SearchHelper.pm

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

revision 1.20, Tue Nov 21 17:23:41 2006 UTC revision 1.26, Sun Feb 4 13:07:24 2007 UTC
# Line 272  Line 272 
272      my $session_id = $cgi->param("SessionID");      my $session_id = $cgi->param("SessionID");
273      my $type = "old";      my $type = "old";
274      if (! $session_id) {      if (! $session_id) {
275            Trace("No session ID found.") if T(3);
276          # Here we're starting a new session. We create the session ID and          # Here we're starting a new session. We create the session ID and
277          # store it in the query object.          # store it in the query object.
278          $session_id = NewSessionID();          $session_id = NewSessionID();
279          $type = "new";          $type = "new";
280          $cgi->param(-name => 'SessionID', -value => $session_id);          $cgi->param(-name => 'SessionID', -value => $session_id);
281        } else {
282            Trace("Session ID is $session_id.") if T(3);
283      }      }
284      # Compute the subclass name.      # Compute the subclass name.
285      my $subClass;      my $subClass;
# Line 679  Line 682 
682          push @colNames, $self->DefaultFeatureColumns();          push @colNames, $self->DefaultFeatureColumns();
683          # Add any additional columns requested by the feature filter.          # Add any additional columns requested by the feature filter.
684          push @colNames, FeatureQuery::AdditionalColumns($self);          push @colNames, FeatureQuery::AdditionalColumns($self);
685            Trace("Full column list determined.") if T(3);
686          # Save the full list.          # Save the full list.
687          $self->{cols} = \@colNames;          $self->{cols} = \@colNames;
688          # Write out the column headers. This also prepares the cache file to receive          # Write out the column headers. This also prepares the cache file to receive
689          # output.          # output.
690            Trace("Writing column headers.") if T(3);
691          $self->WriteColumnHeaders(map { $self->FeatureColumnTitle($_) } @{$self->{cols}});          $self->WriteColumnHeaders(map { $self->FeatureColumnTitle($_) } @{$self->{cols}});
692            Trace("Column headers written.") if T(3);
693      }      }
694      # Get the feature ID.      # Get the feature ID.
695      my $fid = $fd->FID();      my $fid = $fd->FID();
# Line 1042  Line 1048 
1048          $fastaData =~ s/\n//g;          $fastaData =~ s/\n//g;
1049          $fastaData =~ s/\s+//g;          $fastaData =~ s/\s+//g;
1050          # Finally, verify that it's DNA if we're doing DNA stuff.          # Finally, verify that it's DNA if we're doing DNA stuff.
1051          if ($desiredType eq 'dna' && $fastaData =~ /[^agct]/i) {          if ($desiredType eq 'dna' && $fastaData =~ /[^agctxn]/i) {
1052              $self->SetMessage("Invaid characters detected. Is the input really a DNA sequence?");              $self->SetMessage("Invalid characters detected. Is the input really a DNA sequence?");
1053              $okFlag = 0;              $okFlag = 0;
1054          }          }
1055      }      }
# Line 1114  Line 1120 
1120      # Read in the subsystems.      # Read in the subsystems.
1121      my @subs = $sprout->GetAll(['Subsystem'], "ORDER BY Subsystem(classification), Subsystem(id)", [],      my @subs = $sprout->GetAll(['Subsystem'], "ORDER BY Subsystem(classification), Subsystem(id)", [],
1122                                 ['Subsystem(classification)', 'Subsystem(id)']);                                 ['Subsystem(classification)', 'Subsystem(id)']);
1123        # Put any unclassified subsystems at the end. They will always be at the beginning, so if one
1124        # is at the end, ALL subsystems are unclassified and we don't bother.
1125        if ($#subs >= 0 && $subs[$#subs]->[0] ne '') {
1126            while ($subs[0]->[0] eq '') {
1127                my $classLess = shift @subs;
1128                push @subs, $classLess;
1129            }
1130        }
1131      # Declare the return variable.      # Declare the return variable.
1132      my @retVal = ();      my @retVal = ();
1133      # Each element in @subs represents a leaf node, so as we loop through it we will be      # Each element in @subs represents a leaf node, so as we loop through it we will be
# Line 1519  Line 1533 
1533      my $retVal = $cgi->Tr($cgi->td("Results/Page"),      my $retVal = $cgi->Tr($cgi->td("Results/Page"),
1534                            $cgi->td($cgi->popup_menu(-name => 'PageSize',                            $cgi->td($cgi->popup_menu(-name => 'PageSize',
1535                                                      -values => [10, 25, 50, 100, 1000],                                                      -values => [10, 25, 50, 100, 1000],
1536                                                      -default => $pageSize) . " " .                                                      -default => $pageSize)),
                                    $cgi->checkbox(-name => 'ShowURL',  
                                                   -value => 1,  
                                                   -label => 'Show URL')),  
1537                            $cgi->td($cgi->submit(-class => 'goButton',                            $cgi->td($cgi->submit(-class => 'goButton',
1538                                                  -name => 'Search',                                                  -name => 'Search',
1539                                                  -value => $realCaption)));                                                  -value => $realCaption)));
# Line 1767  Line 1778 
1778          # a singleton list, but that's okay.          # a singleton list, but that's okay.
1779          my @values = split (/\0/, $parms{$parmKey});          my @values = split (/\0/, $parms{$parmKey});
1780          # Check for special cases.          # Check for special cases.
1781          if (grep { $_ eq $parmKey } qw(SessionID ResultCount Page PageSize Trace TF ShowURL)) {          if (grep { $_ eq $parmKey } qw(SessionID ResultCount Page PageSize Trace TF)) {
1782              # These are bookkeeping parameters we don't need to start a search.              # These are bookkeeping parameters we don't need to start a search.
1783              @values = ();              @values = ();
1784          } elsif ($parmKey =~ /_SearchThing$/) {          } elsif ($parmKey =~ /_SearchThing$/) {
# Line 2303  Line 2314 
2314      } elsif ($colName =~ /^keyword:(.+)$/) {      } elsif ($colName =~ /^keyword:(.+)$/) {
2315          $retVal = ucfirst $1;          $retVal = ucfirst $1;
2316      } elsif ($colName eq 'orgName') {      } elsif ($colName eq 'orgName') {
2317          $retVal = "Gene Name";          $retVal = "Organism and Gene ID";
2318      } elsif ($colName eq 'protlink') {      } elsif ($colName eq 'protlink') {
2319          $retVal = "NMPDR Protein Page";          $retVal = "NMPDR Protein Page";
2320      } elsif ($colName eq 'subsystem') {      } elsif ($colName eq 'subsystem') {
# Line 2376  Line 2387 
2387          ($retVal) = $record->Value('Feature(assignment)');          ($retVal) = $record->Value('Feature(assignment)');
2388      } elsif ($colName eq 'gblink') {      } elsif ($colName eq 'gblink') {
2389          # Here we want a link to the GBrowse page using the official GBrowse button.          # Here we want a link to the GBrowse page using the official GBrowse button.
2390          $retVal = Formlet('GBrowse', "GetGBrowse.cgi", undef,          $retVal = FakeButton('GBrowse', "GetGBrowse.cgi", undef,
2391                            fid => $fid);                            fid => $fid);
2392      } elsif ($colName eq 'group') {      } elsif ($colName eq 'group') {
2393          # Get the NMPDR group name.          # Get the NMPDR group name.
# Line 2394  Line 2405 
2405          $retVal = $self->FeatureName($fid);          $retVal = $self->FeatureName($fid);
2406      } elsif ($colName eq 'protlink') {      } elsif ($colName eq 'protlink') {
2407          # Here we want a link to the protein page using the official NMPDR button.          # Here we want a link to the protein page using the official NMPDR button.
2408          $retVal = Formlet('NMPDR', "protein.cgi", undef,          $retVal = FakeButton('NMPDR', "protein.cgi", undef,
2409                            prot => $fid, SPROUT => 1, new_framework => 0,                            prot => $fid, SPROUT => 1, new_framework => 0,
2410                            user => '');                            user => '');
2411      }elsif ($colName eq 'subsystem') {      }elsif ($colName eq 'subsystem') {
# Line 2588  Line 2599 
2599      if (! @wordList) {      if (! @wordList) {
2600          if ($required) {          if ($required) {
2601              $self->SetMessage("No search words specified.");              $self->SetMessage("No search words specified.");
2602            } else {
2603                $retVal = 1;
2604          }          }
2605      } elsif (! @plusWords) {      } elsif (! @plusWords) {
2606          $self->SetMessage("At least one keyword must be positive. All the keywords entered are preceded by minus signs.");          $self->SetMessage("At least one keyword must be positive. All the keywords entered are preceded by minus signs.");
# Line 2598  Line 2611 
2611      return $retVal;      return $retVal;
2612  }  }
2613    
2614    =head3 FakeButton
2615    
2616    C<< my $html = SearchHelper::FakeButton($caption, $url, $target, %parms); >>
2617    
2618    Create a fake button that hyperlinks to the specified URL with the specified parameters.
2619    Unlike a real button, this one won't visibly click, but it will take the user to the
2620    correct place.
2621    
2622    The parameters of this method are deliberately identical to L</Formlet> so that we
2623    can switch easily from real buttons to fake ones in the code.
2624    
2625    =over 4
2626    
2627    =item caption
2628    
2629    Caption to be put on the button.
2630    
2631    =item url
2632    
2633    URL for the target page or script.
2634    
2635    =item target
2636    
2637    Frame or target in which the new page should appear. If C<undef> is specified,
2638    the default target will be used.
2639    
2640    =item parms
2641    
2642    Hash containing the parameter names as keys and the parameter values as values.
2643    These will be appended to the URL.
2644    
2645    =back
2646    
2647    =cut
2648    
2649    sub FakeButton {
2650        # Get the parameters.
2651        my ($caption, $url, $target, %parms) = @_;
2652        # Declare the return variable.
2653        my $retVal;
2654        # Compute the target URL.
2655        my $targetUrl = "$url?" . join(";", map { "$_=" . uri_escape($parms{$_}) } keys %parms);
2656        # Compute the target-frame HTML.
2657        my $targetHtml = ($target ? " target=\"$target\"" : "");
2658        # Assemble the result.
2659        return "<a href=\"$targetUrl\" $targetHtml><div class=\"button2 button\">$caption</div></a>";
2660    }
2661    
2662  =head3 Formlet  =head3 Formlet
2663    
2664  C<< my $html = SearchHelper::Formlet($caption, $url, $target, %parms); >>  C<< my $html = SearchHelper::Formlet($caption, $url, $target, %parms); >>

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.26

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3