var $namespaces = array( NS_MAIN );
var $showRedirects = false;
+ /// Feature values
+ protected $features = array();
+
/**
* @var DatabaseBase
*/
return null;
}
- /** If this search backend can list/unlist redirects */
+ /**
+ * If this search backend can list/unlist redirects
+ * @deprecated Call supports( 'list-redirects' );
+ */
function acceptListRedirects() {
- return true;
+ return $this->supports( 'list-redirects' );
+ }
+
+ /**
+ * @since 1.18
+ * @param $feature String
+ * @return Boolean
+ */
+ public function supports( $feature ) {
+ switch( $feature ) {
+ case 'list-redirects':
+ return true;
+ case 'title-suffix-filter':
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Way to pass custom data for engines
+ * @since 1.18
+ * @param $feature String
+ * @param $data Mixed
+ * @return Noolean
+ */
+ public function setFeatureData( $feature, $data ) {
+ $this->features[$feature] = $data;
}
/**
return $titleResult;
}
+ $context = new RequestContext;
+
foreach ( $allSearchTerms as $term ) {
# Exact match? No need to look further.
$title = Title::newFromText( $term );
- if ( is_null( $title ) )
+ if ( is_null( $title ) ){
return null;
+ }
if ( $title->getNamespace() == NS_SPECIAL || $title->isExternal() || $title->exists() ) {
return $title;
}
# See if it still otherwise has content is some sane sense
- $article = MediaWiki::articleFromTitle( $title );
+ $context->setTitle( $title );
+ $article = MediaWiki::articleFromTitle( $title, $context );
if ( $article->hasViewableContent() ) {
return $title;
}
* @return String
*/
public static function getOpenSearchTemplate() {
- global $wgOpenSearchTemplate, $wgServer, $wgScriptPath;
+ global $wgOpenSearchTemplate, $wgServer;
if ( $wgOpenSearchTemplate ) {
return $wgOpenSearchTemplate;
} else {
$ns = implode( '|', SearchEngine::defaultNamespaces() );
if ( !$ns ) $ns = "0";
- return $wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}&namespace=' . $ns;
+ return $wgServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns;
}
}
* @return String
*/
public static function getMWSuggestTemplate() {
- global $wgMWSuggestTemplate, $wgServer, $wgScriptPath;
+ global $wgMWSuggestTemplate, $wgServer;
if ( $wgMWSuggestTemplate )
return $wgMWSuggestTemplate;
else
- return $wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}&namespace={namespaces}&suggest';
+ return $wgServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace={namespaces}&suggest';
}
}
* @ingroup Search
*/
class SearchResult {
+
+ /**
+ * @var Revision
+ */
var $mRevision = null;
var $mImage = null;
+ /**
+ * @var Title
+ */
+ var $mTitle;
+
+ /**
+ * @var String
+ */
+ var $mText;
+
/**
* Return a new SearchResult and initializes it with a title.
*