datatablesCtrl
extends jController
in package
Table of Contents
Properties
- $bbox : array<string|int, mixed>
- $DTColumns : mixed
- $DTLength : null|string
- $DTOrder : mixed
- $DTSearchBuilder : null|array<string|int, mixed>
- $DTStart : null|string
- $expFilter : null|string
- $filteredFeatureIDs : array<string|int, mixed>
- $layerId : null|string
- $project : null|string
- $quickSearchSkippedColumns : array<string|int, string>
- $repository : null|string
- $searchValue : string
- $srsName : null|string
Methods
- filteredFeaturesExtent() : jResponseJson
- Calculates the total extent of the filtered features, in EPSG:4326.
- index() : mixed
- selectFilteredFeatures() : jResponseBinary|jResponseJson
- Returns all features corresponding to the searching parameters, ignoring pagination.
- setErrorResponse() : jResponseJson
- Sets the error in the provided response object based on the given HTTP error code.
- applyQuickSearch() : bool
- Add the quick search on all the columns to the expression filter.
- getExpFilter() : null|string
- Return expression filter parameter.
- getFeatureCount() : null|int
- Get the number of features of a layer.
- getProject() : null|Project
- Get the Lizmap project. If the project does not exist, the user does not have the right to access the project or the user does not have access to WFS data, set the error response.
- getQuickSearchColumns() : array<string|int, string>
- Get the columns searched by the quick search.
- getQuickSearchDbFieldTypes() : null|array<string, string>
- Get the PostgreSQL types of the layer fields, if the WFS requests are run as SQL by Lizmap.
- getQuickSearchLabeledValues() : array<string, array<string|int, mixed>>
- Get the labels of the searched columns displayed with labels in the table.
- getSourceLayerLabels() : null|array<string, string>
- Get the labels of the source layer of a value relation or of a relation reference matching the quick search.
- getUnaccentFunction() : null|string
- Get the PostgreSQL function removing the accents, if it exists in the layer database.
- initClassProperties() : mixed
- Assign values to class instance property.
- transformExtentTo4326() : array<string|int, float>
- Transform an extent into EPSG:4326.
Properties
$bbox
private
array<string|int, mixed>
$bbox
bbox array
$DTColumns
private
mixed
$DTColumns
Array of columns name
$DTLength
private
null|string
$DTLength
Number of features per page
$DTOrder
private
mixed
$DTOrder
Array of columns order
$DTSearchBuilder
private
null|array<string|int, mixed>
$DTSearchBuilder
Array of search builder condition criteria
$DTStart
private
null|string
$DTStart
Pagination start
$expFilter
private
null|string
$expFilter
WFS expression filter
$filteredFeatureIDs
private
array<string|int, mixed>
$filteredFeatureIDs
Array of filtered features ids
$layerId
private
null|string
$layerId
The layer id
$project
private
null|string
$project
The qgis project key
$quickSearchSkippedColumns
private
array<string|int, string>
$quickSearchSkippedColumns
= array()
the columns not searched by the quick search, because too many labels match the search
$repository
private
null|string
$repository
The repository key string
$searchValue
private
string
$searchValue
= ''
Value of the quick search on all the columns
$srsName
private
null|string
$srsName
srs code
Methods
filteredFeaturesExtent()
Calculates the total extent of the filtered features, in EPSG:4326.
public
filteredFeaturesExtent() : jResponseJson
It basically use the same logic of the main endpoint but ignores pagination to get all filtered features. For a PostgreSQL layer, the extent is computed by the database; otherwise the features are got via WFS to calculate it.
Return values
jResponseJsonindex()
public
index() : mixed
selectFilteredFeatures()
Returns all features corresponding to the searching parameters, ignoring pagination.
public
selectFilteredFeatures() : jResponseBinary|jResponseJson
Return values
jResponseBinary|jResponseJsonsetErrorResponse()
Sets the error in the provided response object based on the given HTTP error code.
protected
setErrorResponse(jResponseJson $rep, int $code, string $errorMessage) : jResponseJson
Parameters
- $rep : jResponseJson
-
- the response object to which the error details will be assigned
- $code : int
-
- the HTTP error code
- $errorMessage : string
-
- the custom error message
Return values
jResponseJson —returns the updated response object containing the error details
applyQuickSearch()
Add the quick search on all the columns to the expression filter.
private
applyQuickSearch(Project $lproj, qgisVectorLayer $layer[, null|int $featureCount = null ]) : bool
The quick search is disabled for the layers evaluated by QGIS Server above DataTables::QUICK_SEARCH_MAX_FEATURES features. When it is disabled, the search is ignored.
Parameters
- $lproj : Project
-
the project
- $layer : qgisVectorLayer
-
the layer
- $featureCount : null|int = null
-
the number of features of the layer, requested if null and needed
Return values
bool —true if the quick search is enabled for the layer
getExpFilter()
Return expression filter parameter.
private
getExpFilter() : null|string
Return values
null|stringgetFeatureCount()
Get the number of features of a layer.
private
getFeatureCount(Project $lproj, string $typeName) : null|int
Parameters
- $lproj : Project
-
the project
- $typeName : string
-
the WFS type name of the layer
Return values
null|int —the number of features, or null if the request failed
getProject()
Get the Lizmap project. If the project does not exist, the user does not have the right to access the project or the user does not have access to WFS data, set the error response.
private
getProject(jResponseJson $rep) : null|Project
Parameters
- $rep : jResponseJson
-
- the response object to which the error details will be assigned
Return values
null|Project —- the Lizmap project or null
getQuickSearchColumns()
Get the columns searched by the quick search.
private
getQuickSearchColumns(qgisVectorLayer $layer) : array<string|int, string>
The columns are the DataTables columns which are searchable and published in WFS, as the client can not be trusted.
Parameters
- $layer : qgisVectorLayer
-
the layer
Return values
array<string|int, string> —the names of the searched columns
getQuickSearchDbFieldTypes()
Get the PostgreSQL types of the layer fields, if the WFS requests are run as SQL by Lizmap.
private
getQuickSearchDbFieldTypes(qgisVectorLayer $layer, string $expFilter) : null|array<string, string>
It follows the conditions of WFSRequest::getfeaturePostgres(): a PostgreSQL table, not a SQL query, with all the WFS fields in the database (no virtual field) and, if the expression filter uses $id, a single primary key. When the fields types are returned, the quick search can use database functions, not known by QGIS Server.
Parameters
- $layer : qgisVectorLayer
-
the layer
- $expFilter : string
-
the expression filter of the request
Return values
null|array<string, string> —the type of each field, or null if the filter is evaluated by QGIS Server
getQuickSearchLabeledValues()
Get the labels of the searched columns displayed with labels in the table.
private
getQuickSearchLabeledValues(Project $lproj, qgisVectorLayer $layer, array<string|int, string> $columns) : array<string, array<string|int, mixed>>
The labels of the value maps are stored in the project. For the value relations and the relation references, only the labels matching the quick search are requested in the source layer. If there are too many, the column is not searched and is added to the skipped columns. If they can not be requested, e.g. the source layer is not published in WFS, or for the value relations with multiple values, the codes are searched as for the other columns.
Parameters
- $lproj : Project
-
the project
- $layer : qgisVectorLayer
-
the layer
- $columns : array<string|int, string>
-
the names of the searched columns
Return values
array<string, array<string|int, mixed>> —the labels indexed by code, for each column with labels
getSourceLayerLabels()
Get the labels of the source layer of a value relation or of a relation reference matching the quick search.
private
getSourceLayerLabels(Project $lproj, array<string|int, mixed> $fieldConfig) : null|array<string, string>
At most DataTables::QUICK_SEARCH_MAX_LABELS + 1 labels are requested, to know if there are too many. The filter expression of the value relation is not used: it often depends on the form, and only the codes stored in the layer can be found.
Parameters
- $lproj : Project
-
the project
- $fieldConfig : array<string|int, mixed>
-
the configuration of the field with labels, with the keys source_layer_id, code_field and label_field
Return values
null|array<string, string> —the labels indexed by code, or null if they can not be requested
getUnaccentFunction()
Get the PostgreSQL function removing the accents, if it exists in the layer database.
private
getUnaccentFunction(qgisVectorLayer $layer) : null|string
The f_unaccent immutable function, advised by the Lizmap documentation, is preferred, as it can be used in an index. It is searched with the search path of the layer connection.
Parameters
- $layer : qgisVectorLayer
-
the PostgreSQL layer
Return values
null|string —the function name, f_unaccent or unaccent, or null
initClassProperties()
Assign values to class instance property.
private
initClassProperties() : mixed
transformExtentTo4326()
Transform an extent into EPSG:4326.
private
transformExtentTo4326(Project $lproj, array<string|int, float> $extent, string $crs) : array<string|int, float>
The four corners of the extent are transformed, and the extent of the transformed corners is returned.
Parameters
- $lproj : Project
-
the project, giving the CRS definitions
- $extent : array<string|int, float>
-
the extent [xmin, ymin, xmax, ymax]
- $crs : string
-
the CRS of the extent, e.g. EPSG:3857
Return values
array<string|int, float> —the extent in EPSG:4326, or an empty array if it can not be transformed