/**
* Entry point
*
- * @param string $par
+ * @param string|null $par
*/
public function execute( $par ) {
$request = $this->getRequest();
// parameter, but also as part of the primary url. This can have PII implications
// in releasing page view data. As such issue a 301 redirect to the correct
// URL.
- if ( strlen( $par ) && !strlen( $term ) ) {
+ if ( $par !== null && $par !== '' && $term === '' ) {
$query = $request->getValues();
unset( $query['title'] );
// Strip underscores from title parameter; most of the time we'll want
$url = str_replace( '$1', urlencode( $term ), $searchForwardUrl );
$out->redirect( $url );
} else {
- $out->addHTML(
- "<fieldset>" .
- "<legend>" .
- $this->msg( 'search-external' )->escaped() .
- "</legend>" .
- "<p class='mw-searchdisabled'>" .
- $this->msg( 'searchdisabled' )->escaped() .
- "</p>" .
- $this->msg( 'googlesearch' )->rawParams(
- htmlspecialchars( $term ),
- 'UTF-8',
- $this->msg( 'searchbutton' )->escaped()
- )->text() .
- "</fieldset>"
- );
+ $this->showGoogleSearch( $term );
}
return;
$this->showResults( $term );
}
+ /**
+ * Output a google search form if search is disabled
+ *
+ * @param string $term Search term
+ * @todo FIXME Maybe we should get rid of this raw html message at some future time
+ * @suppress SecurityCheck-XSS
+ */
+ private function showGoogleSearch( $term ) {
+ $this->getOutput()->addHTML(
+ "<fieldset>" .
+ "<legend>" .
+ $this->msg( 'search-external' )->escaped() .
+ "</legend>" .
+ "<p class='mw-searchdisabled'>" .
+ $this->msg( 'searchdisabled' )->escaped() .
+ "</p>" .
+ $this->msg( 'googlesearch' )->rawParams(
+ htmlspecialchars( $term ),
+ 'UTF-8',
+ $this->msg( 'searchbutton' )->escaped()
+ )->text() .
+ "</fieldset>"
+ );
+ }
+
/**
* Set up basic search parameters from the request and user settings.
*
# Extract manually requested namespaces
$nslist = $this->powerSearch( $request );
- if ( !count( $nslist ) ) {
+ if ( $nslist === [] ) {
# Fallback to user preference
$nslist = $this->searchConfig->userNamespaces( $user );
}
$profile = null;
- if ( !count( $nslist ) ) {
+ if ( $nslist === [] ) {
$profile = 'default';
}
'a',
[
'href' => $this->getPageTitle()->getLocalURL( $params ),
- 'title' => $this->msg( 'search-filter-title-prefix-reset' ),
+ 'title' => $this->msg( 'search-filter-title-prefix-reset' )->text(),
],
- $this->msg( 'search-filter-title-prefix-reset' )
+ $this->msg( 'search-filter-title-prefix-reset' )->text()
);
$subtitle .= ')';
$out->setSubtitle( $subtitle );