[TASK] Deprecate TypoScriptFrontendController->page_cache_reg1
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Classes / Domain / Repository / IndexSearchRepository.php
1 <?php
2 namespace TYPO3\CMS\IndexedSearch\Domain\Repository;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Doctrine\DBAL\Driver\Statement;
18 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
19 use TYPO3\CMS\Core\Database\Connection;
20 use TYPO3\CMS\Core\Database\ConnectionPool;
21 use TYPO3\CMS\Core\Database\Query\QueryHelper;
22 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
23 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
24 use TYPO3\CMS\Core\Utility\GeneralUtility;
25 use TYPO3\CMS\Core\Utility\MathUtility;
26 use TYPO3\CMS\IndexedSearch\Indexer;
27 use TYPO3\CMS\IndexedSearch\Utility;
28
29 /**
30 * Index search abstraction to search through the index
31 */
32 class IndexSearchRepository
33 {
34 /**
35 * Indexer object
36 *
37 * @var Indexer
38 */
39 protected $indexerObj;
40
41 /**
42 * External Parsers
43 *
44 * @var array
45 */
46 protected $externalParsers = [];
47
48 /**
49 * Frontend User Group List
50 *
51 * @var string
52 */
53 protected $frontendUserGroupList = '';
54
55 /**
56 * Sections
57 * formally known as $this->piVars['sections']
58 *
59 * @var string
60 */
61 protected $sections = null;
62
63 /**
64 * Search type
65 * formally known as $this->piVars['type']
66 *
67 * @var string
68 */
69 protected $searchType = null;
70
71 /**
72 * Language uid
73 * formally known as $this->piVars['lang']
74 *
75 * @var int
76 */
77 protected $languageUid = null;
78
79 /**
80 * Media type
81 * formally known as $this->piVars['media']
82 *
83 * @var int
84 */
85 protected $mediaType = null;
86
87 /**
88 * Sort order
89 * formally known as $this->piVars['sort_order']
90 *
91 * @var string
92 */
93 protected $sortOrder = null;
94
95 /**
96 * Descending sort order flag
97 * formally known as $this->piVars['desc']
98 *
99 * @var bool
100 */
101 protected $descendingSortOrderFlag = null;
102
103 /**
104 * Result page pointer
105 * formally known as $this->piVars['pointer']
106 *
107 * @var int
108 */
109 protected $resultpagePointer = 0;
110
111 /**
112 * Number of results
113 * formally known as $this->piVars['result']
114 *
115 * @var int
116 */
117 protected $numberOfResults = 10;
118
119 /**
120 * list of all root pages that will be used
121 * If this value is set to less than zero (eg. -1) searching will happen
122 * in ALL of the page tree with no regard to branches at all.
123 *
124 * @var string
125 */
126 protected $searchRootPageIdList;
127
128 /**
129 * formally known as $conf['search.']['searchSkipExtendToSubpagesChecking']
130 * enabled through settings.searchSkipExtendToSubpagesChecking
131 *
132 * @var bool
133 */
134 protected $joinPagesForQuery = false;
135
136 /**
137 * Select clauses for individual words, will be filled during the search
138 *
139 * @var array
140 */
141 protected $wSelClauses = [];
142
143 /**
144 * Flag for exact search count
145 * formally known as $conf['search.']['exactCount']
146 *
147 * Continue counting and checking of results even if we are sure
148 * they are not displayed in this request. This will slow down your
149 * page rendering, but it allows precise search result counters.
150 * enabled through settings.exactCount
151 *
152 * @var bool
153 */
154 protected $useExactCount = false;
155
156 /**
157 * Display forbidden records
158 * formally known as $this->conf['show.']['forbiddenRecords']
159 *
160 * enabled through settings.displayForbiddenRecords
161 *
162 * @var bool
163 */
164 protected $displayForbiddenRecords = false;
165
166 /**
167 * initialize all options that are necessary for the search
168 *
169 * @param array $settings the extbase plugin settings
170 * @param array $searchData the search data
171 * @param array $externalParsers
172 * @param string $searchRootPageIdList
173 */
174 public function initialize($settings, $searchData, $externalParsers, $searchRootPageIdList)
175 {
176 // Initialize the indexer-class - just to use a few function (for making hashes)
177 $this->indexerObj = GeneralUtility::makeInstance(Indexer::class);
178 $this->externalParsers = $externalParsers;
179 $this->searchRootPageIdList = $searchRootPageIdList;
180 $this->frontendUserGroupList = $this->getTypoScriptFrontendController()->gr_list;
181 // Should we use joinPagesForQuery instead of long lists of uids?
182 if ($settings['searchSkipExtendToSubpagesChecking']) {
183 $this->joinPagesForQuery = 1;
184 }
185 if ($settings['exactCount']) {
186 $this->useExactCount = true;
187 }
188 if ($settings['displayForbiddenRecords']) {
189 $this->displayForbiddenRecords = true;
190 }
191 $this->sections = $searchData['sections'];
192 $this->searchType = $searchData['searchType'];
193 $this->languageUid = $searchData['languageUid'];
194 $this->mediaType = $searchData['mediaType'] ?? false;
195 $this->sortOrder = $searchData['sortOrder'];
196 $this->descendingSortOrderFlag = $searchData['desc'];
197 $this->resultpagePointer = $searchData['pointer'];
198 if (isset($searchData['numberOfResults']) && is_numeric($searchData['numberOfResults'])) {
199 $this->numberOfResults = (int)$searchData['numberOfResults'];
200 }
201 }
202
203 /**
204 * Get search result rows / data from database. Returned as data in array.
205 *
206 * @param array $searchWords Search word array
207 * @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
208 * @return bool|array FALSE if no result, otherwise an array with keys for first row, result rows and total number of results found.
209 */
210 public function doSearch($searchWords, $freeIndexUid = -1)
211 {
212 $useMysqlFulltext = (bool)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('indexed_search', 'useMysqlFulltext');
213 // Getting SQL result pointer:
214 $this->getTimeTracker()->push('Searching result');
215 if ($hookObj = &$this->hookRequest('getResultRows_SQLpointer')) {
216 $result = $hookObj->getResultRows_SQLpointer($searchWords, $freeIndexUid);
217 } elseif ($useMysqlFulltext) {
218 $result = $this->getResultRows_SQLpointerMysqlFulltext($searchWords, $freeIndexUid);
219 } else {
220 $result = $this->getResultRows_SQLpointer($searchWords, $freeIndexUid);
221 }
222 $this->getTimeTracker()->pull();
223 // Organize and process result:
224 if ($result) {
225 // Total search-result count
226 $count = $result->rowCount();
227 // The pointer is set to the result page that is currently being viewed
228 $pointer = MathUtility::forceIntegerInRange($this->resultpagePointer, 0, floor($count / $this->numberOfResults));
229 // Initialize result accumulation variables:
230 $c = 0;
231 // Result pointer: Counts up the position in the current search-result
232 $grouping_phashes = [];
233 // Used to filter out duplicates.
234 $grouping_chashes = [];
235 // Used to filter out duplicates BASED ON cHash.
236 $firstRow = [];
237 // Will hold the first row in result - used to calculate relative hit-ratings.
238 $resultRows = [];
239 // Will hold the results rows for display.
240 // Now, traverse result and put the rows to be displayed into an array
241 // Each row should contain the fields from 'ISEC.*, IP.*' combined
242 // + artificial fields "show_resume" (bool) and "result_number" (counter)
243 while ($row = $result->fetch()) {
244 // Set first row
245 if (!$c) {
246 $firstRow = $row;
247 }
248 // Tells whether we can link directly to a document
249 // or not (depends on possible right problems)
250 $row['show_resume'] = $this->checkResume($row);
251 $phashGr = !in_array($row['phash_grouping'], $grouping_phashes);
252 $chashGr = !in_array(($row['contentHash'] . '.' . $row['data_page_id']), $grouping_chashes);
253 if ($phashGr && $chashGr) {
254 // Only if the resume may be shown are we going to filter out duplicates...
255 if ($row['show_resume'] || $this->displayForbiddenRecords) {
256 // Only on documents which are not multiple pages documents
257 if (!$this->multiplePagesType($row['item_type'])) {
258 $grouping_phashes[] = $row['phash_grouping'];
259 }
260 $grouping_chashes[] = $row['contentHash'] . '.' . $row['data_page_id'];
261 // Increase the result pointer
262 $c++;
263 // All rows for display is put into resultRows[]
264 if ($c > $pointer * $this->numberOfResults && $c <= $pointer * $this->numberOfResults + $this->numberOfResults) {
265 $row['result_number'] = $c;
266 $resultRows[] = $row;
267 // This may lead to a problem: If the result check is not stopped here, the search will take longer.
268 // However the result counter will not filter out grouped cHashes/pHashes that were not processed yet.
269 // You can change this behavior using the "search.exactCount" property (see above).
270 if (!$this->useExactCount && $c + 1 > ($pointer + 1) * $this->numberOfResults) {
271 break;
272 }
273 }
274 } else {
275 // Skip this row if the user cannot
276 // view it (missing permission)
277 $count--;
278 }
279 } else {
280 // For each time a phash_grouping document is found
281 // (which is thus not displayed) the search-result count is reduced,
282 // so that it matches the number of rows displayed.
283 $count--;
284 }
285 }
286
287 $result->closeCursor();
288
289 return [
290 'resultRows' => $resultRows,
291 'firstRow' => $firstRow,
292 'count' => $count
293 ];
294 }
295 // No results found
296 return false;
297 }
298
299 /**
300 * Gets a SQL result pointer to traverse for the search records.
301 *
302 * @param array $searchWords Search words
303 * @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
304 * @return Statement
305 */
306 protected function getResultRows_SQLpointer($searchWords, $freeIndexUid = -1)
307 {
308 // This SEARCHES for the searchwords in $searchWords AND returns a
309 // COMPLETE list of phash-integers of the matches.
310 $list = $this->getPhashList($searchWords);
311 // Perform SQL Search / collection of result rows array:
312 if ($list) {
313 // Do the search:
314 $this->getTimeTracker()->push('execFinalQuery');
315 $res = $this->execFinalQuery($list, $freeIndexUid);
316 $this->getTimeTracker()->pull();
317 return $res;
318 }
319 return false;
320 }
321
322 /**
323 * Gets a SQL result pointer to traverse for the search records.
324 *
325 * mysql fulltext specific version triggered by ext_conf_template setting 'useMysqlFulltext'
326 *
327 * @param array $searchWordsArray Search words
328 * @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
329 * @return bool|\mysqli_result|object MySQLi result object / DBAL object
330 */
331 protected function getResultRows_SQLpointerMysqlFulltext($searchWordsArray, $freeIndexUid = -1)
332 {
333 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('index_fulltext');
334 if (strpos($connection->getServerVersion(), 'MySQL') !== 0) {
335 throw new \RuntimeException(
336 'Extension indexed_search is configured to use mysql fulltext, but table \'index_fulltext\''
337 . ' is running on a different DBMS.',
338 1472585525
339 );
340 }
341 // Build the search string, detect which fulltext index to use, and decide whether boolean search is needed or not
342 $searchData = $this->getSearchString($searchWordsArray);
343 // Perform SQL Search / collection of result rows array:
344 $resource = false;
345 if ($searchData) {
346 /** @var TimeTracker $timeTracker */
347 $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
348 // Do the search:
349 $timeTracker->push('execFinalQuery');
350 $resource = $this->execFinalQuery_fulltext($searchData, $freeIndexUid);
351 $timeTracker->pull();
352 }
353 return $resource;
354 }
355
356 /**
357 * Returns a search string for use with MySQL FULLTEXT query
358 *
359 * mysql fulltext specific helper method
360 *
361 * @param array $searchWordArray Search word array
362 * @return string Search string
363 */
364 protected function getSearchString($searchWordArray)
365 {
366 // Initialize variables:
367 $count = 0;
368 // Change this to TRUE to force BOOLEAN SEARCH MODE (useful if fulltext index is still empty)
369 $searchBoolean = false;
370 $fulltextIndex = 'index_fulltext.fulltextdata';
371 // This holds the result if the search is natural (doesn't contain any boolean operators)
372 $naturalSearchString = '';
373 // This holds the result if the search is boolen (contains +/-/| operators)
374 $booleanSearchString = '';
375
376 $searchType = (string)$this->getSearchType();
377
378 // Traverse searchwords and prefix them with corresponding operator
379 foreach ($searchWordArray as $searchWordData) {
380 // Making the query for a single search word based on the search-type
381 $searchWord = $searchWordData['sword'];
382 $wildcard = '';
383 if (strstr($searchWord, ' ')) {
384 $searchType = '20';
385 }
386 switch ($searchType) {
387 case '1':
388 case '2':
389 case '3':
390 // First part of word
391 $wildcard = '*';
392 // Part-of-word search requires boolean mode!
393 $searchBoolean = true;
394 break;
395 case '10':
396 $indexerObj = GeneralUtility::makeInstance(Indexer::class);
397 // Initialize the indexer-class
398 /** @var Indexer $indexerObj */
399 $searchWord = $indexerObj->metaphone($searchWord, $indexerObj->storeMetaphoneInfoAsWords);
400 unset($indexerObj);
401 $fulltextIndex = 'index_fulltext.metaphonedata';
402 break;
403 case '20':
404 $searchBoolean = true;
405 // Remove existing quotes and fix misplaced quotes.
406 $searchWord = trim(str_replace('"', ' ', $searchWord));
407 break;
408 }
409 // Perform search for word:
410 switch ($searchWordData['oper']) {
411 case 'AND NOT':
412 $booleanSearchString .= ' -' . $searchWord . $wildcard;
413 $searchBoolean = true;
414 break;
415 case 'OR':
416 $booleanSearchString .= ' ' . $searchWord . $wildcard;
417 $searchBoolean = true;
418 break;
419 default:
420 $booleanSearchString .= ' +' . $searchWord . $wildcard;
421 $naturalSearchString .= ' ' . $searchWord;
422 }
423 $count++;
424 }
425 if ($searchType == '20') {
426 $searchString = '"' . trim($naturalSearchString) . '"';
427 } elseif ($searchBoolean) {
428 $searchString = trim($booleanSearchString);
429 } else {
430 $searchString = trim($naturalSearchString);
431 }
432 return [
433 'searchBoolean' => $searchBoolean,
434 'searchString' => $searchString,
435 'fulltextIndex' => $fulltextIndex
436 ];
437 }
438
439 /**
440 * Execute final query, based on phash integer list. The main point is sorting the result in the right order.
441 *
442 * mysql fulltext specific helper method
443 *
444 * @param array $searchData Array with search string, boolean indicator, and fulltext index reference
445 * @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
446 * @return Statement
447 */
448 protected function execFinalQuery_fulltext($searchData, $freeIndexUid = -1)
449 {
450 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_fulltext');
451 $queryBuilder->getRestrictions()->removeAll();
452 $queryBuilder->select('index_fulltext.*', 'ISEC.*', 'IP.*')
453 ->from('index_fulltext')
454 ->join(
455 'index_fulltext',
456 'index_phash',
457 'IP',
458 $queryBuilder->expr()->eq('index_fulltext.phash', $queryBuilder->quoteIdentifier('IP.phash'))
459 )
460 ->join(
461 'IP',
462 'index_section',
463 'ISEC',
464 $queryBuilder->expr()->eq('IP.phash', $queryBuilder->quoteIdentifier('ISEC.phash'))
465 );
466
467 // Calling hook for alternative creation of page ID list
468 $searchRootPageIdList = $this->getSearchRootPageIdList();
469 if ($hookObj = &$this->hookRequest('execFinalQuery_idList')) {
470 $pageWhere = $hookObj->execFinalQuery_idList('');
471 $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($pageWhere));
472 } elseif ($this->joinPagesForQuery) {
473 // Alternative to getting all page ids by ->getTreeList() where "excludeSubpages" is NOT respected.
474 $queryBuilder
475 ->join(
476 'ISEC',
477 'pages',
478 'pages',
479 $queryBuilder->expr()->eq('ISEC.page_id', $queryBuilder->quoteIdentifier('pages.uid'))
480 )
481 ->andWhere(
482 $queryBuilder->expr()->eq(
483 'pages.no_search',
484 $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
485 )
486 )
487 ->andWhere(
488 $queryBuilder->expr()->lt(
489 'pages.doktype',
490 $queryBuilder->createNamedParameter(200, \PDO::PARAM_INT)
491 )
492 );
493 $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
494 } elseif ($searchRootPageIdList[0] >= 0) {
495 // Collecting all pages IDs in which to search;
496 // filtering out ALL pages that are not accessible due to restriction containers. Does NOT look for "no_search" field!
497 $idList = [];
498 foreach ($searchRootPageIdList as $rootId) {
499 /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
500 $cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
501 $idList[] = $cObj->getTreeList(-1 * $rootId, 9999);
502 }
503 $idList = GeneralUtility::intExplode(',', implode(',', $idList));
504 $queryBuilder->andWhere(
505 $queryBuilder->expr()->in(
506 'ISEC.page_id',
507 $queryBuilder->createNamedParameter($idList, Connection::PARAM_INT_ARRAY)
508 )
509 );
510 }
511
512 $searchBoolean = '';
513 if ($searchData['searchBoolean']) {
514 $searchBoolean = ' IN BOOLEAN MODE';
515 }
516 $queryBuilder->andWhere(
517 'MATCH (' . $queryBuilder->quoteIdentifier($searchData['fulltextIndex']) . ')'
518 . ' AGAINST (' . $queryBuilder->createNamedParameter($searchData['searchString'])
519 . $searchBoolean
520 . ')'
521 );
522
523 $queryBuilder->andWhere(
524 QueryHelper::stripLogicalOperatorPrefix($this->mediaTypeWhere()),
525 QueryHelper::stripLogicalOperatorPrefix($this->languageWhere()),
526 QueryHelper::stripLogicalOperatorPrefix($this->freeIndexUidWhere($freeIndexUid)),
527 QueryHelper::stripLogicalOperatorPrefix($this->sectionTableWhere())
528 );
529
530 $queryBuilder->groupBy(
531 'IP.phash',
532 'ISEC.phash',
533 'ISEC.phash_t3',
534 'ISEC.rl0',
535 'ISEC.rl1',
536 'ISEC.rl2',
537 'ISEC.page_id',
538 'ISEC.uniqid',
539 'IP.phash_grouping',
540 'IP.data_filename',
541 'IP.data_page_id',
542 // @deprecated since TYPO3 v9, will be removed in TYPO3 v10. Remove along with database field data_page_reg1
543 'IP.data_page_reg1',
544 'IP.data_page_type',
545 'IP.data_page_mp',
546 'IP.gr_list',
547 'IP.item_type',
548 'IP.item_title',
549 'IP.item_description',
550 'IP.item_mtime',
551 'IP.tstamp',
552 'IP.item_size',
553 'IP.contentHash',
554 'IP.crdate',
555 'IP.parsetime',
556 'IP.sys_language_uid',
557 'IP.item_crdate',
558 'IP.cHashParams',
559 'IP.externalUrl',
560 'IP.recordUid',
561 'IP.freeIndexUid',
562 'IP.freeIndexSetId'
563 );
564
565 return $queryBuilder->execute();
566 }
567
568 /***********************************
569 *
570 * Helper functions on searching (SQL)
571 *
572 ***********************************/
573 /**
574 * Returns a COMPLETE list of phash-integers matching the search-result composed of the search-words in the $searchWords array.
575 * The list of phash integers are unsorted and should be used for subsequent selection of index_phash records for display of the result.
576 *
577 * @param array $searchWords Search word array
578 * @return string List of integers
579 */
580 protected function getPhashList($searchWords)
581 {
582 // Initialize variables:
583 $c = 0;
584 // This array accumulates the phash-values
585 $totalHashList = [];
586 $this->wSelClauses = [];
587 // Traverse searchwords; for each, select all phash integers and merge/diff/intersect them with previous word (based on operator)
588 foreach ($searchWords as $k => $v) {
589 // Making the query for a single search word based on the search-type
590 $sWord = $v['sword'];
591 $theType = (string)$this->searchType;
592 // If there are spaces in the search-word, make a full text search instead.
593 if (strstr($sWord, ' ')) {
594 $theType = 20;
595 }
596 $this->getTimeTracker()->push('SearchWord "' . $sWord . '" - $theType=' . $theType);
597 // Perform search for word:
598 switch ($theType) {
599 case '1':
600 // Part of word
601 $res = $this->searchWord($sWord, Utility\LikeWildcard::BOTH);
602 break;
603 case '2':
604 // First part of word
605 $res = $this->searchWord($sWord, Utility\LikeWildcard::RIGHT);
606 break;
607 case '3':
608 // Last part of word
609 $res = $this->searchWord($sWord, Utility\LikeWildcard::LEFT);
610 break;
611 case '10':
612 // Sounds like
613 /**
614 * Indexer object
615 *
616 * @var Indexer
617 */
618 $indexerObj = GeneralUtility::makeInstance(Indexer::class);
619 // Perform metaphone search
620 $storeMetaphoneInfoAsWords = !$this->isTableUsed('index_words');
621 $res = $this->searchMetaphone($indexerObj->metaphone($sWord, $storeMetaphoneInfoAsWords));
622 unset($indexerObj);
623 break;
624 case '20':
625 // Sentence
626 $res = $this->searchSentence($sWord);
627 // If there is a fulltext search for a sentence there is
628 // a likeliness that sorting cannot be done by the rankings
629 // from the rel-table (because no relations will exist for the
630 // sentence in the word-table). So therefore mtime is used instead.
631 // It is not required, but otherwise some hits may be left out.
632 $this->sortOrder = 'mtime';
633 break;
634 default:
635 // Distinct word
636 $res = $this->searchDistinct($sWord);
637 }
638 // If there was a query to do, then select all phash-integers which resulted from this.
639 if ($res) {
640 // Get phash list by searching for it:
641 $phashList = [];
642 while ($row = $res->fetch()) {
643 $phashList[] = $row['phash'];
644 }
645 // Here the phash list are merged with the existing result based on whether we are dealing with OR, NOT or AND operations.
646 if ($c) {
647 switch ($v['oper']) {
648 case 'OR':
649 $totalHashList = array_unique(array_merge($phashList, $totalHashList));
650 break;
651 case 'AND NOT':
652 $totalHashList = array_diff($totalHashList, $phashList);
653 break;
654 default:
655 // AND...
656 $totalHashList = array_intersect($totalHashList, $phashList);
657 }
658 } else {
659 // First search
660 $totalHashList = $phashList;
661 }
662 }
663 $this->getTimeTracker()->pull();
664 $c++;
665 }
666 return implode(',', $totalHashList);
667 }
668
669 /**
670 * Returns a query which selects the search-word from the word/rel tables.
671 *
672 * @param string $wordSel WHERE clause selecting the word from phash
673 * @param string $additionalWhereClause Additional AND clause in the end of the query.
674 * @return Statement
675 */
676 protected function execPHashListQuery($wordSel, $additionalWhereClause = '')
677 {
678 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_words');
679 $queryBuilder->select('IR.phash')
680 ->from('index_words', 'IW')
681 ->from('index_rel', 'IR')
682 ->from('index_section', 'ISEC')
683 ->where(
684 QueryHelper::stripLogicalOperatorPrefix($wordSel),
685 $queryBuilder->expr()->eq('IW.wid', $queryBuilder->quoteIdentifier('IR.wid')),
686 $queryBuilder->expr()->eq('ISEC.phash', $queryBuilder->quoteIdentifier('IR.phash')),
687 QueryHelper::stripLogicalOperatorPrefix($this->sectionTableWhere()),
688 QueryHelper::stripLogicalOperatorPrefix($additionalWhereClause)
689 )
690 ->groupBy('IR.phash');
691
692 return $queryBuilder->execute();
693 }
694
695 /**
696 * Search for a word
697 *
698 * @param string $sWord the search word
699 * @param int $wildcard Bit-field of Utility\LikeWildcard
700 * @return Statement
701 */
702 protected function searchWord($sWord, $wildcard)
703 {
704 $likeWildcard = Utility\LikeWildcard::cast($wildcard);
705 $wSel = $likeWildcard->getLikeQueryPart(
706 'index_words',
707 'IW.baseword',
708 $sWord
709 );
710 $this->wSelClauses[] = $wSel;
711 return $this->execPHashListQuery($wSel, ' AND is_stopword=0');
712 }
713
714 /**
715 * Search for one distinct word
716 *
717 * @param string $sWord the search word
718 * @return Statement
719 */
720 protected function searchDistinct($sWord)
721 {
722 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
723 ->getQueryBuilderForTable('index_words')
724 ->expr();
725 $wSel = $expressionBuilder->eq('IW.wid', $this->md5inthash($sWord));
726 $this->wSelClauses[] = $wSel;
727 return $this->execPHashListQuery($wSel, $expressionBuilder->eq('is_stopword', 0));
728 }
729
730 /**
731 * Search for a sentence
732 *
733 * @param string $sWord the search word
734 * @return Statement
735 */
736 protected function searchSentence($sWord)
737 {
738 $this->wSelClauses[] = '1=1';
739 $likeWildcard = Utility\LikeWildcard::cast(Utility\LikeWildcard::BOTH);
740 $likePart = $likeWildcard->getLikeQueryPart(
741 'index_fulltext',
742 'IFT.fulltextdata',
743 $sWord
744 );
745
746 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_section');
747 return $queryBuilder->select('ISEC.phash')
748 ->from('index_section', 'ISEC')
749 ->from('index_fulltext', 'IFT')
750 ->where(
751 QueryHelper::stripLogicalOperatorPrefix($likePart),
752 $queryBuilder->expr()->eq('ISEC.phash', $queryBuilder->quoteIdentifier(('IFT.phash'))),
753 QueryHelper::stripLogicalOperatorPrefix($this->sectionTableWhere())
754 )
755 ->groupBy('ISEC.phash')
756 ->execute();
757 }
758
759 /**
760 * Search for a metaphone word
761 *
762 * @param string $sWord the search word
763 * @return Statement
764 */
765 protected function searchMetaphone($sWord)
766 {
767 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
768 ->getQueryBuilderForTable('index_words')
769 ->expr();
770 $wSel = $expressionBuilder->eq('IW.metaphone', $expressionBuilder->literal($sWord));
771 $this->wSelClauses[] = $wSel;
772 return $this->execPHashListQuery($wSel, $expressionBuilder->eq('is_stopword', 0));
773 }
774
775 /**
776 * Returns AND statement for selection of section in database. (rootlevel 0-2 + page_id)
777 *
778 * @return string AND clause for selection of section in database.
779 */
780 public function sectionTableWhere()
781 {
782 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
783 ->getQueryBuilderForTable('index_section')
784 ->expr();
785
786 $whereClause = $expressionBuilder->andX();
787 $match = false;
788 if (!($this->searchRootPageIdList < 0)) {
789 $whereClause->add(
790 $expressionBuilder->in('ISEC.rl0', GeneralUtility::intExplode(',', $this->searchRootPageIdList, true))
791 );
792 }
793 if (substr($this->sections, 0, 4) === 'rl1_') {
794 $whereClause->add(
795 $expressionBuilder->in('ISEC.rl1', GeneralUtility::intExplode(',', substr($this->sections, 4)))
796 );
797 $match = true;
798 } elseif (substr($this->sections, 0, 4) === 'rl2_') {
799 $whereClause->add(
800 $expressionBuilder->in('ISEC.rl2', GeneralUtility::intExplode(',', substr($this->sections, 4)))
801 );
802 $match = true;
803 } else {
804 // Traversing user configured fields to see if any of those are used to limit search to a section:
805 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['addRootLineFields'] ?? [] as $fieldName => $rootLineLevel) {
806 if (substr($this->sections, 0, strlen($fieldName) + 1) == $fieldName . '_') {
807 $whereClause->add(
808 $expressionBuilder->in(
809 'ISEC.' . $fieldName,
810 GeneralUtility::intExplode(',', substr($this->sections, strlen($fieldName) + 1))
811 )
812 );
813 $match = true;
814 break;
815 }
816 }
817 }
818 // If no match above, test the static types:
819 if (!$match) {
820 switch ((string)$this->sections) {
821 case '-1':
822 $whereClause->add(
823 $expressionBuilder->eq('ISEC.page_id', (int)$this->getTypoScriptFrontendController()->id)
824 );
825 break;
826 case '-2':
827 $whereClause->add($expressionBuilder->eq('ISEC.rl2', 0));
828 break;
829 case '-3':
830 $whereClause->add($expressionBuilder->gt('ISEC.rl2', 0));
831 break;
832 }
833 }
834
835 return $whereClause->count() ? ' AND ' . $whereClause : '';
836 }
837
838 /**
839 * Returns AND statement for selection of media type
840 *
841 * @return string AND statement for selection of media type
842 */
843 public function mediaTypeWhere()
844 {
845 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
846 ->getQueryBuilderForTable('index_phash')
847 ->expr();
848 switch ($this->mediaType) {
849 case '0':
850 // '0' => 'only TYPO3 pages',
851 $whereClause = $expressionBuilder->eq('IP.item_type', $expressionBuilder->literal('0'));
852 break;
853 case '-2':
854 // All external documents
855 $whereClause = $expressionBuilder->neq('IP.item_type', $expressionBuilder->literal('0'));
856 break;
857 case false:
858 // Intentional fall-through
859 case '-1':
860 // All content
861 $whereClause = '';
862 break;
863 default:
864 $whereClause = $expressionBuilder->eq('IP.item_type', $expressionBuilder->literal($this->mediaType));
865 }
866 return $whereClause ? ' AND ' . $whereClause : '';
867 }
868
869 /**
870 * Returns AND statement for selection of language
871 *
872 * @return string AND statement for selection of language
873 */
874 public function languageWhere()
875 {
876 // -1 is the same as ALL language.
877 if ($this->languageUid < 0) {
878 return '';
879 }
880
881 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
882 ->getQueryBuilderForTable('index_phash')
883 ->expr();
884
885 return ' AND ' . $expressionBuilder->eq('IP.sys_language_uid', (int)$this->languageUid);
886 }
887
888 /**
889 * Where-clause for free index-uid value.
890 *
891 * @param int $freeIndexUid Free Index UID value to limit search to.
892 * @return string WHERE SQL clause part.
893 */
894 public function freeIndexUidWhere($freeIndexUid)
895 {
896 $freeIndexUid = (int)$freeIndexUid;
897 if ($freeIndexUid < 0) {
898 return '';
899 }
900 // First, look if the freeIndexUid is a meta configuration:
901 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
902 ->getQueryBuilderForTable('index_config');
903 $indexCfgRec = $queryBuilder->select('indexcfgs')
904 ->from('index_config')
905 ->where(
906 $queryBuilder->expr()->eq('type', $queryBuilder->createNamedParameter(5, \PDO::PARAM_INT)),
907 $queryBuilder->expr()->eq(
908 'uid',
909 $queryBuilder->createNamedParameter($freeIndexUid, \PDO::PARAM_INT)
910 )
911 )
912 ->execute()
913 ->fetch();
914
915 if (is_array($indexCfgRec)) {
916 $refs = GeneralUtility::trimExplode(',', $indexCfgRec['indexcfgs']);
917 // Default value to protect against empty array.
918 $list = [-99];
919 foreach ($refs as $ref) {
920 list($table, $uid) = GeneralUtility::revExplode('_', $ref, 2);
921 $uid = (int)$uid;
922 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
923 ->getQueryBuilderForTable('index_config');
924 $queryBuilder->select('uid')
925 ->from('index_config');
926 switch ($table) {
927 case 'index_config':
928 $idxRec = $queryBuilder
929 ->where(
930 $queryBuilder->expr()->eq(
931 'uid',
932 $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
933 )
934 )
935 ->execute()
936 ->fetch();
937 if ($idxRec) {
938 $list[] = $uid;
939 }
940 break;
941 case 'pages':
942 $indexCfgRecordsFromPid = $queryBuilder
943 ->where(
944 $queryBuilder->expr()->eq(
945 'pid',
946 $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
947 )
948 )
949 ->execute();
950 while ($idxRec = $indexCfgRecordsFromPid->fetch()) {
951 $list[] = $idxRec['uid'];
952 }
953 break;
954 }
955 }
956 $list = array_unique($list);
957 } else {
958 $list = [$freeIndexUid];
959 }
960
961 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
962 ->getQueryBuilderForTable('index_phash')
963 ->expr();
964 return ' AND ' . $expressionBuilder->in('IP.freeIndexUid', array_map('intval', $list));
965 }
966
967 /**
968 * Execute final query, based on phash integer list. The main point is sorting the result in the right order.
969 *
970 * @param string $list List of phash integers which match the search.
971 * @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
972 * @return Statement
973 */
974 protected function execFinalQuery($list, $freeIndexUid = -1)
975 {
976 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_words');
977 $queryBuilder->select('ISEC.*', 'IP.*')
978 ->from('index_phash', 'IP')
979 ->from('index_section', 'ISEC')
980 ->where(
981 $queryBuilder->expr()->in(
982 'IP.phash',
983 $queryBuilder->createNamedParameter(
984 GeneralUtility::intExplode(',', $list, true),
985 Connection::PARAM_INT_ARRAY
986 )
987 ),
988 QueryHelper::stripLogicalOperatorPrefix($this->mediaTypeWhere()),
989 QueryHelper::stripLogicalOperatorPrefix($this->languageWhere()),
990 QueryHelper::stripLogicalOperatorPrefix($this->freeIndexUidWhere($freeIndexUid)),
991 $queryBuilder->expr()->eq('ISEC.phash', $queryBuilder->quoteIdentifier('IP.phash'))
992 )
993 ->groupBy(
994 'IP.phash',
995 'ISEC.phash',
996 'ISEC.phash_t3',
997 'ISEC.rl0',
998 'ISEC.rl1',
999 'ISEC.rl2',
1000 'ISEC.page_id',
1001 'ISEC.uniqid',
1002 'IP.phash_grouping',
1003 'IP.data_filename',
1004 'IP.data_page_id',
1005 // @deprecated since TYPO3 v9, will be removed in TYPO3 v10. Remove along with database field data_page_reg1
1006 'IP.data_page_reg1',
1007 'IP.data_page_type',
1008 'IP.data_page_mp',
1009 'IP.gr_list',
1010 'IP.item_type',
1011 'IP.item_title',
1012 'IP.item_description',
1013 'IP.item_mtime',
1014 'IP.tstamp',
1015 'IP.item_size',
1016 'IP.contentHash',
1017 'IP.crdate',
1018 'IP.parsetime',
1019 'IP.sys_language_uid',
1020 'IP.item_crdate',
1021 'IP.cHashParams',
1022 'IP.externalUrl',
1023 'IP.recordUid',
1024 'IP.freeIndexUid',
1025 'IP.freeIndexSetId'
1026 );
1027
1028 // Setting up methods of filtering results
1029 // based on page types, access, etc.
1030 if ($hookObj = $this->hookRequest('execFinalQuery_idList')) {
1031 // Calling hook for alternative creation of page ID list
1032 $hookWhere = QueryHelper::stripLogicalOperatorPrefix($hookObj->execFinalQuery_idList($list));
1033 if (!empty($hookWhere)) {
1034 $queryBuilder->andWhere($hookWhere);
1035 }
1036 } elseif ($this->joinPagesForQuery) {
1037 // Alternative to getting all page ids by ->getTreeList() where
1038 // "excludeSubpages" is NOT respected.
1039 $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
1040 $queryBuilder->from('pages');
1041 $queryBuilder->andWhere(
1042 $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('ISEC.page_id')),
1043 $queryBuilder->expr()->eq(
1044 'pages.no_search',
1045 $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
1046 ),
1047 $queryBuilder->expr()->lt(
1048 'pages.doktype',
1049 $queryBuilder->createNamedParameter(200, \PDO::PARAM_INT)
1050 )
1051 );
1052 } elseif ($this->searchRootPageIdList >= 0) {
1053 // Collecting all pages IDs in which to search;
1054 // filtering out ALL pages that are not accessible due to restriction containers.
1055 // Does NOT look for "no_search" field!
1056 $siteIdNumbers = GeneralUtility::intExplode(',', $this->searchRootPageIdList);
1057 $pageIdList = [];
1058 foreach ($siteIdNumbers as $rootId) {
1059 $pageIdList[] = $this->getTypoScriptFrontendController()->cObj->getTreeList(-1 * $rootId, 9999);
1060 }
1061 $queryBuilder->andWhere(
1062 $queryBuilder->expr()->in(
1063 'ISEC.page_id',
1064 $queryBuilder->createNamedParameter(
1065 array_unique(GeneralUtility::intExplode(',', implode(',', $pageIdList), true)),
1066 Connection::PARAM_INT_ARRAY
1067 )
1068 )
1069 );
1070 }
1071 // otherwise select all / disable everything
1072 // If any of the ranking sortings are selected, we must make a
1073 // join with the word/rel-table again, because we need to
1074 // calculate ranking based on all search-words found.
1075 if (substr($this->sortOrder, 0, 5) === 'rank_') {
1076 $queryBuilder
1077 ->from('index_words', 'IW')
1078 ->from('index_rel', 'IR')
1079 ->andWhere(
1080 $queryBuilder->expr()->eq('IW.wid', $queryBuilder->quoteIdentifier('IR.wid')),
1081 $queryBuilder->expr()->eq('ISEC.phash', $queryBuilder->quoteIdentifier('IR.phash'))
1082 );
1083 switch ($this->sortOrder) {
1084 case 'rank_flag':
1085 // This gives priority to word-position (max-value) so that words in title, keywords, description counts more than in content.
1086 // The ordering is refined with the frequency sum as well.
1087 $queryBuilder
1088 ->addSelectLiteral(
1089 $queryBuilder->expr()->max('IR.flags', 'order_val1'),
1090 $queryBuilder->expr()->sum('IR.freq', 'order_val2')
1091 )
1092 ->orderBy('order_val1', $this->getDescendingSortOrderFlag())
1093 ->addOrderBy('order_val2', $this->getDescendingSortOrderFlag());
1094 break;
1095 case 'rank_first':
1096 // Results in average position of search words on page.
1097 // Must be inversely sorted (low numbers are closer to top)
1098 $queryBuilder
1099 ->addSelectLiteral($queryBuilder->expr()->avg('IR.first', 'order_val'))
1100 ->orderBy('order_val', $this->getDescendingSortOrderFlag(true));
1101 break;
1102 case 'rank_count':
1103 // Number of words found
1104 $queryBuilder
1105 ->addSelectLiteral($queryBuilder->expr()->sum('IR.count', 'order_val'))
1106 ->orderBy('order_val', $this->getDescendingSortOrderFlag());
1107 break;
1108 default:
1109 // Frequency sum. I'm not sure if this is the best way to do
1110 // it (make a sum...). Or should it be the average?
1111 $queryBuilder
1112 ->addSelectLiteral($queryBuilder->expr()->sum('IR.freq', 'order_val'))
1113 ->orderBy('order_val', $this->getDescendingSortOrderFlag());
1114 }
1115
1116 if (!empty($this->wSelClauses)) {
1117 // So, words are combined in an OR statement
1118 // (no "sentence search" should be done here - may deselect results)
1119 $wordSel = $queryBuilder->expr()->orX();
1120 foreach ($this->wSelClauses as $wSelClause) {
1121 $wordSel->add(QueryHelper::stripLogicalOperatorPrefix($wSelClause));
1122 }
1123 $queryBuilder->andWhere($wordSel);
1124 }
1125 } else {
1126 // Otherwise, if sorting are done with the pages table or other fields,
1127 // there is no need for joining with the rel/word tables:
1128 switch ((string)$this->sortOrder) {
1129 case 'title':
1130 $queryBuilder->orderBy('IP.item_title', $this->getDescendingSortOrderFlag());
1131 break;
1132 case 'crdate':
1133 $queryBuilder->orderBy('IP.item_crdate', $this->getDescendingSortOrderFlag());
1134 break;
1135 case 'mtime':
1136 $queryBuilder->orderBy('IP.item_mtime', $this->getDescendingSortOrderFlag());
1137 break;
1138 }
1139 }
1140
1141 return $queryBuilder->execute();
1142 }
1143
1144 /**
1145 * Checking if the resume can be shown for the search result
1146 * (depending on whether the rights are OK)
1147 * ? Should it also check for gr_list "0,-1"?
1148 *
1149 * @param array $row Result row array.
1150 * @return bool Returns TRUE if resume can safely be shown
1151 */
1152 protected function checkResume($row)
1153 {
1154 // If the record is indexed by an indexing configuration, just show it.
1155 // At least this is needed for external URLs and files.
1156 // For records we might need to extend this - for instance block display if record is access restricted.
1157 if ($row['freeIndexUid']) {
1158 return true;
1159 }
1160 // Evaluate regularly indexed pages based on item_type:
1161 // External media:
1162 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('index_grlist');
1163 if ($row['item_type']) {
1164 // For external media we will check the access of the parent page on which the media was linked from.
1165 // "phash_t3" is the phash of the parent TYPO3 page row which initiated the indexing of the documents
1166 // in this section. So, selecting for the grlist records belonging to the parent phash-row where the
1167 // current users gr_list exists will help us to know. If this is NOT found, there is still a theoretical
1168 // possibility that another user accessible page would display a link, so maybe the resume of such a
1169 // document here may be unjustified hidden. But better safe than sorry.
1170 if (!$this->isTableUsed('index_grlist')) {
1171 return false;
1172 }
1173
1174 return (bool)$connection->count(
1175 'phash',
1176 'index_grlist',
1177 [
1178 'phash' => (int)$row['phash_t3'],
1179 'gr_list' => $this->frontendUserGroupList
1180 ]
1181 );
1182 }
1183 // Ordinary TYPO3 pages:
1184 if ((string)$row['gr_list'] !== (string)$this->frontendUserGroupList) {
1185 // Selecting for the grlist records belonging to the phash-row where the current users gr_list exists.
1186 // If it is found it is proof that this user has direct access to the phash-rows content although
1187 // he did not himself initiate the indexing...
1188 if (!$this->isTableUsed('index_grlist')) {
1189 return false;
1190 }
1191
1192 return (bool)$connection->count(
1193 'phash',
1194 'index_grlist',
1195 [
1196 'phash' => (int)$row['phash'],
1197 'gr_list' => $this->frontendUserGroupList
1198 ]
1199 );
1200 }
1201 return true;
1202 }
1203
1204 /**
1205 * Returns "DESC" or "" depending on the settings of the incoming
1206 * highest/lowest result order (piVars['desc'])
1207 *
1208 * @param bool $inverse If TRUE, inverse the order which is defined by piVars['desc']
1209 * @return string " DESC" or formerly known as tx_indexedsearch_pi->isDescending
1210 */
1211 protected function getDescendingSortOrderFlag($inverse = false)
1212 {
1213 $desc = $this->descendingSortOrderFlag;
1214 if ($inverse) {
1215 $desc = !$desc;
1216 }
1217 return !$desc ? ' DESC' : '';
1218 }
1219
1220 /**
1221 * Returns if an item type is a multipage item type
1222 *
1223 * @param string $itemType Item type
1224 * @return bool TRUE if multipage capable
1225 */
1226 protected function multiplePagesType($itemType)
1227 {
1228 /** @var \TYPO3\CMS\IndexedSearch\FileContentParser $fileContentParser */
1229 $fileContentParser = $this->externalParsers[$itemType];
1230 return is_object($fileContentParser) && $fileContentParser->isMultiplePageExtension($itemType);
1231 }
1232
1233 /**
1234 * md5 integer hash
1235 * Using 7 instead of 8 just because that makes the integers lower than
1236 * 32 bit (28 bit) and so they do not interfere with UNSIGNED integers
1237 * or PHP-versions which has varying output from the hexdec function.
1238 *
1239 * @param string $str String to hash
1240 * @return int Integer interpretation of the md5 hash of input string.
1241 */
1242 protected function md5inthash($str)
1243 {
1244 return Utility\IndexedSearchUtility::md5inthash($str);
1245 }
1246
1247 /**
1248 * Check if the tables provided are configured for usage.
1249 * This becomes necessary for extensions that provide additional database
1250 * functionality like indexed_search_mysql.
1251 *
1252 * @param string $table_list Comma-separated list of tables
1253 * @return bool TRUE if given tables are enabled
1254 */
1255 protected function isTableUsed($table_list)
1256 {
1257 return Utility\IndexedSearchUtility::isTableUsed($table_list);
1258 }
1259
1260 /**
1261 * Returns an object reference to the hook object if any
1262 *
1263 * @param string $functionName Name of the function you want to call / hook key
1264 * @return object|null Hook object, if any. Otherwise NULL.
1265 */
1266 public function hookRequest($functionName)
1267 {
1268 // Hook: menuConfig_preProcessModMenu
1269 if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['pi1_hooks'][$functionName]) {
1270 $hookObj = GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['pi1_hooks'][$functionName]);
1271 if (method_exists($hookObj, $functionName)) {
1272 $hookObj->pObj = $this;
1273 return $hookObj;
1274 }
1275 }
1276 return null;
1277 }
1278
1279 /**
1280 * Search type
1281 * e.g. sentence (20), any part of the word (1)
1282 *
1283 * @return int
1284 */
1285 public function getSearchType()
1286 {
1287 return (int)$this->searchType;
1288 }
1289
1290 /**
1291 * A list of integer which should be root-pages to search from
1292 *
1293 * @return int[]
1294 */
1295 public function getSearchRootPageIdList()
1296 {
1297 return GeneralUtility::intExplode(',', $this->searchRootPageIdList);
1298 }
1299
1300 /**
1301 * Getter for joinPagesForQuery flag
1302 * enabled through TypoScript 'settings.skipExtendToSubpagesChecking'
1303 *
1304 * @return bool
1305 */
1306 public function getJoinPagesForQuery()
1307 {
1308 return $this->joinPagesForQuery;
1309 }
1310
1311 /**
1312 * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
1313 */
1314 protected function getTypoScriptFrontendController()
1315 {
1316 return $GLOBALS['TSFE'];
1317 }
1318
1319 /**
1320 * @return TimeTracker
1321 */
1322 protected function getTimeTracker()
1323 {
1324 return GeneralUtility::makeInstance(TimeTracker::class);
1325 }
1326 }