MobileFrontend
MobileoptimisedfrontendforMediaWiki
MobileFrontendHooks Class Reference

Hook handlers for MobileFrontend extension. More...

Static Public Member Functions

static onRequestContextCreateSkin ( $context, &$skin)
 RequestContextCreateSkin hook handler. More...
 
static onMediaWikiPerformAction ( $output, $article, $title, $user, $request, $wiki)
 MediaWikiPerformAction hook handler (enable mwui for all pages) More...
 
static onSkinTemplateOutputPageBeforeExec (Skin &$skin, QuickTemplate &$tpl)
 SkinTemplateOutputPageBeforeExec hook handler. More...
 
static onSkinAfterBottomScripts (Skin $skin, &$html)
 SkinAfterBottomScripts hook handler. More...
 
static onOutputPageBeforeHTML (&$out, &$text)
 OutputPageBeforeHTML hook handler. More...
 
static onBeforePageRedirect ( $out, &$redirect, &$code)
 BeforePageRedirect hook handler. More...
 
static onDiffViewHeader ( $diff, $oldRev, $newRev)
 DiffViewHeader hook handler. More...
 
static onGetCacheVaryCookies ( $out, &$cookies)
 GetCacheVaryCookies hook handler. More...
 
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. More...
 
static getResourceLoaderMFConfigVars ()
 Generate config for usage inside MobileFrontend This should be used for variables which: More...
 
static shouldMobileFormatSpecialPages ( $user)
 Should special pages be replaced with mobile formatted equivalents? More...
 
static onSpecialPageInitList (&$list)
 Hook for SpecialPage_initList in SpecialPageFactory. More...
 
static onListDefinedTags (&$tags)
 ListDefinedTags and ChangeTagsListActive hook handler. More...
 
static onTaggableObjectCreation (Taggable $taggable)
 RecentChange_save hook handler that tags mobile changes. More...
 
static onAbuseFilterGenerateUserVars ( $vars, $user)
 AbuseFilter-GenerateUserVars hook handler that adds a user_mobile variable. More...
 
static onAbuseFilterBuilder (&$builder)
 AbuseFilter-builder hook handler that adds user_mobile variable to list of valid vars. More...
 
static onSpecialPageBeforeExecute (SpecialPage $special, $subpage)
 Invocation of hook SpecialPageBeforeExecute. More...
 
static onUserLoginComplete (&$currentUser, &$injected_html)
 UserLoginComplete hook handler. More...
 
static onBeforePageDisplay (OutputPage &$out, Skin &$skin)
 BeforePageDisplay hook handler. More...
 
static onAfterBuildFeedLinks (array &$tags)
 AfterBuildFeedLinks hook handler. More...
 
static onUserGetDefaultOptions (&$wgDefaultUserOptions)
 Register default preferences for MobileFrontend. More...
 
static onGetPreferences ( $user, &$preferences)
 GetPreferences hook handler. More...
 
static onAllowLegacyGadgets ()
 Gadgets::allowLegacy hook handler. More...
 
static onCentralAuthLoginRedirectData ( $centralUser, &$data)
 CentralAuthLoginRedirectData hook handler Saves mobile host so that the CentralAuth wiki could redirect back properly. More...
 
static onCentralAuthSilentLoginRedirect ( $centralUser, &$url, $info)
 CentralAuthSilentLoginRedirect hook handler Points redirects from CentralAuth wiki to mobile domain if user has logged in from it. More...
 
static onResourceLoaderRegisterModules (ResourceLoader &$resourceLoader)
 ResourceLoaderRegisterModules hook handler. More...
 
static findTagline (ParserOutput $po, $fallbackWikibaseDescriptionFunc)
 Finds the wikidata tagline associated with the page. More...
 
static onOutputPageParserOutput ( $outputPage, ParserOutput $po)
 OutputPageParserOutput hook handler. More...
 
static onHTMLFileCacheUseFileCache ()
 HTMLFileCache::useFileCache hook handler Disables file caching for mobile pageviews. More...
 
static onThumbnailBeforeProduceHTML ( $thumbnail, &$attribs, &$linkAttribs)
 Removes the responsive image's variants from the parser output if configured to do so and the thumbnail's MIME type isn't whitelisted. More...
 
static onLoginFormValidErrorMessages (&$messages)
 LoginFormValidErrorMessages hook handler to promote MF specific error message be valid. More...
 
static onMakeGlobalVariablesScript (array &$vars, OutputPage $out)
 Handler for MakeGlobalVariablesScript hook. More...
 
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. More...
 
