Index: trunk/extensions/DynamicSidebar/DynamicSidebar.body.php |
— | — | @@ -26,27 +26,34 @@ |
27 | 27 | global $wgDynamicSidebarUseGroups, $wgDynamicSidebarUseUserpages; |
28 | 28 | global $wgDynamicSidebarUseCategories; |
29 | 29 | |
30 | | - if ( $wgDynamicSidebarUseGroups ) { |
31 | | - $sidebar = preg_replace_callback( '/\* GROUP-SIDEBAR/', array( 'self', 'doGroupSidebar' ), $sidebar ); |
| 30 | + if ( $wgDynamicSidebarUseGroups && isset( $sidebar['GROUP-SIDEBAR'] ) ) { |
| 31 | + // Replace the GROUP-SIDEBAR entry with the group's sidebar |
| 32 | + $groupSB = array(); |
| 33 | + $skin->addToSidebarPlain( $groupSB, self::doGroupSidebar() ); |
| 34 | + array_splice( $sidebar, array_search( 'GROUP-SIDEBAR', $sidebar ), 1, $groupSB ); |
32 | 35 | } |
33 | | - if ( $wgDynamicSidebarUseUserpages ) { |
34 | | - $sidebar = preg_replace_callback( '/\* USER-SIDEBAR/', array( 'self', 'doUserSidebar' ), $sidebar ); |
| 36 | + if ( $wgDynamicSidebarUseUserpages && isset( $sidebar['USER-SIDEBAR'] ) ) { |
| 37 | + // Replace the USER-SIDEBAR entry with the user's sidebar |
| 38 | + $userSB = array(); |
| 39 | + $skin->addToSidebarPlain( $userSB, self::doUserSidebar() ); |
| 40 | + array_splice( $sidebar, array_search( 'USER-SIDEBAR', $sidebar ), 1, $userSB ); |
35 | 41 | } |
36 | | - if ( $wgDynamicSidebarUseCategories ) { |
37 | | - $sidebar = preg_replace_callback( '/\* CATEGORY-SIDEBAR/', array( 'self', 'doCategorySidebar' ), $sidebar ); |
| 42 | + if ( $wgDynamicSidebarUseCategories && isset( $sidebar['CATEGORY-SIDEBAR'] ) ) { |
| 43 | + $catSB = array(); |
| 44 | + $skin->addToSidebarPlain( $catSB, self::doCategorySidebar() ); |
| 45 | + array_splice( $sidebar, array_search( 'CATEGORY-SIDEBAR', $sidebar ), 1, $catSB ); |
38 | 46 | } |
39 | 47 | return true; |
40 | 48 | } |
41 | 49 | |
42 | 50 | /** |
43 | | - * Callback function, replaces $matches with the contents of |
| 51 | + * Grabs the sidebar for the current user |
44 | 52 | * User:<username>/Sidebar |
45 | 53 | * |
46 | | - * @param array $matches unused |
47 | 54 | * @access private |
48 | 55 | * @return string |
49 | 56 | */ |
50 | | - private static function doUserSidebar( $matches ) { |
| 57 | + private static function doUserSidebar() { |
51 | 58 | global $wgUser; |
52 | 59 | $username = $wgUser->getName(); |
53 | 60 | |
— | — | @@ -62,11 +69,8 @@ |
63 | 70 | } |
64 | 71 | |
65 | 72 | /** |
66 | | - * Callback function, replaces $matches with the contents of |
67 | | - * MediaWiki:Sidebar/<group>, based on the current logged in user's |
68 | | - * groups. |
| 73 | + * Grabs the sidebar for the current user's groups |
69 | 74 | * |
70 | | - * @param array $matches unused |
71 | 75 | * @access private |
72 | 76 | * @return string |
73 | 77 | */ |
— | — | @@ -97,11 +101,8 @@ |
98 | 102 | } |
99 | 103 | |
100 | 104 | /** |
101 | | - * Callback function, replaces $matches with the contents of |
102 | | - * MediaWiki:Sidebar/<category>, based on the current logged in user's |
103 | | - * userpage categories. |
| 105 | + * Grabs the sidebar for the current user's categories |
104 | 106 | * |
105 | | - * @param array $matches unused |
106 | 107 | * @access private |
107 | 108 | * @return string |
108 | 109 | */ |
Index: trunk/extensions/DynamicSidebar/DynamicSidebar.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | ); |
41 | 41 | |
42 | 42 | $wgExtensionFunctions[] = 'DynamicSidebar::setup'; |
43 | | -$wgHooks['SkinBeforeParseSidebar'][] = 'DynamicSidebar::modifySidebar'; |
| 43 | +$wgHooks['SkinBuildSidebar'][] = 'DynamicSidebar::modifySidebar'; |
44 | 44 | |
45 | 45 | $dir = dirname( __FILE__ ) . '/'; |
46 | 46 | $wgAutoloadClasses['DynamicSidebar'] = $dir . 'DynamicSidebar.body.php'; |