Allow 'all:' on all wikis in addition to 'searchall' translation
This allows to have a common syntax useable everywhere. Bug: T165110 Change-Id: If71fe5df045fb754925946088f8f793197bc8301
This commit is contained in:
parent
390ff7fca1
commit
39cbbab021
1 changed files with 18 additions and 5 deletions
|
|
@ -335,12 +335,25 @@ abstract class SearchEngine {
|
|||
return false;
|
||||
}
|
||||
$extractedNamespace = null;
|
||||
$allkeywords = [];
|
||||
|
||||
$allkeyword = wfMessage( 'searchall' )->inContentLanguage()->text() . ":";
|
||||
if ( strncmp( $query, $allkeyword, strlen( $allkeyword ) ) == 0 ) {
|
||||
$extractedNamespace = null;
|
||||
$parsed = substr( $query, strlen( $allkeyword ) );
|
||||
} elseif ( strpos( $query, ':' ) !== false ) {
|
||||
$allkeywords[] = wfMessage( 'searchall' )->inContentLanguage()->text() . ":";
|
||||
// force all: so that we have a common syntax for all the wikis
|
||||
if ( !in_array( 'all:', $allkeywords ) ) {
|
||||
$allkeywords[] = 'all:';
|
||||
}
|
||||
|
||||
$allQuery = false;
|
||||
foreach ( $allkeywords as $kw ) {
|
||||
if ( strncmp( $query, $kw, strlen( $kw ) ) == 0 ) {
|
||||
$extractedNamespace = null;
|
||||
$parsed = substr( $query, strlen( $kw ) );
|
||||
$allQuery = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$allQuery && strpos( $query, ':' ) !== false ) {
|
||||
// TODO: should we unify with PrefixSearch::extractNamespace ?
|
||||
$prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
|
||||
$index = $wgContLang->getNsIndex( $prefix );
|
||||
|
|
|
|||
Loading…
Reference in a new issue