Pretify search interface.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 13 Mar 2008 21:41:37 +0000 (21:41 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 13 Mar 2008 21:41:37 +0000 (21:41 +0000)
includes/SpecialSearch.php
languages/messages/MessagesEn.php

index e1b9199..71abcc1 100644 (file)
@@ -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 .= '<label>' .
+                               Xml::check( "ns{$ns}", in_array( $ns, $this->namespaces ), 
+                                       array( 'value' => '1' ) ) .
+                               "{$encName}</label> ";
                }
 
-               $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 "<br /><br />\n<form id=\"powersearch\" method=\"get\" " .
-                 "action=\"$action\">\n{$ret}\n</form>\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 "<script type='text/javascript'>" .
                        "document.getElementById('powerSearchText').focus();" .
                        "</script>";
        }
+       
+       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;
+       }
 }
 
 
index 1eaf899..d0743f9 100644 (file)
@@ -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:<br />$1<br />$2 List redirects<br />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'          => '<form method="get" action="http://www.google.com/search" id="googlesearch">