/**
* Really find the title match.
- * @return null|\Title
+ * @return null|Title
*/
private static function getNearMatchInternal( $searchterm ) {
global $wgContLang, $wgEnableSearchContributorsByIP;
return null;
}
+ # Try files if searching in the Media: namespace
+ if ( $title->getNamespace() == NS_MEDIA ) {
+ $title = Title::makeTitle( NS_FILE, $title->getText() );
+ }
+
if ( $title->isSpecialPage() || $title->isExternal() || $title->exists() ) {
return $title;
}
return $wgCanonicalServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns;
}
}
-
- /**
- * Get internal MediaWiki Suggest template
- *
- * @return String
- */
- public static function getMWSuggestTemplate() {
- global $wgMWSuggestTemplate, $wgServer;
- if ( $wgMWSuggestTemplate )
- return $wgMWSuggestTemplate;
- else
- return $wgServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace={namespaces}&suggest';
- }
}
/**
protected function initText() {
if ( !isset( $this->mText ) ) {
if ( $this->mRevision != null ) {
- //TODO: don't use the text, but the content object!
+ //TODO: if we could plug in some code that knows about special content models *and* about
+ // special features of the search engine, the search could benefit.
$content = $this->mRevision->getContent();
- $this->mText = $content->getTextForSearchIndex();
+ $this->mText = $content ? $content->getTextForSearchIndex() : '';
} else { // TODO: can we fetch raw wikitext for commons images?
$this->mText = '';
}