TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
LiveSearch Class Reference

Public Member Functions

 __construct ()
 
 find ($searchQuery)
 
 getRecordTitlePrep ($title, $titleLength=0)
 
 setLimitCount ($limitCount)
 
 setStartCount ($startCount)
 
 setQueryString ($queryString)
 

Public Attributes

const PAGE_JUMP_TABLE = 'pages'
 
const RECURSIVE_PAGE_LEVEL = 99
 
const GROUP_TITLE_MAX_LENGTH = 15
 
const RECORD_TITLE_MAX_LENGTH = 28
 

Protected Member Functions

 findPageById ($id)
 
 findByGlobalTableList ($pageIdList)
 
 findByTable ($tableName, $pageIdList, $firstResult, $maxResults)
 
 getRecordArray ($queryBuilder, $tableName)
 
 getEditLink ($tableName, $row)
 
 getTitleOfCurrentRecordType ($tableName)
 
 makeQuerySearchByTable (QueryBuilder &$queryBuilder, $tableName, array $fieldsToSearchWithin)
 
 extractSearchableFieldsFromTable ($tableName)
 
 getAvailablePageIds ($id, $depth)
 

Protected Attributes

 $userPermissions = ''
 
 $queryParser = null
 

Private Attributes

 $queryString = ''
 
 $startCount = 0
 
 $limitCount = 5
 

Detailed Description

Class for handling backend live search.

Definition at line 32 of file LiveSearch.php.

Constructor & Destructor Documentation

__construct ( )

Initialize access settings

Definition at line 82 of file LiveSearch.php.

References $GLOBALS, and GeneralUtility\makeInstance().

Member Function Documentation

extractSearchableFieldsFromTable (   $tableName)
protected

Get all fields from given table where we can search for.

Parameters
string$tableNameName of the table for which to get the searchable fields
Returns
array

Definition at line 407 of file LiveSearch.php.

References $GLOBALS, and GeneralUtility\trimExplode().

Referenced by LiveSearch\findByTable().

find (   $searchQuery)

Find records from database based on the given $searchQuery.

Parameters
string$searchQuery
Returns
array Result list of database search.

Definition at line 94 of file LiveSearch.php.

References $GLOBALS, LiveSearch\findByGlobalTableList(), LiveSearch\findByTable(), LiveSearch\getAvailablePageIds(), and LiveSearch\setQueryString().

findByGlobalTableList (   $pageIdList)
protected

Find records from all registered TCA table & column values.

Parameters
string$pageIdListComma separated list of page IDs
Returns
array Records found in the database matching the searchQuery

Definition at line 139 of file LiveSearch.php.

References $GLOBALS, LiveSearch\$limitCount, and LiveSearch\findByTable().

Referenced by LiveSearch\find().

findByTable (   $tableName,
  $pageIdList,
  $firstResult,
  $maxResults 
)
protected

Find records by given table name.

Parameters
string$tableNameDatabase table name
string$pageIdListComma separated list of page IDs
int$firstResult
int$maxResults
Returns
array Records found in the database matching the searchQuery
See also
getRecordArray()
makeQuerySearchByTable()
extractSearchableFieldsFromTable()

Definition at line 173 of file LiveSearch.php.

References $GLOBALS, LiveSearch\extractSearchableFieldsFromTable(), LiveSearch\getRecordArray(), GeneralUtility\makeInstance(), LiveSearch\makeQuerySearchByTable(), and QueryHelper\parseOrderBy().

Referenced by LiveSearch\find(), and LiveSearch\findByGlobalTableList().

findPageById (   $id)
protected

Retrieve the page record from given $id.

Parameters
int$id
Returns
array

Definition at line 123 of file LiveSearch.php.

References BackendUtility\getRecord().

getAvailablePageIds (   $id,
  $depth 
)
protected

Creates an instance of which will select a page tree to $depth and return the object. In that object we will find the ids of the tree.

Parameters
int$idPage id.
int$depthDepth to go down.
Returns
string Comma separated list of uids

Definition at line 467 of file LiveSearch.php.

References GeneralUtility\makeInstance().

Referenced by LiveSearch\find().

getEditLink (   $tableName,
  $row 
)
protected

Build a backend edit link based on given record.

