/**
  * If an exact title match can be found, jump straight ahead to it.
  * @param string $term
  * @public
  */
 function goResult($term)
 {
     global $wgOut;
     global $wgGoToEdit;
     $this->setupPage($term);
     # Try to go to page as entered.
     $t = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($t)) {
         return $this->showResults($term);
     }
     # If there's an exact or very near match, jump right there.
     $t = SearchEngine::getNearMatch($term);
     if (!is_null($t)) {
         $wgOut->redirect($t->getFullURL());
         return;
     }
     # No match, generate an edit URL
     $t = Title::newFromText($term);
     if (!is_null($t)) {
         wfRunHooks('SpecialSearchNogomatch', array(&$t));
         # If the feature is enabled, go straight to the edit page
         if ($wgGoToEdit) {
             $wgOut->redirect($t->getFullURL('action=edit'));
             return;
         }
     }
     if ($t->quickUserCan('create') && $t->quickUserCan('edit')) {
         $wgOut->addWikiMsg('noexactmatch', wfEscapeWikiText($term));
     } else {
         $wgOut->addWikiMsg('noexactmatch-nocreate', wfEscapeWikiText($term));
     }
     return $this->showResults($term);
 }
	/**
	 * Do not go to a near match if query prefixed with ~
	 *
	 * @param $searchterm String
	 * @return Title
	 */
	public static function getNearMatch( $searchterm ) {
		if ( $searchterm[ 0 ] === '~' ) {
			return null;
		} else {
			return parent::getNearMatch( $searchterm );
		}
	}
Exemplo n.º 3
0
 public function goResult($term)
 {
     global $wgOut;
     # Try to go to page as entered.
     $t = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($t)) {
         return $this->showResults($term);
     }
     # If there's an exact or very near match, jump right there.
     $t = SearchEngine::getNearMatch($term);
     if (!is_null($t)) {
         $wgOut->redirect($t->getFullURL());
         return;
     }
     # No match, generate an edit URL
     $t = Title::newFromText($term);
     if (!is_null($t)) {
         global $wgGoToEdit;
         wfRunHooks('SpecialSearchNogomatch', array(&$t));
         # If the feature is enabled, go straight to the edit page
         if ($wgGoToEdit) {
             $wgOut->redirect($t->getFullURL(array('action' => 'edit')));
             return;
         }
     }
 }
Exemplo n.º 4
0
function efGoToCategory_SpecialSearchNogomatch($t)
{
    global $wgOut, $wgRequest;
    $term = $wgRequest->getText('search');
    if (!empty($term) && strpos('category:', strtolower($term)) !== 0) {
        $term = "Category:{$term}";
    }
    $title = SearchEngine::getNearMatch($term);
    if (!is_null($title)) {
        $wgOut->redirect($title->getFullURL());
    }
    return true;
}
Exemplo n.º 5
0
 /**
  * If an exact title match can be found, jump straight ahead to it.
  *
  * @param string $term
  */
 public function goResult($term)
 {
     $this->setupPage($term);
     # Try to go to page as entered.
     $title = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($title)) {
         $this->showResults($term);
         return;
     }
     # 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());
         return;
     }
     # No match, generate an edit URL
     $title = Title::newFromText($term);
     if (!is_null($title)) {
         wfRunHooks('SpecialSearchNogomatch', array(&$title));
     }
     $this->showResults($term);
 }
