New hook SkinBuildSidebar to allow extensions to modify the sidebar to do things...
authorDaniel Friesen <dantman@users.mediawiki.org>
Fri, 1 Aug 2008 14:40:05 +0000 (14:40 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Fri, 1 Aug 2008 14:40:05 +0000 (14:40 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/Skin.php

index 3a66055..f5a74f8 100644 (file)
@@ -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 ===
 
index 98ceb42..491b211 100644 (file)
@@ -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
index 58a4881..87d002b 100644 (file)
@@ -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;