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

Hook handlers for MobileFrontend extension. More...

+ Inheritance diagram for MobileFrontendHooks:
+ Collaboration diagram for MobileFrontendHooks:

Public Member Functions

 onBeforeInitialize ( $title, $unused, $out, $user, $request, $mediaWiki)
 
 onMediaWikiPerformAction ( $output, $article, $title, $user, $request, $wiki)
 MediaWikiPerformAction hook handler (enable mwui for all pages)
 
 onSkinAddFooterLinks (Skin $skin, string $key, array &$footerLinks)
 Update the footer.
 
 onOutputPageBodyAttributes ( $out, $skin, &$bodyAttrs)
 Modifies the <body> element's attributes.
 
 onBeforePageRedirect ( $out, &$redirect, &$code)
 BeforePageRedirect hook handler.
 
 onDifferenceEngineViewHeader ( $diff)
 DifferenceEngineViewHeader hook handler.
 
 onResourceLoaderSiteStylesModulePages ( $skin, array &$pages)
 ResourceLoaderSiteStylesModulePages hook handler.
 
 onResourceLoaderSiteModulePages ( $skin, array &$pages)
 ResourceLoaderSiteModulePages hook handler.
 
 onGetCacheVaryCookies ( $out, &$cookies)
 GetCacheVaryCookies hook handler.
 
 onListDefinedTags (&$tags)
 ListDefinedTags hook handler.
 
 onChangeTagsListActive (&$tags)
 ChangeTagsListActive hook handler.
 
 addDefinedTags (&$tags)
 
 onRecentChange_save ( $recentChange)
 RecentChange_save hook handler that tags mobile changes.
 
 onManualLogEntryBeforePublish ( $logEntry)
 ManualLogEntryBeforePublish hook handler that tags actions logged when user uses mobile mode.
 
 onUserLoginComplete ( $currentUser, &$injected_html, $direct)
 UserLoginComplete hook handler.
 
 onBeforePageDisplay ( $out, $skin)
 BeforePageDisplay hook handler.
 
 onUserGetDefaultOptions (&$defaultUserOptions)
 Register default preferences for MobileFrontend.
 
 onGetPreferences ( $user, &$preferences)
 GetPreferences hook handler.
 
 onHTMLFileCache__useFileCache ( $context)
 HTMLFileCache::useFileCache hook handler Disables file caching for mobile pageviews.
 
 onLoginFormValidErrorMessages (array &$messages)
 LoginFormValidErrorMessages hook handler to promote MF specific error message be valid.
 
 onTitleSquidURLs ( $title, &$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.
 
 onAPIQuerySiteInfoGeneralInfo ( $module, &$result)
 Add the base mobile site URL to the siteinfo API output.
 
 onTextSlotDiffRendererTablePrefix (TextSlotDiffRenderer $textSlotDiffRenderer, IContextSource $context, array &$parts)
 @inheritDoc
 

Static Public Member Functions

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 onTaggableObjectCreation (Taggable $taggable)
 
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 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 hasEditNoticesFeatureConflict (Config $config, User $user)
 Check if a conflicting edit notices gadget is enabled for the current user.
 

Public Attributes

const MOBILE_PREFERENCES_SPECIAL_PAGES = 'mobile-specialpages'
 
const MOBILE_PREFERENCES_EDITOR = 'mobile-editor'
 
const MOBILE_PREFERENCES_FONTSIZE = 'mf-font-size'
 

Static Protected Member Functions

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

Detailed Description

Hook handlers for MobileFrontend extension.

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

◆ addDefinedTags()

MobileFrontendHooks::addDefinedTags ( & $tags)
Parameters
array&$tags

◆ 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

◆ hasEditNoticesFeatureConflict()

static MobileFrontendHooks::hasEditNoticesFeatureConflict ( Config $config,
User $user )
static

Check if a conflicting edit notices gadget is enabled for the current user.

Parameters
Config$config
User$user
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.

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

◆ onAPIQuerySiteInfoGeneralInfo()

MobileFrontendHooks::onAPIQuerySiteInfoGeneralInfo ( $module,
& $result )

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

Parameters
ApiQuerySiteinfo$module
array&$resultApi result array

◆ onBeforeInitialize()

MobileFrontendHooks::onBeforeInitialize ( $title,
$unused,
$out,
$user,
$request,
$mediaWiki )
See also
https://www.mediawiki.org/wiki/Manual:Hooks/BeforeInitialize
Parameters
Title$title
null$unused
OutputPage$out
User$user
WebRequest$request
MediaWiki$mediaWiki

◆ onBeforePageDisplay()

MobileFrontendHooks::onBeforePageDisplay ( $out,
$skin )

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()

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

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

◆ onChangeTagsListActive()

MobileFrontendHooks::onChangeTagsListActive ( & $tags)

ChangeTagsListActive hook handler.

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

◆ onDifferenceEngineViewHeader()

MobileFrontendHooks::onDifferenceEngineViewHeader ( $diff)

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()

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

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()

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

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

◆ onHTMLFileCache__useFileCache()

MobileFrontendHooks::onHTMLFileCache__useFileCache ( $context)

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

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

◆ onListDefinedTags()

MobileFrontendHooks::onListDefinedTags ( & $tags)

ListDefinedTags hook handler.

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

◆ onLoginFormValidErrorMessages()

MobileFrontendHooks::onLoginFormValidErrorMessages ( array & $messages)

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

Parameters
array&$messagesArray of already added messages

◆ onManualLogEntryBeforePublish()

MobileFrontendHooks::onManualLogEntryBeforePublish ( $logEntry)

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

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ManualLogEntryBeforePublish
Parameters
ManualLogEntry$logEntry

◆ onMediaWikiPerformAction()

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

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
WebRequest$request
MediaWiki$wiki

◆ onOutputPageBodyAttributes()

MobileFrontendHooks::onOutputPageBodyAttributes ( $out,
$skin,
& $bodyAttrs )

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

◆ onRecentChange_save()

MobileFrontendHooks::onRecentChange_save ( $recentChange)

RecentChange_save hook handler that tags mobile changes.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/RecentChange_save
Parameters
RecentChange$recentChange

◆ onResourceLoaderSiteModulePages()

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

ResourceLoaderSiteModulePages hook handler.

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

◆ onResourceLoaderSiteStylesModulePages()

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

ResourceLoaderSiteStylesModulePages hook handler.

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

◆ onSkinAddFooterLinks()

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

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
Parameters
Taggable$taggableObject to tag

◆ onTitleSquidURLs()

MobileFrontendHooks::onTitleSquidURLs ( $title,
& $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.

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

◆ onUserGetDefaultOptions()

MobileFrontendHooks::onUserGetDefaultOptions ( & $defaultUserOptions)

Register default preferences for MobileFrontend.

Parameters
array&$defaultUserOptionsReference to default options array

◆ onUserLoginComplete()

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

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.
bool$direct

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