Redesign of the "new search UI" per Trevor's design plans from usability wiki:
* simplify everything, move search box to top * move header below it and make it google-style * move styles from monobook into shared since people didn't really customize it * remove some old unused stuff like default+project namespaces and such Things to do still: * smarter detection of prefix searches * javascript to link to correct link when typing in a query, but clicking on one of the search headers * prev/next still uses MW default navigation, should be replaced with tango icons? * test a bit more with default search backend (i.e. mysql)
This commit is contained in:
parent
58607bec93
commit
abd70a3554
7 changed files with 117 additions and 89 deletions
|
|
@ -1976,16 +1976,14 @@ $wgNamespacesToBeSearchedDefault = array(
|
|||
);
|
||||
|
||||
/**
|
||||
* Additional namespaces to those in $wgNamespacesToBeSearchedDefault that
|
||||
* will be added to default search for "project" page inclusive searches
|
||||
* Namespaces to be searched when user clicks the "Help" tab
|
||||
* on Special:Search
|
||||
*
|
||||
* Same format as $wgNamespacesToBeSearchedDefault
|
||||
*/
|
||||
$wgNamespacesToBeSearchedProject = array(
|
||||
NS_USER => true,
|
||||
$wgNamespacesToBeSearchedHelp = array(
|
||||
NS_PROJECT => true,
|
||||
NS_HELP => true,
|
||||
NS_CATEGORY => true,
|
||||
);
|
||||
|
||||
$wgUseOldSearchUI = true; // temp testing variable
|
||||
|
|
|
|||
|
|
@ -292,28 +292,14 @@ class SearchEngine {
|
|||
}
|
||||
|
||||
/**
|
||||
* An array of "project" namespaces indexes typically searched
|
||||
* by logged-in users
|
||||
* Return the help namespaces to be shown on Special:Search
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public static function projectNamespaces() {
|
||||
global $wgNamespacesToBeSearchedDefault, $wgNamespacesToBeSearchedProject;
|
||||
public static function helpNamespaces() {
|
||||
global $wgNamespacesToBeSearchedHelp;
|
||||
|
||||
return array_keys( $wgNamespacesToBeSearchedProject, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of "project" namespaces indexes typically searched
|
||||
* by logged-in users in addition to the default namespaces
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public static function defaultAndProjectNamespaces() {
|
||||
global $wgNamespacesToBeSearchedDefault, $wgNamespacesToBeSearchedProject;
|
||||
|
||||
return array_keys( $wgNamespacesToBeSearchedDefault +
|
||||
$wgNamespacesToBeSearchedProject, true);
|
||||
return array_keys( $wgNamespacesToBeSearchedHelp, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -206,14 +206,6 @@ class SpecialSearch {
|
|||
return;
|
||||
}
|
||||
|
||||
// show direct page/create link
|
||||
if( !is_null($t) ) {
|
||||
if( !$t->exists() ) {
|
||||
$wgOut->addWikiMsg( 'searchmenu-new', wfEscapeWikiText( $t->getPrefixedText() ) );
|
||||
} else {
|
||||
$wgOut->addWikiMsg( 'searchmenu-exists', wfEscapeWikiText( $t->getPrefixedText() ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Get number of results
|
||||
$titleMatchesSQL = $titleMatches ? $titleMatches->numRows() : 0;
|
||||
|
|
@ -228,16 +220,17 @@ class SpecialSearch {
|
|||
$totalRes = $numTitleMatches + $numTextMatches;
|
||||
|
||||
// show number of results and current offset
|
||||
if( $numSQL > 0 ) {
|
||||
if( $numSQL > 0 ) {
|
||||
$top = wfMsgExt('showingresultstotal', array( 'parseinline' ),
|
||||
$this->offset+1, $this->offset+$numSQL, $totalRes, $numSQL );
|
||||
} elseif( $numSQL >= $this->limit ) {
|
||||
$top = wfShowingResults( $this->offset, $this->limit );
|
||||
$wgOut->addHTML( $this->formHeader($term, $numSQL, $totalRes));
|
||||
|
||||
$wgOut->addHtml( "<div class='searchresults'>" );
|
||||
|
||||
// show direct page/create link
|
||||
if( !is_null($t) ) {
|
||||
if( !$t->exists() ) {
|
||||
$wgOut->addWikiMsg( 'searchmenu-new', wfEscapeWikiText( $t->getPrefixedText() ) );
|
||||
} else {
|
||||
$top = wfShowingResultsNum( $this->offset, $this->limit, $numSQL );
|
||||
$wgOut->addWikiMsg( 'searchmenu-exists', wfEscapeWikiText( $t->getPrefixedText() ) );
|
||||
}
|
||||
$wgOut->addHTML( "<p class='mw-search-numberresults'>{$top}</p>\n" );
|
||||
}
|
||||
|
||||
// prev/next links
|
||||
|
|
@ -247,13 +240,13 @@ class SpecialSearch {
|
|||
wfArrayToCGI( $this->powerSearchOptions(), array( 'search' => $term ) ),
|
||||
max( $titleMatchesSQL, $textMatchesSQL ) < $this->limit
|
||||
);
|
||||
$wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
|
||||
//$wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
|
||||
wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
|
||||
} else {
|
||||
wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
|
||||
}
|
||||
}
|
||||
|
||||
$wgOut->addHtml( "<div class='searchresults'>" );
|
||||
|
||||
if( $titleMatches ) {
|
||||
if( $numTitleMatches > 0 ) {
|
||||
$wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
|
||||
|
|
@ -268,7 +261,7 @@ class SpecialSearch {
|
|||
$wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' );
|
||||
} elseif( $totalRes == 0 ) {
|
||||
# Don't show the 'no text matches' if we received title matches
|
||||
$wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' );
|
||||
# $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' );
|
||||
}
|
||||
// show interwiki results if any
|
||||
if( $textMatches->hasInterwikiResults() ) {
|
||||
|
|
@ -304,14 +297,14 @@ class SpecialSearch {
|
|||
$nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
|
||||
if( $this->searchAdvanced )
|
||||
$this->active = 'advanced';
|
||||
else if( $this->namespaces === NS_FILE || $this->startsWithImage( $term ) )
|
||||
else if( $this->namespaces === array(NS_FILE) || $this->startsWithImage( $term ) )
|
||||
$this->active = 'images';
|
||||
elseif( $this->namespaces === $nsAllSet )
|
||||
elseif( $this->namespaces === $nsAllSet || $this->startsWithAll( $term ) )
|
||||
$this->active = 'all';
|
||||
elseif( $this->namespaces === SearchEngine::defaultNamespaces() )
|
||||
$this->active = 'default';
|
||||
elseif( $this->namespaces === SearchEngine::projectNamespaces() )
|
||||
$this->active = 'project';
|
||||
elseif( $this->namespaces === SearchEngine::helpNamespaces() )
|
||||
$this->active = 'help';
|
||||
else
|
||||
$this->active = 'advanced';
|
||||
# Should advanced UI be used?
|
||||
|
|
@ -648,7 +641,7 @@ class SpecialSearch {
|
|||
} */
|
||||
return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
|
||||
Xml::element( 'legend', null, wfMsg('powersearch-legend') ) .
|
||||
$this->formHeader($term) . $out . $this->didYouMeanHtml .
|
||||
$out . $this->didYouMeanHtml .
|
||||
Xml::closeElement( 'fieldset' );
|
||||
}
|
||||
|
||||
|
|
@ -670,11 +663,12 @@ class SpecialSearch {
|
|||
"</script>";
|
||||
}
|
||||
|
||||
protected function formHeader( $term ) {
|
||||
protected function formHeader( $term, $resultsShown, $totalRes ) {
|
||||
global $wgContLang, $wgCanonicalNamespaceNames, $wgLang;
|
||||
|
||||
|
||||
$sep = ' ';
|
||||
$out = Xml::openElement('div', array( 'style' => 'padding-bottom:0.5em;' ) );
|
||||
$out = Xml::openElement('div', array( 'class' => 'mw-search-formheader' ) );
|
||||
$out .= Xml::openElement('div');
|
||||
|
||||
$bareterm = $term;
|
||||
if( $this->startsWithImage( $term ) )
|
||||
|
|
@ -699,19 +693,18 @@ class SpecialSearch {
|
|||
if( $this->active == 'images' ) {
|
||||
$out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
|
||||
} else {
|
||||
$imageTextForm = $wgContLang->getFormattedNsText(NS_FILE).':'.$bareterm;
|
||||
$out .= $this->makeSearchLink( $imageTextForm, array( NS_FILE ) , $m, $tt );
|
||||
$out .= $this->makeSearchLink( $bareterm, array( NS_FILE ) , $m, $tt );
|
||||
}
|
||||
$out .= $sep;
|
||||
|
||||
$m = wfMsg( 'searchprofile-project' );
|
||||
$tt = wfMsg( 'searchprofile-project-tooltip',
|
||||
$wgLang->commaList( SearchEngine::namespacesAsText( SearchEngine::projectNamespaces() ) ) );
|
||||
$wgLang->commaList( SearchEngine::namespacesAsText( SearchEngine::helpNamespaces() ) ) );
|
||||
$tt = Sanitizer::decodeCharReferences( $tt ); // need to allow entities
|
||||
if( $this->active == 'project' ) {
|
||||
if( $this->active == 'help' ) {
|
||||
$out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
|
||||
} else {
|
||||
$out .= $this->makeSearchLink( $bareterm, SearchEngine::projectNamespaces(), $m, $tt );
|
||||
$out .= $this->makeSearchLink( $bareterm, SearchEngine::helpNamespaces(), $m, $tt );
|
||||
}
|
||||
$out .= $sep;
|
||||
|
||||
|
|
@ -732,6 +725,16 @@ class SpecialSearch {
|
|||
$out .= $this->makeSearchLink( $bareterm, $this->namespaces, $m, $tt, array( 'advanced' => '1' ) );
|
||||
}
|
||||
$out .= Xml::closeElement('div') ;
|
||||
|
||||
if( $totalRes > 0){
|
||||
$countHtml = wfMsgExt('showingresultsheader', array( 'parseinline' ),
|
||||
$this->offset+1, $this->offset+$resultsShown, $totalRes, $term, $resultsShown );
|
||||
$out .= "<p>{$countHtml}</p>\n" ;
|
||||
} else{
|
||||
$out .= "<p> </p>\n";
|
||||
}
|
||||
|
||||
$out .= Xml::closeElement('div') ;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
|
@ -762,17 +765,14 @@ class SpecialSearch {
|
|||
$out .= Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . "\n";
|
||||
$out .= Xml::hidden( 'fulltext', 'Search' );
|
||||
$out .= Xml::submitButton( wfMsg( 'searchbutton' ) );
|
||||
$out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')';
|
||||
//$out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')';
|
||||
$out .= Xml::closeElement( 'form' );
|
||||
// Add prefix link for single-namespace searches
|
||||
$t = Title::newFromText( $term );
|
||||
/*if( $t != null && count($this->namespaces) === 1 ) {
|
||||
$out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
|
||||
}*/
|
||||
return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
|
||||
Xml::element( 'legend', null, wfMsg('searchmenu-legend') ) .
|
||||
$this->formHeader($term) . $out . $this->didYouMeanHtml .
|
||||
Xml::closeElement( 'fieldset' );
|
||||
return $out . $this->didYouMeanHtml;
|
||||
}
|
||||
|
||||
/** Make a search link with some target namespaces */
|
||||
|
|
@ -801,6 +801,18 @@ class SpecialSearch {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Check if query starts with all: prefix */
|
||||
protected function startsWithAll( $term ) {
|
||||
|
||||
$allkeyword = wfMsgForContent('searchall');
|
||||
|
||||
$p = explode( ':', $term );
|
||||
if( count( $p ) > 1 ) {
|
||||
return $p[0] == $allkeyword;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function namespaceTables( $namespaces, $rowsPerTable = 3 ) {
|
||||
global $wgContLang;
|
||||
|
|
|
|||
|
|
@ -1450,9 +1450,9 @@ You can [[:\$1|create this page]].",
|
|||
'searchhelp-url' => 'Help:Contents',
|
||||
'searchmenu-prefix' => '[[Special:PrefixIndex/$1|Browse pages with this prefix]]',
|
||||
'searchmenu-help' => '[[{{MediaWiki:Searchhelp-url}}|{{int:help}}]]?', # do not translate or duplicate this message to other languages
|
||||
'searchprofile-articles' => 'Content pages',
|
||||
'searchprofile-project' => 'Project pages',
|
||||
'searchprofile-images' => 'Files',
|
||||
'searchprofile-articles' => 'Articles',
|
||||
'searchprofile-project' => 'Help',
|
||||
'searchprofile-images' => 'Multimedia',
|
||||
'searchprofile-everything' => 'Everything',
|
||||
'searchprofile-advanced' => 'Advanced',
|
||||
'searchprofile-articles-tooltip' => 'Search in $1',
|
||||
|
|
@ -1478,6 +1478,7 @@ You can [[:\$1|create this page]].",
|
|||
'showingresults' => "Showing below up to {{PLURAL:$1|'''1''' result|'''$1''' results}} starting with #'''$2'''.",
|
||||
'showingresultsnum' => "Showing below {{PLURAL:$3|'''1''' result|'''$3''' results}} starting with #'''$2'''.",
|
||||
'showingresultstotal' => "Showing below {{PLURAL:$4|result '''$1''' of '''$3'''|results '''$1 - $2''' of '''$3'''}}",
|
||||
'showingresultsheader' => "{{PLURAL:$5|Result '''$1''' of '''$3'''|Results '''$1 - $2''' of '''$3'''}} for '''$4'''",
|
||||
'nonefound' => "'''Note''': Only some namespaces are searched by default.
|
||||
Try prefixing your query with ''all:'' to search all content (including talk pages, templates, etc), or use the desired namespace as prefix.",
|
||||
'search-nonefound' => 'There were no results matching the query.',
|
||||
|
|
|
|||
|
|
@ -812,6 +812,7 @@ $wgMessageStructure = array(
|
|||
'showingresults',
|
||||
'showingresultsnum',
|
||||
'showingresultstotal',
|
||||
'showingresultsheader',
|
||||
'nonefound',
|
||||
'search-nonefound',
|
||||
'powersearch',
|
||||
|
|
|
|||
|
|
@ -102,19 +102,55 @@ p.mw-filedelete-editreasons, p.mw-delete-editreasons {
|
|||
}
|
||||
|
||||
/* Search results */
|
||||
.searchresults {
|
||||
}
|
||||
|
||||
.searchresults p {
|
||||
margin-left: 0.4em;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1.2em;
|
||||
}
|
||||
|
||||
div.searchresult {
|
||||
font-size: 95%;
|
||||
width:38em;
|
||||
width:38em;
|
||||
}
|
||||
|
||||
.mw-search-results {
|
||||
margin-left: 0.4em;
|
||||
}
|
||||
|
||||
.mw-search-results li {
|
||||
padding-bottom: 1em;
|
||||
list-style:none;
|
||||
}
|
||||
.mw-search-results li a {
|
||||
font-size: 108%;
|
||||
}
|
||||
|
||||
.mw-search-result-data {
|
||||
color: green;
|
||||
font-size: 97%;
|
||||
}
|
||||
|
||||
.mw-search-formheader {
|
||||
background-color:#ECECEC;
|
||||
margin:1em 0pt;
|
||||
padding:0.02em ;
|
||||
border-top:1px solid #BBBBBB;
|
||||
}
|
||||
|
||||
.mw-search-formheader div {
|
||||
float:left;
|
||||
padding:4px 0.5em 0px 4px;
|
||||
}
|
||||
|
||||
.mw-search-formheader p {
|
||||
margin:0.1em 0pt;
|
||||
padding:0.2em 0.4em 0.2em 0.2em;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
td#mw-search-menu {
|
||||
padding-left:6em;
|
||||
font-size:85%;
|
||||
|
|
@ -138,6 +174,24 @@ div#mw-search-interwiki li {
|
|||
font-size: 90%;
|
||||
}
|
||||
|
||||
div#mw-search-interwiki-caption {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
.mw-search-interwiki-project {
|
||||
font-size: 97%;
|
||||
text-align: left;
|
||||
padding-left: 0.2em;
|
||||
padding-right: 0.15em;
|
||||
padding-bottom: 0.2em;
|
||||
padding-top: 0.15em;
|
||||
background-color:#ececec;
|
||||
border-top:1px solid #BBBBBB;
|
||||
}
|
||||
|
||||
|
||||
span.searchalttitle {
|
||||
font-size: 95%;
|
||||
}
|
||||
|
|
@ -158,13 +212,6 @@ div.searchdidyoumean em {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.searchresults {
|
||||
border:1px solid darkblue;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
/*
|
||||
* UserRights stuff
|
||||
|
|
|
|||
|
|
@ -1542,23 +1542,6 @@ div.mw-lag-warn-high {
|
|||
font-size: 90%;
|
||||
}
|
||||
|
||||
/** Special:Search stuff */
|
||||
div#mw-search-interwiki-caption {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
.mw-search-interwiki-project {
|
||||
font-size: 97%;
|
||||
text-align: left;
|
||||
padding-left: 0.2em;
|
||||
padding-right: 0.15em;
|
||||
padding-bottom: 0.2em;
|
||||
padding-top: 0.15em;
|
||||
background: #cae8ff;
|
||||
}
|
||||
|
||||
/* God-damned hack for the crappy layout */
|
||||
.os-suggest {
|
||||
font-size: 127%;
|
||||
|
|
|
|||
Loading…
Reference in a new issue