From e0224b8f4b2f6f2efdc5fa0c435181e76fa30824 Mon Sep 17 00:00:00 2001 From: Clare Ming Date: Mon, 12 Sep 2022 00:27:05 -0600 Subject: [PATCH] Move SkinTemplate::getFooterIcons() to Skin class - Changing access modifier from protected to public in order to call this method from the SkinComponentFooter class which is introduced in a follow up commit. Bug: T302116 Change-Id: If06112d72ef19001ca5673cf0329fca071384ffe --- includes/skins/Skin.php | 45 +++++++++++++++++++++++++++++++++ includes/skins/SkinTemplate.php | 44 -------------------------------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index c1dc93e525d..143928edcab 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -963,6 +963,51 @@ abstract class Skin extends ContextSource { return ""; } + /** + * Get template representation of the footer. + * @since 1.35 + * @stable to override + * @return array + */ + public function getFooterIcons() { + $config = $this->getConfig(); + + $footericons = []; + foreach ( + $config->get( MainConfigNames::FooterIcons ) as $footerIconsKey => &$footerIconsBlock + ) { + if ( count( $footerIconsBlock ) > 0 ) { + $footericons[$footerIconsKey] = []; + foreach ( $footerIconsBlock as &$footerIcon ) { + if ( isset( $footerIcon['src'] ) ) { + if ( !isset( $footerIcon['width'] ) ) { + $footerIcon['width'] = 88; + } + if ( !isset( $footerIcon['height'] ) ) { + $footerIcon['height'] = 31; + } + } + + // Only output icons which have an image. + // For historic reasons this mimics the `icononly` option + // for BaseTemplate::getFooterIcons. + // In some cases the icon may be an empty array. + // Filter these out. (See T269776) + if ( is_string( $footerIcon ) || isset( $footerIcon['src'] ) ) { + $footericons[$footerIconsKey][] = $footerIcon; + } + } + + // If no valid icons with images were added, unset the parent array + // Should also prevent empty arrays from when no copyright is set. + if ( !count( $footericons[$footerIconsKey] ) ) { + unset( $footericons[$footerIconsKey] ); + } + } + } + return $footericons; + } + /** * Renders a $wgFooterIcons icon according to the method's arguments * @param array $icon The icon to build the html for, see $wgFooterIcons diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 1606f996f1e..52576f6a27b 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -177,50 +177,6 @@ class SkinTemplate extends Skin { echo $this->generateHTML(); } - /** - * Get template representation of the footer. - * @since 1.35 - * @return array - */ - protected function getFooterIcons() { - $config = $this->getConfig(); - - $footericons = []; - foreach ( - $config->get( MainConfigNames::FooterIcons ) as $footerIconsKey => &$footerIconsBlock - ) { - if ( count( $footerIconsBlock ) > 0 ) { - $footericons[$footerIconsKey] = []; - foreach ( $footerIconsBlock as &$footerIcon ) { - if ( isset( $footerIcon['src'] ) ) { - if ( !isset( $footerIcon['width'] ) ) { - $footerIcon['width'] = 88; - } - if ( !isset( $footerIcon['height'] ) ) { - $footerIcon['height'] = 31; - } - } - - // Only output icons which have an image. - // For historic reasons this mimics the `icononly` option - // for BaseTemplate::getFooterIcons. - // In some cases the icon may be an empty array. - // Filter these out. (See T269776) - if ( is_string( $footerIcon ) || isset( $footerIcon['src'] ) ) { - $footericons[$footerIconsKey][] = $footerIcon; - } - } - - // If no valid icons with images were added, unset the parent array - // Should also prevent empty arrays from when no copyright is set. - if ( !count( $footericons[$footerIconsKey] ) ) { - unset( $footericons[$footerIconsKey] ); - } - } - } - return $footericons; - } - /** * @inheritDoc */