Adding new Searches

From DictyWiki

Jump to: navigation, search
  1. write a search class in dicty::UI::Search folder
  2. add class name to @dicty::UI::Search::quicksearch_searches array

NOTE: Implement a 'redirect_link' method in your subclass if you want to redirect to another page for a single result.

That't it!

dicty::UI::Search:: classes

These classes inherit from the dicty::UI::Search class which contains methods for paging the results and displaying a summary. Your dicty::UI::Search:: class implements class specific methods that link the class to methods in dicty::Search that return iterators and counts. It also defines a method 'results_table' that writes an html table summarizing the search results.

=head1 NAME

   dicty::UI::Search::XXX - DESCRIPTION of Object


   This class implements a dicty::UI::Search interface for XXX


   Searches for XXX.  Table output includes a, b, and c and links to the 

=head1 AUTHOR - Your Name

  Your Name your@email


   The rest of the documentation details each of the object
   methods. Internal methods are usually preceded with a _


package dicty::UI::Search::XXX;
use strict;
use CGI qw/:all :html3/;

use dicty::UI::Search;

our @ISA;
@ISA = qw ( dicty::UI::Search );

=head2 summary_text

 Title    : summary_text
 Function : returns text string to be used in summary
 Example  : for a search that displays '200 Gene Product Names'
          : for the summary, summary_text should be 'Gene Product Names'
 Returns  : string
 Args     : none


sub summary_text {
    my ( $self, $obj ) = @_;
    return "XXX";

=head2 redirect_link

 Title    : redirect_link
 Function : url linking to detail page.  Will redirect here if defined and there is only one result
 Returns  : string
 Args     : XXX object


sub redirect_link {
    my ( $self, $obj ) = @_;
    return undef;

=head2 _get_results

 Title    : _get_results
 Function : performs results on query, called by lazy accessor 'results'
 Returns  : results iterator
 Args     : none


sub _get_results {
    my ( $self, $obj ) = @_;

    my $itr = dicty::Search::XXX->Search_by_name_on_XXX( $self->query() );
    return $self->results( $itr );

=head2 _get_count

 Title    : _get_count
 Function : performs count on query, called by lazy accessor 'count'
 Returns  : an integer count
 Args     : none


sub _get_count {
    my ( $self, $obj ) = @_;

    my $count = dicty::Search::XXX->Count_by_XXX( $self->query() );

    return $self->count($count);

=head2 result_table

 Title    : result_table
 Function : writes html table of results, results are paged
          : writes summary including total results,
          : page being displayed, total number of pages
          : and then result table
 Returns  : html string for a table of results and summary of paging info
 Args     : integer: page of results to display


sub result_table {
    my ( $self, $page ) = @_;

    return if ( $self->count() == 0 );

    my @results      = $self->page_results($page);

    my $table = qq{


    # to highlight a field with query:
    # $field  = $self->highlight_query( -text => $field );

    # to highlight a field with query and add soft breaks:
    # $field  = $self->highlight_query(  -text => $field, -soft_breaks => 'true' );

    # to simply soft break a field:
    # $field  = dicty::MiscUtility::soft_breaks( $field );

    return $table;



Personal tools