Localisation updates Cantonese, Chinese and Old/Late Time Chinese
[lhc/web/wiklou.git] / includes / SpecialSearch.php
index 25aba1c..d68ff9a 100644 (file)
@@ -19,7 +19,8 @@
 
 /**
  * Run text & title search and display the output
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
@@ -43,7 +44,7 @@ function wfSpecialSearch( $par = '' ) {
 
 /**
  * implements Special:Search - Run text & title search and display the output
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class SpecialSearch {
 
@@ -102,6 +103,8 @@ class SpecialSearch {
                                return;
                        }
                }
+
+               $wgOut->wrapWikiMsg( "==$1==\n", 'notitlematches' );
                if( $t->quickUserCan( 'create' ) && $t->quickUserCan( 'edit' ) ) {
                        $wgOut->addWikiMsg( 'noexactmatch', wfEscapeWikiText( $term ) );
                } else {
@@ -210,7 +213,7 @@ class SpecialSearch {
                        } else {
                                $top = wfShowingResultsNum( $this->offset, $this->limit, $num );
                        }
-                       $wgOut->addHTML( "<p>{$top}</p>\n" );
+                       $wgOut->addHTML( "<p class='mw-search-numberresults'>{$top}</p>\n" );
                }
 
                // prev/next links
@@ -221,7 +224,7 @@ class SpecialSearch {
                                        $this->powerSearchOptions(),
                                        array( 'search' => $term ) ),
                                        ($num < $this->limit) );
-                       $wgOut->addHTML( "<p>{$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 ) );
@@ -231,8 +234,6 @@ class SpecialSearch {
                        if( $titleMatches->numRows() ) {
                                $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
                                $wgOut->addHTML( $this->showMatches( $titleMatches ) );
-                       } else {
-                               $wgOut->wrapWikiMsg( "==$1==\n", 'notitlematches' );
                        }
                        $titleMatches->free();
                }
@@ -254,7 +255,7 @@ class SpecialSearch {
                        // show results
                        if( $textMatches->numRows() )
                                $wgOut->addHTML( $this->showMatches( $textMatches ) );
-                               
+
                        $textMatches->free();
                }
 
@@ -262,7 +263,7 @@ class SpecialSearch {
                        $wgOut->addWikiMsg( 'nonefound' );
                }
                if( $num || $this->offset ) {
-                       $wgOut->addHTML( "<p>{$prevnext}</p>\n" );
+                       $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
                }
                $wgOut->addHTML( $this->powerSearchBox( $term ) );
                wfProfileOut( $fname );
@@ -336,7 +337,7 @@ class SpecialSearch {
                        
                
                $off = $this->offset + 1;
-               $out .= "<ul start='{$off}' class='mw-search-results'>\n";
+               $out .= "<ul class='mw-search-results'>\n";
 
                while( $result = $matches->next() ) {
                        $out .= $this->showHit( $result, $terms );
@@ -374,6 +375,7 @@ class SpecialSearch {
                //This is not quite safe, but better than showing excerpts from non-readable pages
                //Note that hiding the entry entirely would screw up paging.
                if (!$t->userCanRead()) {
+                       wfProfileOut( $fname );
                        return "<li>{$link}</li>\n";
                }
 
@@ -381,6 +383,7 @@ class SpecialSearch {
                // The least confusing at this point is to drop the result.
                // You may get less results, but... oh well. :P
                if( $result->isMissingRevision() ) {
+                       wfProfileOut( $fname );
                        return "<!-- missing page " .
                                htmlspecialchars( $t->getPrefixedText() ) . "-->\n";
                }
@@ -590,27 +593,38 @@ class SpecialSearch {
                                        Xml::closeElement( 'span' ) . "\n";
                }
 
-               $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1' ) );
+               $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
+               $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' );
                $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) );
                $searchButton = Xml::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'fulltext' ) ) . "\n";
 
                $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
-                       Xml::openElement( 'fieldset' ) .
-                       Xml::element( 'legend', array( ), wfMsg( 'powersearch-legend' ) ) .
-                       Xml::hidden( 'title', 'Special:Search' ) .
-                       wfMsgExt( 'powersearchtext', array( 'parse', 'replaceafter' ),
-                               $namespaces, $redirect, $searchField,
-                               '', '', '', '', '', # Dummy placeholders
+                       Xml::fieldset( wfMsg( 'powersearch-legend' ),
+                               Xml::hidden( 'title', 'Special:Search' ) .
+                               "<p>" .
+                               wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
+                               "<br />" .
+                               $namespaces .
+                               "</p>" .
+                               "<p>" .
+                               $redirect . " " . $redirectLabel .
+                               "</p>" .
+                               wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
+                               "&nbsp;" .
+                               $searchField .
+                               "&nbsp;" .
                                $searchButton ) .
-                       Xml::closeElement( 'fieldset' ) .
-                       Xml::closeElement( 'form' );
+                       "</form>";
 
                return $out;
        }
 
        function powerSearchFocus() {
-               return "<script type='text/javascript'>" .
-                       "document.getElementById('powerSearchText').focus();" .
+               global $wgJsMimeType;
+               return "<script type=\"$wgJsMimeType\">" .
+                       "hookEvent(\"load\", function(){" .
+                               "document.getElementById('powerSearchText').focus();" .
+                       "});" .
                        "</script>";
        }