MobileFrontend
Mobile optimised frontend for MediaWiki
Loading...
Searching...
No Matches
MobileFrontendHooks Class Reference

Hook handlers for MobileFrontend extension. More...

Static Public Member Functions

static onBeforeInitialize ( $title, $unused, OutputPage $out)
 
static onMediaWikiPerformAction ( $output, $article, $title, $user, $request, $wiki)
 MediaWikiPerformAction hook handler (enable mwui for all pages)
 
static onSkinAddFooterLinks (Skin $skin, string $key, array &$footerLinks)
 Update the footer.
 
static onOutputPageBodyAttributes (OutputPage $out, Skin $skin, &$bodyAttrs)
 Modifies the <body> element's attributes.
 
static onBeforePageRedirect ( $out, &$redirect, &$code)
 BeforePageRedirect hook handler.
 
static onDifferenceEngineViewHeader ( $diff)
 DifferenceEngineViewHeader hook handler.
 
static onResourceLoaderSiteStylesModulePages ( $skin, &$pages)
 ResourceLoaderSiteStylesModulePages hook handler.
 
static onResourceLoaderSiteModulePages ( $skin, &$pages)
 ResourceLoaderSiteModulePages hook handler.
 
static onGetCacheVaryCookies ( $out, &$cookies)
 GetCacheVaryCookies hook handler.
 
static onPageRenderingHash (&$confstr, User $user, &$forOptions)
 Varies the parser cache if responsive images should have their variants stripped from the parser output, since the transformation happens during the parse.
 
static getResourceLoaderMFConfigVars ()
 Generate config for usage inside MobileFrontend This should be used for variables which:
 
static shouldMobileFormatSpecialPages ( $user)
 Should special pages be replaced with mobile formatted equivalents?
 
static onListDefinedTags (&$tags)
 ListDefinedTags and ChangeTagsListActive hook handler.
 
static onTaggableObjectCreation (Taggable $taggable)
 RecentChange_save hook handler that tags mobile changes.
 
static onAbuseFilterGenerateUserVars ( $vars, $user, RecentChange $rc=null)
 AbuseFilter-generateUserVars hook handler that adds a user_mobile variable.
 
static onAbuseFilterBuilder (&$builder)
 AbuseFilter-builder hook handler that adds user_mobile variable to list of valid vars.
 
static onUserLoginComplete (&$currentUser, &$injected_html)
 UserLoginComplete hook handler.
 
static onBeforePageDisplay (OutputPage &$out, Skin &$skin)
 BeforePageDisplay hook handler.
 
static onUserGetDefaultOptions (&$defaultUserOptions)
 Register default preferences for MobileFrontend.
 
static onGetPreferences ( $user, &$preferences)
 GetPreferences hook handler.
 
static onAllowLegacyGadgets ()
 Gadgets::allowLegacy hook handler.
 
static onCentralAuthLoginRedirectData ( $centralUser, &$data)
 CentralAuthLoginRedirectData hook handler Saves mobile host so that the CentralAuth wiki could redirect back properly.
 
static onCentralAuthSilentLoginRedirect ( $centralUser, &$url, $info)
 CentralAuthSilentLoginRedirect hook handler Points redirects from CentralAuth wiki to mobile domain if user has logged in from it.
 
static findTagline (ParserOutput $po, $fallbackWikibaseDescriptionFunc)
 Finds the wikidata tagline associated with the page.
 
static onHTMLFileCacheUseFileCache ()
 HTMLFileCache::useFileCache hook handler Disables file caching for mobile pageviews.
 
static onLoginFormValidErrorMessages (&$messages)
 LoginFormValidErrorMessages hook handler to promote MF specific error message be valid.
 
static onTitleSquidURLs (Title $title, array &$urls)
 Handler for TitleSquidURLs hook to add copies of the cache purge URLs which are transformed according to the wgMobileUrlTemplate, so that both mobile and non-mobile URL variants get purged.
 
static onAPIQuerySiteInfoGeneralInfo (ApiQuerySiteinfo $module, array &$result)
 Add the base mobile site URL to the siteinfo API output.
 

Public Attributes

const MOBILE_PREFERENCES_SPECIAL_PAGES = 'mobile-specialpages'
 
const MOBILE_PREFERENCES_EDITOR = 'mobile-editor'
 

Static Protected Member Functions

static getDefaultMobileSkin (Config $config)
 Obtain the default mobile skin.
 

Detailed Description

Hook handlers for MobileFrontend extension.

Hook handler method names should be in the form of: on<HookName>() For instance, the hook handler for the 'RequestContextCreateSkin' would be called: onRequestContextCreateSkin()

If your hook changes the behaviour of the Minerva skin, you are in the wrong place. Any changes relating to Minerva should go into Minerva.hooks.php

Member Function Documentation

◆ findTagline()

static MobileFrontendHooks::findTagline ( ParserOutput $po,
$fallbackWikibaseDescriptionFunc )
static

Finds the wikidata tagline associated with the page.

Parameters
ParserOutput$po
callable$fallbackWikibaseDescriptionFuncA fallback to provide Wikibase description. Function takes wikibase_item as a first and only argument
Returns
?string the tagline as a string, or else null if none is found

