1Ace::Browser::SearchSubUss(e3r)Contributed Perl DocumentAactei:o:nBrowser::SearchSubs(3)
2
3
4
6 Ace::Browser::SearchSubs - Subroutines for AceBrowser search scripts
7
9 use Ace;
10 use Ace::Browser::AceSubs;
11 use Ace::Browser::SearchSubs;
12 use CGI qw(:standard);
13
14 my $form = p(start_form,
15 textfield(-name=>'query'),
16 end_form);
17 AceSearchTable('Search for stuff',$form);
18 ...
19
20 my $query = param('query');
21 my $offset = AceSearchOffset;
22 my ($objects,$count) = do_search($query,$offset);
23 AceResultsTable($objects,$count,$offset,'Here are results');
24
26 Ace::Browser::SearchSubs exports a set of constants and subroutines
27 that are useful for creating AceBrowser search scripts.
28
29 CONSTANTS
30
31 This package exports the following constants:
32
33 MAXOBJECTS The maximum number of objects that can be displayed
34 per page.
35
36 SEARCH_ICON An icon to use for search links. This is deprecated.
37 Use Configuration->Search_icon instead.
38
39 FUNCTIONS
40
41 These functions are exported:
42
43 $offset = AceSearchOffset()
44 When the user is paging back and forth among a multi-page list of
45 results, this function returns the index of the first item to dis‐
46 play.
47
48 AceSearchTable([{hash}],$title,@contents)
49 Given a title and the HTML contents, this formats the search into a
50 table and gives it the background and foreground colors used else‐
51 where for searches. The formatted search is then printed.
52
53 The HTML contents are usually a fill-out form. For convenience,
54 you can provide the contents in multiple parts (lines or elements)
55 and they will be concatenated together.
56
57 If the first argument is a hashref, then its contents will be
58 passed to start_form() to override the form arguments.
59
60 AceResultsTable($objects,$count,$offset,$title)
61 This subroutine formats the results of a search into a pageable
62 list and prints out the resulting HTML. The following arguments
63 are required:
64
65 $objects An array reference containing the objects to place in the
66 table.
67
68 $count The total number of objects.
69
70 $offset The offset into the array, as returned by AceSearchOffset()
71
72 $title A title for the table.
73
74 The array reference should contain no more than MAXOBJECTS objects.
75 The AceDB query should be arranged in such a way that this is the
76 case. A typical idiom is the following:
77
78 my $offset = AceSearchOffset();
79 my $query = param('query');
80 my $count;
81 my @objs = $db->fetch(-query=> $query,
82 -count => MAXOBJECTS,
83 -offset => $offset,
84 -total => \$count
85 );
86 AceResultsTable(\@objs,$count,$offset,'Here are the results');
87
89 Please report them.
90
92 Ace::Object, Ace::Browser::SiteDefs, Ace::Browsr::AceSubs, the
93 README.ACEBROWSER file.
94
96 Lincoln Stein <lstein@cshl.org>.
97
98 Copyright (c) 2001 Cold Spring Harbor Laboratory
99
100 This library is free software; you can redistribute it and/or modify it
101 under the same terms as Perl itself. See DISCLAIMER.txt for dis‐
102 claimers of warranty.
103
104
105
106perl v5.8.8 2001-02-20 Ace::Browser::SearchSubs(3)