Add autocomplete for WhatLinksHere subpages
authorPiRSquared17 <pirsquared@tools.wmflabs.org>
Sun, 23 Nov 2014 22:38:42 +0000 (22:38 +0000)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 5 Jan 2015 18:18:16 +0000 (18:18 +0000)
Implements prefixSearchSubpages()

Change-Id: I15895c0b5ae55419928d624c318a53c27cde2820

includes/specials/SpecialWhatlinkshere.php

index 11ec363..7e7abe5 100644 (file)
@@ -496,6 +496,24 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                );
        }
 
+       /**
+        * 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
+               $prefixSearcher = new StringPrefixSearch;
+               $result = $prefixSearcher->search( $search, $limit, array(), $offset );
+               return $result;
+       }
+
        protected function getGroupName() {
                return 'pagetools';
        }