User:Florianschmidtwelzow/MobileFrontend/Hooks
The MobileFrontend Extension introduces some new hooks, but they are all undocumented. This page tries to document these hooks. Please notice: It's possible, that the Hooks will be replaced or removed in a newer version of MobileFrontend.
MobileFrontendBeforeDOM
editMobileFrontendBeforeDOM | |
---|---|
Available from version master Use page content before it is formatted by MobileFrontend. | |
Define function: | public static function onMobileFrontendBeforeDOM( MobileContext $context, MobileFormatter $formatter ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"MobileFrontendBeforeDOM": "MediaWiki\\Extension\\MyExtension\\Hooks::onMobileFrontendBeforeDOM"
}
}
|
Called from: | File(s): MobileFrontend extension/MobileFrontend.body.php |
Interface: | MobileFrontendBeforeDOMHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:MobileFrontendBeforeDOM extensions.
Details
editThis hook os called before the content parsed by MobileFormatter.
Usage
editSkinMinervaDefaultModules
editSkinMinervaDefaultModules | |
---|---|
Available from version master Add or remove modules loaded by Minerva skin. | |
Define function: | public static function onSkinMinervaDefaultModules( SkinMinerva $skin, array &$modules ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"SkinMinervaDefaultModules": "MediaWiki\\Extension\\MyExtension\\Hooks::onSkinMinervaDefaultModules"
}
}
|
Called from: | File(s): MobileFrontend extension/SkinMinerva.php, MobileFrontend extension/SkinMinervaBeta.php |
Interface: | SkinMinervaDefaultModulesHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:SkinMinervaDefaultModules extensions.
Details
editThe array $modules, submitted with this hook, contains a bunch of JavaScript modules which will be loaded. You can change, remove or add modules with this hook.
Usage
editTo add the module test23 to MobileFrontend, you can use the following code:
// Define the module to load and add a dependency to mobile.stable
$wgResourceModules = array_merge( $wgResourceModules, array(
'mobile.test23' => $wgMFMobileResourceBoilerplate + array(
'dependencies' => array(
'mobile.stable',
),
'scripts' => array(
'javascripts/test23.js',
),
'targets' => array( 'mobile' ),
)
) );
// Hook definition
$wgHooks['SkinMinervaDefaultModules'][] = 'onSkinMinervaDefaultModules';
// add the module to MobileFrontend
function onSkinMinervaDefaultModules( $skin, &$modules ) {
$modules['test23'] = array( 'mobile.test23' );
}
EnableMobileModules (deprecated)
editEnableMobileModules | |
---|---|
Available from version 3b5e3c07f39ef070389a00597b996912f47cad7b (deprecated) Allow other extensions to add modules depending on the MobileFrontend mode. | |
Define function: | public static function onEnableMobileModules( OutputPage $out, string $mode ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"EnableMobileModules": "MediaWiki\\Extension\\MyExtension\\Hooks::onEnableMobileModules"
}
}
|
Called from: | File(s): MobileFrontend extension/SkinMinerva.php |
Interface: | EnableMobileModulesHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:EnableMobileModules extensions.
Details
editNotice: This Hook is depreacted and will be removed in a later version of MobileFrontend. Please use RessourceLoader to load your Module for mobile deveices.
- $out: OutputPage
- $mode: String, such as 'alpha', 'beta', 'stable'
BeforePageDisplayMobile
editBeforePageDisplayMobile | |
---|---|
Available from version master Allow other extensions to use OutputPage before outputPage generates script and style tags. | |
Define function: | public static function onBeforePageDisplayMobile( OutputPage $out ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"BeforePageDisplayMobile": "MediaWiki\\Extension\\MyExtension\\Hooks::onBeforePageDisplayMobile"
}
}
|
Called from: | File(s): MobileFrontend extension/SkinMinerva.php |
Interface: | BeforePageDisplayMobileHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:BeforePageDisplayMobile extensions.
Details
edit- $out: OutputPage
MinervaPreRender
editMinervaPreRender | |
---|---|
Available from version master Called before the entire page is rendered to change the content or something else. | |
Define function: | public static function onMinervaPreRender( MinervaTemplate $template ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"MinervaPreRender": "MediaWiki\\Extension\\MyExtension\\Hooks::onMinervaPreRender"
}
}
|
Called from: | File(s): MobileFrontend extension/MinervaTemplate.php |
Interface: | MinervaPreRenderHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:MinervaPreRender extensions.
Details
edit- $template: MinervaTemplate
BeforeSpecialMobileDiffDisplay
editBeforeSpecialMobileDiffDisplay | |
---|---|
Available from version master Last chance to change content of Difference page before output | |
Define function: | public static function onBeforeSpecialMobileDiffDisplay( OutputPage &$output, MobileContext $ctx, array $revisions ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"BeforeSpecialMobileDiffDisplay": "MediaWiki\\Extension\\MyExtension\\Hooks::onBeforeSpecialMobileDiffDisplay"
}
}
|
Called from: | File(s): MobileFrontend extension/MinervaTemplate.php |
Interface: | BeforeSpecialMobileDiffDisplayHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:BeforeSpecialMobileDiffDisplay extensions.
Details
edit- &$output: OutputPage
- $ctx: MobileContext
- $revisions: array of revisions to compare ($revisions[1] -> Revision; $revisions[0] -> previous Revision)
EnterMobileMode
editfollows
GetMobileUrl
editfollows
SpecialWatchlistQuery
editfollows