From: Bryan Tong Minh Date: Thu, 13 Mar 2008 21:41:37 +0000 (+0000) Subject: Pretify search interface. X-Git-Tag: 1.31.0-rc.0~49128 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=1071b23d69220824e2ffe37fab8657848cae1d7c;p=lhc%2Fweb%2Fwiklou.git Pretify search interface. --- diff --git a/includes/SpecialSearch.php b/includes/SpecialSearch.php index e1b9199f7b..71abcc198b 100644 --- a/includes/SpecialSearch.php +++ b/includes/SpecialSearch.php @@ -154,6 +154,8 @@ class SpecialSearch { wfProfileOut( $fname ); return; } + + $wgOut->addHTML( $this->shortDialog( $term ) ); $search = SearchEngine::create(); $search->setLimitOffset( $this->limit, $this->offset ); @@ -288,6 +290,8 @@ class SpecialSearch { $opt['searchx'] = 1; return $opt; } + + /** * @param SearchResultSet $matches @@ -431,41 +435,74 @@ class SpecialSearch { } function powerSearchBox( $term ) { + global $wgScript; + $namespaces = ''; foreach( SearchEngine::searchableNamespaces() as $ns => $name ) { - $checked = in_array( $ns, $this->namespaces ) - ? ' checked="checked"' - : ''; $name = str_replace( '_', ' ', $name ); if( '' == $name ) { $name = wfMsg( 'blanknamespace' ); } - $namespaces .= Xml::checkLabel( $name, "ns{$ns}", $name, $checked ) . "\n"; + $encName = htmlspecialchars( $name ); + $namespaces .= ' "; } - $checked = $this->searchRedirects - ? ' checked="checked"' - : ''; - $redirect = Xml::check( 'redirs', $checked ) . "\n"; - $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) ); - $searchButton = Xml::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'searchx' ) ); - - $ret = wfMsgExt( 'powersearchtext', array( 'parse', 'replaceafter' ), - $namespaces, $redirect, $searchField, - '', '', '', '', '', # Dummy placeholders - $searchButton ); - - $title = SpecialPage::getTitleFor( 'Search' ); - $action = $title->escapeLocalURL(); - return "

\n
\n{$ret}\n
\n"; - } + $redirect = Xml::check( 'redirs', $this->searchRedirects, + array( 'value' => '1' ) ); + + $searchField = Xml::input( 'search', 50, $term, array( + 'type' => 'text', 'id' => 'powerSearchText' ) ); + + $searchButton = Xml::element( 'input', array( + 'type' => 'submit', + 'name' => 'searchx', + 'value' => wfMsg('powersearch') + ) ) . "\n"; + + $out = Xml::openElement( 'form', array( + 'id' => 'powersearch', + 'method' => 'get', + 'action' => $wgScript ) ); + $out .= Xml::openElement( 'fieldset' ); + $out .= Xml::element( 'legend', array( ), wfMsg( 'powersearch' )); + $out .= Xml::hidden( 'title', 'Special:Search' ); + $out .= wfMsgExt( 'powersearchtext', + $namespaces, $redirect, $searchField, + '', '', '', '', '', # Dummy placeholders + $searchButton ); + $out .= Xml::closeElement( 'fieldset' ); + $out .= Xml::closeElement( 'form' ); + return $out; + } + function powerSearchFocus() { return ""; } + + function shortDialog($term) { + global $wgScript; + + $out = Xml::openElement( 'form', array( + 'id' => 'search', + 'method' => 'get', + 'action' => $wgScript + )); + $out .= Xml::openElement( 'fieldset' ); + $out .= Xml::element( 'legend', array(), wfMsg( 'searchresultshead' ) ); + $out .= Xml::hidden( 'title', 'Special:Search' ); + $out .= Xml::inputLabel( wfMsg( 'search' ), 'search', 'searchbox', 50, $term ) . ' '; + $out .= Xml::submitButton( wfMsg( 'searchbutton' ) ); + $out .= Xml::closeElement( 'fieldset' ); + $out .= Xml::closeElement( 'form' ); + + return $out; + } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 1eaf899573..d0743f999d 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1221,7 +1221,7 @@ Make sure that this change will maintain historical page continuity. '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'''.", 'nonefound' => "'''Note''': Unsuccessful searches are often caused by searching for common words like \"have\" and \"from\", which are not indexed, or by specifying more than one search term (only pages containing all of the search terms will appear in the result).", -'powersearch' => 'Search', +'powersearch' => 'Advanced search', 'powersearchtext' => 'Search in namespaces:
$1
$2 List redirects
Search for $3 $9', 'searchdisabled' => '{{SITENAME}} search is disabled. You can search via Google in the meantime. Note that their indexes of {{SITENAME}} content may be out of date.', 'googlesearch' => '