[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> fulltext.php (summary)

DokuWiki fulltextsearch functions using the index

Author: Andreas Gohr
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
File Size: 933 lines (31 kb)
Included or required: 2 times
Referenced: 0 times
Includes or requires: 0 files

Defines 18 functions

  ft_pageSearch()
  _ft_pageSearch()
  ft_backlinks()
  ft_mediause()
  ft_pageLookup()
  _ft_pageLookup()
  _ft_filterResultsByTime()
  _ft_pageLookupTitleCompare()
  ft_pagesorter()
  ft_pagemtimesorter()
  ft_snippet()
  ft_snippet_re_preprocess()
  ft_resultCombine()
  ft_resultUnite()
  ft_resultComplement()
  ft_queryParser()
  ft_termParser()
  ft_queryUnparser_simple()

Functions
Functions that are not part of a class:

ft_pageSearch($query,&$highlight, $sort = null, $after = null, $before = null)   X-Ref
The fulltext search

Returns a list of matching documents for the given query

refactored into ft_pageSearch(), _ft_pageSearch() and trigger_event()

param: string     $query
param: array      $highlight
param: string     $sort
param: int|string $after  only show results with mtime after this date, accepts timestap or strtotime arguments
param: int|string $before only show results with mtime before this date, accepts timestap or strtotime arguments
return: array

_ft_pageSearch(&$data)   X-Ref
Returns a list of matching documents for the given query

author: Andreas Gohr <andi@splitbrain.org>
author: Kazutaka Miyasaka <kazmiya@gmail.com>
param: array $data event data
return: array matching documents

ft_backlinks($id, $ignore_perms = false)   X-Ref
Returns the backlinks for a given page

Uses the metadata index.

param: string $id           The id for which links shall be returned
param: bool   $ignore_perms Ignore the fact that pages are hidden or read-protected
return: array The pages that contain links to the given page

ft_mediause($id, $ignore_perms = false)   X-Ref
Returns the pages that use a given media file

Uses the relation media metadata property and the metadata index.

Note that before 2013-07-31 the second parameter was the maximum number of results and
permissions were ignored. That's why the parameter is now checked to be explicitely set
to true (with type bool) in order to be compatible with older uses of the function.

param: string $id           The media id to look for
param: bool   $ignore_perms Ignore hidden pages and acls (optional, default: false)
return: array A list of pages that use the given media file

ft_pageLookup($id, $in_ns=false, $in_title=false, $after = null, $before = null)   X-Ref
Quicksearch for pagenames

By default it only matches the pagename and ignores the
namespace. This can be changed with the second parameter.
The third parameter allows to search in titles as well.

The function always returns titles as well

author: Andreas Gohr <andi@splitbrain.org>
author: Adrian Lang <lang@cosmocode.de>
param: string     $id       page id
param: bool       $in_ns    match against namespace as well?
param: bool       $in_title search in title?
param: int|string $after    only show results with mtime after this date, accepts timestap or strtotime arguments
param: int|string $before   only show results with mtime before this date, accepts timestap or strtotime arguments
triggers: SEARCH_QUERY_PAGELOOKUP
return: string[]

_ft_pageLookup(&$data)   X-Ref
Returns list of pages as array(pageid => First Heading)

param: array &$data event data
return: string[]

_ft_filterResultsByTime(array $results, $after, $before)   X-Ref

param: array      $results search results in the form pageid => value
param: int|string $after   only returns results with mtime after this date, accepts timestap or strtotime arguments
param: int|string $before  only returns results with mtime after this date, accepts timestap or strtotime arguments
return: array

_ft_pageLookupTitleCompare($search, $title)   X-Ref
Tiny helper function for comparing the searched title with the title
from the search index. This function is a wrapper around stripos with
adapted argument order and return value.

param: string $search searched title
param: string $title  title from index
return: bool

ft_pagesorter($a, $b)   X-Ref
Sort pages based on their namespace level first, then on their string
values. This makes higher hierarchy pages rank higher than lower hierarchy
pages.

param: string $a
param: string $b
return: int Returns < 0 if $a is less than $b; > 0 if $a is greater than $b, and 0 if they are equal.

ft_pagemtimesorter($a, $b)   X-Ref
Sort pages by their mtime, from newest to oldest

param: string $a
param: string $b
return: int Returns < 0 if $a is newer than $b, > 0 if $b is newer than $a and 0 if they are of the same age

ft_snippet($id,$highlight)   X-Ref
Creates a snippet extract

author: Andreas Gohr <andi@splitbrain.org>
param: string $id page id
param: array $highlight
triggers: FULLTEXT_SNIPPET_CREATE
return: mixed

ft_snippet_re_preprocess($term)   X-Ref
Wraps a search term in regex boundary checks.

param: string $term
return: string

ft_resultCombine($args)   X-Ref
Combine found documents and sum up their scores

This function is used to combine searched words with a logical
AND. Only documents available in all arrays are returned.

based upon PEAR's PHP_Compat function for array_intersect_key()

param: array $args An array of page arrays
return: array

ft_resultUnite($args)   X-Ref
Unites found documents and sum up their scores

based upon ft_resultCombine() function

author: Kazutaka Miyasaka <kazmiya@gmail.com>
param: array $args An array of page arrays
return: array

ft_resultComplement($args)   X-Ref
Computes the difference of documents using page id for comparison

nearly identical to PHP5's array_diff_key()

author: Kazutaka Miyasaka <kazmiya@gmail.com>
param: array $args An array of page arrays
return: array

ft_queryParser($Indexer, $query)   X-Ref
Parses a search query and builds an array of search formulas

author: Andreas Gohr <andi@splitbrain.org>
author: Kazutaka Miyasaka <kazmiya@gmail.com>
param: Doku_Indexer $Indexer
param: string $query search query
return: array of search formulas

ft_termParser($Indexer, $term, $consider_asian = true, $phrase_mode = false)   X-Ref
Transforms given search term into intermediate representation

This function is used in ft_queryParser() and not for general purpose use.

author: Kazutaka Miyasaka <kazmiya@gmail.com>
param: Doku_Indexer $Indexer
param: string       $term
param: bool         $consider_asian
param: bool         $phrase_mode
return: string

ft_queryUnparser_simple(array $and, array $not, array $phrases, array $ns, array $notns)   X-Ref
Recreate a search query string based on parsed parts, doesn't support negated phrases and `OR` searches

param: array $and
param: array $not
param: array $phrases
param: array $ns
param: array $notns
return: string