/** * Return an array of subpages beginning with $search that this special page will accept. * * @param string $search Prefix to search for * @param int $limit Maximum number of results to return (usually 10) * @param int $offset Number of results to skip (usually 0) * @return string[] Matching subpages */ public function prefixSearchSubpages($search, $limit, $offset) { $title = Title::newFromText($search, NS_FILE); if (!$title || $title->getNamespace() !== NS_FILE) { // No prefix suggestion outside of file namespace return array(); } // Autocomplete subpage the same as a normal search, but just for files $prefixSearcher = new TitlePrefixSearch(); $result = $prefixSearcher->search($search, $limit, array(NS_FILE), $offset); return array_map(function (Title $t) { // Remove namespace in search suggestion return $t->getText(); }, $result); }
/** * Return an array of subpages beginning with $search that this special page will accept. * * @param string $search Prefix to search for * @param int $limit Maximum number of results to return (usually 10) * @param int $offset Number of results to skip (usually 0) * @return string[] Matching subpages */ public function prefixSearchSubpages($search, $limit, $offset) { if ($search === '') { return array(); } // Autocomplete subpage the same as a normal search, but just for files $prefixSearcher = new TitlePrefixSearch(); $result = $prefixSearcher->search($search, $limit, array(NS_FILE), $offset); return array_map(function (Title $t) { // Remove namespace in search suggestion return $t->getText(); }, $result); }