Index: trunk/extensions/MWSearch/MWSearch.php |
— | — | @@ -24,13 +24,13 @@ |
25 | 25 | */ |
26 | 26 | |
27 | 27 | # To use this, add something like the following to LocalSettings: |
| 28 | +# |
| 29 | +# require_once("extensions/MWSearch/MWSearch.php"); |
28 | 30 | # |
29 | 31 | # $wgSearchType = 'LuceneSearch'; |
30 | 32 | # $wgLuceneHost = '192.168.0.1'; |
31 | 33 | # $wgLucenePort = 8123; |
32 | 34 | # |
33 | | -# require_once("extensions/MWSearch/MWSearch.php"); |
34 | | -# |
35 | 35 | # To load-balance with from multiple servers: |
36 | 36 | # |
37 | 37 | # $wgLuceneHost = array( "192.168.0.1", "192.168.0.2" ); |
— | — | @@ -41,26 +41,19 @@ |
42 | 42 | |
43 | 43 | |
44 | 44 | # Back-end version (override before including MWSearch.php) |
45 | | -if( !isset($wgLuceneSearchVersion) ) |
46 | | - $wgLuceneSearchVersion = 2; |
| 45 | +$wgLuceneSearchVersion = 2; |
47 | 46 | |
48 | 47 | # If to show related links (if available) below search results |
49 | | -if( !isset($wgLuceneUseRelated) ) |
50 | | - $wgLuceneUseRelated = false; |
| 48 | +$wgLuceneUseRelated = false; |
51 | 49 | |
52 | 50 | # If to use lucene as a prefix search backend |
53 | | -if( !isset($wgEnableLucenePrefixSearch) ) |
54 | | - $wgEnableLucenePrefixSearch = false; |
| 51 | +$wgEnableLucenePrefixSearch = false; |
55 | 52 | |
56 | 53 | # For how long (in seconds) to cache lucene results, off by default (0) |
57 | 54 | # NOTE: caching is typically inefficient for queries, with cache |
58 | 55 | # hit rates way below 1% even for very long expiry times |
59 | | -if( !isset($wgLuceneSearchCacheExpiry) ) |
60 | | - $wgLuceneSearchCacheExpiry = 0; |
| 56 | +$wgLuceneSearchCacheExpiry = 0; |
61 | 57 | |
62 | | -# Not a valid entry point, skip unless MEDIAWIKI is defined |
63 | | -if( defined('MEDIAWIKI') ){ |
64 | | - |
65 | 58 | $wgExtensionCredits['other'][] = array( |
66 | 59 | 'name' => 'MWSearch', |
67 | 60 | 'svn-date' => '$LastChangedDate$', |
— | — | @@ -73,13 +66,14 @@ |
74 | 67 | $dir = dirname(__FILE__) . '/'; |
75 | 68 | |
76 | 69 | $wgExtensionMessagesFiles['MWSearch'] = $dir . 'MWSearch.i18n.php'; |
| 70 | +$wgExtensionFunctions[] = 'efLucenePrefixSetup'; |
77 | 71 | |
78 | | -if($wgLuceneSearchVersion >= 2.1 && $wgEnableLucenePrefixSearch) |
79 | | - $wgHooks['PrefixSearchBackend'][] = 'LuceneSearch::prefixSearch'; |
80 | | - |
81 | 72 | $wgAutoloadClasses['LuceneSearch'] = $dir . 'MWSearch_body.php'; |
82 | 73 | $wgAutoloadClasses['LuceneResult'] = $dir . 'MWSearch_body.php'; |
83 | 74 | $wgAutoloadClasses['LuceneSearchSet'] = $dir . 'MWSearch_body.php'; |
84 | 75 | |
85 | | -} # End of invocation guard |
86 | | - |
| 76 | +function efLucenePrefixSetup() { |
| 77 | + global $wgHooks, $wgLuceneSearchVersion, $wgEnableLucenePrefixSearch; |
| 78 | + if($wgLuceneSearchVersion >= 2.1 && $wgEnableLucenePrefixSearch) |
| 79 | + $wgHooks['PrefixSearchBackend'][] = 'LuceneSearch::prefixSearch'; |
| 80 | +} |