3 * Hooks for InputBox extension
12 public static function register( Parser &$parser ) {
13 // Register the hook with the parser
14 $parser->setHook( 'inputbox', [ 'InputBoxHooks', 'render' ] );
20 // Prepend prefix to wpNewTitle if necessary
21 public static function onSpecialPageBeforeExecute( $special, $subPage ) {
22 $request = $special->getRequest();
23 $prefix = $request->getText( 'prefix', '' );
24 $title = $request->getText( 'wpNewTitle', '' );
25 $search = $request->getText( 'search', '' );
26 $searchfilter = $request->getText( 'searchfilter', '' );
27 if ( $special->getName() == 'Movepage' && $prefix !== '' && $title !== '' ) {
28 $request->setVal( 'wpNewTitle', $prefix . $title );
29 $request->unsetVal( 'prefix' );
31 if ( $special->getName() == 'Search' && $searchfilter !== '' ) {
32 $request->setVal( 'search', $search . ' ' . $searchfilter );
37 // Render the input box
38 public static function render( $input, $args, Parser $parser ) {
40 $inputBox = new InputBox( $parser );
43 $inputBox->extractOptions( $parser->replaceVariables( $input ) );
46 return $inputBox->render();
50 * <inputbox type=create...> sends requests with action=edit, and
51 * possibly a &prefix=Foo. So we pick that up here, munge prefix
52 * and title together, and redirect back out to the real page
53 * @param $output OutputPage
54 * @param $article Article
57 * @param $request WebRequest
58 * @param $wiki MediaWiki
61 public static function onMediaWikiPerformAction(
69 if ( $wiki->getAction( $request ) !== 'edit' ) {
73 if ( $request->getText( 'prefix', '' ) === '' ) {
78 $params = $request->getValues();
79 $title = $params['prefix'];
80 if ( isset( $params['title'] ) ) {
81 $title .= $params['title'];
83 unset( $params['prefix'] );
84 $params['title'] = $title;
87 $output->redirect( wfAppendQuery( $wgScript, $params ), '301' );