Exemplo n.º 6
0
 /**
  * Really find the title match.
  * @return null|\Title
  */
 private static function getNearMatchInternal($searchterm)
 {
     global $wgContLang, $wgEnableSearchContributorsByIP;
     $allSearchTerms = array($searchterm);
     if ($wgContLang->hasVariants()) {
         $allSearchTerms = array_merge($allSearchTerms, $wgContLang->autoConvertToAllVariants($searchterm));
     }
     $titleResult = null;
     if (!wfRunHooks('SearchGetNearMatchBefore', array($allSearchTerms, &$titleResult))) {
         return $titleResult;
     }
     foreach ($allSearchTerms as $term) {
         # Exact match? No need to look further.
         $title = Title::newFromText($term);
         if (is_null($title)) {
             return null;
         }
         if ($title->isSpecialPage() || $title->isExternal() || $title->exists()) {
             return $title;
         }
         # See if it still otherwise has content is some sane sense
         $page = WikiPage::factory($title);
         if ($page->hasViewableContent()) {
             return $title;
         }
         # Now try all lower case (i.e. first letter capitalized)
         #
         $title = Title::newFromText($wgContLang->lc($term));
         if ($title && $title->exists()) {
             return $title;
         }
         # Now try capitalized string
         #
         $title = Title::newFromText($wgContLang->ucwords($term));
         if ($title && $title->exists()) {
             return $title;
         }
         # Now try all upper case
         #
         $title = Title::newFromText($wgContLang->uc($term));
         if ($title && $title->exists()) {
             return $title;
         }
         # Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc
         $title = Title::newFromText($wgContLang->ucwordbreaks($term));
         if ($title && $title->exists()) {
             return $title;
         }
         // Give hooks a chance at better match variants
         $title = null;
         if (!wfRunHooks('SearchGetNearMatch', array($term, &$title))) {
             return $title;
         }
     }
     $title = Title::newFromText($searchterm);
     # Entering an IP address goes to the contributions page
     if ($wgEnableSearchContributorsByIP) {
         if ($title->getNamespace() == NS_USER && User::isIP($title->getText()) || User::isIP(trim($searchterm))) {
             return SpecialPage::getTitleFor('Contributions', $title->getDBkey());
         }
     }
     # Entering a user goes to the user page whether it's there or not
     if ($title->getNamespace() == NS_USER) {
         return $title;
     }
     # Go to images that exist even if there's no local page.
     # There may have been a funny upload, or it may be on a shared
     # file repository such as Wikimedia Commons.
     if ($title->getNamespace() == NS_FILE) {
         $image = wfFindFile($title);
         if ($image) {
             return $title;
         }
     }
     # MediaWiki namespace? Page may be "implied" if not customized.
     # Just return it, with caps forced as the message system likes it.
     if ($title->getNamespace() == NS_MEDIAWIKI) {
         return Title::makeTitle(NS_MEDIAWIKI, $wgContLang->ucfirst($title->getText()));
     }
     # Quoted term? Try without the quotes...
     $matches = array();
     if (preg_match('/^"([^"]+)"$/', $searchterm, $matches)) {
         return SearchEngine::getNearMatch($matches[1]);
     }
     return null;
 }
Exemplo n.º 7
0
 /**
  * If an exact title match can be found, jump straight ahead to it.
  *
  * @param $term String
  */
 public function goResult($term)
 {
     $this->setupPage($term);
     # Try to go to page as entered.
     $t = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($t)) {
         return $this->showResults($term);
     }
     $searchWithNamespace = $t->getNamespace() != 0 ? true : false;
     # If there's an exact or very near match, jump right there.
     $t = SearchEngine::getNearMatch($term);
     if (!wfRunHooks('SpecialSearchGo', array(&$t, &$term))) {
         # Hook requested termination
         return;
     }
     if (!is_null($t) && ($searchWithNamespace || $t->getNamespace() == NS_MAIN || $t->getNamespace() == NS_CATEGORY)) {
         // Wikia change (ADi): hook call added
         wfRunHooks('SpecialSearchIsgomatch', array(&$t, $term));
         $this->getOutput()->redirect($t->getFullURL());
         return;
     }
     # No match, generate an edit URL
     $t = Title::newFromText($term);
     if (!is_null($t)) {
         global $wgGoToEdit;
         wfRunHooks('SpecialSearchNogomatch', array(&$t));
         wfDebugLog('nogomatch', $t->getText(), false);
         # If the feature is enabled, go straight to the edit page
         if ($wgGoToEdit) {
             $this->getOutput()->redirect($t->getFullURL(array('action' => 'edit')));
             return;
         }
     }
     return $this->showResults($term);
 }
Exemplo n.º 8
0
 /**
  * If an exact title match can be found, jump straight ahead to it.
  *
  * @param $term String
  */
 public function goResult($term)
 {
     $this->setupPage($term);
     # Try to go to page as entered.
     $title = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($title)) {
         $this->showResults($term);
         return;
     }
     # If there's an exact or very near match, jump right there.
     $title = SearchEngine::getNearMatch($term);
     if (!wfRunHooks('SpecialSearchGo', array(&$title, &$term))) {
         # Hook requested termination
         return;
     }
     if (!is_null($title)) {
         $this->getOutput()->redirect($title->getFullURL());
         return;
     }
     # No match, generate an edit URL
     $title = Title::newFromText($term);
     if (!is_null($title)) {
         global $wgGoToEdit;
         wfRunHooks('SpecialSearchNogomatch', array(&$title));
         wfDebugLog('nogomatch', $title->getFullText(), 'private');
         # If the feature is enabled, go straight to the edit page
         if ($wgGoToEdit) {
             $this->getOutput()->redirect($title->getFullURL(array('action' => 'edit')));
             return;
         }
     }
     $this->showResults($term);
 }
 /**
  * If an exact title match can be find, or a very slightly close match,
  * return the title. If no match, returns NULL.
  *
  * @param string $term
  * @return Title
  */
 public static function getNearMatch($searchterm)
 {
     global $wgContLang;
     $allSearchTerms = array($searchterm);
     if ($wgContLang->hasVariants()) {
         $allSearchTerms = array_merge($allSearchTerms, $wgContLang->convertLinkToAllVariants($searchterm));
     }
     foreach ($allSearchTerms as $term) {
         # Exact match? No need to look further.
         $title = Title::newFromText($term);
         if (is_null($title)) {
             return NULL;
         }
         if ($title->getNamespace() == NS_SPECIAL || $title->exists()) {
             return $title;
         }
         # Now try all lower case (i.e. first letter capitalized)
         #
         $title = Title::newFromText($wgContLang->lc($term));
         if ($title->exists()) {
             return $title;
         }
         # Now try capitalized string
         #
         $title = Title::newFromText($wgContLang->ucwords($term));
         if ($title->exists()) {
             return $title;
         }
         # Now try all upper case
         #
         $title = Title::newFromText($wgContLang->uc($term));
         if ($title->exists()) {
             return $title;
         }
         # Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc
         $title = Title::newFromText($wgContLang->ucwordbreaks($term));
         if ($title->exists()) {
             return $title;
         }
         global $wgCapitalLinks, $wgContLang;
         if (!$wgCapitalLinks) {
             // Catch differs-by-first-letter-case-only
             $title = Title::newFromText($wgContLang->ucfirst($term));
             if ($title->exists()) {
                 return $title;
             }
             $title = Title::newFromText($wgContLang->lcfirst($term));
             if ($title->exists()) {
                 return $title;
             }
         }
         // Give hooks a chance at better match variants
         $title = null;
         if (!wfRunHooks('SearchGetNearMatch', array($term, &$title))) {
             return $title;
         }
     }
     $title = Title::newFromText($searchterm);
     # Entering an IP address goes to the contributions page
     if ($title->getNamespace() == NS_USER && User::isIP($title->getText()) || User::isIP(trim($searchterm))) {
         return SpecialPage::getTitleFor('Contributions', $title->getDBkey());
     }
     # Entering a user goes to the user page whether it's there or not
     if ($title->getNamespace() == NS_USER) {
         return $title;
     }
     # Go to images that exist even if there's no local page.
     # There may have been a funny upload, or it may be on a shared
     # file repository such as Wikimedia Commons.
     if ($title->getNamespace() == NS_IMAGE) {
         $image = wfFindFile($title);
         if ($image) {
             return $title;
         }
     }
     # MediaWiki namespace? Page may be "implied" if not customized.
     # Just return it, with caps forced as the message system likes it.
     if ($title->getNamespace() == NS_MEDIAWIKI) {
         return Title::makeTitle(NS_MEDIAWIKI, $wgContLang->ucfirst($title->getText()));
     }
     # Quoted term? Try without the quotes...
     $matches = array();
     if (preg_match('/^"([^"]+)"$/', $searchterm, $matches)) {
         return SearchEngine::getNearMatch($matches[1]);
     }
     return NULL;
 }
 /**
  * If an exact title match can be find, or a very slightly close match,
  * return the title. If no match, returns NULL.
  *
  * @static
  * @param string $term
  * @return Title
  * @access private
  */
 function getNearMatch($term)
 {
     # Exact match? No need to look further.
     $title = Title::newFromText($term);
     if (is_null($title)) {
         return NULL;
     }
     if ($title->getNamespace() == NS_SPECIAL || $title->exists()) {
         return $title;
     }
     # Now try all lower case (i.e. first letter capitalized)
     #
     $title = Title::newFromText(strtolower($term));
     if ($title->exists()) {
         return $title;
     }
     # Now try capitalized string
     #
     $title = Title::newFromText(ucwords(strtolower($term)));
     if ($title->exists()) {
         return $title;
     }
     # Now try all upper case
     #
     $title = Title::newFromText(strtoupper($term));
     if ($title->exists()) {
         return $title;
     }
     global $wgCapitalLinks, $wgContLang;
     if (!$wgCapitalLinks) {
         // Catch differs-by-first-letter-case-only
         $title = Title::newFromText($wgContLang->ucfirst($term));
         if ($title->exists()) {
             return $title;
         }
         $title = Title::newFromText($wgContLang->lcfirst($term));
         if ($title->exists()) {
             return $title;
         }
     }
     $title = Title::newFromText($term);
     # Entering an IP address goes to the contributions page
     if ($title->getNamespace() == NS_USER && User::isIP($title->getText()) || User::isIP(trim($term))) {
         return Title::makeTitle(NS_SPECIAL, "Contributions/" . $title->getDbkey());
     }
     # Entering a user goes to the user page whether it's there or not
     if ($title->getNamespace() == NS_USER) {
         return $title;
     }
     # Quoted term? Try without the quotes...
     if (preg_match('/^"([^"]+)"$/', $term, $matches)) {
         return SearchEngine::getNearMatch($matches[1]);
     }
     return NULL;
 }
