1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+ package Foswiki::UI::Search
6
7UI functions for searching.
8
9=cut
10
11package Foswiki::UI::Search;
12
13use strict;
14use warnings;
15
16use Foswiki ();
17
18BEGIN {
19    if ( $Foswiki::cfg{UseLocale} ) {
20        require locale;
21        import locale();
22    }
23}
24
25=begin TML
26
27---++ StaticMethod search( $session )
28
29Deprecated - now redirects to WebSearch topic.
30
31Perform a search as dictated by CGI parameters:
32
33| *Parameter:* | *Description:* | *Default:* |
34| ="text"= | Search term. Is a keyword search, literal search or regular expression search, depending on the =type= parameter. SearchHelp has more | required |
35| =search="text"= | (Alternative to above) | N/A |
36| =web="Name"= <br /> =web="%USERSWEB%, Know"= <br /> =web="all"= | Comma-separated list of webs to search. The special word =all= means all webs that do *not* have the =NOSEARCHALL= variable set to =on= in their %WEBPREFSTOPIC%. You can specifically *exclude* webs from an =all= search using a minus sign - for example, =web="all,-Secretweb"=. | Current web |
37| =topic="%WEBPREFSTOPIC%"= <br /> =topic="*Bug"= | Limit search to topics: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. | All topics in a web |
38| =excludetopic="Web*"= <br /> =excludetopic="%HOMETOPIC%, <nop>WebChanges"= | Exclude topics from search: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. | None |
39| =type="keyword"= <br /> =type="literal"= <br /> =type="regex"= | Do a keyword search like =soap "web service" -shampoo=; a literal search like =web service=; or RegularExpression search like =soap;web service;!shampoo= | =%<nop>SEARCHVAR- DEFAULTTYPE%= [[DefaultPreferences][preferences]] setting (%SEARCHVARDEFAULTTYPE%) |
40| =scope="topic"= <br /> =scope="text"= <br /> =scope="all"= | Search topic name (title); the text (body) of topic; or all (both) | ="text"= |
41| =order="topic"= <br /> =order="created"= <br />  =order="modified"= <br /> =order="editby"= <br /> =order=<br />&nbsp;"formfield(name)"= | Sort the results of search by the topic names, topic creation time, last modified time, last editor, or named field of DataForms. The sorting is done web by web; in case you want to sort across webs, create a [[FormattedSearch][formatted]] table and sort it with TablePlugin's initsort | Sort by topic name |
42| =limit="all"= <br /> =limit="16"= | Limit the number of results returned. This is done after sorting if =order= is specified | All results |
43| =date="..."= | limits the results to those pages with latest edit time in the given TimeInterval.  | All results |
44| =reverse="on"= | Reverse the direction of the search | Ascending search |
45| =casesensitive="on"= | Case sensitive search | Ignore case |
46| =bookview="on"= | BookView search, e.g. show complete topic text | Show topic summary |
47| =nonoise="on"= | Shorthand for =nosummary="on" nosearch="on" nototal="on" zeroresults="off" noheader="on" noempty="on"= | Off |
48| =nosummary="on"= | Show topic title only | Show topic summary |
49| =nosearch="on"= | Suppress search string | Show search string |
50| =noheader="on"= | Suppress search header <br /> <span style='background: #FFB0B0;'> *Topics: Changed: By:* </span> | Show search header |
51| =nototal="on"= | Do not show number of topics found | Show number |
52| =zeroresults="off"= | Suppress all output if there are no hits | =zeroresults="on"=, displays: "Number of topics: 0" |
53| =noempty="on"= | Suppress results for webs that have no hits. | Show webs with no hits |
54| =header="..."= <br /> =format="..."= | Custom format results: see *[[FormattedSearch]]* for usage, variables &amp; examples | Results in table |
55| =expandvariables="on"= | Expand variables before applying a FormattedSearch on a search hit. Useful to show the expanded text, e.g. to show the result of a SpreadSheetPlugin =%<nop>CALC{}%= instead of the formula | Raw text |
56| =multiple="on"= | Multiple hits per topic. Each hit can be [[FormattedSearch][formatted]]. The last token is used in case of a regular expression ";" _and_ search | Only one hit per topic |
57| =nofinalnewline="on"= | If =on=, the search variable does not end in a line by itself. Any text continuing immediately after the search tag on the same line will be rendered as part of the table generated by the search, if appropriate. | =off= |
58| =separator=", "= | Line separator between hits | Newline ="$n"= |
59
60=cut
61
62sub search {
63    my $session = shift;
64
65    my $query   = $session->{request};
66    my $webName = $session->{webName};
67
68    #TODO: is WebSearch a constant?
69    my $searchUrl = $session->getScriptUrl( 1, 'view', $webName, 'WebSearch' );
70    $session->redirect( $searchUrl, 1 );    # with passthrough
71}
72
731;
74__END__
75Foswiki - The Free and Open Source Wiki, http://foswiki.org/
76
77Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
78are listed in the AUTHORS file in the root of this distribution.
79NOTE: Please extend that file, not this notice.
80
81Additional copyrights apply to some or all of the code in this
82file as follows:
83
84Copyright (C) 1999-2007 Peter Thoeny, peter@thoeny.org
85and TWiki Contributors. All Rights Reserved. TWiki Contributors
86are listed in the AUTHORS file in the root of this distribution.
87
88This program is free software; you can redistribute it and/or
89modify it under the terms of the GNU General Public License
90as published by the Free Software Foundation; either version 2
91of the License, or (at your option) any later version. For
92more details read LICENSE in the root of this distribution.
93
94This program is distributed in the hope that it will be useful,
95but WITHOUT ANY WARRANTY; without even the implied warranty of
96MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
97
98As per the GPL, removal of this notice is prohibited.
99