* @param array $titles
* @return array
*/
- protected abstract function titles( array $titles );
+ abstract protected function titles( array $titles );
/**
* When implemented in a descendant class, receives an array of titles as strings and returns
*
* @return array
*/
- protected abstract function strings( array $strings );
+ abstract protected function strings( array $strings );
/**
* Do a prefix search of titles and return a list of matching page names.
protected function specialSearch( $search, $limit ) {
global $wgContLang;
- # normalize searchKey, so aliases with spaces can be found - bug 25675
- $search = str_replace( ' ', '_', $search );
+ list( $searchKey, $subpageSearch ) = explode( '/', $search, 2 );
+
+ // Handle subpage search separately.
+ if ( $subpageSearch !== null ) {
+ // Try matching the full search string as a page name
+ $specialTitle = Title::makeTitleSafe( NS_SPECIAL, $searchKey );
+ $special = SpecialPageFactory::getPage( $specialTitle->getText() );
+ if ( $special ) {
+ $subpages = $special->prefixSearchSubpages( $subpageSearch, $limit );
+ return array_map( function ( $sub ) use ( $specialTitle ) {
+ return $specialTitle->getSubpage( $sub );
+ }, $subpages );
+ } else {
+ return array();
+ }
+ }
- $searchKey = $wgContLang->caseFold( $search );
+ # normalize searchKey, so aliases with spaces can be found - bug 25675
+ $searchKey = str_replace( ' ', '_', $searchKey );
+ $searchKey = $wgContLang->caseFold( $searchKey );
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
class StringPrefixSearch extends PrefixSearch {
protected function titles( array $titles ) {
- return array_map( function( Title $t ) { return $t->getPrefixedText(); }, $titles );
+ return array_map( function ( Title $t ) {
+ return $t->getPrefixedText();
+ }, $titles );
}
protected function strings( array $strings ) {