<?php
+/**
+ * PrefixSearch - Handles searching prefixes of titles and finding any page
+ * names that match. Used largely by the OpenSearch implementation.
+ *
+ * @ingroup Search
+ */
+
class PrefixSearch {
/**
* Do a prefix search of titles and return a list of matching page names.
if( count($namespaces) == 1 ){
$ns = $namespaces[0];
if( $ns == NS_MEDIA ) {
- $namespaces = array(NS_IMAGE);
+ $namespaces = array(NS_FILE);
} elseif( $ns == NS_SPECIAL ) {
return self::specialSearch( $search, $limit );
}
/**
* Unless overridden by PrefixSearchBackend hook...
- * This is case-sensitive except the first letter (per $wgCapitalLinks)
+ * This is case-sensitive (First character may
+ * be automatically capitalized by Title::secureAndSpit()
+ * later on depending on $wgCapitalLinks)
*
* @param array $namespaces Namespaces to search in
* @param string $search term
* @return array of title strings
*/
protected static function defaultSearchBackend( $namespaces, $search, $limit ) {
- global $wgCapitalLinks, $wgContLang;
-
- if( $wgCapitalLinks ) {
- $search = $wgContLang->ucfirst( $search );
- }
-
$ns = array_shift($namespaces); // support only one namespace
if( in_array(NS_MAIN,$namespaces))
$ns = NS_MAIN; // if searching on many always default to main
// Reformat useful data for future printing by JSON engine
$srchres = array ();
- foreach ($data['query']['allpages'] as & $pageinfo) {
+ foreach ((array)$data['query']['allpages'] as $pageinfo) {
// Note: this data will no be printable by the xml engine
// because it does not support lists of unnamed items
$srchres[] = $pageinfo['title'];