Exemplo n.º 11
0
 /**
  * If an exact title match can be found, jump straight ahead to
  * @param string $term
  * @access public
  */
 function goResult($term)
 {
     global $wgOut;
     global $wgGoToEdit;
     $this->setupPage($term);
     # Try to go to page as entered.
     #
     $t = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($t)) {
         return $this->showResults($term);
     }
     # If there's an exact or very near match, jump right there.
     $t = SearchEngine::getNearMatch($term);
     if (!is_null($t)) {
         $wgOut->redirect($t->getFullURL());
         return;
     }
     # No match, generate an edit URL
     $t = Title::newFromText($term);
     if (is_null($t)) {
         $editurl = '';
         # hrm...
     } else {
         # If the feature is enabled, go straight to the edit page
         if ($wgGoToEdit) {
             $wgOut->redirect($t->getFullURL('action=edit'));
             return;
         } else {
             $editurl = $t->escapeLocalURL('action=edit');
         }
     }
     $wgOut->addWikiText(wfMsg('nogomatch', ":{$term}"));
     return $this->showResults($term);
 }
Exemplo n.º 12
0
 /**
  * Provided a string, uses MediaWiki's ability to find article matches to instantiate a Wikia Search Article Match.
  * @param string $term
  * @param array $namespaces
  * @return \Wikia\Search\Match\Article|NULL
  */
 public function getArticleMatchForTermAndNamespaces($term, array $namespaces)
 {
     $articleMatch = null;
     $searchEngine = new \SearchEngine();
     $title = $searchEngine->getNearMatch($term);
     $articleId = $title !== null ? $title->getArticleId() : 0;
     if ($articleId > 0 && in_array($title->getNamespace(), $namespaces)) {
         $this->getPageFromPageId($articleId);
         $articleMatch = new \Wikia\Search\Match\Article($title->getArticleId(), $this, $term);
     }
     return $articleMatch;
 }
