Robmoen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180649
Change subject: hygiene: small special:search refactor
......................................................................
hygiene: small special:search refactor
* removed some unneeded members
** Grepped for usage through repo and extensions
* added isPowerSearch method
* pull search options out of search profile tabs
and into its own method
* consistent creation of did you mean html
Change-Id: I0da81609e3bc685c971b85a08e228cdda4455c18
---
M includes/specials/SpecialSearch.php
1 file changed, 29 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/49/180649/1
diff --git a/includes/specials/SpecialSearch.php
b/includes/specials/SpecialSearch.php
index a7dea88..cf6f4ea 100644
--- a/includes/specials/SpecialSearch.php
+++ b/includes/specials/SpecialSearch.php
@@ -63,7 +63,7 @@
/**
* @var string
*/
- protected $didYouMeanHtml, $fulltext;
+ protected $fulltext;
const NAMESPACES_CURRENT = 'sense';
@@ -165,7 +165,6 @@
}
}
- $this->didYouMeanHtml = ''; # html of did you mean... link
$this->fulltext = $request->getVal( 'fulltext' );
$this->profile = $profile;
}
@@ -289,8 +288,11 @@
$stParams
);
- $this->didYouMeanHtml = '<div class="searchdidyoumean">'
- . $this->msg( 'search-suggest' )->rawParams(
$suggestLink )->text() . '</div>';
+ # html of did you mean... search suggestion link
+ $didYouMeanHtml =
+ Xml::openElement( 'div', array( 'class' =>
'searchdidyoumean' ) ) .
+ $this->msg( 'search-suggest' )->rawParams(
$suggestLink )->text() .
+ Xml::closeElement( 'div' );
}
if ( !Hooks::run( 'SpecialSearchResultsPrepend', array( $this,
$out, $term ) ) ) {
@@ -303,7 +305,7 @@
Xml::openElement(
'form',
array(
- 'id' => ( $this->profile === 'advanced'
? 'powersearch' : 'search' ),
+ 'id' => ( $this->isPowerSearch() ?
'powersearch' : 'search' ),
'method' => 'get',
'action' => wfScript(),
)
@@ -331,8 +333,9 @@
$this->shortDialog( $term, $num, $totalRes ) .
Xml::closeElement( 'div' ) .
$this->searchProfileTabs( $term ) .
+ $this->searchOptions( $term ) .
Xml::closeElement( 'form' ) .
- $this->didYouMeanHtml
+ $didYouMeanHtml
);
$filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
@@ -459,8 +462,6 @@
* @param string $term
*/
protected function setupPage( $term ) {
- # Should advanced UI be used?
- $this->searchAdvanced = ( $this->profile === 'advanced' );
$out = $this->getOutput();
if ( strval( $term ) !== '' ) {
$out->setPageTitle( $this->msg( 'searchresults' ) );
@@ -471,6 +472,15 @@
}
// add javascript specific to special:search
$out->addModules( 'mediawiki.special.search' );
+ }
+
+ /**
+ * Return true if current search is a power (advanced) search
+ *
+ * @return bool
+ */
+ protected function isPowerSearch() {
+ return $this->profile === 'advanced';
}
/**
@@ -498,7 +508,7 @@
*/
protected function powerSearchOptions() {
$opt = array();
- if ( $this->profile !== 'advanced' ) {
+ if ( !$this->isPowerSearch() ) {
$opt['profile'] = $this->profile;
} else {
foreach ( $this->namespaces as $n ) {
@@ -1036,11 +1046,18 @@
$out .= Xml::element( 'div', array( 'style' => 'clear:both' ),
'', false );
$out .= Xml::closeElement( 'div' );
- // Hidden stuff
+ return $out;
+ }
+
+ /**
+ * @param string $term Search term
+ * @return string
+ */
+ protected function searchOptions( $term ) {
$opts = array();
$opts['profile'] = $this->profile;
- if ( $this->profile === 'advanced' ) {
+ if ( $this->isPowerSearch() ) {
$out .= $this->powerSearchBox( $term, $opts );
} else {
$form = '';
@@ -1062,7 +1079,7 @@
$out .= Html::hidden( 'profile', $this->profile ) . "\n";
// Term box
$out .= Html::input( 'search', $term, 'search', array(
- 'id' => $this->profile === 'advanced' ?
'powerSearchText' : 'searchText',
+ 'id' => $this->isPowerSearch() ? 'powerSearchText' :
'searchText',
'size' => '50',
'autofocus',
'class' => 'mw-ui-input mw-ui-input-inline',
--
To view, visit https://gerrit.wikimedia.org/r/180649
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0da81609e3bc685c971b85a08e228cdda4455c18
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits