‪TYPO3CMS  ‪main
TYPO3\CMS\IndexedSearch\Controller\SearchController Class Reference
Inheritance diagram for TYPO3\CMS\IndexedSearch\Controller\SearchController:
TYPO3\CMS\Extbase\Mvc\Controller\ActionController TYPO3\CMS\Extbase\Mvc\Controller\ControllerInterface

Public Member Functions

 __construct (private readonly Context $context, private readonly IndexSearchRepository $searchRepository, private readonly TypoScriptService $typoScriptService, private readonly Lexer $lexer, private readonly LinkFactory $linkFactory,)
 
 searchAction (array $search=[])
 
 formAction (array $search=[])
 
 noTypoScriptAction ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController
 injectResponseFactory (ResponseFactoryInterface $responseFactory)
 
 injectStreamFactory (StreamFactoryInterface $streamFactory)
 
 injectConfigurationManager (ConfigurationManagerInterface $configurationManager)
 
 injectValidatorResolver (ValidatorResolver $validatorResolver)
 
 injectViewResolver (ViewResolverInterface $viewResolver)
 
 injectReflectionService (ReflectionService $reflectionService)
 
 injectHashService (HashService $hashService)
 
 injectMvcPropertyMappingConfigurationService (MvcPropertyMappingConfigurationService $mvcPropertyMappingConfigurationService)
 
 injectEventDispatcher (EventDispatcherInterface $eventDispatcher)
 
 injectPropertyMapper (PropertyMapper $propertyMapper)
 
 injectInternalFlashMessageService (FlashMessageService $flashMessageService)
 
 injectInternalExtensionService (ExtensionService $extensionService)
 
 initializeControllerArgumentsBaseValidators ()
 
 processRequest (RequestInterface $request)
 
 addFlashMessage (string $messageBody, string $messageTitle='', ContextualFeedbackSeverity $severity=ContextualFeedbackSeverity::OK, bool $storeInSession=true)
 
 throwStatus (int $statusCode, string $statusMessage='', ?string $content=null)
 

Protected Member Functions

 initialize (array $searchData=[])
 
 getDisplayResults (array $searchData, array $searchWords, array|bool $resultData, int $freeIndexUid=-1)
 
array compileResultRows (array $searchData, array $resultRows, int $freeIndexUid=-1)
 
array compileSingleResultRow (array $searchData, array $row, int $headerOnly=0)
 
 makeDescription (array $row, bool $noMarkup=false, int $length=180)
 
 markupSWpartsOfString (string $str)
 
 getSearchWords (array $searchData, bool $useDefaultOperator)
 
array procSearchWordsByLexer (array $searchWords)
 
array getAllAvailableSearchTypeOptions ()
 
array getAllAvailableOperandsOptions ()
 
array getAllAvailableMediaTypesOptions ()
 
array getAllAvailableSectionsOptions ()
 
array getAllAvailableIndexConfigurationsOptions ()
 
array getAllAvailableSortOrderOptions ()
 
array getAllAvailableGroupOptions ()
 
array getAllAvailableSortDescendingOptions ()
 
array getAllAvailableNumberOfResultsOptions ()
 
array removeOptionsFromOptionList (array $allOptions, mixed $blindOptions)
 
 linkPage (int $pageUid, array $row, string $linkText)
 
array getMenuOfPages (int $pageUid)
 
string getPathFromPageId (int $id, string $pathMP='')
 
 initializeExternalParsers ()
 
bool multiplePagesType (string $item_type)
 
array processExtendedSearchParameters ()
 
 loadSettings ()
 
 getNumberOfResults (int $numberOfResults)
 
 addOperatorLabel (array $searchWord)
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController
 initializeAction ()
 
 initializeActionMethodArguments ()
 
 initializeActionMethodValidators ()
 
 renderAssetsForRequest (RequestInterface $request)
 
 resolveActionMethodName ()
 
 callActionMethod (RequestInterface $request)
 
 resolveView ()
 
 setViewConfiguration (ViewInterface $view)
 
 errorAction ()
 
 addErrorFlashMessage ()
 
 getErrorFlashMessage ()
 
 forwardToReferringRequest ()
 
 getFlattenedValidationErrorMessage ()
 
 getFlashMessageQueue (string $identifier=null)
 
 redirect (?string $actionName, ?string $controllerName=null, ?string $extensionName=null, ?array $arguments=null, ?int $pageUid=null, $_=null, int $statusCode=303)
 
 redirectToUri (string|UriInterface $uri, $_=null, int $statusCode=303)
 
 addBaseUriIfNecessary (string $uri)
 
 mapRequestArgumentsToControllerArguments ()
 
 htmlResponse (string $html=null)
 
 jsonResponse (string $json=null)
 

