diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2014-03-02 20:08:56 +0000 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2014-03-02 20:08:56 +0000 |
commit | 6c196437d1096ad1c443124ca28927e4d36319e5 (patch) | |
tree | 5711a1401177a68ba1731a6b82f3d2ebd878c373 | |
parent | ebe968f9a6f10af5b97b582c09af82afc1986c84 (diff) | |
parent | a7e8b43e07d1665d3fdff8bde3a9850c0228efaf (diff) | |
download | rpg-6c196437d1096ad1c443124ca28927e4d36319e5.tar.gz rpg-6c196437d1096ad1c443124ca28927e4d36319e5.tar.bz2 |
Merge pull request #546 from splitbrain/phrase_match
Add FULLTEXT_PHRASE_MATCH event for allowing plugins to match phrases FS#2936
-rw-r--r-- | inc/fulltext.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php index 87b5a7370..dd918f214 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -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 } } |