* (bug 16281) Show copyright system message on special pages
* Upload license preview now uses the API instead of action=ajax
* (bug 7346) Add <guid> to RSS to avoid duplicates
+* (bug 19996) Added new hooks for Special:Search, which allow to further restrict/expand it.
=== Bug fixes in 1.16 ===
skin-specific JS pages
* (bug 5061) Use the more precise thumbcaption thumbimage and thumbinner classes
for image divs.
-* IE50Fixes.css and IE55Fixes.css have been dropped from the Monobook and Chick
- skins
== API changes in 1.16 ==
$title : Page title
$text : Current text being indexed
-'SearchGetNearMatch': An extra chance for exact-title-matches in "go" searches
+'SearchGetNearMatchBefore': Perform exact-title-matches in "go" searches before the normal operations
+$allSearchTerms : Array of the search terms in all content languages
+&$titleResult : Outparam; the value to return. A Title object or null.
+
+'SearchGetNearMatch': An extra chance for exact-title-matches in "go" searches if nothing was found
$term : Search term string
&$title : Outparam; set to $title object and return false for a match
+'SearchGetNearMatchComplete': A chance to modify exact-title-matches in "go" searches
+$term : Search term string
+&$title : Current Title object that is being returned (null if none found).
+
+'SearchEngineReplacePrefixesComplete': Run after SearchEngine::replacePrefixes().
+$searchEngine : The SearchEngine object. Users of this hooks will be interested
+in the $searchEngine->namespaces array.
+$query : Original query.
+&$parsed : Resultant query with the prefixes stripped.
+
+'SearchableNamespaces': An option to modify which namespaces are searchable.
+&$arr : Array of namespaces ($nsId => $name) which will be used.
+
'SetupAfterCache': Called in Setup.php, after cache objects are set
'ShowMissingArticle': Called when generating the output for a non-existent page
* @return Title
*/
public static function getNearMatch( $searchterm ) {
+ $title = self::getNearMatchInternal( $searchterm );
+
+ wfRunHooks( 'SearchGetNearMatchComplete', array( $searchterm, &$title ) );
+ return $title;
+ }
+
+ /**
+ * Really find the title match.
+ */
+ private static function getNearMatchInternal( $searchterm ) {
global $wgContLang;
$allSearchTerms = array($searchterm);
- if($wgContLang->hasVariants()){
+ if ( $wgContLang->hasVariants() ) {
$allSearchTerms = array_merge($allSearchTerms,$wgContLang->convertLinkToAllVariants($searchterm));
}
- foreach($allSearchTerms as $term){
+ if( !wfRunHooks( 'SearchGetNearMatchBefore', array( $allSearchTerms, &$titleResult ) ) ) {
+ return $titleResult;
+ }
+
+ foreach($allSearchTerms as $term) {
# Exact match? No need to look further.
$title = Title::newFromText( $term );
function replacePrefixes( $query ){
global $wgContLang;
- if( strpos($query,':') === false )
- return $query; // nothing to do
-
$parsed = $query;
+ if( strpos($query,':') === false ) { // nothing to do
+ wfRunHooks( 'SearchEngineReplacePrefixesComplete', array( $this, $query, &$parsed ) );
+ return $parsed;
+ }
+
$allkeyword = wfMsgForContent('searchall').":";
if( strncmp($query, $allkeyword, strlen($allkeyword)) == 0 ){
$this->namespaces = null;
}
}
if(trim($parsed) == '')
- return $query; // prefix was the whole query
+ $parsed = $query; // prefix was the whole query
+
+ wfRunHooks( 'SearchEngineReplacePrefixesComplete', array( $this, $query, &$parsed ) );
return $parsed;
}
$arr[$ns] = $name;
}
}
+
+ wfRunHooks( 'SearchableNamespaces', array( &$arr ) );
return $arr;
}