* */ $wgExtensionFunctions[] = "wfUserSidebarExtension"; $wgExtensionCredits['other'][] = array( 'name' => 'UserSidebar', 'version' => '2006/05/14', 'author' => 'Austin Che', 'url' => 'http://openwetware.org/wiki/User:Austin/Extensions/UserSidebar', 'description' => 'Enable user customizable sidebars', ); function userSidebarBeforeSidebar() { global $wgMessageCache, $wgEnableSidebarCache, $wgUser; $revision = Revision::newFromTitle(Title::makeTitle(NS_USER, $wgUser->getName() . '/sidebar')); if (! $revision) return true; // no user sidebar, use site sidebar $message = $revision->getText(); if ($message) { // user has sidebar // to change the sidebar, we simply disable the use of the message cache getting // text from the database such that it instead will next try to get messages from // extensions, i.e. from addMessage() $wgMessageCache->disable(); // disable cache of sidebar $wgEnableSidebarCache = false; $wgMessageCache->addMessage('sidebar', $message); } return true; } function userSidebarAfterSidebar() { global $wgMessageCache; $wgMessageCache->enable(); return true; } function wfUserSidebarExtension() { global $wgMessageCache, $wgHooks; // these hooks were simply chosen as being the last hook before and after // the buildSidebar() call in SkinTemplate.php $wgHooks['SkinTemplateContentActions'][] = "userSidebarBeforeSidebar"; // one problem with this hook is that it's not guaranteed to always be called // if the message cache is not re-enabled or if there are calls to look up text between // these two hooks, then the database will be ignored $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = "userSidebarAfterSidebar"; } ?>