static onAuthChangeFormFields (array $requests, array $fieldInfo, array &$formDescriptor, $action)
 Handler for the AuthChangeFormFields hook to add a logo on top of the login screen. More...
 
static onAPIQuerySiteInfoGeneralInfo (ApiQuerySiteinfo $module, array &$result)
 Add the base mobile site URL to the siteinfo API output. More...
 
static onGetDifferenceEngine (IContextSource $context, $old, $new, $refreshCache, $unhide, &$differenceEngine)
 Use inline diff engine when on Special:MobileDiff. More...
 

Public Attributes

const MOBILE_PREFERENCES_SECTION = 'rendering/mobile'
 
const MOBILE_PREFERENCES_SPECIAL_PAGES = 'mobile-specialpages'
 
const ENABLE_SPECIAL_PAGE_OPTIMISATIONS = '1'
 
const DEVICE_WIDTH_TABLET = '720px'
 

Static Protected Member Functions

static getDefaultMobileSkin (IContextSource $context, MobileContext $mobileContext)
 Obtain the default mobile skin. More...
 
static isPageContentModelEditable (Title $title)
 Checks whether the editor can handle the existing content handler type. More...
 

Detailed Description

Hook handlers for MobileFrontend extension.

Hook handler method names should be in the form of: on<HookName>() For intance, 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

◆ getDefaultMobileSkin()

static MobileFrontendHooks::getDefaultMobileSkin ( IContextSource  $context,
MobileContext  $mobileContext 
)
staticprotected

Obtain the default mobile skin.

Parameters
IContextSource$contextContextSource interface
MobileContext$mobileContext
Exceptions
RuntimeExceptionif MFDefaultSkinClass is incorrectly configured
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
bool

◆ isPageContentModelEditable()

static MobileFrontendHooks::isPageContentModelEditable ( Title  $title)
staticprotected

Checks whether the editor can handle the existing content handler type.

Parameters
Title$title
Returns
bool

◆ 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.
Returns
bool

◆ onAbuseFilterGenerateUserVars()

static MobileFrontendHooks::onAbuseFilterGenerateUserVars (   $vars,
  $user 
)
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
AbuseFilterVariableHolder$varsobject to add vars to
User$user
Returns
bool

◆ onAfterBuildFeedLinks()

static MobileFrontendHooks::onAfterBuildFeedLinks ( array &  $tags)
static

AfterBuildFeedLinks hook handler.

Remove all feed links in mobile view.

Parameters
array&$tagsAdded feed links

◆ 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

◆ onAuthChangeFormFields()

static MobileFrontendHooks::onAuthChangeFormFields ( array  $requests,
array  $fieldInfo,
array &  $formDescriptor,
  $action 
)
static

Handler for the AuthChangeFormFields hook to add a logo on top of the login screen.

This is the AuthManager equivalent of changeUserLoginCreateForm.

Parameters
AuthenticationRequest[]$requestsAuthenticationRequest objects array
array$fieldInfoField description as given by AuthenticationRequest::mergeFieldInfo
array&$formDescriptorA form descriptor suitable for the HTMLForm constructor
string$actionOne of the AuthManager::ACTION_* constants

◆ 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.
Returns
bool

◆ 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
Returns
bool

◆ 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
CentralAuthUser$centralUser
array&$dataRedirect data
Returns
bool

◆ 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
CentralAuthUser$centralUser
string&$urlto redirect to
array$infotoken information
Returns
bool

◆ onDiffViewHeader()

static MobileFrontendHooks::onDiffViewHeader (   $diff,
  $oldRev,
  $newRev 
)
static

DiffViewHeader hook handler.

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

Redirect Diff page to mobile version if appropriate

Parameters
DifferenceEngine$diffDifferenceEngine object that's calling
Revision$oldRevRevision object of the "old" revision (may be null/invalid)
Revision$newRevRevision object of the "new" revision
Returns
bool

◆ 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
Returns
bool

◆ onGetDifferenceEngine()

static MobileFrontendHooks::onGetDifferenceEngine ( IContextSource  $context,
  $old,
  $new,
  $refreshCache,
  $unhide,
$differenceEngine 
)
static

Use inline diff engine when on Special:MobileDiff.

Parameters
IContextSource$context
int$oldOld revision ID or 0 for current
int$newNew revision ID or 0 for current
bool$refreshCacheRefresh diff cache
bool$unhideShow deleted revisions
DifferenceEngine&$differenceEngineDifference engine to alter/replace

◆ 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
Returns
bool

◆ 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.
Returns
bool

◆ onLoginFormValidErrorMessages()

static MobileFrontendHooks::onLoginFormValidErrorMessages ( $messages)
static

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

Parameters
array&$messagesArray of already added messages

◆ onMakeGlobalVariablesScript()

static MobileFrontendHooks::onMakeGlobalVariablesScript ( array &  $vars,
OutputPage  $out 
)
static

Handler for MakeGlobalVariablesScript hook.

For values that depend on the current page, user or request state.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript
Parameters
array&$varsVariables to be added into the output
OutputPage$outOutputPage instance calling the hook
Returns
bool true in all cases

◆ 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
Returns
bool

◆ onOutputPageBeforeHTML()

static MobileFrontendHooks::onOutputPageBeforeHTML ( $out,
$text 
)
static

OutputPageBeforeHTML hook handler.

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

Applies MobileFormatter to mobile viewed content Also enables Related Articles in the footer in the beta mode. Adds inline script to allow opening of sections while JS is still loading

Parameters
OutputPage&$outthe OutputPage object to which wikitext is added
string&$textthe HTML to be wrapped inside the #mw-content-text element
Returns
bool

◆ onOutputPageParserOutput()

static MobileFrontendHooks::onOutputPageParserOutput (   $outputPage,
ParserOutput  $po 
)
static

OutputPageParserOutput hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
Parameters
OutputPage$outputPagethe OutputPage object to which wikitext is added
ParserOutput$po
Returns
bool

◆ 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

◆ onRequestContextCreateSkin()

static MobileFrontendHooks::onRequestContextCreateSkin (   $context,
$skin 
)
static

RequestContextCreateSkin hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/RequestContextCreateSkin
Parameters
IContextSource$contextThe RequestContext object the skin is being created for.
Skin | null | string&$skinA variable reference you may set a Skin instance or string key on to override the skin that will be used for the context.
Returns
bool

◆ onResourceLoaderRegisterModules()

static MobileFrontendHooks::onResourceLoaderRegisterModules ( ResourceLoader &  $resourceLoader)
static

ResourceLoaderRegisterModules hook handler.

Registers:

  • EventLogging schema modules, if the EventLogging extension is loaded;
  • Modules for the Visual Editor overlay, if the VisualEditor extension is loaded; and
  • Modules for the notifications overlay, if the Echo extension is loaded.
See also
https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderRegisterModules
Parameters
ResourceLoader&$resourceLoader
Returns
bool Always true

◆ onSkinAfterBottomScripts()

static MobileFrontendHooks::onSkinAfterBottomScripts ( Skin  $skin,
$html 
)
static

SkinAfterBottomScripts hook handler.

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

Adds an inline script for lazy loading the images in Grade C browsers.

Parameters
Skin$skin
string&$htmlbottomScripts text. Append to $text to add additional text/scripts after the stock bottom scripts.
Returns
bool

◆ onSkinTemplateOutputPageBeforeExec()

static MobileFrontendHooks::onSkinTemplateOutputPageBeforeExec ( Skin &  $skin,
QuickTemplate &  $tpl 
)
static

SkinTemplateOutputPageBeforeExec hook handler.

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

Adds a link to view the current page in 'mobile view' to the desktop footer.

Parameters
Skin&$skin
QuickTemplate&$tpl
Returns
bool

◆ onSpecialPageBeforeExecute()

static MobileFrontendHooks::onSpecialPageBeforeExecute ( SpecialPage  $special,
  $subpage 
)
static

Invocation of hook SpecialPageBeforeExecute.

We use this hook to ensure that login/account creation pages are redirected to HTTPS if they are not accessed via HTTPS and $wgSecureLogin == true - but only when using the mobile site.

Parameters
SpecialPage$special
string$subpagesubpage name
Returns
bool

◆ onSpecialPageInitList()

static MobileFrontendHooks::onSpecialPageInitList ( $list)
static

Hook for SpecialPage_initList in SpecialPageFactory.

Parameters
array&$listlist of special page classes
Returns
bool hook return value

◆ 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
Returns
bool

◆ onThumbnailBeforeProduceHTML()

static MobileFrontendHooks::onThumbnailBeforeProduceHTML (   $thumbnail,
$attribs,
$linkAttribs 
)
static

Removes the responsive image's variants from the parser output if configured to do so and the thumbnail's MIME type isn't whitelisted.

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

Parameters
ThumbnailImage$thumbnail
array&$attribsThe attributes of the DOMElement being contructed to represent the thumbnail
array&$linkAttribsThe attributes of the DOMElement being constructed to represent the link to original file

◆ 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 ( $wgDefaultUserOptions)
static

Register default preferences for MobileFrontend.

Parameters
array&$wgDefaultUserOptionsReference 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.
Returns
bool

◆ 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: