63 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_grlist');
64 $result = $queryBuilder
66 ->from(
'index_grlist')
68 $queryBuilder->expr()->eq(
70 $queryBuilder->createNamedParameter($phash, \PDO::PARAM_INT)
74 $numberOfRows = $queryBuilder
79 while ($row = $result->fetch()) {
80 $row[
'pcount'] = $numberOfRows;
94 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_fulltext');
97 ->from(
'index_fulltext')
99 $queryBuilder->expr()->eq(
101 $queryBuilder->createNamedParameter($phash, \PDO::PARAM_INT)
116 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_rel');
121 $queryBuilder->expr()->eq(
123 $queryBuilder->createNamedParameter($phash, \PDO::PARAM_INT)
139 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_phash');
141 ->select(
'index_phash.*')
142 ->addSelectLiteral($queryBuilder->expr()->count(
'*',
'pcount'))
143 ->from(
'index_phash')
144 ->where($queryBuilder->expr()->neq(
'item_type', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)))
172 ->orderBy(
'item_type')
175 while ($row = $res->fetch()) {
180 if ($row[
'pcount'] > 1) {
181 $res2 = $queryBuilder
183 ->from(
'index_phash')
185 $queryBuilder->expr()->eq(
187 $queryBuilder->createNamedParameter($row[
'phash_grouping'], \PDO::PARAM_INT)
189 $queryBuilder->expr()->neq(
191 $queryBuilder->createNamedParameter($row[
'phash'], \PDO::PARAM_INT)
195 while ($row2 = $res2->fetch()) {
220 foreach ($tables as $tableName) {
221 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
222 $recordList[$tableName] = $queryBuilder
246 $revTypes = array_flip($types);
247 $revTypes[0] =
'TYPO3 page';
249 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_phash');
251 ->select(
'item_type')
252 ->addSelectLiteral($queryBuilder->expr()->count(
'*',
'count'))
253 ->from(
'index_phash')
254 ->groupBy(
'item_type')
255 ->orderBy(
'item_type')
258 while ($row = $res->fetch()) {
259 $itemType = $row[
'item_type'];
261 'count' => $row[
'count'],
262 'name' => $revTypes[$itemType],
278 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_phash');
279 $items = $queryBuilder
281 ->from(
'index_phash')
283 $queryBuilder->expr()->eq(
285 $queryBuilder->createNamedParameter($itemType, \PDO::PARAM_STR)
288 ->groupBy(
'phash_grouping')
292 return count($items);
303 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_section');
304 return (
int)$queryBuilder
306 ->from(
'index_section')
308 $queryBuilder->expr()->eq(
310 $queryBuilder->createNamedParameter($pageHash, \PDO::PARAM_INT)
325 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_phash');
327 ->select(
'index_phash.*')
328 ->addSelectLiteral($queryBuilder->expr()->count(
'*',
'pcount'))
329 ->from(
'index_phash')
330 ->where($queryBuilder->expr()->neq(
'data_page_id', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)))
358 ->orderBy(
'data_page_id')
361 while ($row = $res->fetch()) {
365 if ($row[
'pcount'] > 1) {
366 $res2 = $queryBuilder
368 ->from(
'index_phash')
370 $queryBuilder->expr()->eq(
372 $queryBuilder->createNamedParameter($row[
'phash_grouping'], \PDO::PARAM_INT)
374 $queryBuilder->expr()->neq(
376 $queryBuilder->createNamedParameter($row[
'phash'], \PDO::PARAM_INT)
380 while ($row2 = $res2->fetch()) {
399 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
400 ->getQueryBuilderForTable(
'index_stat_word');
403 ->from(
'index_stat_word')
404 ->addSelectLiteral($queryBuilder->expr()->count(
'*',
'c'))
406 $queryBuilder->expr()->eq(
408 $queryBuilder->createNamedParameter($pageUid, \PDO::PARAM_INT)
412 ->orderBy(
'c',
'desc')
413 ->setMaxResults((
int)$max);
415 if (!empty($additionalWhere)) {
419 $result = $queryBuilder->execute();
420 $countQueryBuilder = clone $queryBuilder;
421 $countQueryBuilder->resetQueryPart(
'orderBy');
422 $count = (int)$countQueryBuilder
426 $result->closeCursor();
431 $queryBuilder->where(
432 $queryBuilder->expr()->in(
434 $queryBuilder->createNamedParameter(
435 $this->extGetTreeList((
int)$pageUid),
436 Connection::PARAM_INT_ARRAY
443 return $queryBuilder->execute()->fetchAll();
454 $unserializedCHashParams = unserialize($row[
'cHashParams']);
455 $row[
'static_page_arguments'] = $row[
'static_page_arguments'] ? json_decode($row[
'static_page_arguments'],
true) :
null;
460 $row[
'cHashParams'] = !empty($unserializedCHashParams) ? $unserializedCHashParams :
'';
461 $row[
'grList'] = $grListRec;
472 public function getTree($pageId, $depth = 4, $mode)
480 $tree = GeneralUtility::makeInstance(PageTreeView::class);
482 $tree->init(
'AND ' . $perms_clause);
483 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
484 $HTML =
'<span title="' . htmlspecialchars($pageRecord[
'title']) .
'">' . $iconFactory->getIconForRecord(
'pages', $pageRecord,
Icon::SIZE_SMALL)->render() .
'</span>';
486 'row' => $pageRecord,
491 $tree->getTree((
int)$pageId, $depth,
'');
494 foreach ($tree->tree as $singleLine) {
495 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_phash');
496 $result = $queryBuilder->select(
515 'IP.item_description',
522 'IP.sys_language_uid',
529 ->addSelectLiteral($queryBuilder->expr()->count(
'*',
'count_val'))
530 ->from(
'index_phash',
'IP')
531 ->from(
'index_section',
'ISEC')
533 $queryBuilder->expr()->eq(
'IP.phash', $queryBuilder->quoteIdentifier(
'ISEC.phash')),
534 $queryBuilder->expr()->eq(
536 $queryBuilder->createNamedParameter($singleLine[
'row'][
'uid'], \PDO::PARAM_INT)
552 'IP.item_description',
559 'IP.sys_language_uid',
573 ->orderBy(
'IP.item_type')
574 ->addOrderBy(
'IP.tstamp')
581 while ($row = $result->fetch()) {
583 $this->allPhashListed[] = $row[
'phash'];
586 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
587 ->getQueryBuilderForTable(
'index_rel');
588 $wordCountResult = $queryBuilder->count(
'index_words.baseword')
590 ->from(
'index_words')
592 $queryBuilder->expr()->eq(
594 $queryBuilder->createNamedParameter($row[
'phash'], \PDO::PARAM_INT)
596 $queryBuilder->expr()->eq(
'index_words.wid', $queryBuilder->quoteIdentifier(
'index_rel.wid'))
598 ->groupBy(
'index_words.baseword')
601 $row[
'wordCount'] = $queryBuilder
602 ->count(
'index_rel.wid')
605 $wordCountResult->closeCursor();
607 if ($mode ===
'content') {
608 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
609 ->getQueryBuilderForTable(
'index_fulltext');
610 $row[
'fulltextData'] = $queryBuilder->select(
'*')
611 ->from(
'index_fulltext')
613 $queryBuilder->expr()->eq(
615 $queryBuilder->createNamedParameter($row[
'phash'], \PDO::PARAM_INT)
622 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
623 ->getQueryBuilderForTable(
'index_rel');
624 $wordRecords = $queryBuilder->select(
'index_words.baseword')
626 ->from(
'index_words')
628 $queryBuilder->expr()->eq(
630 $queryBuilder->createNamedParameter($row[
'phash'], \PDO::PARAM_INT)
632 $queryBuilder->expr()->eq(
634 $queryBuilder->quoteIdentifier(
'index_rel.wid')
637 ->groupBy(
'index_words.baseword')
638 ->orderBy(
'index_words.baseword')
642 if (is_array($wordRecords)) {
643 $row[
'allWords'] = array_column($wordRecords,
'baseword');
650 $singleLine[
'lines'] = $lines;
651 $allLines[] = $singleLine;
680 protected function getPageTreeIds(
int $id,
int $depth,
int $begin): array
682 if (!$id || $depth <= 0) {
685 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
686 ->getQueryBuilderForTable(
'pages');
688 $queryBuilder->getRestrictions()
690 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
691 $result = $queryBuilder
692 ->select(
'uid',
'title')
695 $queryBuilder->expr()->eq(
'pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
700 while ($row = $result->fetch()) {
702 $pageIds[] = (int)$row[
'uid'];
705 $pageIds = array_merge($pageIds, $this->
getPageTreeIds((
int)$row[
'uid'], $depth - 1, $begin - 1));
720 if ($phashList ===
'ALL') {
721 $this->
getTree($pageId, $depth,
'');
723 $this->allPhashListed = [];
725 $phashRows = GeneralUtility::trimExplode(
',', $phashList,
true);
728 foreach ($phashRows as $phash) {
729 $phash = (int)$phash;
732 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
733 ->getQueryBuilderForTable(
'index_section');
736 ->from(
'index_section')
738 $queryBuilder->expr()->eq(
740 $queryBuilder->createNamedParameter($phash, \PDO::PARAM_INT)
744 while ($row = $res->fetch()) {
745 $idList[] = (int)$row[
'page_id'];
748 if (!empty($idList)) {
750 $pageCache = GeneralUtility::makeInstance(CacheManager::class)->getCache(
'cache_pages');
751 foreach ($idList as $pageId) {
752 $pageCache->flushByTag(
'pageId_' . $pageId);
765 foreach ($tableArr as $table) {
766 GeneralUtility::makeInstance(ConnectionPool::class)
767 ->getConnectionForTable($table)
768 ->delete($table, [
'phash' => (
int)$phash]);
781 foreach ($words as $wid => $state) {
782 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'index_words');
784 ->update(
'index_words')
785 ->set(
'is_stopword', (
int)$state)
787 $queryBuilder->expr()->eq(
789 $queryBuilder->createNamedParameter($wid, \PDO::PARAM_INT)
806 if (!is_array($pageRec)) {
809 $keywords = array_flip(GeneralUtility::trimExplode(
',', $pageRec[
'keywords'],
true));
811 foreach ($words as $key => $v) {
815 unset($keywords[$key]);
820 $data[
'pages'][$pageId][
'keywords'] = implode(
', ', array_keys($keywords));
821 $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
822 $dataHandler->start($data, []);
823 $dataHandler->process_datamap();
834 if (!isset($this->iconFileNameCache[$itemType])) {
836 if ($itemType ===
'0') {
837 $icon =
'EXT:indexed_search/Resources/Public/Icons/FileTypes/pages.gif';
838 } elseif ($this->external_parsers[$itemType]) {
839 $icon = $this->external_parsers[$itemType]->getIcon($itemType);
841 $this->iconFileNameCache[$itemType] = $icon;
843 return $this->iconFileNameCache[$itemType];