DataTables
in package
Tags
Table of Contents
Constants
- QUICK_SEARCH_MAX_FEATURES : mixed = 50000
- Maximum number of features of a layer evaluated by QGIS Server for the quick search.
- QUICK_SEARCH_MAX_LABELS : mixed = 500
- Maximum number of labels found in the source layer of a value relation or of a relation reference, for the quick search. Above it, the column is not searched.
- QUICK_SEARCH_MAX_WORDS : mixed = 3
- Maximum number of words of a quick search, the next ones are ignored.
- PG_NOT_SEARCHED_TYPES : mixed = array('bool', 'bytea', 'geometry', 'geography',...
- PostgreSQL types which are not searched: booleans, binary data, geometries, documents.
- PG_TEXT_TYPES : mixed = array('varchar', 'text', 'bpchar', 'char', 'nam...
- PostgreSQL types of text values, searched directly with ILIKE.
Methods
- buildLabeledColumnExpression() : string
- Build the condition of the quick search on a column with labels.
- buildLabelSearchExpression() : string
- Build the expression filter to get the labels of a source layer matching the quick search.
- buildQuickSearchExpression() : string
- Build the expression filter of a quick search on several columns.
- convertCriteriaToExpression() : string
- convertSearchToExpression() : string
- getLabelCodesMatchingWord() : array<string|int, string>
- Get the codes whose label contains a word of the quick search.
- getQuickSearchWords() : array<string|int, string>
- Get the words of a quick search.
- isQuickSearchDbType() : bool
- Check if a PostgreSQL column can be searched by the quick search.
- isQuickSearchEnabled() : bool
- Check if the quick search is enabled for a layer, depending on its size.
- normalizeQuickSearchText() : string
- Remove the accents of a text and convert it to lower case.
Constants
QUICK_SEARCH_MAX_FEATURES
Maximum number of features of a layer evaluated by QGIS Server for the quick search.
public
mixed
QUICK_SEARCH_MAX_FEATURES
= 50000
Above it, the quick search is disabled: QGIS Server would read all the features. The layers queried as SQL by Lizmap are not limited.
QUICK_SEARCH_MAX_LABELS
Maximum number of labels found in the source layer of a value relation or of a relation reference, for the quick search. Above it, the column is not searched.
public
mixed
QUICK_SEARCH_MAX_LABELS
= 500
QUICK_SEARCH_MAX_WORDS
Maximum number of words of a quick search, the next ones are ignored.
public
mixed
QUICK_SEARCH_MAX_WORDS
= 3
PG_NOT_SEARCHED_TYPES
PostgreSQL types which are not searched: booleans, binary data, geometries, documents.
protected
mixed
PG_NOT_SEARCHED_TYPES
= array('bool', 'bytea', 'geometry', 'geography', 'raster', 'box', 'box2d', 'box3d', 'json', 'jsonb', 'xml', 'tsvector', 'tsquery', 'oid')
The other types, e.g. numbers, dates, uuid or arrays, are converted to text with concat().
PG_TEXT_TYPES
PostgreSQL types of text values, searched directly with ILIKE.
protected
mixed
PG_TEXT_TYPES
= array('varchar', 'text', 'bpchar', 'char', 'name', 'citext')
The types are given as returned by Jelix, without the digits, e.g. int for int4.
Methods
buildLabeledColumnExpression()
Build the condition of the quick search on a column with labels.
public
static buildLabeledColumnExpression(string $quotedColumn, array<string|int, string> $codes[, null|string $dbFieldType = null ]) : string
The column must have one of the given codes. When run as SQL, the non text columns are converted to text with concat(), to compare them safely with the codes.
Parameters
- $quotedColumn : string
-
the quoted name of the column
- $codes : array<string|int, string>
-
the codes of the labels matching the search
- $dbFieldType : null|string = null
-
the PostgreSQL type of the column, null if the expression is evaluated by QGIS Server
Return values
string —the condition, or an empty string if there is no code
buildLabelSearchExpression()
Build the expression filter to get the labels of a source layer matching the quick search.
public
static buildLabelSearchExpression(string $search, string $labelField[, null|array<string, string> $dbFieldTypes = null ][, null|string $unaccentFunction = null ]) : string
The source layer is the layer of a value relation or of a relation reference. The label must contain at least one of the words: the conditions are combined with OR.
Parameters
- $search : string
-
the value typed by the user
- $labelField : string
-
the name of the label field
- $dbFieldTypes : null|array<string, string> = null
-
the PostgreSQL type of each field, null if the expression is evaluated by QGIS Server
- $unaccentFunction : null|string = null
-
the PostgreSQL function removing accents, or null
Return values
string —the expression, or an empty string if there is nothing to search
buildQuickSearchExpression()
Build the expression filter of a quick search on several columns.
public
static buildQuickSearchExpression(string $search, array<string|int, string> $columns[, null|array<string, string> $dbFieldTypes = null ][, null|string $unaccentFunction = null ][, array<string, array<string|int, mixed>> $labeledValues = array() ]) : string
Each word must be found in at least one of the columns: the conditions on the columns are combined with OR, and the conditions on the words with AND.
Without the database types, the expression is evaluated by QGIS Server, which converts any value to text for ILIKE: every column is searched with ILIKE. With the PostgreSQL types, the expression is run as SQL by Lizmap: the text columns are searched with ILIKE, optionally without accents, the other columns are converted to text with concat(), and booleans, geometries or binary data are not searched.
The columns with labels, e.g. a value map, are searched in the labels displayed in the table: the codes of the matching labels are searched with IN.
Parameters
- $search : string
-
the value typed by the user
- $columns : array<string|int, string>
-
the names of the searched columns
- $dbFieldTypes : null|array<string, string> = null
-
the PostgreSQL type of each column, null if the expression is evaluated by QGIS Server
- $unaccentFunction : null|string = null
-
the PostgreSQL function removing accents, unaccent or f_unaccent, or null
- $labeledValues : array<string, array<string|int, mixed>> = array()
-
the labels of the columns with labels, as an array of labels by code for each column
Return values
string —the expression, or an empty string if there is nothing to search
convertCriteriaToExpression()
public
static convertCriteriaToExpression(DTCriteria $criteria) : string
Parameters
- $criteria : DTCriteria
-
A search criteria provided by DataTables search builder
Return values
string —the expression build against criteria. If the criteria is not valid, return an empty string.
convertSearchToExpression()
public
static convertSearchToExpression(DTSearchBuilder $search[, int $depth = 0 ]) : string
Parameters
- $search : DTSearchBuilder
-
A search provided by DataTables
- $depth : int = 0
-
Depth level
Return values
stringgetLabelCodesMatchingWord()
Get the codes whose label contains a word of the quick search.
public
static getLabelCodesMatchingWord(array<string|int, mixed> $labels, string $word) : array<string|int, string>
The search is case and accent insensitive. As in a LIKE pattern, the wildcards % and _ of the word match any characters and any character. The label of the NULL value of a value map is ignored: it is not displayed in the table.
Parameters
- $labels : array<string|int, mixed>
-
the labels, indexed by code
- $word : string
-
a word of the quick search
Return values
array<string|int, string> —the codes of the matching labels
getQuickSearchWords()
Get the words of a quick search.
public
static getQuickSearchWords(string $search) : array<string|int, string>
The search is split on white spaces, like the smart search of DataTables. The control characters and the backslashes are removed: the backslash is an escape character with a different meaning in QGIS expressions and in PostgreSQL. The wildcards % and _ are kept, they match any characters as in a LIKE pattern.
Parameters
- $search : string
-
the value typed by the user
Return values
array<string|int, string> —the unique words, at most QUICK_SEARCH_MAX_WORDS
isQuickSearchDbType()
Check if a PostgreSQL column can be searched by the quick search.
public
static isQuickSearchDbType(string $type) : bool
Parameters
- $type : string
-
the PostgreSQL type, as returned by Jelix
Return values
bool —true if the column is searched
isQuickSearchEnabled()
Check if the quick search is enabled for a layer, depending on its size.
public
static isQuickSearchEnabled(bool $sqlQuery, int $featureCount, int $columnCount[, int $maxFeatures = self::QUICK_SEARCH_MAX_FEATURES ]) : bool
When the filter is evaluated by QGIS Server, the quick search is disabled above the maximum number of features. When it is run as SQL by Lizmap, it is always enabled.
Parameters
- $sqlQuery : bool
-
true if the filter is run as SQL by Lizmap
- $featureCount : int
-
the number of features of the layer
- $columnCount : int
-
the number of searched columns
- $maxFeatures : int = self::QUICK_SEARCH_MAX_FEATURES
-
the maximum number of features, 0 for no limit
Return values
bool —true if the quick search is enabled
normalizeQuickSearchText()
Remove the accents of a text and convert it to lower case.
public
static normalizeQuickSearchText(string $text) : string
The accents are only removed if the PHP intl extension is installed.
Parameters
- $text : string
-
the text
Return values
string —the text in lower case, without accents if possible