From 3e7309606dbf4afe231dfdca19c4fc59e712b83e Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sat, 4 Dec 2010 20:55:23 +0000 Subject: [PATCH] Implement $wgFooterIcons to replace copyrightico and poweredbyico with a flexible list of icons that can be customized by extensions, hosting, farms, wikimedia, etc... Implementations for MonoBook, Vector, and Modern. Modern implementation uses text instead of icons as desired. --- includes/DefaultSettings.php | 19 ++++++++++++++ includes/Setup.php | 22 ++++++++++++++++ includes/SkinTemplate.php | 15 +++++++++++ skins/Modern.php | 47 ++++++++++++++++++++++----------- skins/MonoBook.php | 42 ++++++++++++++++++++++++----- skins/Vector.php | 51 +++++++++++++++++++++++++++++++----- 6 files changed, 167 insertions(+), 29 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 7ab734b33b..0dc2d9f648 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2262,6 +2262,25 @@ $wgDisableOutputCompression = false; */ $wgExperimentalHtmlIds = true; +/** + * Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code + * You can add new icons to the built in copyright or poweredby, or you can create + * a new block. Though note that you may need to add some custom css to get good styling + * of new blocks in monobook. vector and modern should work without any special css. + */ +$wgFooterIcons = array( + "copyright" => array( + "copyright" => array(), // placeholder for the built in copyright icon + ), + "poweredby" => array( + "mediawiki" => array( + "src" => null, // Defaults to "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" + "url" => "http://www.mediawiki.org/", + "alt" => "Powered by MediaWiki", + ) + ), +); + /** * Search form behavior for Vector skin only * true = use an icon search button diff --git a/includes/Setup.php b/includes/Setup.php index d78aade74a..b937c0ead8 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -63,6 +63,28 @@ if( isset( $wgFileStore['deleted']['directory'] ) ) { $wgDeletedDirectory = $wgFileStore['deleted']['directory']; } +if( isset($wgFooterIcons["copyright"]) && + isset($wgFooterIcons["copyright"]["copyright"]) && + $wgFooterIcons["copyright"]["copyright"] === array() ) { + if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) { + $wgFooterIcons["copyright"]["copyright"] = $wgCopyrightIcon; + } elseif ( $wgRightsIcon || $wgRightsText ) { + $wgFooterIcons["copyright"]["copyright"] = array( + "url" => $wgRightsUrl, + "src" => $wgRightsIcon, + "alt" => $wgRightsText, + ); + } else { + unset($wgFooterIcons["copyright"]["copyright"]); + } +} + +if( isset($wgFooterIcons["poweredby"]) && + isset($wgFooterIcons["poweredby"]["mediawiki"]) && + $wgFooterIcons["poweredby"]["mediawiki"]["src"] === null ) { + $wgFooterIcons["poweredby"]["mediawiki"]["src"] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png"; +} + /** * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure. diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 5a78f909f3..a722971239 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -425,6 +425,21 @@ class SkinTemplate extends Skin { 'disclaimer', ), ) ); + + global $wgFooterIcons; + $tpl->set( 'footericons', $wgFooterIcons ); + foreach ( $tpl->data["footericons"] as $footerIconsKey => &$footerIconsBlock ) { + if ( count($footerIconsBlock) > 0 ) { + foreach ( $footerIconsBlock as &$footerIcon ) { + if ( isset($footerIcon["src"]) ) { + if ( !isset($footerIcon["width"]) ) $footerIcon["width"] = 88; + if ( !isset($footerIcon["height"]) ) $footerIcon["height"] = 31; + } + } + } else { + unset($tpl->data["footericons"][$footerIconsKey]); + } + } if ( $wgDebugComments ) { $tpl->setRef( 'debug', $out->mDebugtext ); diff --git a/skins/Modern.php b/skins/Modern.php index c5bddc63bc..086f8bfabc 100644 --- a/skins/Modern.php +++ b/skins/Modern.php @@ -21,17 +21,6 @@ class SkinModern extends SkinTemplate { var $skinname = 'modern', $stylename = 'modern', $template = 'ModernTemplate', $useHeadElement = true; - /* - * We don't like the default getPoweredBy, the icon clashes with the - * skin L&F. - */ - function getPoweredBy() { - global $wgVersion; - $text = "
Powered by MediaWiki $wgVersion
"; - wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) ); - return $text; - } - function setupSkinUserCss( OutputPage $out ){ // Do not call parent::setupSkinUserCss(), we have our own print style $out->addStyle( 'common/shared.css', 'screen' ); @@ -63,6 +52,18 @@ class ModernTemplate extends MonoBookTemplate { // Suppress warnings to prevent notices about missing indexes in $this->data wfSuppressWarnings(); + // Generate additional footer links + $footerlinks = $this->data["footerlinks"]; + // fold footerlinks into a single array using a bit of trickery + $footerlinks = call_user_func_array('array_merge', array_values($footerlinks)); + // Generate additional footer icons + $footericons = $this->data["footericons"]; + // Unset copyright.copyright since we don't need the icon and already output a copyright from footerlinks + unset($footericons["copyright"]["copyright"]); + if ( count($footericons["copyright"]) <= 0 ) { + unset($footericons["copyright"]); + } + $this->html( 'headelement' ); ?> @@ -182,10 +183,6 @@ class ModernTemplate extends MonoBookTemplate { html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?> diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 663279aca8..e3e2e9a3b0 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -74,6 +74,22 @@ class MonoBookTemplate extends QuickTemplate { $footerlinks = $this->data["footerlinks"]; // fold footerlinks into a single array using a bit of trickery $footerlinks = call_user_func_array('array_merge', array_values($footerlinks)); + // Generate additional footer icons + $footericons = $this->data["footericons"]; + // Unset any icons which don't have an image + foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) { + foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) { + if ( !is_string($footerIcon) && !isset($footerIcon["src"]) ) { + unset($footerIconsBlock[$footerIconKey]); + } + } + } + // Redo removal of any empty blocks + foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) { + if ( count($footerIconsBlock) <= 0 ) { + unset($footericons[$footerIconsKey]); + } + } $this->html( 'headelement' ); ?>
@@ -171,12 +187,26 @@ class MonoBookTemplate extends QuickTemplate {