PHP Class phpbb\search\fulltext_native

Inheritance: extends phpbb\search\base
Datei anzeigen Open project: phpbb/phpbb

Protected Properties

Property Type Description
$common_words array Common words are words with length less/more than min/max length
$config phpbb\config\config Config object
$db phpbb\db\driver\driver_interface Database connection
$must_contain_ids array Post ids of posts containing words that are to be included
$must_exclude_one_ids array Post ids of posts containing atleast one word that needs to be excluded
$must_not_contain_ids array Post ids of posts containing words that should not be included
$php_ext string PHP Extension
$phpbb_root_path string Relative path to board root
$search_query string Operators are prefixed in search query and common words excluded
$stats array Associative array holding index stats
$user phpbb\user User object
$word_length array Associative array stores the min and max word length to be searched

Public Methods

Method Description
__construct ( &$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user ) Initialises the fulltext_native search backend with min/max word length
acp ( ) Returns a list of options for the ACP to display
author_search ( string $type, boolean $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, integer $topic_id, array $author_ary, string $author_name, &$id_ary, integer &$start, integer $per_page ) : boolean | integer Performs a search on an author's posts without caring about message contents. Depends on display specific params
delete_index ( $acp_module, $u_action ) Deletes all words from the index
get_common_words ( ) : array Returns the common_words array
get_name ( ) : string Returns the name of this search backend to be displayed to administrators
get_search_query ( ) : string Returns the search_query
get_word_length ( ) : array Returns the word_length array
index ( string $mode, integer $post_id, &$message, &$subject, integer $poster_id, integer $forum_id ) Updates wordlist and wordmatch tables when a message is posted or changed
index_created ( ) Returns true if both FULLTEXT indexes exist
index_remove ( $post_ids, $author_ids, $forum_ids ) Removes entries from the wordmatch table for the specified post_ids
index_stats ( ) Returns an associative array containing information about the indexes
keyword_search ( string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, integer $topic_id, array $author_ary, string $author_name, &$id_ary, integer &$start, integer $per_page ) : boolean | integer Performs a search on keywords depending on display specific params. You have to run split_keywords() first
split_keywords ( string $keywords, string $terms ) : boolean This function fills $this->search_query with the cleaned user search query
split_message ( string $text ) : array Split a text into words of a given length
tidy ( ) Tidy up indexes: Tag 'common words' and remove words no longer referenced in the match table

Protected Methods

Method Description
cleanup ( string $text, string $allowed_chars = null, string $encoding = 'utf-8' ) : string Clean up a text to remove non-alphanumeric characters
get_stats ( )

Method Details

__construct() public method

Initialises the fulltext_native search backend with min/max word length
public __construct ( &$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user )

acp() public method

Returns a list of options for the ACP to display
public acp ( )

cleanup() protected method

This method receives a UTF-8 string, normalizes and validates it, replaces all non-alphanumeric characters with strings then returns the result. Any number of "allowed chars" can be passed as a UTF-8 string in NFC.
protected cleanup ( string $text, string $allowed_chars = null, string $encoding = 'utf-8' ) : string
$text string Text to split, in UTF-8 (not normalized or sanitized)
$allowed_chars string String of special chars to allow
$encoding string Text encoding
return string Cleaned up text, only alphanumeric chars are left

delete_index() public method

Deletes all words from the index
public delete_index ( $acp_module, $u_action )

get_common_words() public method

Returns the common_words array
public get_common_words ( ) : array
return array common words that are ignored by search backend

get_name() public method

Returns the name of this search backend to be displayed to administrators
public get_name ( ) : string
return string Name

get_search_query() public method

Returns the search_query
public get_search_query ( ) : string
return string search query

get_stats() protected method

protected get_stats ( )

get_word_length() public method

Returns the word_length array
public get_word_length ( ) : array
return array min and max word length for searching

index() public method

Updates wordlist and wordmatch tables when a message is posted or changed
public index ( string $mode, integer $post_id, &$message, &$subject, integer $poster_id, integer $forum_id )
$mode string Contains the post mode: edit, post, reply, quote
$post_id integer The id of the post which is modified/created
$poster_id integer Post author's user id
$forum_id integer The id of the forum in which the post is located

index_created() public method

Returns true if both FULLTEXT indexes exist
public index_created ( )

index_remove() public method

Removes entries from the wordmatch table for the specified post_ids
public index_remove ( $post_ids, $author_ids, $forum_ids )

index_stats() public method

Returns an associative array containing information about the indexes
public index_stats ( )

split_keywords() public method

If $terms is 'any' then the words will be extracted from the search query and combined with | inside brackets. They will afterwards be treated like an standard search query. Then it analyses the query and fills the internal arrays $must_not_contain_ids, $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search()
public split_keywords ( string $keywords, string $terms ) : boolean
$keywords string contains the search query string as entered by the user
$terms string is either 'all' (use search query as entered, default words to 'must be contained in post') or 'any' (find all posts containing at least one of the given words)
return boolean false if no valid keywords were found and otherwise true

split_message() public method

The text is converted to UTF-8, cleaned up, and split. Then, words that conform to the defined length range are returned in an array. NOTE: duplicates are NOT removed from the return array
public split_message ( string $text ) : array
$text string Text to split, encoded in UTF-8
return array Array of UTF-8 words

tidy() public method

Tidy up indexes: Tag 'common words' and remove words no longer referenced in the match table
public tidy ( )

Property Details

$common_words protected_oe property

Common words are words with length less/more than min/max length
protected array $common_words
return array

$config protected_oe property

Config object
protected config,phpbb\config $config
return phpbb\config\config

$db protected_oe property

Database connection
protected driver_interface,phpbb\db\driver $db
return phpbb\db\driver\driver_interface

$must_contain_ids protected_oe property

Post ids of posts containing words that are to be included
protected array $must_contain_ids
return array

$must_exclude_one_ids protected_oe property

Post ids of posts containing atleast one word that needs to be excluded
protected array $must_exclude_one_ids
return array

$must_not_contain_ids protected_oe property

Post ids of posts containing words that should not be included
protected array $must_not_contain_ids
return array

$php_ext protected_oe property

PHP Extension
protected string $php_ext
return string

$phpbb_root_path protected_oe property

Relative path to board root
protected string $phpbb_root_path
return string

$search_query protected_oe property

Operators are prefixed in search query and common words excluded
protected string $search_query
return string

$stats protected_oe property

Associative array holding index stats
protected array $stats
return array

$user protected_oe property

User object
protected user,phpbb $user
return phpbb\user

$word_length protected_oe property

Associative array stores the min and max word length to be searched
protected array $word_length
return array