Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
/lib/ -> searchlib.php (source)

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

(no description)

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 518 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 5 classes

search_token:: (2 methods):
  __construct()
  search_token()

name:: (3 methods):
  sanitize()
  getValue()
  getType()

search_lexer:: (2 methods):
  __construct()
  search_lexer()

name:: (3 methods):
  sanitize()
  getValue()
  getType()

search_parser:: (15 methods):
  get_parsed_array()
  accept()
  indatefrom()
  indateto()
  intags()
  ininstance()
  inuserid()
  inusername()
  inmeta()
  inrequired()
  inexcluded()
  inquotedstring()
  plainstring()
  search_generate_text_SQL()
  search_generate_SQL()


Class: search_token  - X-Ref

Class to hold token/value pairs after they're parsed.

__construct($type,$value)   X-Ref
No description

search_token($type, $value)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

sanitize($userstring)   X-Ref
No description

getValue()   X-Ref
No description

getType()   X-Ref
No description

Class: search_lexer  - X-Ref

This class does the heavy lifting of lexing the search string into tokens.
Using a full-blown lexer is probably overkill for this application, but
might be useful for other tasks.

__construct(&$parser)   X-Ref
No description

search_lexer(&$parser)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

sanitize($userstring)   X-Ref
No description

getValue()   X-Ref
No description

getType()   X-Ref
No description

Class: search_parser  - X-Ref

This class takes care of sticking the proper token type/value pairs into
the parsed token  array.
Most functions in this class should only be called by the lexer, the
one exception being getParseArray() which returns the result.

get_parsed_array()   X-Ref
No description

accept()   X-Ref
No description

indatefrom($content)   X-Ref
No description

indateto($content)   X-Ref
No description

intags($content)   X-Ref
No description

ininstance($content)   X-Ref
No description

inuserid($content)   X-Ref
No description

inusername($content)   X-Ref
No description

inmeta($content)   X-Ref
No description

inrequired($content)   X-Ref
No description

inexcluded($content)   X-Ref
No description

inquotedstring($content)   X-Ref
No description

plainstring($content)   X-Ref
No description

search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,$userfirstnamefield, $userlastnamefield, $timefield, $instancefield)   X-Ref
Primitive function to generate a SQL string from a parse tree
using TEXT indexes. If searches aren't suitable to use TEXT
this function calls the default search_generate_SQL() one.


search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,$userfirstnamefield, $userlastnamefield, $timefield, $instancefield,$tagfields = [])   X-Ref
Primitive function to generate a SQL string from a parse tree.
Parameters:

$parsetree should be a parse tree generated by a
search_lexer/search_parser combination.
Other fields are database table names to search.