◆ getDefaultMobileSkin()

static MobileFrontendHooks::getDefaultMobileSkin ( Config $config)
staticprotected

Obtain the default mobile skin.

Parameters
Config$config
Exceptions
SkinExceptionIf a factory function isn't registered for the skin name
Returns
Skin

◆ getResourceLoaderMFConfigVars()

static MobileFrontendHooks::getResourceLoaderMFConfigVars ( )
static

Generate config for usage inside MobileFrontend This should be used for variables which:

  • vary with the html
  • variables that should work cross skin including anonymous users
  • used for both, stable and beta mode (don't use MobileContext::isBetaGroupMember in this function - T127860)
Returns
array

◆ onAbuseFilterBuilder()

static MobileFrontendHooks::onAbuseFilterBuilder ( & $builder)
static

AbuseFilter-builder hook handler that adds user_mobile variable to list of valid vars.

Parameters
array&$builderArray in AbuseFilter::getBuilderValues to add to.

◆ onAbuseFilterGenerateUserVars()

static MobileFrontendHooks::onAbuseFilterGenerateUserVars ( $vars,
$user,
RecentChange $rc = null )
static

AbuseFilter-generateUserVars hook handler that adds a user_mobile variable.

Altering the variables generated for a specific user

See also
hooks.txt in AbuseFilter extension
Parameters
VariableHolder$varsobject to add vars to
User$user
RecentChange | null$rcIf the variables should be generated for an RC entry, this is the entry. Null if it's for the current action being filtered.

◆ onAllowLegacyGadgets()

static MobileFrontendHooks::onAllowLegacyGadgets ( )
static

Gadgets::allowLegacy hook handler.

Returns
bool

◆ onAPIQuerySiteInfoGeneralInfo()

static MobileFrontendHooks::onAPIQuerySiteInfoGeneralInfo ( ApiQuerySiteinfo $module,
array & $result )
static

Add the base mobile site URL to the siteinfo API output.

Parameters
ApiQuerySiteinfo$module
array&$resultApi result array

◆ onBeforeInitialize()

static MobileFrontendHooks::onBeforeInitialize ( $title,
$unused,
OutputPage $out )
static
See also
https://www.mediawiki.org/wiki/Manual:Hooks/BeforeInitialize
Parameters
mixed$title
mixed$unused
OutputPage$out

◆ onBeforePageDisplay()

static MobileFrontendHooks::onBeforePageDisplay ( OutputPage & $out,
Skin & $skin )
static

BeforePageDisplay hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
Parameters
OutputPage&$out
Skin&$skinSkin object that will be used to generate the page, added in 1.13.

◆ onBeforePageRedirect()

static MobileFrontendHooks::onBeforePageRedirect ( $out,
& $redirect,
& $code )
static

BeforePageRedirect hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageRedirect

Ensures URLs are handled properly for select special pages.

Parameters
OutputPage$out
string&$redirectURL string, modifiable
string&$codeHTTP code (eg '301' or '302'), modifiable

◆ onCentralAuthLoginRedirectData()

static MobileFrontendHooks::onCentralAuthLoginRedirectData ( $centralUser,
& $data )
static

CentralAuthLoginRedirectData hook handler Saves mobile host so that the CentralAuth wiki could redirect back properly.

See also
CentralAuthHooks::doCentralLoginRedirect in CentralAuth extension
Parameters
\MediaWiki\Extension\CentralAuth\User\CentralAuthUser$centralUser
array&$dataRedirect data

◆ onCentralAuthSilentLoginRedirect()

static MobileFrontendHooks::onCentralAuthSilentLoginRedirect ( $centralUser,
& $url,
$info )
static

CentralAuthSilentLoginRedirect hook handler Points redirects from CentralAuth wiki to mobile domain if user has logged in from it.

See also
SpecialCentralLogin in CentralAuth extension
Parameters
\MediaWiki\Extension\CentralAuth\User\CentralAuthUser$centralUser
string&$urlto redirect to
array$infotoken information

◆ onDifferenceEngineViewHeader()

static MobileFrontendHooks::onDifferenceEngineViewHeader ( $diff)
static

DifferenceEngineViewHeader hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/DifferenceEngineViewHeader

Redirect Diff page to mobile version if appropriate

Parameters
DifferenceEngine$diffDifferenceEngine object that's calling

◆ onGetCacheVaryCookies()

static MobileFrontendHooks::onGetCacheVaryCookies ( $out,
& $cookies )
static

GetCacheVaryCookies hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/GetCacheVaryCookies
Parameters
OutputPage$out
array&$cookiesarray of cookies name, add a value to it if you want to add a cookie that have to vary cache options

◆ onGetPreferences()

static MobileFrontendHooks::onGetPreferences ( $user,
& $preferences )
static

GetPreferences hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
Parameters
User$userUser whose preferences are being modified
array&$preferencesPreferences description array, to be fed to an HTMLForm object

◆ onHTMLFileCacheUseFileCache()

static MobileFrontendHooks::onHTMLFileCacheUseFileCache ( )
static

HTMLFileCache::useFileCache hook handler Disables file caching for mobile pageviews.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/HTMLFileCache::useFileCache
Returns
bool

◆ onListDefinedTags()

static MobileFrontendHooks::onListDefinedTags ( & $tags)
static

ListDefinedTags and ChangeTagsListActive hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ListDefinedTags
https://www.mediawiki.org/wiki/Manual:Hooks/ChangeTagsListActive
Parameters
array&$tagsThe list of tags. Add your extension's tags to this array.

◆ onLoginFormValidErrorMessages()

static MobileFrontendHooks::onLoginFormValidErrorMessages ( & $messages)
static

LoginFormValidErrorMessages hook handler to promote MF specific error message be valid.

Parameters
array&$messagesArray of already added messages

◆ onMediaWikiPerformAction()

static MobileFrontendHooks::onMediaWikiPerformAction ( $output,
$article,
$title,
$user,
$request,
$wiki )
static

MediaWikiPerformAction hook handler (enable mwui for all pages)

See also
https://www.mediawiki.org/wiki/Manual:Hooks/MediaWikiPerformAction
Parameters
OutputPage$output
Article$article
Title$titlePage title
User$userUser performing action
RequestContext$request
MediaWiki$wiki

◆ onOutputPageBodyAttributes()

static MobileFrontendHooks::onOutputPageBodyAttributes ( OutputPage $out,
Skin $skin,
& $bodyAttrs )
static

Modifies the <body> element's attributes.

By default, the class attribute is set to the output's "bodyClassName" property.

Parameters
OutputPage$out
Skin$skin
string[]&$bodyAttrs

◆ onPageRenderingHash()

static MobileFrontendHooks::onPageRenderingHash ( & $confstr,
User $user,
& $forOptions )
static

Varies the parser cache if responsive images should have their variants stripped from the parser output, since the transformation happens during the parse.

See $wgMFStripResponsiveImages and $wgMFResponsiveImageWhitelist for more detail about the stripping of responsive images.

See https://www.mediawiki.org/wiki/Manual:Hooks/PageRenderingHash for more detail about the PageRenderingHash hook.

Parameters
string&$confstrReference to the parser cache key
User$userThe user that is requesting the page
array&$forOptionsThe options used to generate the parser cache key

◆ onResourceLoaderSiteModulePages()

static MobileFrontendHooks::onResourceLoaderSiteModulePages ( $skin,
& $pages )
static

ResourceLoaderSiteModulePages hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderSiteModulePages
Parameters
string$skin
array&$pagesto sort modules from.

◆ onResourceLoaderSiteStylesModulePages()

static MobileFrontendHooks::onResourceLoaderSiteStylesModulePages ( $skin,
& $pages )
static

ResourceLoaderSiteStylesModulePages hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderSiteStylesModulePages
Parameters
string$skin
array&$pagesto sort modules from.

◆ onSkinAddFooterLinks()

static MobileFrontendHooks::onSkinAddFooterLinks ( Skin $skin,
string $key,
array & $footerLinks )
static

Update the footer.

Parameters
Skin$skin
string$keythe current key for the current group (row) of footer links. e.g. info or places.
array&$footerLinksan empty array that can be populated with new links. keys should be strings and will be used for generating the ID of the footer item and value should be an HTML string.

◆ onTaggableObjectCreation()

static MobileFrontendHooks::onTaggableObjectCreation ( Taggable $taggable)
static

RecentChange_save hook handler that tags mobile changes.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/RecentChange_save

ManualLogEntryBeforePublish hook handler that tags actions logged when user uses mobile mode

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ManualLogEntryBeforePublish
Parameters
Taggable$taggableObject to tag

◆ onTitleSquidURLs()

static MobileFrontendHooks::onTitleSquidURLs ( Title $title,
array & $urls )
static

Handler for TitleSquidURLs hook to add copies of the cache purge URLs which are transformed according to the wgMobileUrlTemplate, so that both mobile and non-mobile URL variants get purged.

See also
* https://www.mediawiki.org/wiki/Manual:Hooks/TitleSquidURLs
Parameters
Title$titlethe article title
array&$urlsthe set of URLs to purge

◆ onUserGetDefaultOptions()

static MobileFrontendHooks::onUserGetDefaultOptions ( & $defaultUserOptions)
static

Register default preferences for MobileFrontend.

Parameters
array&$defaultUserOptionsReference to default options array

◆ onUserLoginComplete()

static MobileFrontendHooks::onUserLoginComplete ( & $currentUser,
& $injected_html )
static

UserLoginComplete hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/UserLoginComplete

Used here to handle watchlist actions made by anons to be handled after login or account creation.

Parameters
User&$currentUserthe user object that was created on login
string&$injected_htmlFrom 1.13, any HTML to inject after the login success message.

◆ shouldMobileFormatSpecialPages()

static MobileFrontendHooks::shouldMobileFormatSpecialPages ( $user)
static

Should special pages be replaced with mobile formatted equivalents?

Parameters
User$userfor which we need to make the decision based on user prefs
Returns
bool whether special pages should be substituted with mobile friendly equivalents

The documentation for this class was generated from the following file: