Split Pager classes out of SpecialPage files
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 5b9778c..dfab8d4 100644 (file)
@@ -204,8 +204,13 @@ class SpecialSearch extends SpecialPage {
                # If there's an exact or very near match, jump right there.
                $title = SearchEngine::getNearMatch( $term );
 
-               if ( !is_null( $title ) ) {
-                       $this->getOutput()->redirect( $title->getFullURL() );
+               if ( !is_null( $title ) &&
+                       Hooks::run( 'SpecialSearchGoResult', [ $term, $title, &$url ] )
+               ) {
+                       if ( $url === null ) {
+                               $url = $title->getFullURL();
+                       }
+                       $this->getOutput()->redirect( $url );
 
                        return;
                }
@@ -294,7 +299,7 @@ class SpecialSearch extends SpecialPage {
                }
 
                // start rendering the page
-               $out->addHtml(
+               $out->addHTML(
                        Xml::openElement(
                                'form',
                                [
@@ -318,7 +323,7 @@ class SpecialSearch extends SpecialPage {
                $num = $titleMatchesNum + $textMatchesNum;
                $totalRes = $numTitleMatches + $numTextMatches;
 
-               $out->addHtml(
+               $out->addHTML(
                        # This is an awful awful ID name. It's not a table, but we
                        # named it poorly from when this was a table so now we're
                        # stuck with it
@@ -337,7 +342,7 @@ class SpecialSearch extends SpecialPage {
                        return;
                }
 
-               $out->addHtml( "<div class='searchresults'>" );
+               $out->addHTML( "<div class='searchresults'>" );
 
                // prev/next links
                $prevnext = null;
@@ -424,7 +429,7 @@ class SpecialSearch extends SpecialPage {
                        $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
                }
 
-               $out->addHtml( "</div>" );
+               $out->addHTML( "</div>" );
 
                Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
 
@@ -546,7 +551,7 @@ class SpecialSearch extends SpecialPage {
                ) {
                        // invalid title
                        // preserve the paragraph for margins etc...
-                       $this->getOutput()->addHtml( '<p></p>' );
+                       $this->getOutput()->addHTML( '<p></p>' );
 
                        return;
                }
@@ -575,7 +580,7 @@ class SpecialSearch extends SpecialPage {
                        $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
                } else {
                        // preserve the paragraph for margins etc...
-                       $this->getOutput()->addHtml( '<p></p>' );
+                       $this->getOutput()->addHTML( '<p></p>' );
                }
        }
 
@@ -1221,6 +1226,8 @@ class SpecialSearch extends SpecialPage {
                        'size' => '50',
                        'autofocus' => trim( $term ) === '',
                        'class' => 'mw-ui-input mw-ui-input-inline',
+                       // identifies the location of the search bar for tracking purposes
+                       'data-search-loc' => 'content',
                ] ) . "\n";
                $out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
                $out .= Html::submitButton(