Harej has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/357437 )
Change subject: Allow appending searchfilters to terms ...................................................................... Allow appending searchfilters to terms For search-style inputboxes, if you have `searchfilter=foo` as a parameter, it will append `foo` after the search term. This is useful for leveraging search filters in custom search boxes without exposing it to the user. Bug: T147951 Change-Id: Ie23ce220ff9657c38fe5b41195e297ca7cebf7f1 --- M InputBox.classes.php M InputBox.hooks.php 2 files changed, 11 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/InputBox refs/changes/37/357437/1 diff --git a/InputBox.classes.php b/InputBox.classes.php index e5a4290..1ee1931 100644 --- a/InputBox.classes.php +++ b/InputBox.classes.php @@ -36,6 +36,7 @@ private $mInline = false; private $mPrefix = ''; private $mDir = ''; + private $mSearchFilter = ''; /* Functions */ @@ -167,6 +168,10 @@ if ( $this->mPrefix != '' ) { $htmlOut .= Html::hidden( 'prefix', $this->mPrefix ); + } + + if ( $this->mSearchFilter != '' ) { + $htmlOut .= Html::hidden( 'searchfilter', $this->mSearchFilter ); } $htmlOut .= $this->mBR; @@ -599,6 +604,7 @@ 'inline' => 'mInline', 'prefix' => 'mPrefix', 'dir' => 'mDir', + 'searchfilter' => 'mSearchFilter' ]; foreach ( $options as $name => $var ) { if ( isset( $values[$name] ) ) { diff --git a/InputBox.hooks.php b/InputBox.hooks.php index 9bdae13..60c16d1 100644 --- a/InputBox.hooks.php +++ b/InputBox.hooks.php @@ -22,10 +22,15 @@ $request = $special->getRequest(); $prefix = $request->getText( 'prefix', '' ); $title = $request->getText( 'wpNewTitle', '' ); + $search = $request->getText( 'search', '' ); + $searchfilter = $request->getText( 'searchfilter', '' ); if ( $special->getName() == 'Movepage' && $prefix !== '' && $title !== '' ) { $request->setVal( 'wpNewTitle', $prefix . $title ); $request->unsetVal( 'prefix' ); } + if ( $special->getName() == 'Search' && $searchfilter !== '' ) { + $request->setVal( 'search', $search . ' ' . $searchfilter ); + } return true; } -- To view, visit https://gerrit.wikimedia.org/r/357437 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie23ce220ff9657c38fe5b41195e297ca7cebf7f1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/InputBox Gerrit-Branch: master Gerrit-Owner: Harej <jamesmh...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits