From 74370b6703382af2d35d9154188f35b3494f07b1 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Fri, 1 Aug 2008 14:40:05 +0000 Subject: [PATCH] New hook SkinBuildSidebar to allow extensions to modify the sidebar to do things like adding custom portlets. --- RELEASE-NOTES | 2 ++ docs/hooks.txt | 5 +++++ includes/Skin.php | 9 +++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3a660559ee..f5a74f8569 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -38,6 +38,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN if they ran roughly the same code for both hooks (as is almost certain). * Signature (~~~~) "cleaning", i.e. template removal, can be disabled with $wgCleanSignatures=false +* Extensions can use the SkinBuildSidebar hook to modify the content of the + sidebar and add custom portlets to it === Bug fixes in 1.14 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 98ceb42681..491b21138e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1057,6 +1057,11 @@ $skin: Skin object &$text: bottomScripts Text Append to $text to add additional text/scripts after the stock bottom scripts. +'SkinBuildSidebar': At the end of Skin::buildSidebar() +$skin: Skin object +&$bar: Sidebar contents +Modify $bar to add or modify sidebar portlets. + 'SkinSubPageSubtitle': At the beginning of Skin::subPageSubtitle() $skin: Skin object &$subpages: Subpage links HTML diff --git a/includes/Skin.php b/includes/Skin.php index 58a4881d6b..87d002bf19 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1681,12 +1681,8 @@ END; continue; if (strpos($line, '**') !== 0) { $line = trim($line, '* '); - if ( $line == 'SEARCH' || $line == 'TOOLBOX' || $line == 'LANGUAGES' ) { - # Special box type - $bar[$line] = array(); - } else { - $heading = $line; - } + $heading = $line; + if( !array_key_exists($heading, $bar) ) $bar[$heading] = array(); } else { if (strpos($line, '|') !== false) { // sanity check $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) ); @@ -1719,6 +1715,7 @@ END; } else { continue; } } } + wfRunHooks('SkinBuildSidebar', array($skin, &$bar)); if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry ); wfProfileOut( __METHOD__ ); return $bar; -- 2.20.1