Exemplo n.º 13
0
 /**
  * If an exact title match can be find, or a very slightly close match,
  * return the title. If no match, returns NULL.
  *
  * @static
  * @param string $term
  * @return Title
  * @private
  */
 function getNearMatch($searchterm)
 {
     global $wgContLang;
     $allSearchTerms = array($searchterm);
     if ($wgContLang->hasVariants()) {
         $allSearchTerms = array_merge($allSearchTerms, $wgContLang->convertLinkToAllVariants($searchterm));
     }
     foreach ($allSearchTerms as $term) {
         # Exact match? No need to look further.
         $title = Title::newFromText($term);
         if (is_null($title)) {
             return NULL;
         }
         if ($title->getNamespace() == NS_SPECIAL || $title->exists()) {
             return $title;
         }
         # Now try all lower case (i.e. first letter capitalized)
         #
         $title = Title::newFromText($wgContLang->lc($term));
         if ($title->exists()) {
             return $title;
         }
         # Now try capitalized string
         #
         $title = Title::newFromText($wgContLang->ucwords($term));
         if ($title->exists()) {
             return $title;
         }
         # Now try all upper case
         #
         $title = Title::newFromText($wgContLang->uc($term));
         if ($title->exists()) {
             return $title;
         }
         # Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc
         $title = Title::newFromText($wgContLang->ucwordbreaks($term));
         if ($title->exists()) {
             return $title;
         }
         global $wgCapitalLinks, $wgContLang;
         if (!$wgCapitalLinks) {
             // Catch differs-by-first-letter-case-only
             $title = Title::newFromText($wgContLang->ucfirst($term));
             if ($title->exists()) {
                 return $title;
             }
             $title = Title::newFromText($wgContLang->lcfirst($term));
             if ($title->exists()) {
                 return $title;
             }
         }
     }
     $title = Title::newFromText($searchterm);
     # Entering an IP address goes to the contributions page
     if ($title->getNamespace() == NS_USER && User::isIP($title->getText()) || User::isIP(trim($searchterm))) {
         return SpecialPage::getTitleFor('Contributions', $title->getDbkey());
     }
     # Entering a user goes to the user page whether it's there or not
     if ($title->getNamespace() == NS_USER) {
         return $title;
     }
     # Quoted term? Try without the quotes...
     $matches = array();
     if (preg_match('/^"([^"]+)"$/', $searchterm, $matches)) {
         return SearchEngine::getNearMatch($matches[1]);
     }
     return NULL;
 }