Protected Attributes

string $sword = ''
 
array $searchWords = []
 
string int $searchRootPageIdList = 0
 
int $defaultResultNumber = 10
 
array $availableResultsNumbers = []
 
array $externalParsers = []
 
array $firstRow = []
 
array $requiredFrontendUsergroups = []
 
array $resultSections = []
 
array $pathCache = []
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController
ResponseFactoryInterface $responseFactory
 
StreamFactoryInterface $streamFactory
 
HashService $hashService
 
ReflectionService $reflectionService
 
ViewInterface $view
 
string $defaultViewObjectName = TemplateView::class
 
string $actionMethodName = 'indexAction'
 
string $errorMethodName = 'errorAction'
 
MvcPropertyMappingConfigurationService $mvcPropertyMappingConfigurationService
 
EventDispatcherInterface $eventDispatcher
 
RequestInterface $request
 
UriBuilder $uriBuilder
 
array $settings
 
ValidatorResolver $validatorResolver
 
Arguments $arguments
 
ConfigurationManagerInterface $configurationManager
 

Private Member Functions

 getTypoScriptFrontendController ()
 

Detailed Description

Index search frontend

Creates a search form for indexed search. Indexing must be enabled for this to make sense.

This class is a specific controller implementation and is not considered part of the Public TYPO3 API.

Definition at line 57 of file SearchController.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\IndexedSearch\Controller\SearchController::__construct ( private readonly Context  $context,
private readonly IndexSearchRepository  $searchRepository,
private readonly TypoScriptService  $typoScriptService,
private readonly Lexer  $lexer,
private readonly LinkFactory  $linkFactory 
)

Definition at line 93 of file SearchController.php.

Member Function Documentation

◆ addOperatorLabel()

TYPO3\CMS\IndexedSearch\Controller\SearchController::addOperatorLabel ( array  $searchWord)
protected

Process the search word operator to be used in e.g. locallang keys

Definition at line 1153 of file SearchController.php.

◆ compileResultRows()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::compileResultRows ( array  $searchData,
array  $resultRows,
int  $freeIndexUid = -1 
)
protected

Takes the array with resultrows as input and returns the result-HTML-code Takes the "group" var into account: Makes a "section" or "flat" display.

Parameters
array$resultRows‪Result rows
int$freeIndexUid‪Pointing to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
Returns
‪array the result rows with additional information

