<?php
/**
* Contain a class for special pages
- * @package MediaWiki
- * @subpackage Search
- */
-
-/**
- * @package MediaWiki
+ * @addtogroup Search
*/
class SearchEngine {
var $limit = 10;
* 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 ) {
+ public static function getNearMatch( $searchterm ) {
global $wgContLang;
$allSearchTerms = array($searchterm);
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;
}
/**
* Make a list of searchable namespaces and their canonical names.
* @return array
- * @access public
*/
- function searchableNamespaces() {
+ public static function searchableNamespaces() {
global $wgContLang;
$arr = array();
foreach( $wgContLang->getNamespaces() as $ns => $name ) {
$class = 'SearchMySQL4';
} else if ( $wgDBtype == 'postgres' ) {
$class = 'SearchPostgres';
+ } else if ( $wgDBtype == 'oracle' ) {
+ $class = 'SearchOracle';
} else {
$class = 'SearchEngineDummy';
}
* @param string $title
* @abstract
*/
- function updateTitle( $id, $title ) {
+ function updateTitle( $id, $title ) {
// no-op
- }
+ }
}
-/** @package MediaWiki */
+
+/**
+ * @addtogroup Search
+ */
class SearchResultSet {
/**
* Fetch an array of regular expression fragments for matching
function next() {
return false;
}
+
+ /**
+ * Frees the result set, if applicable.
+ * @ access public
+ */
+ function free() {
+ // ...
+ }
}
-/** @package MediaWiki */
+
+/**
+ * @addtogroup Search
+ */
class SearchResult {
function SearchResult( $row ) {
$this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
}
/**
- * @package MediaWiki
+ * @addtogroup Search
*/
class SearchEngineDummy {
function search( $term ) {
function searchtitle() {}
function searchtext() {}
}
-?>
+