[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.13, Fri Nov 3 00:40:16 2006 UTC revision 1.15, Fri Nov 10 22:01:36 2006 UTC
# Line 113  Line 113 
113    
114  =item 4  =item 4
115    
116  In the C<SearchSkeleton.cgi> script, add a C<use> statement for your search tool  In the C<SearchSkeleton.cgi> script and add a C<use> statement for your search tool.
 and then put the class name in the C<@advancedClasses> list.  
117    
118  =back  =back
119    
# Line 177  Line 176 
176    
177  =back  =back
178    
179    If you are doing a feature search, you can also change the list of feature
180    columns displayed and their display order by overriding
181    L</DefaultFeatureColumns>.
182    
183  Finally, when generating the code for your controls, be sure to use any incoming  Finally, when generating the code for your controls, be sure to use any incoming
184  query parameters as default values so that the search request is persistent.  query parameters as default values so that the search request is persistent.
185    
# Line 222  Line 225 
225      }      }
226    
227  A Find method is of course much more complicated than generating a form, and there  A Find method is of course much more complicated than generating a form, and there
228  are variations on the above them. For example, you could eschew feature filtering  are variations on the above theme. For example, you could eschew feature filtering
229  entirely in favor of your own custom filtering, you could include extra columns  entirely in favor of your own custom filtering, you could include extra columns
230  in the output, or you could search for something that's not a feature at all. The  in the output, or you could search for something that's not a feature at all. The
231  above code is just a loose framework.  above code is just a loose framework.
# Line 654  Line 657 
657      my $extraCols = $fd->ExtraCols();      my $extraCols = $fd->ExtraCols();
658      # Check for a first-call situation.      # Check for a first-call situation.
659      if (! defined $self->{cols}) {      if (! defined $self->{cols}) {
660          # Here we need to set up the column information. Start with the defaults.          Trace("Setting up the columns.") if T(3);
661          $self->{cols} = $self->DefaultFeatureColumns();          # Here we need to set up the column information. Start with the extras,
662          # Add any additional columns requested by the feature filter.          # sorted by column name.
663          push @{$self->{cols}}, FeatureQuery::AdditionalColumns($self);          my @colNames = ();
         # Append the extras, sorted by column name.  
664          for my $col (sort keys %{$extraCols}) {          for my $col (sort keys %{$extraCols}) {
665              push @{$self->{cols}}, "X=$col";              push @colNames, "X=$col";
666          }          }
667            # Add the default columns.
668            push @colNames, $self->DefaultFeatureColumns();
669            # Add any additional columns requested by the feature filter.
670            push @colNames, FeatureQuery::AdditionalColumns($self);
671            # Save the full list.
672            $self->{cols} = \@colNames;
673          # 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
674          # output.          # output.
675          $self->WriteColumnHeaders(map { $self->FeatureColumnTitle($_) } @{$self->{cols}});          $self->WriteColumnHeaders(map { $self->FeatureColumnTitle($_) } @{$self->{cols}});
# Line 1211  Line 1219 
1219      push @lines, "</SELECT>";      push @lines, "</SELECT>";
1220      # Check for multiple selection.      # Check for multiple selection.
1221      if ($multiple) {      if ($multiple) {
1222          # Since multi-select is on, we set up some buttons to set and clear selections.          # Multi-select is on, so we need to add some selection helpers. First is
1223            # the search box. This allows the user to type text and have all genomes containing
1224            # the text selected automatically.
1225            my $searchThingName = "${menuName}_SearchThing";
1226            push @lines, "<br>Select genomes containing <INPUT type=\"text\" name=\"$searchThingName\" " .
1227                         "size=\"30\" onBlur=\"selectViaSearch($menuName, $searchThingName); $showSelect\" />";
1228            # Next are the buttons to set and clear selections.
1229          push @lines, "<br />";          push @lines, "<br />";
         push @lines, "<INPUT type=\"button\" name=\"SelectAll\" class=\"bigButton\" value=\"Select All\" onClick=\"selectAll($menuName); $showSelect\" />";  
1230          push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll($menuName); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll($menuName); $showSelect\" />";
1231            push @lines, "<INPUT type=\"button\" name=\"SelectAll\" class=\"bigButton\" value=\"Select All\" onClick=\"selectAll($menuName); $showSelect\" />";
1232          push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome($menuName, $nmpdrCount, true); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome($menuName, $nmpdrCount, true); $showSelect\" />";
1233          push @lines, "<INPUT type=\"button\" name=\"OtherOnly\" class=\"bigButton\" value=\"Select Supporting\" onClick=\"selectSome($menuName, $nmpdrCount, false); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"OtherOnly\" class=\"bigButton\" value=\"Select Supporting\" onClick=\"selectSome($menuName, $nmpdrCount, false); $showSelect\" />";
         # Now add the search box. This allows the user to type text and have all genomes containing  
         # the text selected automatically.  
         my $searchThingName = "${menuName}_SearchThing";  
         push @lines, "<br>Select genomes containing <INPUT type=\"text\" name=\"$searchThingName\" size=\"30\" />&nbsp;" .  
                      "<INPUT type=\"button\" name=\"Select\" class=\"button\" value=\"Search\" onClick=\"selectViaSearch($menuName, $searchThingName); $showSelect\" />";  
1234          # Add the status display, too.          # Add the status display, too.
1235          push @lines, "<DIV id=\"$divID\" class=\"selectStatus\"></DIV>";          push @lines, "<DIV id=\"$divID\" class=\"selectStatus\"></DIV>";
1236          # Queue to update the status display when the form loads. We need to modify the show statement          # Queue to update the status display when the form loads. We need to modify the show statement
# Line 1663  Line 1672 
1672  Return a list of advanced class names. This list is used to generate the directory  Return a list of advanced class names. This list is used to generate the directory
1673  of available searches on the search page.  of available searches on the search page.
1674    
1675  The reason we have to convert the list from a string is that the B<NMPDRSetup.pl>  We use the %INC variable to accomplish this.
 script is only able to insert strings into the generated B<FIG_Config> file.  
1676    
1677  =cut  =cut
1678    
1679  sub AdvancedClassList {  sub AdvancedClassList {
1680      return split /\s+/, $FIG_Config::advanced_classes;      my @retVal = map { $_ =~ /^SH(\w+)\.pm/; $1 } grep { $_ =~ /^SH/ } keys %INC;
1681        return @retVal;
1682  }  }
1683    
1684  =head2 Feature Column Methods  =head2 Feature Column Methods
# Line 1692  Line 1701 
1701    
1702  =head3 DefaultFeatureColumns  =head3 DefaultFeatureColumns
1703    
1704  C<< my $colNames = $shelp->DefaultFeatureColumns(); >>  C<< my @colNames = $shelp->DefaultFeatureColumns(); >>
1705    
1706  Return a reference to a list of the default feature column identifiers. These  Return a list of the default feature column identifiers. These identifiers can
1707  identifiers can be passed to L</FeatureColumnTitle> and L</FeatureColumnValue> in  be passed to L</FeatureColumnTitle> and L</FeatureColumnValue> in order to
1708  order to produce the column titles and row values.  produce the column titles and row values.
1709    
1710  =cut  =cut
1711    
# Line 1704  Line 1713 
1713      # Get the parameters.      # Get the parameters.
1714      my ($self) = @_;      my ($self) = @_;
1715      # Return the result.      # Return the result.
1716      return ['orgName', 'function', 'gblink', 'protlink',      return qw(orgName function gblink protlink);
             FeatureQuery::AdditionalColumns($self)];  
1717  }  }
1718    
1719  =head3 FeatureColumnTitle  =head3 FeatureColumnTitle
# Line 1750  Line 1758 
1758      } elsif ($colName =~ /^keyword:(.+)$/) {      } elsif ($colName =~ /^keyword:(.+)$/) {
1759          $retVal = ucfirst $1;          $retVal = ucfirst $1;
1760      } elsif ($colName eq 'orgName') {      } elsif ($colName eq 'orgName') {
1761          $retVal = "Name";          $retVal = "Feature Name";
1762      } elsif ($colName eq 'protlink') {      } elsif ($colName eq 'protlink') {
1763          $retVal = "NMPDR Protein Page";          $retVal = "NMPDR Protein Page";
1764      } elsif ($colName eq 'subsystem') {      } elsif ($colName eq 'subsystem') {
# Line 1838  Line 1846 
1846      } elsif ($colName =~ /^keyword:(.+)$/) {      } elsif ($colName =~ /^keyword:(.+)$/) {
1847          # Here we want keyword-related values. This is also expensive, so          # Here we want keyword-related values. This is also expensive, so
1848          # we compute them when the row is displayed.          # we compute them when the row is displayed.
1849          $retVal = "%%colName=$fid";          $retVal = "%%$colName=$fid";
1850      } elsif ($colName eq 'orgName') {      } elsif ($colName eq 'orgName') {
1851          # Here we want the formatted organism name and feature number.          # Here we want the formatted organism name and feature number.
1852          $retVal = $self->FeatureName($fid);          $retVal = $self->FeatureName($fid);
# Line 1890  Line 1898 
1898      # Get the Sprout and CGI objects.      # Get the Sprout and CGI objects.
1899      my $sprout = $self->DB();      my $sprout = $self->DB();
1900      my $cgi = $self->Q();      my $cgi = $self->Q();
1901        Trace("Runtime column $type with text \"$text\" found.") if T(4);
1902      # Separate the text into a type and data.      # Separate the text into a type and data.
1903      if ($type eq 'alias') {      if ($type eq 'alias') {
1904          # Here the caller wants external alias links for a feature. The text          # Here the caller wants external alias links for a feature. The text

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3