Add "Discussions" option to search when LiquidThreads is active. Includes some fixes to SpecialSearch.php, to allow this sort of change
This commit is contained in:
parent
a333c00559
commit
1ec4f9dbaa
2 changed files with 39 additions and 22 deletions
|
|
@ -1402,6 +1402,9 @@ $opts: FormOptions for this request
|
|||
target doesn't exist
|
||||
$title: title object generated from the text entred by the user
|
||||
|
||||
'SpecialSearchProfiles': allows modification of search profiles
|
||||
&$profiles: profiles, which can be modified.
|
||||
|
||||
'SpecialSearchResults': called before search result display when there
|
||||
are matches
|
||||
$term: string of search term
|
||||
|
|
|
|||
|
|
@ -334,16 +334,15 @@ class SpecialSearch {
|
|||
$nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
|
||||
if( $this->searchAdvanced )
|
||||
$this->active = 'advanced';
|
||||
else if( $this->namespaces === array(NS_FILE) || $this->startsWithImage( $term ) )
|
||||
$this->active = 'images';
|
||||
elseif( $this->namespaces === $nsAllSet || $this->startsWithAll( $term ) )
|
||||
$this->active = 'all';
|
||||
elseif( $this->namespaces === SearchEngine::defaultNamespaces() )
|
||||
$this->active = 'default';
|
||||
elseif( $this->namespaces === SearchEngine::helpNamespaces() )
|
||||
$this->active = 'help';
|
||||
else
|
||||
$this->active = 'advanced';
|
||||
else {
|
||||
$profiles = $this->getSearchProfiles();
|
||||
|
||||
foreach( $profiles as $key => $data ) {
|
||||
if ( $this->namespaces == $data['namespaces'] && $key != 'advanced')
|
||||
$this->active = $key;
|
||||
}
|
||||
|
||||
}
|
||||
# Should advanced UI be used?
|
||||
$this->searchAdvanced = ($this->active === 'advanced');
|
||||
if( !empty( $term ) ) {
|
||||
|
|
@ -811,20 +810,11 @@ class SpecialSearch {
|
|||
"document.getElementById('searchText').focus();" .
|
||||
"});" );
|
||||
}
|
||||
|
||||
protected function formHeader( $term, $resultsShown, $totalNum ) {
|
||||
global $wgContLang, $wgCanonicalNamespaceNames, $wgLang;
|
||||
|
||||
$out = Xml::openElement('div', array( 'class' => 'mw-search-formheader' ) );
|
||||
|
||||
$bareterm = $term;
|
||||
if( $this->startsWithImage( $term ) ) {
|
||||
// Deletes prefixes
|
||||
$bareterm = substr( $term, strpos( $term, ':' ) + 1 );
|
||||
}
|
||||
|
||||
protected function getSearchProfiles() {
|
||||
// Builds list of Search Types (profiles)
|
||||
$nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
|
||||
|
||||
// Builds list of Search Types (profiles)
|
||||
$profiles = array(
|
||||
'default' => array(
|
||||
'message' => 'searchprofile-articles',
|
||||
|
|
@ -859,6 +849,30 @@ class SpecialSearch {
|
|||
'parameters' => array( 'advanced' => 1 ),
|
||||
)
|
||||
);
|
||||
|
||||
wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );
|
||||
|
||||
foreach( $profiles as $key => &$data ) {
|
||||
sort($data['namespaces']);
|
||||
}
|
||||
|
||||
return $profiles;
|
||||
}
|
||||
|
||||
protected function formHeader( $term, $resultsShown, $totalNum ) {
|
||||
global $wgContLang, $wgCanonicalNamespaceNames, $wgLang;
|
||||
|
||||
$out = Xml::openElement('div', array( 'class' => 'mw-search-formheader' ) );
|
||||
|
||||
$bareterm = $term;
|
||||
if( $this->startsWithImage( $term ) ) {
|
||||
// Deletes prefixes
|
||||
$bareterm = substr( $term, strpos( $term, ':' ) + 1 );
|
||||
}
|
||||
|
||||
|
||||
$profiles = $this->getSearchProfiles();
|
||||
|
||||
// Outputs XML for Search Types
|
||||
$out .= Xml::openElement( 'div', array( 'class' => 'search-types' ) );
|
||||
$out .= Xml::openElement( 'ul' );
|
||||
|
|
|
|||
Loading…
Reference in a new issue