TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject:
TYPO3\CMS\Frontend\ContentObject\AbstractContentObject tslib_content_SearchResult tslib_search

Public Member Functions

 __construct (\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj=NULL)
 
 register_tables_and_columns ($requestedCols, $allowedCols)
 
 explodeCols ($in)
 
 register_and_explode_search_string ($sword)
 
 split ($origSword, $specchars='+-', $delchars='+.,-')
 
 build_search_query ($endClause)
 
 build_search_query_for_searchwords ()
 
 get_operator ($operator)
 
 count_query ()
 
 execute_query ()
 
 get_searchwords ()
 
 get_searchwordsArray ()
 
- Public Member Functions inherited from TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
 __construct (\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj)
 
 render ($conf=array())
 
 getContentObject ()
 

Public Attributes

 $tables = array()
 
 $group_by = 'PRIMARY_KEY'
 
 $default_operator = 'AND'
 
 $operator_translate_table_caseinsensitive = TRUE
 
 $operator_translate_table
 
 $sword_array
 
 $queryParts
 
 $other_where_clauses
 
 $fTable
 
 $res_offset = 0
 
 $res_shows = 20
 
 $res_count
 
 $pageIdList = ''
 
 $listOfSearchFields = ''
 

Additional Inherited Members

- Protected Attributes inherited from TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
 $cObj
 
 $fileFactory = NULL
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Search class used for the content object SEARCHRESULT and searching in database tables, typ. "pages" and "tt_content" Used to generate search queries for TypoScript. The class is included from "class.tslib_pagegen.php" based on whether there has been detected content in the GPvar "sword"

Definition at line 22 of file SearchResultContentObject.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ build_search_query()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::build_search_query (   $endClause)

This creates the search-query. In TypoScript this is used for searching only records not hidden, start/endtimed and fe_grouped! (enable-fields, see tt_content) Sets $this->queryParts

Parameters
string$endClauseSome extra conditions that the search must match.
Returns
boolean Returns TRUE no matter what - sweet isn't it! private
See also
::SEARCHRESULT()
Todo:
Define visibility

Definition at line 458 of file SearchResultContentObject.php.

References TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\$group_by, TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\$tables, and TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\build_search_query_for_searchwords().

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct().

◆ build_search_query_for_searchwords()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::build_search_query_for_searchwords ( )

Creates the part of the SQL-sentence, that searches for the search-words ($this->sword_array)

Returns
string Part of where class limiting result to the those having the search word. private
Todo:
Define visibility

Definition at line 536 of file SearchResultContentObject.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\build_search_query().

◆ count_query()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::count_query ( )

Counts the results and sets the result in $this->res_count

Returns
boolean TRUE, if $this->query was found
Todo:
Define visibility

Definition at line 600 of file SearchResultContentObject.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct().

◆ execute_query()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::execute_query ( )

Executes the search, sets result pointer in $this->result

Returns
boolean TRUE, if $this->query was set and query performed
Todo:
Define visibility

Definition at line 614 of file SearchResultContentObject.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct().

◆ explodeCols()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::explodeCols (   $in)

Function that can convert the syntax for entering which tables/fields the search should be conducted in.

Parameters
string$inThis is the code-line defining the tables/fields to search. Syntax: '[table1].[field1]-[field2]-[field3] : [table2].[field1]-[field2]'
Returns
array An array where the values is "[table].[field]" strings to search
See also
register_tables_and_columns()
Todo:
Define visibility

Definition at line 338 of file SearchResultContentObject.php.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\register_tables_and_columns().

◆ get_operator()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::get_operator (   $operator)

This returns an SQL search-operator (eg. AND, OR, NOT) translated from the current localized set of operators (eg. in danish OG, ELLER, IKKE).

Parameters
string$operatorThe possible operator to find in the internal operator array.
Returns
string If found, the SQL operator for the localized input operator. private
Todo:
Define visibility

Definition at line 574 of file SearchResultContentObject.php.

References TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\$operator_translate_table.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\register_and_explode_search_string().

◆ get_searchwords()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::get_searchwords ( )

Returns URL-parameters with the current search words. Used when linking to result pages so that search words can be highlighted.

