Skip to content
Snippets Groups Projects
Commit a7e8b43e authored by Michael Hamann's avatar Michael Hamann
Browse files

Add FULLTEXT_PHRASE_MATCH event for allowing plugins to match phrases

Our index doesn't support phrase searches so we are searching for the
pages that contain all words of the phrase and then search again in the
content of the pages. As plugins can also add additional text to the
index this event allows plugins to do phrase matching in their content.
parent 04032c73
No related branches found
No related tags found
No related merge requests found
......@@ -72,8 +72,20 @@ function _ft_pageSearch(&$data) {
$pages = end($stack);
$pages_matched = array();
foreach(array_keys($pages) as $id){
$text = utf8_strtolower(rawWiki($id));
if (strpos($text, $phrase) !== false) {
$evdata = array(
'id' => $id,
'phrase' => $phrase,
'text' => rawWiki($id)
);
$evt = new Doku_Event('FULLTEXT_PHRASE_MATCH',$evdata);
if ($evt->advise_before() && $evt->result !== true) {
$text = utf8_strtolower($evdata['text']);
if (strpos($text, $phrase) !== false) {
$evt->result = true;
}
}
$evt->advise_after();
if ($evt->result === true) {
$pages_matched[$id] = 0; // phrase: always 0 hit
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment