(no commit message)
[openafs-wiki.git] / TWiki / TWikiSearchDotPm.mdwn
1 # <a name="Package &lt;code&gt;TWiki::Search="></a> Package =TWiki::Search
2
3 This module implements all the search functionality.
4
5 <div>
6   <ul>
7     <li><a href="#Package =TWiki::Search="> Package TWiki::Search</a><ul>
8         <li><a href="#ClassMethod <strong>new</strong> ($session)"> ClassMethod new <tt>($session)</tt></a></li>
9         <li><a href="#ObjectMethod <strong>finish</strong> ()"> ObjectMethod finish <tt>()</tt></a></li>
10         <li><a href="#StaticMethod <strong>get_TextPattern</strong> ("> StaticMethod getTextPattern <tt>($text,$pattern)</tt></a></li>
11         <li><a href="#ObjectMethod <strong>searchWeb</strong> (...)"> ObjectMethod searchWeb <tt>(...)</tt></a></li>
12         <li><a href="#StaticMethod *display_FormField*"> StaticMethod displayFormField <tt>($meta,$args) -&gt; $text</tt></a></li>
13       </ul>
14     </li>
15   </ul>
16 </div>
17
18 ## <a name="ClassMethod &lt;strong&gt;new&lt;/strong&gt; ($session)"></a> [[ClassMethod]] **new** `($session)`
19
20 Constructor for the singleton Search engine object.
21
22 ## <a name="ObjectMethod &lt;strong&gt;finish&lt;/strong&gt; ()"></a> [[ObjectMethod]] **finish** `()`
23
24 Break circular references.
25
26 ## <a name="StaticMethod &lt;strong&gt;get_TextPattern&lt;/strong&gt; ("></a> [[StaticMethod]] **getTextPattern** `($text,$pattern)`
27
28 Sanitise search pattern - currently used for [[FormattedSearch]] only
29
30 ## <a name="ObjectMethod &lt;strong&gt;searchWeb&lt;/strong&gt; (...)"></a> [[ObjectMethod]] **searchWeb** `(...)`
31
32 Search one or more webs according to the parameters.
33
34 If `_callback` is set, that means the caller wants results as soon as they are ready. =\_callback\_ should be set to a reference to a function which takes `_cbdata` as the first parameter and remaining parameters the same as 'print'.
35
36 If `_callback` is set, the result is always undef. Otherwise the result is a string containing the rendered search results.
37
38 If `inline` is set, then the results are **not** decorated with the search template head and tail blocks.
39
40 The function will throw Error::Simple if it encounters any problems with the syntax of the search string.
41
42 Note: If `format` is set, `template` will be ignored.
43
44 Note: For legacy, if `regex` is defined, it will force type='regex'
45
46 If `type="word"` it will be changed to `type="keyword"` with `wordBoundaries=1`. This will be used for searching with scope="text" only, because scope="topic" will do a Perl search on topic names.
47
48 SMELL: If `template` is defined `bookview` will not work
49
50 SMELL: it seems that if you define `_callback` or `inline` then you are responsible for converting the TML to HTML yourself!
51
52 FIXME: `callback` cannot work with format parameter (consider format='| $topic |'
53
54 ## <a name="StaticMethod &lt;strong&gt;display_FormField*"></a> [[StaticMethod]] \*displayFormField `($meta,$args) -> $text`
55
56 Parse the arguments to a $formfield specification and extract the relevant formfield from the given meta data.
57
58 - `args` string containing name of form field
59
60 In addition to the name of a field `args` can be appended with a commas followed by a string format (\\d+)([,\\s\*]\\.\\.\\.)?). This supports the formatted search function $formfield and is used to shorten the returned string or a hyphenated string.