From: Ævar Arnfjörð Bjarmason Date: Tue, 24 May 2005 20:06:52 +0000 (+0000) Subject: * (bug 419, 1764) Using a custom syntax for the sidebar and supporting multiple X-Git-Tag: 1.5.0alpha2~95 X-Git-Url: https://git.cyclocoop.org/admin/%7B%7Blocalurl:Special:UserLogin%7D%7D?a=commitdiff_plain;h=d23c84fbf9271bb4b91f6d39c04791f3ba37e8d3;p=lhc%2Fweb%2Fwiklou.git * (bug 419, 1764) Using a custom syntax for the sidebar and supporting multiple sidebars through the MediaWiki namespace. --- diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 8c62be4698..eae160d016 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -383,7 +383,7 @@ class SkinTemplate extends Skin { } else { $tpl->set( 'body_onload', false ); } - $tpl->set( 'navigation_urls', $this->getNavigationLinks() ); + $tpl->set( 'sidebar', $this->buildSidebar() ); $tpl->set( 'nav_urls', $this->buildNavUrls() ); // execute template @@ -704,15 +704,37 @@ class SkinTemplate extends Skin { return $content_actions; } - function getNavigationLinks() { - global $wgOut; - $fname = 'SkinTemplate::getNavigationLinks'; + /** + * Build an array that represents the sidebar(s), the navigation bar among them + * + * @return array + * @access private + */ + function buildSidebar() { + $fname = 'SkinTemplate::buildSidebar'; wfProfileIn( $fname ); - $parsed = $wgOut->parse( wfMsgForContent( 'navbar' ) ); + $lines = explode( "\n", wfMsgForContent( 'sidebar' ) ); + foreach ($lines as $line) { + if (strpos($line, '*') !== 0) + continue; + if (strpos($line, '**') !== 0) { + $line = trim($line, '* '); + $heading = $line; + } else { + if (strpos($line, '|') !== false) { // sanity check + $line = explode( '|' , trim($line, '* '), 2 ); + $bar[$heading][] = array( + 'text' => wfMsg( $line[1] ), + 'href' => $this->makeInternalOrExternalUrl( wfMsgForContent( $line[0] ) ), + 'id' => 'n-' . $line[1], + ); + } else { continue; } + } + } wfProfileOut( $fname ); - return $parsed; + return $bar; } /** diff --git a/languages/Language.php b/languages/Language.php index 59ec85e4e2..107d7b8116 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -254,14 +254,22 @@ global $wgRightsText; # The navigation toolbar, int: is used here to make sure that the appropriate # messages are automatically pulled from the user-selected language file. -'navbar' =>' -* [[{{msg:mainpage}}|{{int:mainpage}}]] -* [[{{msg:portal-url}}|{{int:portal}}]] -* [[{{msg:currentevents-url}}|{{int:currentevents}}]] -* [[{{msg:recentchanges-url}}|{{int:recentchanges}}]] -* [[{{msg:randompage-url}}|{{int:randompage}}]] -* [[{{msg:helppage}}|{{int:help}}]] -* [[{{msg:sitesupport-url}}|{{int:sitesupport}}]]', + +'sidebar' => " +This is the markup that's parsed when the sidebar(s) are generated, lines that +do not begin with * or ** are automatically discarded. + +Only put [a-z-] in the level one headings since it will be used as an XHMTL id. + +* navigation +** mainpage|mainpage +** portal-url|portal +** currentevents-url|currentevents +** recentchanges-url|recentchanges +** randompage-url|randompage +** helppage|help +** sitesupport-url|sitesupport +", # User preference toggles 'tog-underline' => 'Underline links', diff --git a/skins/MonoBook.php b/skins/MonoBook.php index b021999351..66eee2eae7 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -107,7 +107,7 @@ class MonoBookTemplate extends QuickTemplate {
msg('personaltools') ?>
-
-
msg('navigation') ?>
-
- data['navigation_urls']; ?> + data['sidebar'] as $bar => $cont) { ?> +
+
msg( $bar ) ?>
+
+
    + $val) { ?> +
  • +
+