$profile = new ProfileSection( __METHOD__ );
$search = $this->getSearchEngine();
- $search->setLimitOffset( $this->limit, $this->offset );
+ // Request an extra result to determine whether a "next page" link is useful
+ $search->setLimitOffset( $this->limit + 1, $this->offset );
$search->setNamespaces( $this->namespaces );
$this->saveNamespaces();
$search->prefix = $this->mPrefix;
$this->offset,
$this->limit,
$this->powerSearchOptions() + array( 'search' => $term ),
- max( $titleMatchesNum, $textMatchesNum ) < $this->limit
+ max( $titleMatchesNum, $textMatchesNum ) <= $this->limit
);
}
wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
if ( $num === 0 ) {
if ( $textStatus ) {
$out->addHTML( '<div class="error">' .
- htmlspecialchars( $textStatus->getWikiText( 'search-error' ) ) . '</div>' );
+ $textStatus->getMessage( 'search-error' ) . '</div>' );
} else {
$out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>",
array( 'search-nonefound', wfEscapeWikiText( $term ) ) );
if ( $title->isKnown() ) {
$messageName = 'searchmenu-exists';
- } elseif ( $title->userCan( 'create', $this->getUser() ) ) {
+ } elseif ( $title->quickUserCan( 'create', $this->getUser() ) ) {
$messageName = 'searchmenu-new';
} else {
$messageName = 'searchmenu-new-nocreate';
// Reset namespace preferences: namespaces are not searched
// when they're not mentioned in the URL parameters.
foreach ( MWNamespace::getValidNamespaces() as $n ) {
- if ( $n >= 0 ) {
- $user->setOption( 'searchNs' . $n, false );
- }
+ $user->setOption( 'searchNs' . $n, false );
}
// The request parameters include all the namespaces we just searched.
// Even if they're the same as an existing profile, they're not eaten.
$out = "<ul class='mw-search-results'>\n";
$result = $matches->next();
- while ( $result ) {
+ $count = 0;
+ while ( $result && $count < $this->limit ) {
$out .= $this->showHit( $result, $terms );
$result = $matches->next();
+ $count++;
}
$out .= "</ul>\n";