When we introduce a SkinMustache class ideally it would subclass Skin rather than SkinTemplate but to make its introduction easier we made it extend SkinTemplate. After seeing how this class has grown, the class inheritance is correct but SkinTemplate carries a lot of QuickTemplate specific code that should be factored out.
To avoid having an unreadable 3000 line class, we will take the opportunity to reorganize the skin code. We will introduce a SkinComponent interface which will have one abstract method getTemplateData that returns template data. This will allow us to reason about certain parts of skin code more intuitively ie. if we need to modify the data sent to the footer template, the SkinComponentFooter will contain all the information we need.
These classes will be marked as @unstable to allow us to tweak emergent refactors. For example in future the SkinComponentFooter may be merged into a generic SkinComponentMenu
In the long long term future, it's imagined that skins/extensions will be able to define their own components and skins can choose which components to render, but this is out of scope for this inital work.
# Acceptance criteria
[x] Skin::getFooterLinks is promoted from SkinTemplate.php to Skin.php. The hook SkinAddFooterLinks is not impacted by this move as it already uses the skin and currently only lives in that class for compatibility reasons.
[] A QuickTemplate::setAll method is added to allow passing of data in the form of an array, to the set methods in QuickTemplate
- [x] SkinMustache methods are promoted to SkinTemplate: getFooterTemplateData, getLogoData, buildSearchProps, getPortletsTemplateData, getPortletData, getPortletLabel
- [x] SkinMustache::tailElement is generalized and moved to OutputPage T257704
- [] The following methods will be pulled out into a SkinMenuDirector which will be in charge of managing the menu data passed to skinromoted from SkinTemplate to Skin:
-- [] getJsConfigVars
-- [] wrapHTML
-- [] prepareUndeleteLink
-- [] prepareUserLanguageAttributes
- [] A SkinComponent interface will be created. To begin with we will create the SkinComponentSearch https://gerrit.wikimedia.org/r/c/mediawiki/core/+/730618
-- [] The methods makeSearchButton, getSearchPageTitle and setSearchPageTitle will be moved from Skin.php to SkinComponentSearch. The existing methods will be deprecated if not used, or make use of the new classes.
-- [] The method buildSearchProps will be moved from SkinTemplate to SkinComponentSearch
-- [] Skin::getTemplateData will be created. SkinTemplate::getTemplateData will call parent.
-- [] Existing protected/public methods will continue to exist for backwards compatibility.
- [] The SkinComponentFooter component will be created
-- [] The private getFooterTemplateData and protected getFooterItems will be moved to a SkinComponentFooter class. This will be good ground work for improving the menu system in T272624 and will make the Skin more readable.Skin::getFooterItems will be kept for backwards compatibility and use SkinComponentFooter
-- [] Skin::getFooterLinks,getCopyright, Existing SkinTemplate methods will be modified to use the MenuDirector and promoted to Skin where needed:getSiteFooterLinks will use the new SkinComponentFooter class
- [] The SkinComponentLogo component will be created.
-- [] The private getLogoData method will be moved to a SkinComponentLogo class.
- [] Menu generation will be moved into components
-- [] The SkinComponentSidebar component will be created.
-- [] The SkinComponentPortlets component will be created.
-- [] The following methods will be moved to the relevant SkinComponent classes.
-- [] getPortletsTemplateData
-- [] buildContentNavigationUrls
-- [] buildPersonalPageItem
-- [] buildPersonalUrls
-- [] getReturnToParam
-- [] makeTalkUrlDetails
-- [] buildLogoutLinkData
-- [] buildLoginData
-- [] tabAction
-- [] getWatchLinkAttrs
-- [] runOnSkinTemplateNavigationHooks
-- [] useCombinedLoginLink
-- [] buildCreateAccountData
-- [] injectLegacyMenusIntoPersonalTools
- [] The parts of setupTemplateContext() that relate to Skin should be upstreamed to the Skin method. SkinTemplate should call parent.
- [] The following methods should be promoted from SkinTemplate to Skin:
-- [] getJsConfigVars
-- [] getTemplateData
-- [] buildSearchProps
-- [] getLogoData
-- [] getPortletData
-- [] getPortletLabel
-- [] getFooterTemplateData
-- [] getFooterIcons
-- [] wrapHTML
-- [] prepareUndeleteLink
-- [] prepareUserLanguageAttributesinjectLegacyMenusIntoPersonalTools
- [] The parts of setupTemplateContext() that relate to Skin should be upstreamed to the Skin method. SkinTemplate should call parent.
# Notes about hooks:
- [] Callers to the SkinTemplateNavigationUniversal hook should be modified to take the more generic Skin as a parameter (CologneBlue, MonoBook, ULS).
- [] Callers to the SkinMinervaOptionsInit hook should be modified to take the more generic Skin as a parameter.
- [] Skin::outputPage should no longer be abstract. The method in SkinTemplate should be copied to Skin.
- [] Callers of Skin::runOnSkinTemplateNavigationHooks and SkinTemplateNavigation__Universal should be modified to expect a Skin rather than SkinTemplate class (VisualEditor, Vector)
- [] Callers of the PersonalUrls hook must be modified to expect an instance of Skin rather than SkinTemplate e.g. https://gerrit.wikimedia.org/g/mediawiki/extensions/BetaFeatures/+/101ac03487f86d3b72b4953c54e677c7d4877a9d/includes/Hooks.php#355
-- [] SkinTemplate::prepareQuickTemplate should be modified to make use of Skin::getTemplateData where possible.
- [] SkinMustache extends Skin rather than SkinTemplate