[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> search.php (summary)

DokuWiki search functions

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

Defines 11 functions

  search()
  search_qsearch()
  search_index()
  search_namespaces()
  search_media()
  search_list()
  search_pagename()
  search_allpages()
  sort_search_fulltext()
  pathID()
  search_universal()

Functions
Functions that are not part of a class:

search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural')   X-Ref
Recurse directory

This function recurses into a given base directory
and calls the supplied function for each file and directory

author: Andreas Gohr <andi@splitbrain.org>
param: array    &$data The results of the search are stored here
param: string    $base Where to start the search
param: callback  $func Callback (function name or array with object,method)
param: array     $opts option array will be given to the Callback
param: string    $dir  Current directory beyond $base
param: int       $lvl  Recursion Level
param: mixed     $sort 'natural' to use natural order sorting (default);

search_qsearch(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
Searches for pages beginning with the given query

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

search_index(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
Build the browsable index of pages

$opts['ns'] is the currently viewed namespace

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

search_namespaces(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
List all namespaces

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

search_media(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
List all mediafiles in a namespace
$opts['depth']     recursion level, 0 for all
$opts['showmsg']   shows message if invalid media id is used
$opts['skipacl']   skip acl checking
$opts['pattern']   check given pattern
$opts['hash']      add hashes to result list

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

search_list(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
This function just lists documents (for RSS namespace export)

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

search_pagename(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
Quicksearch for searching matching pagenames

$opts['query'] is the search query

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

search_allpages(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
Just lists all documents

$opts['depth']   recursion level, 0 for all
$opts['hash']    do md5 sum of content?
$opts['skipacl'] list everything regardless of ACL

author: Andreas Gohr <andi@splitbrain.org>
return: bool
param: array $data
param: string $base
param: string $file
param: string $type
param: integer $lvl
param: array $opts

sort_search_fulltext($a,$b)   X-Ref
fulltext sort

Callback sort function for use with usort to sort the data
structure created by search_fulltext. Sorts descending by count

author: Andreas Gohr <andi@splitbrain.org>
return: int
param: array $a
param: array $b

pathID($path,$keeptxt=false)   X-Ref
translates a document path to an ID

author: Andreas Gohr <andi@splitbrain.org>
return: mixed|string
param: string $path
param: bool $keeptxt

search_universal(&$data,$base,$file,$type,$lvl,$opts)   X-Ref
This is a very universal callback for the search() function, replacing
many of the former individual functions at the cost of a more complex
setup.

How the function behaves, depends on the options passed in the $opts
array, where the following settings can be used.

depth      int     recursion depth. 0 for unlimited                       (default: 0)
keeptxt    bool    keep .txt extension for IDs                            (default: false)
listfiles  bool    include files in listing                               (default: false)
listdirs   bool    include namespaces in listing                          (default: false)
pagesonly  bool    restrict files to pages                                (default: false)
skipacl    bool    do not check for READ permission                       (default: false)
sneakyacl  bool    don't recurse into nonreadable dirs                    (default: false)
hash       bool    create MD5 hash for files                              (default: false)
meta       bool    return file metadata                                   (default: false)
filematch  string  match files against this regexp                        (default: '', so accept everything)
idmatch    string  match full ID against this regexp                      (default: '', so accept everything)
dirmatch   string  match directory against this regexp when adding        (default: '', so accept everything)
nsmatch    string  match namespace against this regexp when adding        (default: '', so accept everything)
recmatch   string  match directory against this regexp when recursing     (default: '', so accept everything)
showmsg    bool    warn about non-ID files                                (default: false)
showhidden bool    show hidden files(e.g. by hidepages config) too        (default: false)
firsthead  bool    return first heading for pages                         (default: false)

author: Andreas Gohr <gohr@cosmocode.de>
return: bool if this directory should be traversed (true) or not (false)
param: array &$data  - Reference to the result data structure
param: string $base  - Base usually $conf['datadir']
param: string $file  - current file or directory relative to $base
param: string $type  - Type either 'd' for directory or 'f' for file
param: int    $lvl   - Current recursion depht
param: array  $opts  - option array as given to search()