MediaWiki  1.29.2
InputBox.hooks.php
Go to the documentation of this file.
1 <?php
9 // InputBox hooks
11  // Initialization
12  public static function register( Parser &$parser ) {
13  // Register the hook with the parser
14  $parser->setHook( 'inputbox', array( 'InputBoxHooks', 'render' ) );
15 
16  // Continue
17  return true;
18  }
19 
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  if ( $special->getName() == 'Movepage' && $prefix !== '' && $title !== '' ) {
26  $request->setVal( 'wpNewTitle', $prefix . $title );
27  $request->unsetVal( 'prefix' );
28  }
29  return true;
30  }
31 
32  // Render the input box
33  public static function render( $input, $args, Parser $parser ) {
34  // Create InputBox
35  $inputBox = new InputBox( $parser );
36 
37  // Configure InputBox
38  $inputBox->extractOptions( $parser->replaceVariables( $input ) );
39 
40  // Return output
41  return $inputBox->render();
42  }
43 
56  public static function onMediaWikiPerformAction(
57  $output,
58  $article,
59  $title,
60  $user,
61  $request,
62  $wiki
63  ) {
64  if( $wiki->getAction( $request ) !== 'edit' ){
65  # not our problem
66  return true;
67  }
68  if( $request->getText( 'prefix', '' ) === '' ){
69  # Fine
70  return true;
71  }
72 
73  $params = $request->getValues();
74  $title = $params['prefix'];
75  if ( isset( $params['title'] ) ) {
76  $title .= $params['title'];
77  }
78  unset( $params['prefix'] );
79  $params['title'] = $title;
80 
82  $output->redirect( wfAppendQuery( $wgScript, $params ), '301' );
83  return false;
84  }
85 }
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
InputBoxHooks::onSpecialPageBeforeExecute
static onSpecialPageBeforeExecute( $special, $subPage)
Definition: InputBox.hooks.php:21
$wgScript
$wgScript
The URL path to index.php.
Definition: DefaultSettings.php:202
InputBoxHooks::render
static render( $input, $args, Parser $parser)
Definition: InputBox.hooks.php:33
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
$params
$params
Definition: styleTest.css.php:40
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
InputBox
Definition: InputBox.classes.php:10
InputBoxHooks::onMediaWikiPerformAction
static onMediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki)
<inputbox type="create..."> sends requests with action=edit, and possibly a &prefix=Foo.
Definition: InputBox.hooks.php:56
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:500
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
InputBoxHooks
Definition: InputBox.hooks.php:10
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2536
$output
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition: hooks.txt:1049
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$args
if( $line===false) $args
Definition: cdb.php:63
$article
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:78
$special
this hook is for auditing only RecentChangesLinked and Watchlist $special
Definition: hooks.txt:990
array
the array() calling protocol came about after MediaWiki 1.4rc1.