Author: sylvain_machefert
Description:
On my wiki, I needed to add a new search of similar words than the ones searched (for example, search "Yovano" should find "Jovano" and "йовано", search "Katysha" find "Катюша"...).
(this is still in beta, need a lot of improvements, you can see results at http://tousauxbalkans.free.fr ).
To do that, I created an extension with a copy/paste of a piece of code from SpecialSearch for regular searches, plus my own code for guessing similar words.
I'll try to create a patch from CVS if find how to do this, but here I explain the few things I had to change in SpecialSearch :
- in showResults function, I added the call to SearchOverride hook if exists. 2 parameters : $this = the object SpecialSearch, and $term = the searched word(s).
<pre>
if (wfRunHooks('SearchOverride', array($this, $term))) {
$search =& $this->getSearchEngine();
$titleMatches = $search->searchTitle( $term );
$textMatches = $search->searchText( $term );
...<snip>...
if( $num || $this->offset ) {
$wgOut->addHTML( "<p>{$prevnext}</p>\n" );
}
}
$wgOut->addHTML( $this->powerSearchBox( $term ) );
wfProfileOut( $fname );
</pre>
- function &getSearchEngine() is tagged as private, must be public. My hook need to create a search engine !
- My hook need also to access to limit, offset, and powerSearchOptions(). Make all them public, not private.
Version: 1.4.x
Severity: enhancement