1 # Copyright (C) 2006, 2007, 2008 Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/search-list.pl">search-list.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Search_List_Extension">Search List Extension</a></p>';
21 push(@MyRules, \
&SearchListRule
);
24 if ($bol && /\G(<list (.*?)>)/cgis) {
26 Clean
(CloseHtmlEnvironments
());
28 my ($oldpos, $old_) = (pos, $_);
29 my $original = $OpenPageName;
34 local ($OpenPageName, %Page);
36 foreach my $id (SearchTitleAndBody
($term)) {
37 $hash{$id} = 1 unless $id eq $original; # skip the page with the query
39 my @found = keys %hash;
40 if (defined &PageSort
) {
41 @found = sort PageSort
@found;
43 @found = sort(@found);
45 @found = map { $q->li(GetPageLink
($_)) } @found;
46 print $q->start_div({-class=>'search list'}),
47 $q->ul(@found), $q->end_div;
48 Clean
(AddHtmlEnvironment
('p')); # if dirty block is looked at later, this will disappear
49 ($_, pos) = ($old_, $oldpos); # restore \G (assignment order matters!)
56 # Add a new action list
58 $Action{list
} = \
&DoList
;
62 my $match = GetParam
('match', '');
63 my $search = GetParam
('search', '');
64 ReportError
(T
('The search parameter is missing.')) unless $match or $search;
65 print GetHeader
('', Ts
('Page list for %s', $match||$search), '');
66 local (%Page, $OpenPageName);
68 foreach my $id (grep(/$match/, $search
69 ? SearchTitleAndBody
($search)
73 my @found = keys %hash;
74 if (defined &PageSort
) {
75 @found = sort PageSort
@found;
77 @found = sort(@found);
79 @found = map { $q->li(GetPageLink
($_)) } @found;
80 print $q->start_div({-class=>'search list'}),
81 $q->ul(@found), $q->end_div;