Parameters
string$tableNameRecord table name
array$rowCurrent record row from database.
Returns
string Link to open an edit window for record.
See also
::readPageAccess()

Definition at line 246 of file LiveSearch.php.

References $GLOBALS, Permission\CONTENT_EDIT, BackendUtility\getRecord(), Permission\PAGE_EDIT, and BackendUtility\readPageAccess().

Referenced by LiveSearch\getRecordArray().

getRecordArray (   $queryBuilder,
  $tableName 
)
protected

Process the Database operation to get the search result.

Parameters
QueryBuilder$queryBuilderDatabase table name
string$tableName
Returns
array
See also
getTitleFromCurrentRow()
getEditLink()

Definition at line 219 of file LiveSearch.php.

References LiveSearch\getEditLink(), BackendUtility\getRecordTitle(), LiveSearch\getTitleOfCurrentRecordType(), GeneralUtility\makeInstance(), and Icon\SIZE_SMALL.

Referenced by LiveSearch\findByTable().

getRecordTitlePrep (   $title,
  $titleLength = 0 
)

Crops a title string to a limited length and if it really was cropped, wrap it in a |, which offers a tooltip with the original title when moving mouse over it.

Parameters
string$titleThe title string to be cropped
int$titleLengthCrop title after this length - if not set, BE_USER->uc['titleLen'] is used
Returns
string The processed title string, wrapped in | if cropped

Definition at line 288 of file LiveSearch.php.

References $GLOBALS, and MathUtility\canBeInterpretedAsInteger().

getTitleOfCurrentRecordType (   $tableName)
protected

Retrieve the record name

Parameters
string$tableNameRecord table name
Returns
string

Definition at line 274 of file LiveSearch.php.

References $GLOBALS.

Referenced by LiveSearch\getRecordArray().

makeQuerySearchByTable ( QueryBuilder $queryBuilder,
  $tableName,
array  $fieldsToSearchWithin 
)
protected

Build the MySql where clause by table.

Parameters
QueryBuilder$queryBuilder
string$tableNameRecord table name
array$fieldsToSearchWithinUser right based visible fields where we can search within.
Returns
CompositeExpression

Definition at line 305 of file LiveSearch.php.

References $GLOBALS, MathUtility\canBeInterpretedAsInteger(), QueryBuilder\createNamedParameter(), QueryBuilder\escapeLikeWildcards(), QueryBuilder\expr(), GeneralUtility\inList(), QueryBuilder\quoteIdentifier(), and QueryHelper\stripLogicalOperatorPrefix().

Referenced by LiveSearch\findByTable().

setLimitCount (   $limitCount)

Setter for limit value.

Parameters
int$limitCount
Returns
void

Definition at line 429 of file LiveSearch.php.

References LiveSearch\$limitCount, and MathUtility\convertToPositiveInteger().

setQueryString (   $queryString)

Setter for the search query string.

Parameters
string$queryString
Returns
void

Definition at line 454 of file LiveSearch.php.

References LiveSearch\$queryString.

Referenced by LiveSearch\find().

setStartCount (   $startCount)

Setter for start count value.

Parameters
int$startCount
Returns
void

Definition at line 443 of file LiveSearch.php.

References LiveSearch\$startCount, and MathUtility\convertToPositiveInteger().

Member Data Documentation

$limitCount = 5
private

Definition at line 67 of file LiveSearch.php.

Referenced by LiveSearch\findByGlobalTableList(), and LiveSearch\setLimitCount().

$queryParser = null
protected

Definition at line 77 of file LiveSearch.php.

$queryString = ''
private

Definition at line 57 of file LiveSearch.php.

Referenced by LiveSearch\setQueryString().

$startCount = 0
private

Definition at line 62 of file LiveSearch.php.

Referenced by LiveSearch\setStartCount().

$userPermissions = ''
protected

Definition at line 72 of file LiveSearch.php.

const GROUP_TITLE_MAX_LENGTH = 15

Definition at line 47 of file LiveSearch.php.

const PAGE_JUMP_TABLE = 'pages'

Definition at line 37 of file LiveSearch.php.

const RECORD_TITLE_MAX_LENGTH = 28

Definition at line 52 of file LiveSearch.php.

const RECURSIVE_PAGE_LEVEL = 99

Definition at line 42 of file LiveSearch.php.