Exemplo n.º 14
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgTitle, $wgContLang, $wgUser, $wgScriptPath, $wgLuceneDisableTitleMatches, $wgLuceneDisableSuggestions, $wgUser;
     global $wgGoToEdit;
     wfLoadExtensionMessages('LuceneSearch');
     $fname = 'LuceneSearch::execute';
     wfProfileIn($fname);
     $this->setHeaders();
     $wgOut->addHTML('<!-- titlens = ' . $wgTitle->getNamespace() . '-->');
     foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
         if ($wgRequest->getCheck('ns' . $ns)) {
             $this->namespaces[] = $ns;
         }
     }
     if (count($this->namespaces) == 0) {
         foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
             if ($wgUser->getOption('searchNs' . $ns)) {
                 $this->namespaces[] = $ns;
             }
         }
         if (count($this->namespaces) == 0) {
             global $wgNamespacesToBeSearchedDefault;
             foreach ($wgNamespacesToBeSearchedDefault as $ns => $searchit) {
                 if ($searchit) {
                     $this->namespaces[] = $ns;
                 }
             }
         }
     }
     $bits = split('/', $wgRequest->getVal('title'), 2);
     if (!empty($bits[1])) {
         $q = str_replace('_', ' ', $bits[1]);
     } else {
         $q = $wgRequest->getText('search');
     }
     list($limit, $offset) = $wgRequest->getLimitOffset(LS_PER_PAGE, 'searchlimit');
     if ($wgRequest->getVal('gen') == 'titlematch') {
         $this->sendTitlePrefixes($q, $limit);
         wfProfileOut($fname);
         return;
     }
     $this->mSkin =& $wgUser->getSkin();
     if (!$wgLuceneDisableSuggestions) {
         $wgOut->addHTML($this->makeSuggestJS());
     }
     $wgOut->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen,projection', 'href' => $wgScriptPath . '/extensions/LuceneSearch/lucenesearch.css'));
     $wgOut->addWikiText(wfMsg('searchresulttext'));
     $wgOut->addHTML($this->showShortDialog($q));
     if ($q === false || strlen($q) == 0) {
         // No search active. Put input focus in the search box.
         $wgOut->addHTML($this->makeFocusJS());
     } else {
         if (!$wgRequest->getText('fulltext')) {
             $t = SearchEngine::getNearMatch($q);
             if (!is_null($t)) {
                 $wgOut->redirect($t->getFullURL());
                 wfProfileOut($fname);
                 return;
             }
         }
         # No match, generate an edit URL
         $t = Title::newFromText($q);
         if (!$wgRequest->getText('go') || is_null($t)) {
             $editurl = '';
             # hrm...
         } else {
             wfRunHooks('SpecialSearchNogomatch', array(&$t));
             # If the feature is enabled, go straight to the edit page
             if ($wgGoToEdit) {
                 $wgOut->redirect($t->getFullURL('action=edit'));
                 return;
             }
             if ($t->quickUserCan('create') && $t->quickUserCan('edit')) {
                 $wgOut->addWikiText(wfMsg('noexactmatch', $t->getPrefixedText()));
             } else {
                 $wgOut->addWikiText(wfMsg('noexactmatch-nocreate', $t->getPrefixedText()));
             }
         }
         $case = 'ignore';
         # Replace localized namespace prefixes (from lucene-search 2.0)
         global $wgLuceneSearchVersion;
         if ($wgLuceneSearchVersion >= 2) {
             $searchq = $this->replacePrefixes($q);
             if ($wgRequest->getText('fulltext') == wfMsg('searchexactcase')) {
                 $case = 'exact';
             }
         } else {
             $searchq = $q;
         }
         global $wgDisableTextSearch;
         if (!$wgDisableTextSearch) {
             $results = LuceneSearchSet::newFromQuery('search', $searchq, $this->namespaces, $limit, $offset, $case);
         }
         if ($wgDisableTextSearch || $results === false) {
             if ($wgDisableTextSearch) {
                 $wgOut->addHTML(wfMsg('searchdisabled'));
             } else {
                 $wgOut->addWikiText(wfMsg('lucenefallback'));
             }
             $wgOut->addHTML(wfMsg('googlesearch', htmlspecialchars($q), 'utf-8', htmlspecialchars(wfMsg('search'))));
             wfProfileOut($fname);
             return;
         }
         $subtitleMsg = is_object(Title::newFromText($q)) ? 'searchsubtitle' : 'searchsubtitleinvalid';
         $wgOut->setSubtitle($wgOut->parse(wfMsg($subtitleMsg, wfEscapeWikiText($q))));
         // If the search returned no results, an alternate fuzzy search
         // match may be displayed as a suggested search. Link it.
         if ($results->hasSuggestion()) {
             $suggestion = $results->getSuggestion();
             $o = ' ' . wfMsg('searchdidyoumean', $this->makeLink($suggestion, $offset, $limit, $case), htmlspecialchars($suggestion));
             $wgOut->addHTML('<div style="text-align: center;">' . $o . '</div>');
         }
         $nmtext = '';
         if ($offset == 0 && !$wgLuceneDisableTitleMatches) {
             $titles = LuceneSearchSet::newFromQuery('titlematch', $q, $this->namespaces, 5, $case);
             if ($titles && $titles->hasResults()) {
                 $nmtext = '<p>' . wfMsg('searchnearmatches') . '</p>';
                 $nmtext .= '<ul>';
                 $nmtext .= implode("\n", $titles->iterateResults(array(&$this, 'formatNearMatch')));
                 $nmtext .= '</ul>';
                 $nmtext .= '<hr />';
             }
         }
         $wgOut->addHTML($nmtext);
         if (!$results->hasResults()) {
             # Pass search terms back in a few different formats
             # $1: Plain search terms
             # $2: Search terms with s/ /_/
             # $3: URL-encoded search terms
             $tmsg = array(htmlspecialchars($q), htmlspecialchars(str_replace(' ', '_', $q)), wfUrlEncode($q));
             $wgOut->addHtml(wfMsgWikiHtml('searchnoresults', $tmsg[0], $tmsg[1], $tmsg[2]));
         } else {
             #$showresults = min($limit, count($results)-$numresults);
             $i = $offset;
             $resq = trim(preg_replace("/[ |\\[\\]()\"{}+]+/", " ", $q));
             $contextWords = implode("|", array_map(array(&$this, 'regexQuote'), $wgContLang->convertForSearchResult(split(" ", $resq))));
             $top = wfMsg('searchnumber', $offset + 1, min($results->getTotalHits(), $offset + $limit), $results->getTotalHits());
             $out = '<ul id="lucene-results">';
             $numchunks = ceil($results->getTotalHits() / $limit);
             $whichchunk = $offset / $limit;
             $prevnext = "";
             if ($whichchunk > 0) {
                 $prevnext .= '<a href="' . $this->makelink($q, $offset - $limit, $limit, $case) . '">' . wfMsg('searchprev') . '</a> ';
             }
             $first = max($whichchunk - 11, 0);
             $last = min($numchunks, $whichchunk + 11);
             //$wgOut->addWikiText("whichchunk=$whichchunk numchunks=$numchunks first=$first last=$last num=".count($chunks)." limit=$limit offset=$offset results=".count($results)."\n\n");
             if ($last - $first > 1) {
                 for ($i = $first; $i < $last; $i++) {
                     if ($i === $whichchunk) {
                         $prevnext .= '<strong>' . ($i + 1) . '</strong> ';
                     } else {
                         $prevnext .= '<a href="' . $this->makelink($q, $limit * $i, $limit, $case) . '">' . ($i + 1) . '</a> ';
                     }
                 }
             }
             if ($whichchunk < $last - 1) {
                 $prevnext .= '<a href="' . $this->makelink($q, $offset + $limit, $limit, $case) . '">' . wfMsg('searchnext') . '</a> ';
             }
             $prevnext = '<div style="text-align: center;">' . $prevnext . '</div>';
             $top .= $prevnext;
             $out .= implode("\n", $results->iterateResults(array(&$this, 'showHit'), $contextWords));
             $out .= '</ul>';
         }
         #$wgOut->addHTML('<hr />');
         if (isset($top)) {
             $wgOut->addHTML($top);
         }
         if (isset($out)) {
             $wgOut->addHTML($out);
         }
         #if( isset( $prevnext ) ) $wgOut->addHTML('<hr />' . $prevnext);
         if (isset($prevnext)) {
             $wgOut->addHTML($prevnext);
         }
         $wgOut->addHTML($this->showFullDialog($q));
     }
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     wfProfileOut($fname);
 }