idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
36,700
public function getSearchStatistics ( int $ rootPageId , int $ days = 30 , $ limit = 10 ) { $ now = time ( ) ; $ timeStart = ( int ) ( $ now - 86400 * $ days ) ; $ limit = ( int ) $ limit ; return $ this -> getPreparedQueryBuilderForSearchStatisticsAndTopKeywords ( $ rootPageId , $ timeStart , $ limit ) -> execute ( ) ...
Fetches must popular search keys words from the table tx_solr_statistics
36,701
public function getTopKeyWordsWithHits ( int $ rootPageId , int $ days = 30 , int $ limit = 10 ) : array { return $ this -> getTopKeyWordsWithOrWithoutHits ( $ rootPageId , $ days , $ limit , false ) ; }
Find Top search keywords with results
36,702
public function getTopKeyWordsWithoutHits ( int $ rootPageId , int $ days = 30 , int $ limit = 10 ) : array { return $ this -> getTopKeyWordsWithOrWithoutHits ( $ rootPageId , $ days , $ limit , true ) ; }
Find Top search keywords without results
36,703
protected function getTopKeyWordsWithOrWithoutHits ( int $ rootPageId , int $ days = 30 , int $ limit = 10 , bool $ withoutHits = false ) : array { $ now = time ( ) ; $ timeStart = $ now - 86400 * $ days ; $ queryBuilder = $ this -> getPreparedQueryBuilderForSearchStatisticsAndTopKeywords ( $ rootPageId , $ timeStart ,...
Find Top search keywords with or without results
36,704
public function getQueriesOverTime ( int $ rootPageId , int $ days = 30 , int $ bucketSeconds = 3600 ) : array { $ now = time ( ) ; $ timeStart = $ now - 86400 * intval ( $ days ) ; $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ result = $ queryBuilder -> addSelectLiteral ( 'FLOOR(`tstamp`/' . $ bucketSeconds . ') ...
Get number of queries over time
36,705
public function getFrequentSearchTermsFromStatisticsByFrequentSearchConfiguration ( array $ frequentSearchConfiguration ) : array { $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ resultSet = $ queryBuilder -> addSelectLiteral ( $ frequentSearchConfiguration [ 'select.' ] [ 'SELECT' ] ) -> from ( $ frequentSearchCon...
Regurns a result set by given plugin . tx_solr . search . frequentSearches . select configuration .
36,706
public function saveStatisticsRecord ( array $ statisticsRecord ) { $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ queryBuilder -> insert ( $ this -> table ) -> values ( $ statisticsRecord ) -> execute ( ) ; }
Persists statistics record
36,707
public function countByRootPageId ( int $ rootPageId ) : int { $ queryBuilder = $ this -> getQueryBuilder ( ) ; return ( int ) $ this -> getQueryBuilder ( ) -> count ( '*' ) -> from ( $ this -> table ) -> andWhere ( $ queryBuilder -> expr ( ) -> eq ( 'root_pid' , $ rootPageId ) ) -> execute ( ) -> fetchColumn ( 0 ) ; }
Counts rows for specified site
36,708
protected function getUrlAndDecodeResponse ( $ url , PageIndexerResponse $ response ) { $ headers = $ this -> getHeaders ( ) ; $ rawResponse = $ this -> getUrl ( $ url , $ headers , $ this -> timeout ) ; $ decodedResponse = $ response -> getResultsFromJson ( $ rawResponse -> getBody ( ) -> getContents ( ) ) ; if ( $ ra...
This method is used to retrieve an url from the frontend and decode the response .
36,709
public function getHeaders ( ) { $ headers = $ this -> header ; $ headers [ ] = 'User-Agent: ' . $ this -> getUserAgent ( ) ; $ itemId = $ this -> indexQueueItem -> getIndexQueueUid ( ) ; $ pageId = $ this -> indexQueueItem -> getRecordPageId ( ) ; $ indexerRequestData = [ 'requestId' => $ this -> requestId , 'item' =>...
Generates the headers to be send with the request .
36,710
public function isAuthenticated ( ) { $ authenticated = false ; if ( is_null ( $ this -> parameters ) ) { return $ authenticated ; } $ calculatedHash = md5 ( $ this -> parameters [ 'item' ] . '|' . $ this -> parameters [ 'page' ] . '|' . $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 'encryptionKey' ] ) ; if ( $ this -> p...
Checks whether this is a legitimate request coming from the Index Queue page indexer worker task .
36,711
public function setParameter ( $ parameter , $ value ) { if ( is_bool ( $ value ) ) { $ value = $ value ? '1' : '0' ; } $ this -> parameters [ $ parameter ] = $ value ; }
Sets a request s parameter and its value .
36,712
protected function getUrl ( $ url , $ headers , $ timeout ) : ResponseInterface { try { $ options = $ this -> buildGuzzleOptions ( $ headers , $ timeout ) ; $ response = $ this -> requestFactory -> request ( $ url , 'GET' , $ options ) ; } catch ( ClientException $ e ) { $ response = $ e -> getResponse ( ) ; } catch ( ...
Fetches a page by sending the configured headers .
36,713
protected function buildGuzzleOptions ( $ headers , $ timeout ) { $ finalHeaders = [ ] ; foreach ( $ headers as $ header ) { list ( $ name , $ value ) = explode ( ':' , $ header , 2 ) ; $ finalHeaders [ $ name ] = trim ( $ value ) ; } $ options = [ 'headers' => $ finalHeaders , 'timeout' => $ timeout ] ; if ( ! empty (...
Build the options array for the guzzle client .
36,714
public static function renderStatic ( array $ arguments , \ Closure $ renderChildrenClosure , RenderingContextInterface $ renderingContext ) { return BackendUtility :: wrapInHelp ( '' , '' , '' , [ 'title' => $ arguments [ 'title' ] , 'description' => $ arguments [ 'description' ] ] ) ; }
Render a help button wit the given title and content
36,715
protected function getSiteForRootPageId ( int $ pageId ) : array { return is_array ( $ this -> sites [ $ pageId ] ) ? $ this -> sites [ $ pageId ] : [ ] ; }
Retrieves the configured site for a rootPageId .
36,716
public function buildSearchQuery ( $ rawQuery , $ resultsPerPage = 10 , array $ additionalFiltersFromRequest = [ ] ) : SearchQuery { if ( $ this -> typoScriptConfiguration -> getLoggingQuerySearchWords ( ) ) { $ this -> logger -> log ( SolrLogManager :: INFO , 'Received search query' , [ $ rawQuery ] ) ; } return $ thi...
Initializes the Query object and SearchComponents and returns the initialized query object when a search should be executed .
36,717
public function buildSuggestQuery ( string $ queryString , array $ additionalFilters , int $ requestedPageId , string $ groupList ) : SuggestQuery { $ this -> newSuggestQuery ( $ queryString ) -> useFiltersFromTypoScript ( ) -> useSiteHashFromTypoScript ( $ requestedPageId ) -> useUserAccessGroups ( explode ( ',' , $ g...
Builds a SuggestQuery with all applied filters .
36,718
public function buildRecordQuery ( $ type , $ uid , $ pageId ) : Query { $ siteRepository = GeneralUtility :: makeInstance ( SiteRepository :: class ) ; $ site = $ siteRepository -> getSiteByPageId ( $ pageId ) ; return $ this -> newSearchQuery ( '' ) -> useQueryString ( '*:*' ) -> useFilter ( 'type:' . $ type . ' AND ...
Returns a query for single record
36,719
public function useBoostQueriesFromTypoScript ( ) : QueryBuilder { $ searchConfiguration = $ this -> typoScriptConfiguration -> getSearchConfiguration ( ) ; if ( ! empty ( $ searchConfiguration [ 'query.' ] [ 'boostQuery' ] ) ) { return $ this -> useBoostQueries ( $ searchConfiguration [ 'query.' ] [ 'boostQuery' ] ) ;...
Uses the configured boost queries from typoscript
36,720
public function useBoostFunctionFromTypoScript ( ) : QueryBuilder { $ searchConfiguration = $ this -> typoScriptConfiguration -> getSearchConfiguration ( ) ; if ( ! empty ( $ searchConfiguration [ 'query.' ] [ 'boostFunction' ] ) ) { return $ this -> useBoostFunction ( $ searchConfiguration [ 'query.' ] [ 'boostFunctio...
Uses the configured boostFunction from the typoscript configuration .
36,721
public function useMinimumMatchFromTypoScript ( ) : QueryBuilder { $ searchConfiguration = $ this -> typoScriptConfiguration -> getSearchConfiguration ( ) ; if ( ! empty ( $ searchConfiguration [ 'query.' ] [ 'minimumMatch' ] ) ) { return $ this -> useMinimumMatch ( $ searchConfiguration [ 'query.' ] [ 'minimumMatch' ]...
Uses the configured minimumMatch from the typoscript configuration .
36,722
public function useReturnFieldsFromTypoScript ( ) : QueryBuilder { $ returnFieldsArray = ( array ) $ this -> typoScriptConfiguration -> getSearchQueryReturnFieldsAsArray ( [ '*' , 'score' ] ) ; return $ this -> useReturnFields ( ReturnFields :: fromArray ( $ returnFieldsArray ) ) ; }
Applies the configured return fields from the typoscript configuration .
36,723
public function useSiteHashFromTypoScript ( int $ requestedPageId ) : QueryBuilder { $ queryConfiguration = $ this -> typoScriptConfiguration -> getObjectByPathOrDefault ( 'plugin.tx_solr.search.query.' , [ ] ) ; $ allowedSites = $ this -> siteHashService -> getAllowedSitesForPageIdAndAllowedSitesConfiguration ( $ requ...
Can be used to apply the allowed sites from plugin . tx_solr . search . query . allowedSites to the query .
36,724
public function useSiteHashFromAllowedSites ( $ allowedSites ) : QueryBuilder { $ isAnySiteAllowed = trim ( $ allowedSites ) === '*' ; if ( $ isAnySiteAllowed ) { return $ this ; } $ allowedSites = GeneralUtility :: trimExplode ( ',' , $ allowedSites ) ; $ filters = [ ] ; foreach ( $ allowedSites as $ site ) { $ siteHa...
Can be used to apply a list of allowed sites to the query .
36,725
public function useUserAccessGroups ( array $ groups ) : QueryBuilder { $ groups = array_map ( 'intval' , $ groups ) ; $ groups [ ] = 0 ; $ groups = array_unique ( $ groups ) ; sort ( $ groups , SORT_NUMERIC ) ; $ accessFilter = '{!typo3access}' . implode ( ',' , $ groups ) ; $ this -> queryToBuild -> removeFilterQuery...
Can be used to filter the result on an applied list of user groups .
36,726
public function useInitialQueryFromTypoScript ( ) : QueryBuilder { if ( $ this -> typoScriptConfiguration -> getSearchInitializeWithEmptyQuery ( ) || $ this -> typoScriptConfiguration -> getSearchQueryAllowEmptyQuery ( ) ) { $ this -> useAlternativeQuery ( '*:*' ) ; } if ( $ this -> typoScriptConfiguration -> getSearch...
Applies the configured initial query settings to set the alternative query for solr as required .
36,727
protected function applyPassedResultsPerPage ( SearchRequest $ searchRequest ) { $ requestedPerPage = $ searchRequest -> getResultsPerPage ( ) ; $ perPageSwitchOptions = $ this -> typoScriptConfiguration -> getSearchResultsPerPageSwitchOptionsAsArray ( ) ; if ( isset ( $ requestedPerPage ) && in_array ( $ requestedPerP...
Checks if the passed resultsPerPageValue is valid and applies it . If the perPage value was changed it is stored in the session and the current page is set to 0 since the pagination should start from the beginning then .
36,728
protected function shouldHideResultsFromInitialSearch ( SearchRequest $ searchRequest ) { return ( $ this -> typoScriptConfiguration -> getSearchInitializeWithEmptyQuery ( ) || $ this -> typoScriptConfiguration -> getSearchInitializeWithQuery ( ) ) && ! $ this -> typoScriptConfiguration -> getSearchShowResultsOfInitial...
Checks it the results should be hidden in the response .
36,729
protected function getRequest ( array $ requestArguments = [ ] , $ pageId = 0 , $ languageId = 0 ) { $ searchRequest = GeneralUtility :: makeInstance ( SearchRequest :: class , $ requestArguments , $ pageId , $ languageId , $ this -> typoScriptConfiguration ) ; return $ searchRequest ; }
Creates an instance of the SearchRequest .
36,730
protected function adjustPageArgumentToPositiveInteger ( array $ arguments ) { $ page = isset ( $ arguments [ 'page' ] ) ? intval ( $ arguments [ 'page' ] ) : 0 ; $ arguments [ 'page' ] = max ( $ page , 0 ) ; return $ arguments ; }
This methods sets the page argument to an expected positive integer value in the arguments array .
36,731
public static function getMapArrayFromFlatArray ( array $ options ) : array { $ keyValueMap = [ ] ; $ valueFromKeyNode = - 1 ; foreach ( $ options as $ key => $ value ) { $ isKeyNode = ( ( $ key % 2 ) == 0 ) ; if ( $ isKeyNode ) { $ valueFromKeyNode = $ value ; } else { if ( $ valueFromKeyNode == - 1 ) { throw new \ Un...
This method is used to covert a array structure with json . nl = flat to have it as return with json . nl = map .
36,732
public function getForFacet ( $ sorting ) { $ noSortingSet = $ sorting !== 0 && $ sorting !== FALSE && empty ( $ sorting ) ; $ sortingIsCount = $ sorting === 'count' || $ sorting === 1 || $ sorting === '1' || $ sorting === TRUE ; if ( $ noSortingSet ) { return '' ; } elseif ( $ sortingIsCount ) { return 'count' ; } els...
Return expression for facet sorting
36,733
public function getForJsonFacet ( $ sorting , $ direction ) { $ isMetricSorting = strpos ( $ sorting , 'metrics_' ) === 0 ; $ expression = $ isMetricSorting ? $ sorting : $ this -> getForFacet ( $ sorting ) ; $ direction = strtolower ( $ direction ) ; if ( ! empty ( $ direction ) && in_array ( $ direction , [ 'asc' , '...
Return expression for facet sorting combined with direction
36,734
protected function cleanUpIndex ( ) { $ cleanUpResult = true ; $ solrConfiguration = $ this -> getSite ( ) -> getSolrConfiguration ( ) ; $ solrServers = GeneralUtility :: makeInstance ( ConnectionManager :: class ) -> getConnectionsBySite ( $ this -> getSite ( ) ) ; $ typesToCleanUp = [ ] ; $ enableCommitsSetting = $ s...
Removes documents of the selected types from the index .
36,735
public function getAdditionalInformation ( ) { $ site = $ this -> getSite ( ) ; if ( is_null ( $ site ) ) { return 'Invalid site configuration for scheduler please re-create the task!' ; } $ information = 'Site: ' . $ this -> getSite ( ) -> getLabel ( ) ; if ( ! empty ( $ this -> indexingConfigurationsToReIndex ) ) { $...
This method is designed to return some additional information about the task that may help to set it apart from other tasks from the same class This additional information is used - for example - in the Scheduler s BE module This method should be implemented in most task classes
36,736
public function getAllRequirementsMet ( AbstractFacet $ facet ) { $ requirements = $ facet -> getRequirements ( ) ; if ( ! is_array ( $ requirements ) || count ( $ requirements ) === 0 ) { return true ; } foreach ( $ requirements as $ requirement ) { $ requirementMet = $ this -> getRequirementMet ( $ facet , $ requirem...
Checks if facet meets all requirements .
36,737
protected function getRequirementMet ( AbstractFacet $ facet , $ requirement = [ ] ) { $ selectedItemValues = $ this -> getSelectedItemValues ( $ facet , $ requirement [ 'facet' ] ) ; $ csvActiveFacetItemValues = implode ( ', ' , $ selectedItemValues ) ; $ requirementValues = GeneralUtility :: trimExplode ( ',' , $ req...
Checks if a single requirement is met .
36,738
protected function getSelectedItemValues ( AbstractFacet $ facet , $ facetNameToCheckRequirementsOn ) { $ facetToCheckRequirements = $ facet -> getResultSet ( ) -> getFacets ( ) -> getByName ( $ facetNameToCheckRequirementsOn ) -> getByPosition ( 0 ) ; if ( ! $ facetToCheckRequirements instanceof AbstractFacet ) { thro...
Returns the active item values of a facet
36,739
protected function getNegationWhenConfigured ( $ value , $ configuration ) { if ( ! is_array ( $ configuration ) || empty ( $ configuration [ 'negate' ] ) || ( bool ) $ configuration [ 'negate' ] === false ) { return $ value ; } return ! ( ( bool ) $ value ) ; }
Negates the result when configured .
36,740
public function indexAction ( ) { if ( $ this -> selectedSolrCoreConnection === null ) { $ this -> view -> assign ( 'can_not_proceed' , true ) ; return ; } $ synonyms = [ ] ; $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; $ rawSynonyms = $ coreAdmin -> getSynonyms ( ) ; foreach ( $ rawSynon...
Gets synonyms and stopwords for the currently selected core
36,741
public function addSynonymsAction ( string $ baseWord , string $ synonyms , $ overrideExisting ) { if ( empty ( $ baseWord ) || empty ( $ synonyms ) ) { $ this -> addFlashMessage ( 'Please provide a base word and synonyms.' , 'Missing parameter' , FlashMessage :: ERROR ) ; } else { $ baseWord = mb_strtolower ( $ baseWo...
Add synonyms to selected core
36,742
public function exportSynonymsAction ( $ fileFormat = 'txt' ) { $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; $ synonyms = $ coreAdmin -> getSynonyms ( ) ; return $ this -> exportFile ( ManagedResourcesUtility :: exportSynonymsToTxt ( $ synonyms ) , 'synonyms' , $ fileFormat ) ; }
Exports synonyms to a download file .
36,743
public function deleteAllSynonymsAction ( ) { $ allSynonymsCouldBeDeleted = $ this -> deleteAllSynonyms ( ) ; $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; $ reloadResponse = $ coreAdmin -> reloadCore ( ) ; if ( $ allSynonymsCouldBeDeleted && $ reloadResponse -> getHttpStatus ( ) == 200 ) ...
Delete complete synonym list
36,744
public function deleteSynonymsAction ( $ baseWord ) { $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; $ deleteResponse = $ coreAdmin -> deleteSynonym ( $ baseWord ) ; $ reloadResponse = $ coreAdmin -> reloadCore ( ) ; if ( $ deleteResponse -> getHttpStatus ( ) == 200 && $ reloadResponse -> g...
Deletes a synonym mapping by its base word .
36,745
public function saveStopWordsAction ( string $ stopWords , $ replaceStopwords = true ) { $ newStopWords = mb_strtolower ( $ stopWords ) ; $ newStopWords = GeneralUtility :: trimExplode ( "\n" , $ newStopWords , true ) ; $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; $ oldStopWords = $ coreA...
Saves the edited stop word list to Solr
36,746
protected function sendFileResponse ( ) { $ this -> response -> sendHeaders ( ) ; $ this -> response -> send ( ) ; $ this -> response -> shutdown ( ) ; exit ( ) ; }
This method send the headers and content and does an exit since without the exit TYPO3 produces and error .
36,747
protected function deleteAllSynonyms ( ) : bool { $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; $ synonyms = $ coreAdmin -> getSynonyms ( ) ; $ allSynonymsCouldBeDeleted = true ; foreach ( $ synonyms as $ baseWord => $ synonym ) { $ deleteResponse = $ coreAdmin -> deleteSynonym ( $ baseWor...
Delete complete synonym list form solr
36,748
protected function deleteExistingSynonym ( $ overrideExisting , $ deleteSynonymsBefore , $ baseWord ) { $ coreAdmin = $ this -> selectedSolrCoreConnection -> getAdminService ( ) ; if ( ! $ deleteSynonymsBefore && $ overrideExisting && $ coreAdmin -> getSynonyms ( $ baseWord ) ) { $ coreAdmin -> deleteSynonym ( $ baseWo...
Delete synonym entry if selceted before
36,749
public function registerParser ( $ className , $ priority ) { if ( ! class_exists ( $ className ) ) { throw new \ InvalidArgumentException ( 'Class ' . $ className . ' does not exist.' , 1468863997 ) ; } if ( ! is_subclass_of ( $ className , AbstractResultParser :: class ) ) { throw new \ InvalidArgumentException ( 'Pa...
Can be used to register a custom parser .
36,750
public function hasParser ( $ className , $ priority ) { if ( empty ( $ this -> parsers [ $ priority ] ) ) { return false ; } return $ this -> parsers [ $ priority ] === $ className ; }
Method to check if a certain parser is allready registered
36,751
public function getSetFacetValueUri ( SearchRequest $ previousSearchRequest , $ facetName , $ facetValue ) { $ previousSearchRequest = $ previousSearchRequest -> getCopyForSubRequest ( ) -> removeAllGroupItemPages ( ) -> removeAllFacetValuesByName ( $ facetName ) ; return $ this -> getAddFacetValueUri ( $ previousSearc...
Removes all other facet values for this name and only set s the passed value for the facet .
36,752
protected function buildLinkWithInMemoryCache ( $ pageUid , array $ arguments ) { $ values = [ ] ; $ structure = $ arguments ; $ this -> getSubstitution ( $ structure , $ values ) ; $ hash = md5 ( $ pageUid . json_encode ( $ structure ) ) ; if ( isset ( self :: $ preCompiledLinks [ $ hash ] ) ) { self :: $ hitCount ++ ...
Build the link with an i memory cache that reduces the amount of required typolink calls .
36,753
public function findAllKeywords ( $ limit = 10 ) : array { $ lastSearchesResultSet = $ this -> getLastSearchesResultSet ( $ limit ) ; if ( empty ( $ lastSearchesResultSet ) ) { return [ ] ; } $ lastSearches = [ ] ; foreach ( $ lastSearchesResultSet as $ row ) { $ lastSearches [ ] = html_entity_decode ( $ row [ 'keyword...
Finds the last searched keywords from the database
36,754
protected function getLastSearchesResultSet ( $ limit ) : array { $ queryBuilder = $ this -> getQueryBuilder ( ) ; return $ queryBuilder -> select ( 'keywords' ) -> addSelectLiteral ( $ queryBuilder -> expr ( ) -> max ( 'tstamp' , 'maxtstamp' ) ) -> from ( $ this -> table ) -> groupBy ( 'keywords' ) -> orderBy ( 'maxts...
Returns all last searches
36,755
public function add ( string $ lastSearchesKeywords , int $ lastSearchesLimit ) { $ nextSequenceId = $ this -> resolveNextSequenceIdForGivenLimit ( $ lastSearchesLimit ) ; $ rowsCount = $ this -> count ( ) ; if ( $ nextSequenceId < $ rowsCount ) { $ this -> update ( [ 'sequence_id' => $ nextSequenceId , 'keywords' => $...
Adds keywords to last searches or updates the oldest row by given limit .
36,756
protected function resolveNextSequenceIdForGivenLimit ( int $ lastSearchesLimit ) : int { $ nextSequenceId = 0 ; $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ result = $ queryBuilder -> select ( 'sequence_id' ) -> from ( $ this -> table ) -> orderBy ( 'tstamp' , 'DESC' ) -> setMaxResults ( 1 ) -> execute ( ) -> fe...
Resolves next sequence id by given last searches limit .
36,757
public function modifyQuery ( Query $ query ) { return $ this -> queryBuilder -> startFrom ( $ query ) -> useDebug ( true ) -> getQuery ( ) ; }
Enables the query s debug mode to get more detailed information .
36,758
public function extractByQuery ( Query $ query ) { try { $ response = $ this -> createAndExecuteRequest ( $ query ) ; $ fileName = basename ( $ query -> getFile ( ) ) ; $ metaKey = $ fileName . '_metadata' ; return [ $ response -> { $ fileName } , ( array ) $ response -> { $ metaKey } ] ; } catch ( \ Exception $ e ) { ...
Performs a content and meta data extraction request .
36,759
public function deleteByType ( $ type , $ commit = true ) { $ this -> deleteByQuery ( 'type:' . trim ( $ type ) ) ; if ( $ commit ) { $ this -> commit ( false , false ) ; } }
Deletes all index documents of a certain type and does a commit afterwards .
36,760
public function initialize ( $ webRoot , $ scriptFileName = PATH_site , $ phpSelf = '/index.php' , $ scriptName = '/index.php' ) { if ( $ this -> isInitialized ) { return false ; } if ( defined ( 'TYPO3_PATH_WEB' ) ) { throw new WebRootAllReadyDefinedException ( 'TYPO3_PATH_WEB is already defined' ) ; } define ( 'TYPO3...
Initializes the frontend related server variables for the cli context .
36,761
public function search ( SearchRequest $ searchRequest ) { $ resultSet = $ this -> getInitializedSearchResultSet ( $ searchRequest ) ; $ this -> lastResultSet = $ resultSet ; $ resultSet = $ this -> handleSearchHook ( 'beforeSearch' , $ resultSet ) ; if ( $ this -> shouldReturnEmptyResultSetWithoutExecutedSearch ( $ se...
Performs a search and returns a SearchResultSet .
36,762
protected function getParsedSearchResults ( $ resultSet ) { $ parserRegistry = GeneralUtility :: makeInstance ( ResultParserRegistry :: class , $ this -> typoScriptConfiguration ) ; $ useRawDocuments = ( bool ) $ this -> typoScriptConfiguration -> getValueByPathOrDefaultValue ( 'plugin.tx_solr.features.useRawDocuments'...
Uses the configured parser and retrieves the parsed search resutls .
36,763
protected function shouldReturnEmptyResultSetWithoutExecutedSearch ( SearchRequest $ searchRequest ) { if ( $ searchRequest -> getRawUserQueryIsNull ( ) && ! $ this -> getInitialSearchIsConfigured ( ) ) { return true ; } if ( $ searchRequest -> getRawUserQueryIsEmptyString ( ) && ! $ this -> typoScriptConfiguration -> ...
Evaluates conditions on the request and configuration and returns true if no search should be triggered and an empty SearchResultSet should be returned .
36,764
protected function getInitializedSearchResultSet ( SearchRequest $ searchRequest ) : SearchResultSet { $ resultSetClass = $ this -> getResultSetClassName ( ) ; $ resultSet = GeneralUtility :: makeInstance ( $ resultSetClass ) ; $ resultSet -> setUsedSearchRequest ( $ searchRequest ) ; $ resultSet -> setUsedPage ( ( int...
Initializes the SearchResultSet from the SearchRequest
36,765
protected function doASearch ( $ query , $ searchRequest ) : ResponseAdapter { $ offsetMultiplier = max ( 0 , $ searchRequest -> getPage ( ) - 1 ) ; $ offSet = $ offsetMultiplier * ( int ) $ searchRequest -> getResultsPerPage ( ) ; $ response = $ this -> search -> search ( $ query , $ offSet , null ) ; if ( $ response ...
Executes the search and builds a fake response for a current bug in Apache Solr 6 . 3
36,766
protected function modifyQuery ( Query $ query , SearchRequest $ searchRequest , Search $ search ) { if ( is_array ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXTCONF' ] [ 'solr' ] [ 'modifySearchQuery' ] ) ) { foreach ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXTCONF' ] [ 'solr' ] [ 'modifySearchQuery' ] as $ classReference ) { $...
Allows to modify a query before eventually handing it over to Solr .
36,767
public function getDocumentById ( $ documentId ) { $ query = $ this -> queryBuilder -> newSearchQuery ( $ documentId ) -> useQueryFields ( QueryFields :: fromString ( 'id' ) ) -> getQuery ( ) ; $ response = $ this -> search -> search ( $ query , 0 , 1 ) ; $ parsedData = $ response -> getParsedData ( ) ; $ resultDocumen...
Retrieves a single document from solr by document id .
36,768
private function handleSearchHook ( $ eventName , SearchResultSet $ resultSet ) { if ( ! is_array ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXTCONF' ] [ 'solr' ] [ $ eventName ] ) ) { return $ resultSet ; } foreach ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXTCONF' ] [ 'solr' ] [ $ eventName ] as $ classReference ) { $ afterSear...
This method is used to call the registered hooks during the search execution .
36,769
public function getLastSearchWasExecutedWithEmptyQueryString ( ) { $ wasEmptyQueryString = false ; if ( $ this -> lastResultSet != null ) { $ wasEmptyQueryString = $ this -> lastResultSet -> getUsedSearchRequest ( ) -> getRawUserQueryIsEmptyString ( ) ; } return $ wasEmptyQueryString ; }
This method returns true when the last search was executed with an empty query string or whitespaces only . When no search was triggered it will return false .
36,770
public function cObjGetSingleExt ( $ name , array $ configuration , $ TyposcriptKey , $ contentObject ) { if ( ! is_array ( $ configuration [ 'classes.' ] ) ) { throw new \ InvalidArgumentException ( 'No class configuration configured for SOLR_CLASSIFICATION object. Given configuration: ' . serialize ( $ configuration ...
Executes the SOLR_CLASSIFICATION content object .
36,771
protected function buildClassificationsFromConfiguration ( $ configuredMappedClasses ) : array { $ classifications = [ ] ; foreach ( $ configuredMappedClasses as $ class ) { if ( ( empty ( $ class [ 'patterns' ] ) && empty ( $ class [ 'matchPatterns' ] ) ) || empty ( $ class [ 'class' ] ) ) { throw new \ InvalidArgumen...
Builds an array of Classification objects from the passed classification configuration .
36,772
public function isValidSolrPath ( $ path ) { $ path = trim ( $ path ) ; if ( ( ! empty ( $ path ) ) && ( preg_match ( '/^[^*?"<>|:#]*$/' , $ path ) ) ) { return true ; } return false ; }
Validate that a path is a valid Solr Path
36,773
protected function buildSolrHierarchyFromPath ( $ path ) { $ hierarchy = [ ] ; $ path = HierarchyTool :: substituteSlashes ( $ path ) ; $ treeParts = GeneralUtility :: trimExplode ( '/' , $ path , true ) ; $ currentTreeParts = [ ] ; foreach ( $ treeParts as $ i => $ part ) { $ currentTreeParts [ ] = $ part ; $ hierarch...
Builds a Solr hierarchy from path string .
36,774
public function findDomainRecordsByRootPagesIds ( array $ rootPageIds = [ ] ) { $ resultTmp = $ this -> getDomainRecordsByRootPageIds ( $ rootPageIds ) ; $ result = [ ] ; foreach ( $ resultTmp as $ key => $ row ) { $ result [ $ row [ 'pid' ] ] = $ row ; } return $ result ; }
Retrieves sys_domain records for a set of root page ids .
36,775
protected function getDomainRecordsByRootPageIds ( array $ rootPageIds = [ ] ) { $ queryBuilder = $ this -> getQueryBuilder ( ) ; return $ queryBuilder -> select ( 'uid' , 'pid' ) -> from ( $ this -> table ) -> where ( $ queryBuilder -> expr ( ) -> in ( 'pid' , $ rootPageIds ) ) -> groupBy ( 'uid' , 'pid' , 'sorting' )...
Fetches the domain records for TYPO3 9 .
36,776
public function authorizeFrontendUser ( ) { $ accessRootline = $ this -> getAccessRootline ( ) ; $ stringAccessRootline = ( string ) $ accessRootline ; if ( empty ( $ stringAccessRootline ) ) { return ; } if ( ! is_array ( $ GLOBALS [ 'TSFE' ] -> fe_user -> user ) ) { $ GLOBALS [ 'TSFE' ] -> fe_user -> user = [ ] ; } $...
Fakes a logged in user to retrieve access restricted content .
36,777
protected function getAccessRootline ( ) { $ stringAccessRootline = '' ; if ( $ this -> request -> getParameter ( 'accessRootline' ) ) { $ stringAccessRootline = $ this -> request -> getParameter ( 'accessRootline' ) ; } $ accessRootline = GeneralUtility :: makeInstance ( Rootline :: class , $ stringAccessRootline ) ; ...
Gets the access rootline as defined by the request .
36,778
protected function getHighestAuthenticationServicePriority ( ) { $ highestPriority = 0 ; if ( is_array ( $ GLOBALS [ 'T3_SERVICES' ] [ 'auth' ] ) ) { foreach ( $ GLOBALS [ 'T3_SERVICES' ] [ 'auth' ] as $ service ) { if ( $ service [ 'priority' ] > $ highestPriority ) { $ highestPriority = $ service [ 'priority' ] ; } }...
Determines the highest priority of all registered authentication services .
36,779
public function hook_indexContent ( TypoScriptFrontendController $ page ) { $ this -> logger = GeneralUtility :: makeInstance ( SolrLogManager :: class , __CLASS__ ) ; $ this -> page = $ page ; $ configuration = Util :: getSolrConfiguration ( ) ; $ logPageIndexed = $ configuration -> getLoggingIndexingPageIndexed ( ) ;...
Handles the indexing of the page content during post processing of a generated page .
36,780
protected function getSolrConnection ( Item $ indexQueueItem ) { $ connectionManager = GeneralUtility :: makeInstance ( ConnectionManager :: class ) ; $ solrConnection = $ connectionManager -> getConnectionByRootPageId ( $ indexQueueItem -> getRootPageUid ( ) , $ GLOBALS [ 'TSFE' ] -> sys_language_uid ) ; return $ solr...
Gets the solr connection to use for indexing the page based on the Index Queue item s properties .
36,781
protected function getIndexQueueItem ( ) { $ indexQueue = GeneralUtility :: makeInstance ( Queue :: class ) ; $ indexQueueItem = $ indexQueue -> getItem ( $ this -> request -> getParameter ( 'item' ) ) ; return $ indexQueueItem ; }
This method retrieves the item from the index queue that is indexed in this request .
36,782
public function initialize ( ) { $ initializationQuery = 'INSERT INTO tx_solr_indexqueue_item (root, item_type, item_uid, indexing_configuration, indexing_priority, changed, errors) ' . $ this -> buildSelectStatement ( ) . ',"" ' . 'FROM ' . $ this -> type . ' ' . 'WHERE ' . $ this -> buildPagesClause ( ) . $ this -> b...
Initializes Index Queue items for a certain site and indexing configuration .
36,783
protected function buildSelectStatement ( ) { $ changedField = $ GLOBALS [ 'TCA' ] [ $ this -> type ] [ 'ctrl' ] [ 'tstamp' ] ; if ( ! empty ( $ GLOBALS [ 'TCA' ] [ $ this -> type ] [ 'ctrl' ] [ 'enablecolumns' ] [ 'starttime' ] ) ) { $ changedField = 'GREATEST(' . $ GLOBALS [ 'TCA' ] [ $ this -> type ] [ 'ctrl' ] [ 'e...
Builds the SELECT part of the Index Queue initialization query .
36,784
protected function getIndexingPriority ( ) { $ priority = 0 ; if ( ! empty ( $ this -> indexingConfiguration [ 'indexingPriority' ] ) ) { $ priority = ( int ) $ this -> indexingConfiguration [ 'indexingPriority' ] ; } return $ priority ; }
Reads the indexing priority for an indexing configuration .
36,785
protected function buildPagesClause ( ) { $ pages = $ this -> getPages ( ) ; $ pageIdField = ( $ this -> type === 'pages' ) ? 'uid' : 'pid' ; return $ pageIdField . ' IN(' . implode ( ',' , $ pages ) . ')' ; }
Builds a part of the WHERE clause of the Index Queue initialization query . This part selects the limits items to be selected from the pages in a site only plus additional pages that may have been configured .
36,786
protected function getPages ( ) { $ pages = $ this -> site -> getPages ( ) ; $ additionalPageIds = [ ] ; if ( ! empty ( $ this -> indexingConfiguration [ 'additionalPageIds' ] ) ) { $ additionalPageIds = GeneralUtility :: intExplode ( ',' , $ this -> indexingConfiguration [ 'additionalPageIds' ] ) ; } $ pages = array_m...
Gets the pages in a site plus additional pages that may have been configured .
36,787
protected function buildTcaWhereClause ( ) { $ tcaWhereClause = '' ; $ conditions = [ ] ; if ( isset ( $ GLOBALS [ 'TCA' ] [ $ this -> type ] [ 'ctrl' ] [ 'delete' ] ) ) { $ conditions [ 'delete' ] = $ GLOBALS [ 'TCA' ] [ $ this -> type ] [ 'ctrl' ] [ 'delete' ] . ' = 0' ; } if ( isset ( $ GLOBALS [ 'TCA' ] [ $ this ->...
Builds the WHERE clauses of the Index Queue initialization query based on TCA information for the type to be initialized .
36,788
protected function logInitialization ( array $ logData ) { if ( ! $ this -> site -> getSolrConfiguration ( ) -> getLoggingIndexingIndexQueueInitialization ( ) ) { return ; } $ logSeverity = isset ( $ logData [ 'error' ] ) ? SolrLogManager :: ERROR : SolrLogManager :: NOTICE ; $ logData = array_merge ( $ logData , [ 'si...
Writes the passed log data to the log .
36,789
public function findOneByPageIdAndByLanguageId ( $ pageId , $ languageId ) { $ documentCollection = $ this -> findByPageIdAndByLanguageId ( $ pageId , $ languageId ) ; return reset ( $ documentCollection ) ; }
Returns firs found Apache_Solr_Document for current page by given language id .
36,790
protected function initializeSearch ( $ pageId , $ languageId = 0 ) { if ( ! is_int ( $ pageId ) ) { throw new \ InvalidArgumentException ( 'Invalid page ID = ' . $ pageId , 1487332926 ) ; } if ( ! is_int ( $ languageId ) ) { throw new \ InvalidArgumentException ( 'Invalid language ID = ' . $ languageId , 1487335178 ) ...
Initializes Search for given language
36,791
public function cObjGetSingleExt ( $ name , array $ configuration , $ TyposcriptKey , $ contentObject ) { $ contentExtractor = GeneralUtility :: makeInstance ( HtmlContentExtractor :: class , $ this -> getRawContent ( $ contentObject , $ configuration ) ) ; return $ contentExtractor -> getIndexableContent ( ) ; }
Executes the SOLR_CONTENT content object .
36,792
protected function getRawContent ( $ contentObject , $ configuration ) { $ content = '' ; if ( isset ( $ configuration [ 'value' ] ) ) { $ content = $ configuration [ 'value' ] ; unset ( $ configuration [ 'value' ] ) ; } if ( ! empty ( $ configuration ) ) { $ content = $ contentObject -> stdWrap ( $ content , $ configu...
Gets the raw content as configured - a certain value or database field .
36,793
public function update ( $ pageId ) { $ pageSelect = GeneralUtility :: makeInstance ( PageRepository :: class ) ; $ rootLineArray = $ pageSelect -> getRootLine ( $ pageId ) ; $ currentPage = array_shift ( $ rootLineArray ) ; $ currentPageUid = ( int ) $ currentPage [ 'uid' ] ; if ( empty ( $ rootLineArray ) && $ curren...
Handles updates of the Index Queue in case a newly created or changed page is part of a tree that is mounted into a another site .
36,794
protected function addPageToMountingSiteIndexQueue ( $ mountedPageId , array $ mountProperties ) { $ siteRepository = GeneralUtility :: makeInstance ( SiteRepository :: class ) ; $ mountingSite = $ siteRepository -> getSiteByPageId ( $ mountProperties [ 'mountPageDestination' ] ) ; $ pageInitializer = GeneralUtility ::...
Adds a page to the Index Queue of a site mounting the page .
36,795
public function parseJson ( $ baseWord , $ jsonString ) { $ decodedResponse = json_decode ( $ jsonString ) ; $ synonyms = [ ] ; if ( ! empty ( $ baseWord ) ) { if ( is_array ( $ decodedResponse -> { $ baseWord } ) ) { $ synonyms = $ decodedResponse -> { $ baseWord } ; } } else { if ( isset ( $ decodedResponse -> synony...
Parse the solr synonyms response from an json string to an array .
36,796
public function processRequest ( PageIndexerRequest $ request , PageIndexerResponse $ response ) { $ this -> request = $ request ; $ this -> response = $ response ; $ this -> logger = GeneralUtility :: makeInstance ( SolrLogManager :: class , __CLASS__ ) ; if ( $ request -> getParameter ( 'loggingEnabled' ) ) { $ this ...
Starts the execution of a frontend helper .
36,797
public function getField ( $ fieldName ) { trigger_error ( 'Method getField is deprecated since EXT:solr 10 and will be removed in EXT:solr 11. Please use document[$fieldname] without the array key value.' , E_USER_DEPRECATED ) ; return isset ( $ this -> fields [ $ fieldName ] ) ? [ 'value' => $ this -> fields [ $ fie...
Backwards compatible implementation of the getField method .
36,798
public function fromPage ( TypoScriptFrontendController $ page , $ url , Rootline $ pageAccessRootline , $ mountPointParameter ) : Document { $ document = GeneralUtility :: makeInstance ( Document :: class ) ; $ site = $ this -> getSiteByPageId ( $ page -> id ) ; $ pageRecord = $ page -> page ; $ accessGroups = $ this ...
This method can be used to build an Document from a TYPO3 page .
36,799
protected function getDocumentIdGroups ( Rootline $ pageAccessRootline ) { $ groups = $ pageAccessRootline -> getGroups ( ) ; $ groups = Rootline :: cleanGroupArray ( $ groups ) ; if ( empty ( $ groups ) ) { $ groups [ ] = 0 ; } $ groups = implode ( ',' , $ groups ) ; return $ groups ; }
Gets a comma separated list of frontend user groups to use for the document ID .