sidebars through the MediaWiki namespace.
} 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
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;
}
/**
# 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',
<h5><?php $this->msg('personaltools') ?></h5>
<div class="pBody">
<ul>
- <?php foreach($this->data['personal_urls'] as $key => $item) {
+ <?php foreach($this->data['personal_urls'] as $bar => $item) {
?><li id="pt-<?php echo htmlspecialchars($key) ?>"><a href="<?php
echo htmlspecialchars($item['href']) ?>"<?php
if(!empty($item['class'])) { ?> class="<?php
title="<?php $this->msg('mainpage') ?>"></a>
</div>
<script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
- <div class="portlet" id="p-nav">
- <h5><?php $this->msg('navigation') ?></h5>
- <div class="pBody">
- <?php echo $this->data['navigation_urls']; ?>
+ <?php foreach ($this->data['sidebar'] as $bar => $cont) { ?>
+ <div class='portlet' id='p-<?php echo htmlspecialchars($bat) ?>'>
+ <h5><?php $this->msg( $bar ) ?></h5>
+ <div class='pBody'>
+ <ul>
+ <?php foreach($cont as $key => $val) { ?>
+ <li id="<?php echo htmlspecialchars($val['href'])
+ ?>"><a href="<?php echo htmlspecialchars($val['href']) ?>"><?php
+ echo htmlspecialchars($val['text'])?></a></li><?php
+ } ?>
+ </ul>
</div>
</div>
+ <?php } ?>
<div id="p-search" class="portlet">
<h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
<div class="pBody">