Skip to content

Commit efb33b8

Browse files
authored
Merge pull request #11 from michaelkubina-subhh/5.0.6_subhh_fix_highlighting
[BUGFIX] Fix search in document filtering and highlighting
2 parents 3b12e49 + ec3fa94 commit efb33b8

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

Classes/Common/Solr/SolrSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public function submit($start, $rows, $processResults = true)
537537
$searchResult['highlight'] = $doc['highlight'];
538538
$searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end
539539
preg_replace('/;+/', ';', // replace any multiple of ; with a single ;
540-
preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ;
540+
preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}{\sAND\s}{\sOR\s}{\sNOT\s}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ;
541541
}
542542
$documents[$doc['uid']]['searchResults'][] = $searchResult;
543543
}

Classes/Domain/Repository/DocumentRepository.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,10 @@ public function getPreviousDocumentUid($uid)
683683
return $prevDocument['uid'];
684684
}
685685

686-
return $this->getLastChild($this->getPreviousDocumentUid($parentId));
686+
$previousDocumentId = $this->getPreviousDocumentUid($parentId);
687+
if ($previousDocumentId) {
688+
return $this->getLastChild($previousDocumentId);
689+
}
687690
}
688691
}
689692

@@ -727,7 +730,10 @@ public function getNextDocumentUid($uid)
727730
return $nextDocument['uid'];
728731
}
729732

730-
return $this->getFirstChild($this->getNextDocumentUid($parentId));
733+
$nextDocumentId = $this->getNextDocumentUid($parentId);
734+
if ($nextDocumentId) {
735+
return $this->getFirstChild($nextDocumentId);
736+
}
731737
}
732738
}
733739

Classes/Middleware/SearchInDocument.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
104104
[
105105
'tx_dlf[id]' => !empty($resultDocument->getUid()) ? $resultDocument->getUid() : $parameters['uid'],
106106
'tx_dlf[page]' => $resultDocument->getPage(),
107-
'tx_dlf[highlight_word]' => $parameters['q']
107+
'tx_dlf[highlight_word]' => preg_replace('/^;|;$/', '', // remove ; at beginning or end
108+
preg_replace('/;+/', ';', // replace any multiple of ; with a single ;
109+
preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}{\sAND\s}{\sOR\s}{\sNOT\s}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $parameters['q']))) // replace search operators and special characters with ;
108110
]
109111
);
110112

Resources/Public/JavaScript/PageView/SearchInDocument.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function triggerSearchAfterHitLoad() {
212212

213213
if(searchedQueryParam && decodeURIComponent(queryParam[0]).indexOf(searchedQueryParam) !== -1) {
214214
$("input[id='tx-dlf-search-in-document-query']").val(decodeURIComponent(queryParam[1]));
215-
$("#tx-dlf-search-in-document-form").submit();
215+
//$("#tx-dlf-search-in-document-form").submit();
216216
break;
217217
}
218218
}

0 commit comments

Comments
 (0)