Definition at line 286 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\compileSingleResultRow(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getPathFromPageId(), and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\getDisplayResults().

◆ compileSingleResultRow()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::compileSingleResultRow ( array  $searchData,
array  $row,
int  $headerOnly = 0 
)
protected

◆ formAction()

TYPO3\CMS\IndexedSearch\Controller\SearchController::formAction ( array  $search = [])

◆ getAllAvailableGroupOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableGroupOptions ( )
protected

◆ getAllAvailableIndexConfigurationsOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableIndexConfigurationsOptions ( )
protected

◆ getAllAvailableMediaTypesOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableMediaTypesOptions ( )
protected

◆ getAllAvailableNumberOfResultsOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableNumberOfResultsOptions ( )
protected

get the values for the "results" selector

Returns
‪array Associative array with options

Definition at line 904 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\removeOptionsFromOptionList().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\processExtendedSearchParameters().

◆ getAllAvailableOperandsOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableOperandsOptions ( )
protected

◆ getAllAvailableSearchTypeOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableSearchTypeOptions ( )
protected

◆ getAllAvailableSectionsOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableSectionsOptions ( )
protected

get the values for the "section" selector Here values like "rl1_" and "rl2_" + a root level 1/2 id can be added to perform searches in root level 1+2 specifically. The id-values can even be comma-separated. e.g. "rl1_1,2" would search for stuff inside pages on menu-level 1 which has the uids 1 and 2.

Returns
‪array Associative array with options

Definition at line 764 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\getMenuOfPages(), TYPO3\CMS\IndexedSearch\Controller\SearchController\removeOptionsFromOptionList(), and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\processExtendedSearchParameters().

◆ getAllAvailableSortDescendingOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableSortDescendingOptions ( )
protected

◆ getAllAvailableSortOrderOptions()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getAllAvailableSortOrderOptions ( )
protected

get the values for the "section" selector Here values like "rl1_" and "rl2_" + a root level 1/2 id can be added to perform searches in root level 1+2 specifically. The id-values can even be comma-separated. e.g. "rl1_1,2" would search for stuff inside pages on menu-level 1 which has the uids 1 and 2.

Returns
‪array Associative array with options

Definition at line 847 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\removeOptionsFromOptionList(), and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\processExtendedSearchParameters().

◆ getDisplayResults()

TYPO3\CMS\IndexedSearch\Controller\SearchController::getDisplayResults ( array  $searchData,
array  $searchWords,
array|bool  $resultData,
int  $freeIndexUid = -1 
)
protected

Compiles the HTML display of the incoming array of result rows.

Parameters
array$searchWords‪Search words array (for display of text describing what was searched for)
array | bool$resultData‪Array with result rows, count, first row.
int$freeIndexUid‪Pointing to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.

Definition at line 239 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\$resultSections, TYPO3\CMS\IndexedSearch\Controller\SearchController\$searchWords, TYPO3\CMS\IndexedSearch\Controller\SearchController\compileResultRows(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getPathFromPageId(), and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\searchAction().

◆ getMenuOfPages()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::getMenuOfPages ( int  $pageUid)
protected

Return the menu of pages used for the selector.

Parameters
int$pageUid‪Page ID for which to return menu
Returns
‪array Menu items (for making the section selector box)

Definition at line 971 of file SearchController.php.

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSectionsOptions().

◆ getNumberOfResults()

TYPO3\CMS\IndexedSearch\Controller\SearchController::getNumberOfResults ( int  $numberOfResults)
protected

◆ getPathFromPageId()

string TYPO3\CMS\IndexedSearch\Controller\SearchController::getPathFromPageId ( int  $id,
string  $pathMP = '' 
)
protected

◆ getSearchWords()

TYPO3\CMS\IndexedSearch\Controller\SearchController::getSearchWords ( array  $searchData,
bool  $useDefaultOperator 
)
protected

Splits the search word input into an array where each word is represented by an array with key "sword" holding the search word and key "oper" holding the SQL operator (e.g. AND, OR)

Only words with 2 or more characters are accepted Max 200 chars total Space is used to split words, "" can be used search for a whole string AND, OR and NOT are prefix words, overruling the default operator +/|/- equals AND, OR and NOT as operators. All search words are converted to lowercase.

$defOp is the default operator. 1=OR, 0=AND

Parameters
bool$useDefaultOperator‪If TRUE, the default operator will be OR, not AND

Definition at line 585 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\$searchWords, TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility\getExplodedSearchString(), TYPO3\CMS\IndexedSearch\Controller\SearchController\procSearchWordsByLexer(), TYPO3\CMS\IndexedSearch\Type\SENTENCE, and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\initialize().

◆ getTypoScriptFrontendController()

TYPO3\CMS\IndexedSearch\Controller\SearchController::getTypoScriptFrontendController ( )
private

◆ initialize()

◆ initializeExternalParsers()

TYPO3\CMS\IndexedSearch\Controller\SearchController::initializeExternalParsers ( )
protected

simple function to initialize possible external parsers feeds the $this->externalParsers array

Definition at line 1035 of file SearchController.php.

References $GLOBALS.

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\initialize().

◆ linkPage()

TYPO3\CMS\IndexedSearch\Controller\SearchController::linkPage ( int  $pageUid,
array  $row,
string  $linkText 
)
protected

◆ loadSettings()

TYPO3\CMS\IndexedSearch\Controller\SearchController::loadSettings ( )
protected

◆ makeDescription()

TYPO3\CMS\IndexedSearch\Controller\SearchController::makeDescription ( array  $row,
bool  $noMarkup = false,
int  $length = 180 
)
protected

Returns the resume for the search-result.

Parameters
bool$noMarkup‪If noMarkup is FALSE, then the index_fulltext table is used to select the content of the page, split it with regex to display the search words in the text.
Todo:
‪overwork this

Definition at line 470 of file SearchController.php.

References $output, TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs(), TYPO3\CMS\IndexedSearch\Controller\SearchController\markupSWpartsOfString(), and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\compileSingleResultRow().

◆ markupSWpartsOfString()

TYPO3\CMS\IndexedSearch\Controller\SearchController::markupSWpartsOfString ( string  $str)
protected

Marks up the search words from $this->searchWords in the $str with a color.

Parameters
string$str‪Text in which to find and mark up search words. This text is assumed to be UTF-8 like the search words internally is.

Definition at line 499 of file SearchController.php.

References $output, TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs(), and TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange().

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\makeDescription().

◆ multiplePagesType()

bool TYPO3\CMS\IndexedSearch\Controller\SearchController::multiplePagesType ( string  $item_type)
protected

Returns if an item type is a multipage item type

Parameters
string$item_type‪Item type
Returns
‪bool TRUE if multipage capable

Definition at line 1053 of file SearchController.php.

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\compileSingleResultRow().

◆ noTypoScriptAction()

TYPO3\CMS\IndexedSearch\Controller\SearchController::noTypoScriptAction ( )

TypoScript was not loaded

Definition at line 673 of file SearchController.php.

References TYPO3\CMS\Extbase\Mvc\Controller\ActionController\htmlResponse().

◆ processExtendedSearchParameters()

◆ procSearchWordsByLexer()

array TYPO3\CMS\IndexedSearch\Controller\SearchController::procSearchWordsByLexer ( array  $searchWords)
protected

Post-process the search word array, so it will match the words that was indexed (including case-folding if any). If any words are split into multiple words (e.g. CJK will be!) the operator of the main word will remain.

Parameters
array$searchWords‪Search word array
Returns
‪array Search word array, processed through lexer

Definition at line 623 of file SearchController.php.

References TYPO3\CMS\IndexedSearch\Controller\SearchController\$searchWords.

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\getSearchWords().

◆ removeOptionsFromOptionList()

◆ searchAction()

Member Data Documentation

◆ $availableResultsNumbers

array TYPO3\CMS\IndexedSearch\Controller\SearchController::$availableResultsNumbers = []
protected

Definition at line 73 of file SearchController.php.

◆ $defaultResultNumber

int TYPO3\CMS\IndexedSearch\Controller\SearchController::$defaultResultNumber = 10
protected

◆ $externalParsers

array TYPO3\CMS\IndexedSearch\Controller\SearchController::$externalParsers = []
protected

Definition at line 74 of file SearchController.php.

◆ $firstRow

array TYPO3\CMS\IndexedSearch\Controller\SearchController::$firstRow = []
protected

Will hold the first row in result - used to calculate relative hit-ratings.

Definition at line 79 of file SearchController.php.

◆ $pathCache

array TYPO3\CMS\IndexedSearch\Controller\SearchController::$pathCache = []
protected

Definition at line 91 of file SearchController.php.

◆ $requiredFrontendUsergroups

array TYPO3\CMS\IndexedSearch\Controller\SearchController::$requiredFrontendUsergroups = []
protected

Required fe_groups memberships for display of a result.

Definition at line 84 of file SearchController.php.

◆ $resultSections

array TYPO3\CMS\IndexedSearch\Controller\SearchController::$resultSections = []
protected

Page tree sections for search result.

Definition at line 89 of file SearchController.php.

Referenced by TYPO3\CMS\IndexedSearch\Controller\SearchController\getDisplayResults().

◆ $searchRootPageIdList

string int TYPO3\CMS\IndexedSearch\Controller\SearchController::$searchRootPageIdList = 0
protected

This is the id of the site root. This value may be a comma separated list of integer (prepared for this) Root-page PIDs to search in (rl0 field where clause, see initialize() function)

If this value is set to less than zero (e.g. -1) searching will happen in ALL of the page tree with no regard to branches at all.

Definition at line 70 of file SearchController.php.

◆ $searchWords

◆ $sword

string TYPO3\CMS\IndexedSearch\Controller\SearchController::$sword = ''
protected