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 This package exports the following constants:
31
32 MAXOBJECTS The maximum number of objects that can be displayed
33 per page.
34
35 SEARCH_ICON An icon to use for search links. This is deprecated.
36 Use Configuration->Search_icon instead.
37
38 FUNCTIONS
39 These functions are exported:
40
41 $offset = AceSearchOffset()
42 When the user is paging back and forth among a multi-page list of
43 results, this function returns the index of the first item to
44 display.
45
46 AceSearchTable([{hash}],$title,@contents)
47 Given a title and the HTML contents, this formats the search into a
48 table and gives it the background and foreground colors used
49 elsewhere for searches. The formatted search is then printed.
50
51 The HTML contents are usually a fill-out form. For convenience,
52 you can provide the contents in multiple parts (lines or elements)
53 and they will be concatenated together.
54
55 If the first argument is a hashref, then its contents will be
56 passed to start_form() to override the form arguments.
57
58 AceResultsTable($objects,$count,$offset,$title)
59 This subroutine formats the results of a search into a pageable
60 list and prints out the resulting HTML. The following arguments
61 are required:
62
63 $objects An array reference containing the objects to place in the
64 table.
65
66 $count The total number of objects.
67
68 $offset The offset into the array, as returned by AceSearchOffset()
69
70 $title A title for the table.
71
72 The array reference should contain no more than MAXOBJECTS objects.
73 The AceDB query should be arranged in such a way that this is the
74 case. A typical idiom is the following:
75
76 my $offset = AceSearchOffset();
77 my $query = param('query');
78 my $count;
79 my @objs = $db->fetch(-query=> $query,
80 -count => MAXOBJECTS,
81 -offset => $offset,
82 -total => \$count
83 );
84 AceResultsTable(\@objs,$count,$offset,'Here are the results');
85
87 Please report them.
88
90 Ace::Object, Ace::Browser::SiteDefs, Ace::Browsr::AceSubs, the
91 README.ACEBROWSER file.
92
94 Lincoln Stein <lstein@cshl.org>.
95
96 Copyright (c) 2001 Cold Spring Harbor Laboratory
97
98 This library is free software; you can redistribute it and/or modify it
99 under the same terms as Perl itself. See DISCLAIMER.txt for
100 disclaimers of warranty.
101
102
103
104perl v5.12.0 2006-11-01 Ace::Browser::SearchSubs(3)