data/TWiki/TWikiSearchDotPm.txt
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
colas@0
     1
---+ Package =TWiki::Search=
colas@0
     2
colas@0
     3
This module implements all the search functionality.
colas@0
     4
colas@0
     5
colas@0
     6
%TOC%
colas@0
     7
colas@0
     8
---++ ClassMethod *new* <tt>($session)</tt>
colas@0
     9
colas@0
    10
Constructor for the singleton Search engine object.
colas@0
    11
colas@0
    12
colas@0
    13
colas@0
    14
---++ ObjectMethod *finish* <tt>()</tt>
colas@0
    15
Break circular references.
colas@0
    16
colas@0
    17
colas@0
    18
colas@0
    19
---++ StaticMethod *getTextPattern* <tt>($text,$pattern)</tt>
colas@0
    20
colas@0
    21
Sanitise search pattern - currently used for FormattedSearch only
colas@0
    22
colas@0
    23
colas@0
    24
colas@0
    25
---++ ObjectMethod *searchWeb* <tt>(...)</tt>
colas@0
    26
colas@0
    27
Search one or more webs according to the parameters.
colas@0
    28
colas@0
    29
If =_callback= is set, that means the caller wants results as
colas@0
    30
soon as they are ready. =_callback_ should be set to a reference
colas@0
    31
to a function which takes =_cbdata= as the first parameter and
colas@0
    32
remaining parameters the same as 'print'.
colas@0
    33
colas@0
    34
If =_callback= is set, the result is always undef. Otherwise the
colas@0
    35
result is a string containing the rendered search results.
colas@0
    36
colas@0
    37
If =inline= is set, then the results are *not* decorated with
colas@0
    38
the search template head and tail blocks.
colas@0
    39
colas@0
    40
The function will throw Error::Simple if it encounters any problems with the
colas@0
    41
syntax of the search string.
colas@0
    42
colas@0
    43
Note: If =format= is set, =template= will be ignored.
colas@0
    44
colas@0
    45
Note: For legacy, if =regex= is defined, it will force type='regex'
colas@0
    46
colas@0
    47
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.
colas@0
    48
colas@0
    49
SMELL: If =template= is defined =bookview= will not work
colas@0
    50
colas@0
    51
SMELL: it seems that if you define =_callback= or =inline= then you are
colas@0
    52
	responsible for converting the TML to HTML yourself!
colas@0
    53
	
colas@0
    54
FIXME: =callback= cannot work with format parameter (consider format='| $topic |'
colas@0
    55
colas@0
    56
colas@0
    57
colas@0
    58
---++ StaticMethod *displayFormField* <tt>($meta,$args) -> $text</tt>
colas@0
    59
colas@0
    60
Parse the arguments to a $formfield specification and extract
colas@0
    61
the relevant formfield from the given meta data.
colas@0
    62
colas@0
    63
   * =args= string containing name of form field
colas@0
    64
colas@0
    65
In addition to the name of a field =args= can be appended with a commas
colas@0
    66
followed by a string format (\d+)([,\s*]\.\.\.)?). This supports the formatted
colas@0
    67
search function $formfield and is used to shorten the returned string or a 
colas@0
    68
hyphenated string.
colas@0
    69
colas@0
    70