TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SearchController Class Reference
Inheritance diagram for SearchController:
ActionController AbstractController ControllerInterface

Public Member Functions

 injectTypoScriptService (\TYPO3\CMS\Extbase\Service\TypoScriptService $typoScriptService)
 
 initialize ($searchData=array())
 
 searchAction ($search=array())
 
 formAction ($search=array())
 
- Public Member Functions inherited from ActionController
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 injectCacheService (\TYPO3\CMS\Extbase\Service\CacheService $cacheService)
 
 injectMvcPropertyMappingConfigurationService (\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService $mvcPropertyMappingConfigurationService)
 
 processRequest (\TYPO3\CMS\Extbase\Mvc\RequestInterface $request,\TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
 
- Public Member Functions inherited from AbstractController
 injectSignalSlotDispatcher (\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
 
 injectValidatorResolver (\TYPO3\CMS\Extbase\Validation\ValidatorResolver $validatorResolver)
 
 getControllerContext ()
 
 __construct ()
 
 injectConfigurationManager (ConfigurationManagerInterface $configurationManager)
 
 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 addFlashMessage ($messageBody, $messageTitle= '', $severity=\TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession=true)
 
 canProcessRequest (\TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
 
 processRequest (\TYPO3\CMS\Extbase\Mvc\RequestInterface $request,\TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
 
 forward ($actionName, $controllerName=null, $extensionName=null, array $arguments=null)
 
 throwStatus ($statusCode, $statusMessage=null, $content=null)
 

Protected Member Functions

 getDisplayResults ($searchWords, $resultData, $freeIndexUid=-1)
 
 compileResultRows ($resultRows, $freeIndexUid=-1)
 
 compileSingleResultRow ($row, $headerOnly=0)
 
 getSpecialConfigurationForResultRow ($row)
 
 makeRating ($row)
 
 makeDescription ($row, $noMarkup=false, $length=180)
 
 markupSWpartsOfString ($str)
 
 writeSearchStat ($searchParams, $searchWords, $count, $pt)
 
 getSearchWords ($defaultOperator)
 
 procSearchWordsByLexer ($searchWords)
 
 getAllAvailableSearchTypeOptions ()
 
 getAllAvailableOperandsOptions ()
 
 getAllAvailableMediaTypesOptions ()
 
 getAllAvailableLanguageOptions ()
 
 getAllAvailableSectionsOptions ()
 
 getAllAvailableIndexConfigurationsOptions ()
 
 getAllAvailableSortOrderOptions ()
 
 getAllAvailableGroupOptions ()
 
 getAllAvailableSortDescendingOptions ()
 
 getAllAvailableNumberOfResultsOptions ()
 
 removeOptionsFromOptionList ($allOptions, $blindOptions)
 
 linkPage ($pageUid, $linkText, $row=array(), $markUpSwParams=array())
 
 getMenuOfPages ($pageUid)
 
 getPathFromPageId ($id, $pathMP= '')
 
 getFirstSysDomainRecordForPage ($id)
 
 initializeExternalParsers ()
 
 hookRequest ($functionName)
 
 multiplePagesType ($item_type)
 
 getDatabaseConnection ()
 
 loadSettings ()
 
- Protected Member Functions inherited from ActionController
 initializeActionMethodArguments ()
 
 resolveActionMethodName ()
 
 emitBeforeCallActionMethodSignal (array $preparedArguments)
 
 setViewConfiguration (ViewInterface $view)
 
 getViewProperty ($extbaseFrameworkConfiguration, $setting)
 
 resolveViewObjectName ()
 
 initializeView (ViewInterface $view)
 
 initializeAction ()
 
 errorAction ()
 
 clearCacheOnError ()
 
 addErrorFlashMessage ()
 
 getErrorFlashMessage ()
 
 forwardToReferringRequest ()
 
 getFlattenedValidationErrorMessage ()
 
- Protected Member Functions inherited from AbstractController
 redirect ($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
 
 redirectToUri ($uri, $delay=0, $statusCode=303)
 
 addBaseUriIfNecessary ($uri)
 

Protected Attributes

 $sword = null
 
 $searchWords = array()
 
 $searchData
 
 $searchRootPageIdList = 0
 
 $defaultResultNumber = 10
 
 $searchRepository = null
 
 $lexerObj
 
 $externalParsers = array()
 
 $firstRow = array()
 
 $domainRecords = array()
 
 $requiredFrontendUsergroups = array()
 
 $resultSections = array()
 
 $pathCache = array()
 
 $iconFileNameCache = array()
 
 $indexerConfig = array()
 
 $enableMetaphoneSearch = false
 
 $typoScriptService
 
- Protected Attributes inherited from ActionController
 $reflectionService
 
 $cacheService
 
 $view = null
 
 $namespacesViewObjectNamePattern = '@vendor\@extension\View\@controller\@action@format'
 
 $viewFormatToObjectNameMap = array()
 
 $defaultViewObjectName = \TYPO3\CMS\Fluid\View\TemplateView::class
 
 $actionMethodName = 'indexAction'
 
 $errorMethodName = 'errorAction'
 
 $mvcPropertyMappingConfigurationService
 
 $request
 
 $response
 
- Protected Attributes inherited from AbstractController
 $signalSlotDispatcher
 
 $objectManager
 
 $uriBuilder
 
 $extensionName
 
 $settings
 
 $request
 
 $response
 
 $validatorResolver
 
 $arguments
 
 $supportedRequestTypes = array(\TYPO3\CMS\Extbase\Mvc\Request::class)
 
 $controllerContext
 
 $configurationManager
 

Additional Inherited Members

- Static Public Member Functions inherited from ActionController
static getActionMethodParameters ($objectManager)
 

Detailed Description

Index search frontend

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

Definition at line 28 of file SearchController.php.

Member Function Documentation

compileResultRows (   $resultRows,
  $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$resultRowsResult rows
int$freeIndexUidPointing to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
Returns
string HTML

Definition at line 317 of file SearchController.php.

References SearchController\compileSingleResultRow(), elseif, SearchController\getPathFromPageId(), GeneralUtility\quoteJSvalue(), and LocalizationUtility\translate().

Referenced by SearchController\getDisplayResults().

compileSingleResultRow (   $row,
  $headerOnly = 0 
)
protected

This prints a single result row, including a recursive call for subrows.

Parameters
array$rowSearch result row
int$headerOnly1=Display only header (for sub-rows!), 2=nothing at all
Returns
string HTML code

Definition at line 402 of file SearchController.php.

References $GLOBALS, GeneralUtility\formatSize(), SearchController\getPathFromPageId(), SearchController\getSpecialConfigurationForResultRow(), SearchController\linkPage(), SearchController\makeDescription(), SearchController\makeRating(), SearchController\multiplePagesType(), and LocalizationUtility\translate().

Referenced by SearchController\compileResultRows().

formAction (   $search = array())
getAllAvailableGroupOptions ( )
protected

get the values for the "group" selector

Returns
array Associative array with options

Definition at line 1156 of file SearchController.php.

References SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableIndexConfigurationsOptions ( )
protected

get the values for the "freeIndexUid" selector

Returns
array Associative array with options

Definition at line 1100 of file SearchController.php.

References $GLOBALS, SearchController\getDatabaseConnection(), GeneralUtility\intExplode(), SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableLanguageOptions ( )
protected

get the values for the "language" selector

Returns
array Associative array with options

Definition at line 1022 of file SearchController.php.

References $GLOBALS, $lang, SearchController\getDatabaseConnection(), SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableMediaTypesOptions ( )
protected

get the values for the "media type" selector

Returns
array Associative array with options

Definition at line 985 of file SearchController.php.

References SearchController\removeOptionsFromOptionList(), LocalizationUtility\translate(), and GeneralUtility\trimExplode().

Referenced by SearchController\formAction().

getAllAvailableNumberOfResultsOptions ( )
protected

get the values for the "results" selector

Returns
array Associative array with options

Definition at line 1196 of file SearchController.php.

References SearchController\removeOptionsFromOptionList().

Referenced by SearchController\formAction().

getAllAvailableOperandsOptions ( )
protected

get the values for the "defaultOperand" selector

Returns
array Associative array with options

Definition at line 965 of file SearchController.php.

References SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableSearchTypeOptions ( )
protected

get the values for the "type" selector

Returns
array Associative array with options

Definition at line 941 of file SearchController.php.

References SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableSectionsOptions ( )
protected

get the values for the "section" selector Here values like "rl1_" and "rl2_" + a rootlevel 1/2 id can be added to perform searches in rootlevel 1+2 specifically. The id-values can even be commaseparated. Eg. "rl1_1,2" would search for stuff inside pages on menu-level 1 which has the uid's 1 and 2.

Returns
array Associative array with options

Definition at line 1054 of file SearchController.php.

References SearchController\getMenuOfPages(), SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableSortDescendingOptions ( )
protected

get the values for the "sortDescending" selector

Returns
array Associative array with options

Definition at line 1176 of file SearchController.php.

References SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getAllAvailableSortOrderOptions ( )
protected

get the values for the "section" selector Here values like "rl1_" and "rl2_" + a rootlevel 1/2 id can be added to perform searches in rootlevel 1+2 specifically. The id-values can even be commaseparated. Eg. "rl1_1,2" would search for stuff inside pages on menu-level 1 which has the uid's 1 and 2.

Returns
array Associative array with options

Definition at line 1136 of file SearchController.php.

References SearchController\removeOptionsFromOptionList(), and LocalizationUtility\translate().

Referenced by SearchController\formAction().

getDatabaseConnection ( )
protected
getDisplayResults (   $searchWords,
  $resultData,
  $freeIndexUid = -1 
)
protected

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

Parameters
array$searchWordsSearch words array (for display of text describing what was searched for)
array$resultDataArray with result rows, count, first row.
int$freeIndexUidPointing to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
Returns
array

Definition at line 280 of file SearchController.php.

References SearchController\$resultSections, SearchController\$searchWords, SearchController\compileResultRows(), SearchController\getPathFromPageId(), and LocalizationUtility\translate().

Referenced by SearchController\searchAction().

getFirstSysDomainRecordForPage (   $id)
protected

Gets the first sys_domain record for the page, $id

Parameters
int$idPage id
Returns
string Domain name

Definition at line 1354 of file SearchController.php.

References $GLOBALS, and SearchController\getDatabaseConnection().

Referenced by SearchController\getPathFromPageId().

getMenuOfPages (   $pageUid)
protected

Return the menu of pages used for the selector.

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

Definition at line 1286 of file SearchController.php.

References $GLOBALS, and SearchController\getDatabaseConnection().

Referenced by SearchController\getAllAvailableSectionsOptions().

getPathFromPageId (   $id,
  $pathMP = '' 
)
protected

Returns the path to the page $id

Parameters
int$idPage ID
string$pathMPContent of the MP (mount point) variable
Returns
string Path (HTML-escaped)

Definition at line 1308 of file SearchController.php.

References $GLOBALS, and SearchController\getFirstSysDomainRecordForPage().

Referenced by SearchController\compileResultRows(), SearchController\compileSingleResultRow(), SearchController\getDisplayResults(), and SearchController\linkPage().

getSearchWords (   $defaultOperator)
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 (eg. 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$defaultOperatorIf TRUE, the default operator will be OR, not AND
Returns
array Search words if any found

Definition at line 802 of file SearchController.php.

References $GLOBALS, SearchController\$searchWords, SearchController\hookRequest(), SearchController\procSearchWordsByLexer(), and LocalizationUtility\translate().

Referenced by SearchController\initialize().

getSpecialConfigurationForResultRow (   $row)
protected

Returns configuration from TypoScript for result row based on ID / location in page tree!

Parameters
array$rowResult row
Returns
array Configuration array

Definition at line 509 of file SearchController.php.

References $GLOBALS.

Referenced by SearchController\compileSingleResultRow().

hookRequest (   $functionName)
protected

Returns an object reference to the hook object if any

Parameters
string$functionNameName of the function you want to call / hook key
Returns
object|NULL Hook object, if any. Otherwise NULL.

Definition at line 1387 of file SearchController.php.

References $GLOBALS, and GeneralUtility\getUserObj().

Referenced by SearchController\getSearchWords(), SearchController\initialize(), and SearchController\searchAction().

initialize (   $searchData = array())
initializeExternalParsers ( )
protected

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

Returns
void

Definition at line 1367 of file SearchController.php.

References $GLOBALS, and GeneralUtility\getUserObj().

Referenced by SearchController\initialize().

injectTypoScriptService ( \TYPO3\CMS\Extbase\Service\TypoScriptService  $typoScriptService)
Parameters
\TYPO3\CMS\Extbase\Service\TypoScriptService$typoScriptService

Definition at line 147 of file SearchController.php.

References SearchController\$typoScriptService.

linkPage (   $pageUid,
  $linkText,
  $row = array(),
  $markUpSwParams = array() 
)
protected

Links the $linkText to page $pageUid

Parameters
int$pageUidPage id
string$linkTextTitle String to link
array$rowResult row
array$markUpSwParamsAdditional parameters for marking up seach words
Returns
string tag wrapped title string.
Todo:
make use of the UriBuilder

Definition at line 1242 of file SearchController.php.

References AbstractController\$uriBuilder, GeneralUtility\getIndpEnv(), SearchController\getPathFromPageId(), and GeneralUtility\implodeArrayForUrl().

Referenced by SearchController\compileSingleResultRow().

loadSettings ( )
protected

Load settings and apply stdWrap to them

Definition at line 1425 of file SearchController.php.

References $GLOBALS, and MathUtility\forceIntegerInRange().

Referenced by SearchController\initialize().

makeDescription (   $row,
  $noMarkup = false,
  $length = 180 
)
protected

Returns the resume for the search-result.

Parameters
array$rowSearch result row
bool$noMarkupIf 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.
int$lengthString length
Returns
string HTML string
Todo:
overwork this

Definition at line 650 of file SearchController.php.

References $GLOBALS, SearchController\getDatabaseConnection(), SearchController\markupSWpartsOfString(), and LocalizationUtility\translate().

Referenced by SearchController\compileSingleResultRow().

makeRating (   $row)
protected

Return the rating-HTML code for the result row. This makes use of the $this->firstRow

Parameters
array$rowResult row array
Returns
string String showing ranking value
Todo:
can this be a ViewHelper?

Definition at line 534 of file SearchController.php.

References $GLOBALS, MathUtility\forceIntegerInRange(), and LocalizationUtility\translate().

Referenced by SearchController\compileSingleResultRow().

markupSWpartsOfString (   $str)
protected

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

Parameters
string$strText in which to find and mark up search words. This text is assumed to be UTF-8 like the search words internally is.
Returns
string Processed content

Definition at line 681 of file SearchController.php.

References $GLOBALS, elseif, MathUtility\forceIntegerInRange(), and GeneralUtility\makeInstance().

Referenced by SearchController\makeDescription().

multiplePagesType (   $item_type)
protected

Returns if an item type is a multipage item type

Parameters
string$item_typeItem type
Returns
bool TRUE if multipage capable

Definition at line 1406 of file SearchController.php.

Referenced by SearchController\compileSingleResultRow().

procSearchWordsByLexer (   $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 splitted into multiple words (eg. CJK will be!) the operator of the main word will remain.

Parameters
array$searchWordsSearch word array
Returns
array Search word array, processed through lexer

Definition at line 851 of file SearchController.php.

References $GLOBALS, SearchController\$searchWords, and GeneralUtility\getUserObj().

Referenced by SearchController\getSearchWords().

removeOptionsFromOptionList (   $allOptions,
  $blindOptions 
)
protected

removes blinding entries from the option list of a selector

Parameters
array$allOptionsassociative array containing all options
array$blindOptionsassociative array containing the optionkey as they key and the value = 1 if it should be removed
Returns
array Options from $allOptions with some options removed

Definition at line 1220 of file SearchController.php.

Referenced by SearchController\getAllAvailableGroupOptions(), SearchController\getAllAvailableIndexConfigurationsOptions(), SearchController\getAllAvailableLanguageOptions(), SearchController\getAllAvailableMediaTypesOptions(), SearchController\getAllAvailableNumberOfResultsOptions(), SearchController\getAllAvailableOperandsOptions(), SearchController\getAllAvailableSearchTypeOptions(), SearchController\getAllAvailableSectionsOptions(), SearchController\getAllAvailableSortDescendingOptions(), and SearchController\getAllAvailableSortOrderOptions().

searchAction (   $search = array())
writeSearchStat (   $searchParams,
  $searchWords,
  $count,
  $pt 
)
protected

Write statistics information to database for the search operation

Parameters
array$searchParamssearch params
array$searchWordsSearch Word array
int$countNumber of hits
int$ptMilliseconds the search took
Returns
void

Definition at line 754 of file SearchController.php.

References $GLOBALS, SearchController\$searchWords, SearchController\getDatabaseConnection(), and GeneralUtility\getIndpEnv().

Referenced by SearchController\searchAction().

Member Data Documentation

$defaultResultNumber = 10
protected

Definition at line 61 of file SearchController.php.

$domainRecords = array()
protected

Definition at line 95 of file SearchController.php.

$enableMetaphoneSearch = false
protected

Definition at line 137 of file SearchController.php.

$externalParsers = array()
protected

Definition at line 81 of file SearchController.php.

$firstRow = array()
protected

Definition at line 88 of file SearchController.php.

$iconFileNameCache = array()
protected

Definition at line 123 of file SearchController.php.

$indexerConfig = array()
protected

Definition at line 130 of file SearchController.php.

$lexerObj
protected

Definition at line 75 of file SearchController.php.

$pathCache = array()
protected

Definition at line 116 of file SearchController.php.

$requiredFrontendUsergroups = array()
protected

Definition at line 102 of file SearchController.php.

$resultSections = array()
protected

Definition at line 109 of file SearchController.php.

Referenced by SearchController\getDisplayResults().

$searchData
protected
$searchRepository = null
protected

Definition at line 68 of file SearchController.php.

$searchRootPageIdList = 0
protected

Definition at line 56 of file SearchController.php.

$searchWords = array()
protected
$sword = null
protected

Definition at line 35 of file SearchController.php.

Referenced by SearchController\initialize().

$typoScriptService
protected

Definition at line 142 of file SearchController.php.

Referenced by SearchController\injectTypoScriptService().