X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSearchEngine.php;h=11fc3deb2e001d5cc3b54b37b71328cc15a7ba5d;hb=af7be3b1b7b2f9e1aa32007857a21df3c6a0cfc0;hp=5e598883fe224cb10e91d2b65b9b8ec961e8ea0b;hpb=85b6e95beae0e37f65e39015d94df832ce1bde80;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 5e598883fe..11fc3deb2e 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -1,12 +1,7 @@ getNamespace() == NS_USER && User::isIP($title->getText() ) ) || User::isIP( trim( $searchterm ) ) ) { - return Title::makeTitle( NS_SPECIAL, "Contributions/" . $title->getDbkey() ); + return SpecialPage::getTitleFor( 'Contributions', $title->getDbkey() ); } @@ -124,16 +117,33 @@ class SearchEngine { 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; } - function legalSearchChars() { + public static function legalSearchChars() { return "A-Za-z_'0-9\\x80-\\xFF\\-"; } @@ -164,9 +174,8 @@ class SearchEngine { /** * 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 ) { @@ -192,9 +201,8 @@ class SearchEngine { * active database backend, and return a configured instance. * * @return SearchEngine - * @private */ - function create() { + public static function create() { global $wgDBtype, $wgSearchType; if( $wgSearchType ) { $class = $wgSearchType; @@ -202,6 +210,8 @@ class SearchEngine { $class = 'SearchMySQL4'; } else if ( $wgDBtype == 'postgres' ) { $class = 'SearchPostgres'; + } else if ( $wgDBtype == 'oracle' ) { + $class = 'SearchOracle'; } else { $class = 'SearchEngineDummy'; } @@ -231,12 +241,15 @@ class SearchEngine { * @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 @@ -309,9 +322,20 @@ class SearchResultSet { 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 ); @@ -334,7 +358,7 @@ class SearchResult { } /** - * @package MediaWiki + * @addtogroup Search */ class SearchEngineDummy { function search( $term ) { @@ -347,4 +371,4 @@ class SearchEngineDummy { function searchtitle() {} function searchtext() {} } -?> +