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

 __construct (HookContainer $hookContainer, Config $config, SkinFactory $skinFactory, UserOptionsLookup $userOptionsLookup, WatchlistManager $watchlistManager, MobileContext $mobileContext, FeaturesManager $featuresManager, ?GadgetRepo $gadgetRepo)
 
 onRequestContextCreateSkin ( $context, &$skin)
 RequestContextCreateSkin hook handler.
 
 onSkinAddFooterLinks (Skin $skin, string $key, array &$footerLinks)
 Update the footer.
 
 onSkinAfterBottomScripts ( $skin, &$html)
 SkinAfterBottomScripts hook handler.
 
 onBeforeDisplayNoArticleText ( $article)
 BeforeDisplayNoArticleText hook handler.
 
 onOutputPageBeforeHTML ( $out, &$text)
 OutputPageBeforeHTML hook handler.
 
 onBeforePageRedirect ( $out, &$redirect, &$code)
 BeforePageRedirect hook handler.
 
 onMediaWikiPerformAction ( $output, $article, $title, $user, $request, $entryPoint)
 MediaWikiPerformActionHook hook handler.
 
 onResourceLoaderSiteStylesModulePages ( $skin, array &$pages)
 ResourceLoaderSiteStylesModulePages hook handler.
 
 onResourceLoaderSiteModulePages ( $skin, array &$pages)
 ResourceLoaderSiteModulePages hook handler.
 
 onGetCacheVaryCookies ( $out, &$cookies)
 GetCacheVaryCookies hook handler.
 
 shouldMobileFormatSpecialPages ( $user)
 Should special pages be replaced with mobile formatted equivalents?
 
 onSpecialPage_initList (&$list)
 Hook for SpecialPage_initList in SpecialPageFactory.
 
 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.
 
 onSpecialPageBeforeExecute ( $special, $subpage)
 Invocation of hook SpecialPageBeforeExecute.
 
 onPostLoginRedirect (&$returnTo, &$returnToQuery, &$type)
 PostLoginRedirect hook handler.
 
 onAfterBuildFeedLinks (&$tags)
 AfterBuildFeedLinks hook handler.
 
 onUserGetDefaultOptions (&$defaultUserOptions)
 Register default preferences for MobileFrontend.
 
 onGetPreferences ( $user, &$preferences)
 GetPreferences hook handler.
 
 onOutputPageParserOutput ( $outputPage, $po)
 OutputPageParserOutput hook handler.
 
 onArticleParserOptions (Article $article, ParserOptions $parserOptions)
 ArticleParserOptions 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 wgMobileUrlCallback, so that both mobile and non-mobile URL variants get purged.
 
 onAuthChangeFormFields ( $requests, $fieldInfo, &$formDescriptor, $action)
 Handler for the AuthChangeFormFields hook to add a logo on top of the login screen.
 
 onAPIQuerySiteInfoGeneralInfo ( $module, &$result)
 Add the base mobile site URL to the siteinfo API output.
 

Static Public Member Functions

static getResourceLoaderMFConfigVars ()
 Generate config for usage inside MobileFrontend This should be used for variables which:
 
static onAbuseFilterBuilder (&$builder)
 AbuseFilter-builder hook handler that adds user_mobile variable to list of valid vars.
 
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.
 

Public Attributes

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

Protected Member Functions

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

MobileFrontendHooks::getDefaultMobileSkin ( )
protected

Obtain the default mobile skin.

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.

◆ onAfterBuildFeedLinks()

MobileFrontendHooks::onAfterBuildFeedLinks ( & $tags)

AfterBuildFeedLinks hook handler.

Remove all feed links in mobile view.

Parameters
array&$tagsAdded feed links

◆ onAPIQuerySiteInfoGeneralInfo()

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

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

Parameters
ApiQuerySiteinfo$module
array&$resultApi result array

◆ onArticleParserOptions()

MobileFrontendHooks::onArticleParserOptions ( Article $article,
ParserOptions $parserOptions )

ArticleParserOptions hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ArticleParserOptions
Parameters
Article$article
ParserOptions$parserOptions

◆ onAuthChangeFormFields()

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

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

◆ onBeforeDisplayNoArticleText()

MobileFrontendHooks::onBeforeDisplayNoArticleText ( $article)

BeforeDisplayNoArticleText hook handler.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/BeforeDisplayNoArticleText
Parameters
Article$articleThe (empty) article
Returns
bool This hook can abort

◆ 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

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

◆ 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,
$entryPoint )

MediaWikiPerformActionHook hook handler.

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

Set Diff page to diff-only mode for mobile view

Parameters
OutputPage$outputContext output
Article$articleArticle on which the action will be performed
Title$titleTitle on which the action will be performed
User$userContext user
WebRequest$requestContext request
ActionEntryPoint$entryPoint
Returns
bool|void True or no return value to continue or false to abort

◆ onOutputPageBeforeHTML()

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

OutputPageBeforeHTML hook handler.

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

Applies MobileFormatter to mobile viewed content

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

◆ onOutputPageParserOutput()

MobileFrontendHooks::onOutputPageParserOutput ( $outputPage,
$po )

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

◆ onPostLoginRedirect()

MobileFrontendHooks::onPostLoginRedirect ( & $returnTo,
& $returnToQuery,
& $type )

PostLoginRedirect hook handler.

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

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

@inheritDoc

◆ 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

◆ onRequestContextCreateSkin()

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

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

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

◆ onSkinAfterBottomScripts()

MobileFrontendHooks::onSkinAfterBottomScripts ( $skin,
& $html )

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.

◆ onSpecialPage_initList()

MobileFrontendHooks::onSpecialPage_initList ( & $list)

Hook for SpecialPage_initList in SpecialPageFactory.

Parameters
array&$listlist of special page classes

◆ onSpecialPageBeforeExecute()

MobileFrontendHooks::onSpecialPageBeforeExecute ( $special,
$subpage )

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

◆ onTitleSquidURLs()

MobileFrontendHooks::onTitleSquidURLs ( $title,
& $urls )

Handler for TitleSquidURLs hook to add copies of the cache purge URLs which are transformed according to the wgMobileUrlCallback, 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

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