Search
in package
Search and view results from the DB
Tags
Table of Contents
Constants
- RESULT_STRUCTURE = [ 'Score' => 0, 'Title' => '', 'Content' => '', 'Image' => '', 'Link' => '', 'Date' => '', 'Component' => '', //'Class' => '', //'Id' => '', //'Mimetype' => 'text/html', 'AdditionalData' => [], 'Categorization' => [], //'Translations' => [], //'Parent' => [], //'RelatedEntries' => [], 'OtherRelations' => [], ]
- Structure of a result set
Properties
- $options : array<string|int, mixed>
- Set options (of $validOptions) to be applied to the search algorithm
- $rootPage : Page
- Root page for search. If specified only results from this page's branch are delivered
- $validOptions : array<string|int, mixed>
- List of valid options that can be applied to the search algorithm
- $result : DataSet
- DataSet collection containing the result of the search operation
- $term : string
- The term used to find content by
Methods
- __construct() : mixed
- Resolves cmd. If it's a node placeholder, search is limited to the node's branch
- appendResult() : mixed
- Add new set of results to the DataSet collection
- getAccessablePage() : Page
- Returns an accessable page of this module (if any)
- getOptions() : array<string|int, mixed>
- Return the set options
- getPage() : mixed
- getPercentageFromScore() : int
- getResultArray() : array<string|int, mixed>
- Returns search results
- getRootPage() : Page
- Returns the specified root page (if any)
- getSearchResult() : array<string|int, mixed>
- Get a result for search term
- getTerm() : string
- Return the term to search by
- isPageListable() : bool
- Check if a specific page (identified by argument $page) is eligible to be listed in the search results
- parseContentForResultDescription() : string
- Extract plaintext from HTML code and ensure it's length is within the configured max length for search result descriptions.
- shortenSearchContent() : string
- Shorten and format the search result content
- listHiddenPages() : bool
- Return if the system has been configured to list hidden pages or not
- listProtectedPages() : bool
- Return if the system has been configured to list protected pages or not
- setOptions() : mixed
- Set the options to be applied on the search algorithms
- setTerm() : mixed
- Set the term to search by
Constants
RESULT_STRUCTURE
Structure of a result set
public
array<string|int, mixed>
RESULT_STRUCTURE
= [
'Score' => 0,
'Title' => '',
'Content' => '',
'Image' => '',
'Link' => '',
'Date' => '',
'Component' => '',
//'Class' => '',
//'Id' => '',
//'Mimetype' => 'text/html',
'AdditionalData' => [],
'Categorization' => [],
//'Translations' => [],
//'Parent' => [],
//'RelatedEntries' => [],
'OtherRelations' => [],
]
Properties
$options
Set options (of $validOptions) to be applied to the search algorithm
protected
array<string|int, mixed>
$options
= array('includeAssociationData' => false)
$rootPage
Root page for search. If specified only results from this page's branch are delivered
protected
Page
$rootPage
= null
$validOptions
List of valid options that can be applied to the search algorithm
protected
array<string|int, mixed>
$validOptions
= array('zipLookup', 'mode', 'includeAssociationData')
$result
DataSet collection containing the result of the search operation
private
DataSet
$result
$term
The term used to find content by
private
string
$term
= ''
Methods
__construct()
Resolves cmd. If it's a node placeholder, search is limited to the node's branch
public
__construct([Page $page = null ]) : mixed
Parameters
- $page : Page = null
-
Current page
appendResult()
Add new set of results to the DataSet collection
public
appendResult(DataSet $result) : mixed
Parameters
- $result : DataSet
getAccessablePage()
Returns an accessable page of this module (if any)
public
getAccessablePage(string $module[, string $command = '' ][, bool $allowEmptyCommand = false ]) : Page
This should be called by all search event handlers that do not call getResultArray(). If it returns null, no search results should be returned!
Parameters
- $module : string
-
Module name to find page for
- $command : string = ''
-
(optional) Command limitation
- $allowEmptyCommand : bool = false
-
If set to TRUE and $command is set to an empty string, then only application pages having an empty cmd set will be taken into consideration.
Return values
Page —Page of module
getOptions()
Return the set options
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of set options
getPage()
public
getPage(mixed $pos, mixed $page_content) : mixed
Parameters
- $pos : mixed
- $page_content : mixed
getPercentageFromScore()
public
getPercentageFromScore(float $score) : int
Parameters
- $score : float
-
Score value from SQL MATCH/AGAINST function
Return values
int —Value between 25 and 100
getResultArray()
Returns search results
public
getResultArray(string $query, mixed $module, mixed $command, string $pagevar, string $term[, mixed $parseSearchData = null ]) : array<string|int, mixed>
The entries in the array returned contain the following indices: 'Score': The matching score ([0..100]) 'Title': The object or content title 'Content': The content 'Link': The link to the (detailed) view of the result 'Date': The change date, optional Mind that the date is not available for all types of results. Note that the $term parameter is not currently used, but may be useful i.e. for hilighting matches in the results.
Parameters
- $query : string
-
The query
- $module : mixed
- $command : mixed
- $pagevar : string
-
The ID parameter name for referencing found objects in the URL
- $term : string
-
The search term
- $parseSearchData : mixed = null
Tags
Return values
array<string|int, mixed> —The search results array
getRootPage()
Returns the specified root page (if any)
public
getRootPage() : Page
Return values
Page —The specified root page
getSearchResult()
Get a result for search term
public
getSearchResult(string $term[, array<string|int, mixed> $options = array() ]) : array<string|int, mixed>
Parameters
- $term : string
-
Search value
- $options : array<string|int, mixed> = array()
-
Options to be applied on the search algorithms
Return values
array<string|int, mixed> —Return a array of result
getTerm()
Return the term to search by
public
getTerm() : string
Return values
stringisPageListable()
Check if a specific page (identified by argument $page) is eligible to be listed in the search results
public
isPageListable(Page $page) : bool
Parameters
- $page : Page
-
The page to be checked if it is eligible to be listed
Return values
bool —Whether or not the supplied page is eligible to be listed
parseContentForResultDescription()
Extract plaintext from HTML code and ensure it's length is within the configured max length for search result descriptions.
public
parseContentForResultDescription(string $content) : string
Parameters
- $content : string
-
The HTML content to parse
Return values
string —Plaintext excerpt of $content cut to the configured length of the global option searchDescriptionLength
shortenSearchContent()
Shorten and format the search result content
public
static shortenSearchContent(string $content[, int $max_length = NULL ][, string $keyword = '' ]) : string
Strips template placeholders and blocks, as well as certain tags, and fixes the character encoding
Parameters
- $content : string
-
The content
- $max_length : int = NULL
-
The maximum allowed length of the preview content, in characters(*)
- $keyword : string = ''
-
If set, then the returned content will be shortened in such a way that it will contain (if possible) that keyword.
Tags
Return values
string —The formatted content
listHiddenPages()
Return if the system has been configured to list hidden pages or not
protected
listHiddenPages() : bool
Return values
bool —Whether or not if hidden pages shall be listed
listProtectedPages()
Return if the system has been configured to list protected pages or not
protected
listProtectedPages() : bool
Return values
bool —Whether or not if protected pages shall be listed
setOptions()
Set the options to be applied on the search algorithms
protected
setOptions(mixed $options) : mixed
Parameters
- $options : mixed
setTerm()
Set the term to search by
private
setTerm(mixed $term) : mixed
Parameters
- $term : mixed