Returns
string URL-parameters with the searchwords
Todo:
Define visibility

Definition at line 628 of file SearchResultContentObject.php.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct().

◆ get_searchwordsArray()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::get_searchwordsArray ( )

Returns an array with the search words in

Returns
array IF the internal sword_array contained search words it will return these, otherwise "void
Todo:
Define visibility

Definition at line 644 of file SearchResultContentObject.php.

◆ register_and_explode_search_string()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::register_and_explode_search_string (   $sword)

Takes a search-string (WITHOUT SLASHES or else it'll be a little sppooky , NOW REMEMBER to unslash!!) Sets up $this->sword_array op with operators. This function uses $this->operator_translate_table as well as $this->default_operator

Parameters
string$swordThe input search-word string.
Returns
void
Todo:
Define visibility

Definition at line 366 of file SearchResultContentObject.php.

References TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\$default_operator, TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\get_operator(), and TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\split().

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct().

◆ register_tables_and_columns()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::register_tables_and_columns (   $requestedCols,
  $allowedCols 
)

Creates the $this->tables-array. The 'pages'-table is ALWAYS included as the search is page-based. Apart from this there may be one and only one table, joined with the pages-table. This table is the first table mentioned in the requested-list. If any more tables are set here, they are ignored.

Parameters
string$requestedColsis a list (-) of columns that we want to search. This could be input from the search-form (see TypoScript documentation)
string$allowedCols$allowedCols: is the list of columns, that MAY be searched. All allowed cols are set as result-fields. All requested cols MUST be in the allowed-fields list.
Returns
void
Todo:
Define visibility

Definition at line 299 of file SearchResultContentObject.php.

References TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\explodeCols().

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct().

◆ split()

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::split (   $origSword,
  $specchars = '+-',
  $delchars = '+.,
-'   
)

Used to split a search-word line up into elements to search for. This function will detect boolean words like AND and OR, + and -, and even find sentences encapsulated in "" This function could be re-written to be more clean and effective - yet it's not that important.

Parameters
string$origSwordThe raw sword string from outside
string$speccharsSpecial chars which are used as operators (+- is default)
string$delcharsSpecial chars which are deleted if the append the searchword (+-., is default)
Returns
mixed Returns an ARRAY if there were search words, otherwise the return value may be unset.
Todo:
Define visibility

Definition at line 401 of file SearchResultContentObject.php.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\register_and_explode_search_string().

Member Data Documentation

◆ $default_operator

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$default_operator = 'AND'

◆ $fTable

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$fTable

◆ $group_by

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$group_by = 'PRIMARY_KEY'

◆ $listOfSearchFields

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$listOfSearchFields = ''
Todo:
Define visibility

Definition at line 111 of file SearchResultContentObject.php.

◆ $operator_translate_table

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$operator_translate_table
Initial value:
= array(
array('+', 'AND'),
array('|', 'AND'),
array('-', 'AND NOT'),
array('and', 'AND'),
array('or', 'OR'),
array('not', 'AND NOT')
)
Todo:
Define visibility

Definition at line 49 of file SearchResultContentObject.php.

Referenced by TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\get_operator().

◆ $operator_translate_table_caseinsensitive

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$operator_translate_table_caseinsensitive = TRUE
Todo:
Define visibility

Definition at line 43 of file SearchResultContentObject.php.

◆ $other_where_clauses

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$other_where_clauses
Todo:
Define visibility

Definition at line 76 of file SearchResultContentObject.php.

◆ $pageIdList

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$pageIdList = ''
Todo:
Define visibility

Definition at line 106 of file SearchResultContentObject.php.

◆ $queryParts

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$queryParts
Todo:
Define visibility

Definition at line 70 of file SearchResultContentObject.php.

◆ $res_count

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$res_count

◆ $res_offset

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$res_offset = 0
Todo:
Define visibility

Definition at line 88 of file SearchResultContentObject.php.

◆ $res_shows

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$res_shows = 20
Todo:
Define visibility

Definition at line 94 of file SearchResultContentObject.php.

◆ $sword_array

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$sword_array
Todo:
Define visibility

Definition at line 64 of file SearchResultContentObject.php.

◆ $tables

TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject::$tables = array()