From df5dc915fb273bd1abc5f7ebe054b4c1960194a6 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 13 Jun 2014 20:51:58 +0200 Subject: [PATCH] Add SpecialEditWatchlist::prefixSearchSubpages Also add 'clear' to SpecialWatchlist::prefixSearchSubpages Change-Id: Ibc1ca44a9472cd86a6dc5df04274089b8fcf30a2 --- includes/specials/SpecialEditWatchlist.php | 15 +++++++++++++++ includes/specials/SpecialWatchlist.php | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index ebbef17f16..02d8d709ba 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -117,6 +117,21 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { } } + /** + * Return an array of subpages beginning with $search that this special page will accept. + * + * @param string $search Prefix to search for + * @param integer $limit Maximum number of results to return + * @return string[] Matching subpages + */ + public function prefixSearchSubpages( $search, $limit = 10 ) { + // SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added + // here and there - no 'edit' here, because that the default for this page + $subpages = array( 'clear', 'raw' ); + $escaped = preg_quote( $search ); + return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit ); + } + /** * Extract a list of titles from a blob of text, returning * (prefixed) strings; unwatchable titles are ignored diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 1add311360..2aec8dfec2 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -87,7 +87,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { * @return string[] Matching subpages */ public function prefixSearchSubpages( $search, $limit = 10 ) { - $subpages = array( 'edit', 'raw' ); + // See also SpecialEditWatchlist::prefixSearchSubpages + $subpages = array( 'clear', 'edit', 'raw' ); $escaped = preg_quote( $search ); return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit ); } -- 2.20.1