Merge "Add 'mediawiki.ui.button' CSS module"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 8c8de8e..b6b219f 100644 (file)
@@ -37,7 +37,6 @@ class SpecialSearch extends SpecialPage {
         * null|string
         */
        protected $profile;
-       function getProfile() { return $this->profile; }
 
        /// Search engine
        protected $searchEngine;
@@ -60,7 +59,6 @@ class SpecialSearch extends SpecialPage {
         * @var array
         */
        protected $namespaces;
-       function getNamespaces() { return $this->namespaces; }
 
        /**
         * @var bool
@@ -88,7 +86,9 @@ class SpecialSearch extends SpecialPage {
                $this->outputHeader();
                $out = $this->getOutput();
                $out->allowClickjacking();
-               $out->addModuleStyles( 'mediawiki.special' );
+               $out->addModuleStyles( array(
+                       'mediawiki.special', 'mediawiki.special.search', 'mediawiki.ui'
+               ) );
 
                // Strip underscores from title parameter; most of the time we'll want
                // text form here. But don't strip underscores from actual text params!
@@ -105,8 +105,8 @@ class SpecialSearch extends SpecialPage {
 
                if ( $request->getVal( 'fulltext' )
                        || !is_null( $request->getVal( 'offset' ) )
-                       || !is_null( $request->getVal( 'searchx' ) ) )
-               {
+                       || !is_null( $request->getVal( 'searchx' ) )
+               {
                        $this->showResults( $search );
                } else {
                        $this->goResult( $search );
@@ -374,7 +374,7 @@ class SpecialSearch extends SpecialPage {
                // prev/next links
                if ( $num || $this->offset ) {
                        // Show the create link ahead
-                       $this->showCreateLink( $t );
+                       $this->showCreateLink( $t, $num );
                        $prevnext = $this->getLanguage()->viewPrevNext( $this->getTitle(), $this->offset, $this->limit,
                                $this->powerSearchOptions() + array( 'search' => $term ),
                                max( $titleMatchesNum, $textMatchesNum ) < $this->limit
@@ -420,7 +420,7 @@ class SpecialSearch extends SpecialPage {
                        } else {
                                $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>",
                                        array( 'search-nonefound', wfEscapeWikiText( $term ) ) );
-                               $this->showCreateLink( $t );
+                               $this->showCreateLink( $t, $num );
                        }
                }
                $out->addHtml( "</div>" );
@@ -434,8 +434,9 @@ class SpecialSearch extends SpecialPage {
 
        /**
         * @param $t Title
+        * @param int $num The number of search results found
         */
-       protected function showCreateLink( $t ) {
+       protected function showCreateLink( $t, $num ) {
                // show direct page/create link if applicable
 
                // Check DBkey !== '' in case of fragment link only.
@@ -453,7 +454,7 @@ class SpecialSearch extends SpecialPage {
                } else {
                        $messageName = 'searchmenu-new-nocreate';
                }
-               $params = array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) );
+               $params = array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ), Message::numParam( $num ) );
                wfRunHooks( 'SpecialSearchCreateLink', array( $t, &$params ) );
 
                // Extensions using the hook might still return an empty $messageName
@@ -474,9 +475,10 @@ class SpecialSearch extends SpecialPage {
                $out = $this->getOutput();
                if ( strval( $term ) !== '' ) {
                        $out->setPageTitle( $this->msg( 'searchresults' ) );
-                       $out->setHTMLTitle( $this->msg( 'pagetitle' )->rawParams(
-                               $this->msg( 'searchresults-title' )->rawParams( $term )->text()
-                       ) );
+                       $out->setHTMLTitle( $this->msg( 'pagetitle' )
+                               ->rawParams( $this->msg( 'searchresults-title' )->rawParams( $term ) )
+                               ->inContentLanguage()->text()
+                       );
                }
                // add javascript specific to special:search
                $out->addModules( 'mediawiki.special.search' );
@@ -1093,10 +1095,14 @@ class SpecialSearch extends SpecialPage {
                $out .= Html::input( 'search', $term, 'search', array(
                        'id' => $this->profile === 'advanced' ? 'powerSearchText' : 'searchText',
                        'size' => '50',
-                       'autofocus'
+                       'autofocus',
+                       'class' => 'mw-ui-input',
                ) ) . "\n";
                $out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
-               $out .= Xml::submitButton( $this->msg( 'searchbutton' )->text() ) . "\n";
+               $out .= Xml::submitButton(
+                       $this->msg( 'searchbutton' )->text(),
+                       array( 'class' => array( 'mw-ui-button', 'mw-ui-primary' ) )
+               ) . "\n";
                return $out . $this->didYouMeanHtml;
        }
 
@@ -1181,6 +1187,22 @@ class SpecialSearch extends SpecialPage {
                return $this->searchEngine;
        }
 
+       /**
+        * Current search profile.
+        * @return null|string
+        */
+       function getProfile() {
+               return $this->profile;
+       }
+
+       /**
+        * Current namespaces.
+        * @return array
+        */
+       function getNamespaces() {
+               return $this->namespaces;
+       }
+
        /**
         * Users of hook SpecialSearchSetupEngine can use this to
         * add more params to links to not lose selection when