return $toolbox;
}
+ /**
+ * Create an array of personal tools items from the data in the quicktemplate
+ * stored by SkinTemplate.
+ * The resulting array is built acording to a format intended to be passed
+ * through makeListItem to generate the html.
+ * This is in reality the same list as already stored in personal_urls
+ * however it is reformatted so that you can just pass the individual items
+ * to makeListItem instead of hardcoding the element creation boilerplate.
+ */
+ function getPersonalTools() {
+ $personal_tools = array();
+ foreach( $this->data['personal_urls'] as $key => $ptool ) {
+ # The class on a personal_urls item is meant to go on the <a> instead
+ # of the <li> so we have to use a single item "links" array instead
+ # of using most of the personal_url's keys directly
+ $personal_tools[$key] = array();
+ $personal_tools[$key]["links"][] = array();
+ $personal_tools[$key]["links"][0]["single-id"] = $personal_tools[$key]["id"] = "pt-$key";
+ $personal_tools[$key]["active"] = $ptool["active"];
+ foreach ( array("href", "class", "text") as $k ) {
+ if ( isset($ptool[$k]) )
+ $personal_tools[$key]["links"][0][$k] = $ptool[$k];
+ }
+ }
+ return $personal_tools;
+ }
+
/**
* Makes a link, usually used by makeListItem to generate a link for an item
* in a list used in navigation lists, portlets, portals, sidebars, etc...
// generating tooltips and accesskeys.
$link['single-id'] = $item['id'];
}
- $html = $this->makeLink( $key, $link );
+ $html = $this->makeLink( $key, $link );
}
$attrs = array();
}
}
if ( isset( $item['active'] ) && $item['active'] ) {
+ if ( !isset( $attrs['class'] ) ) {
+ $attrs['class'] = '';
+ }
$attrs['class'] .= ' active';
$attrs['class'] = trim( $attrs['class'] );
}
<h5><?php $this->msg('personaltools') ?></h5>
<div class="pBody">
<ul>
-<?php foreach($this->data['personal_urls'] as $key => $item) { ?>
- <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
- if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
- echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
- if(!empty($item['class'])) { ?> class="<?php
- echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
- echo htmlspecialchars($item['text']) ?></a></li>
-<?php } ?>
+<?php foreach($this->getPersonalTools() as $key => $item) { ?>
+ <?php echo $this->makeListItem($key, $item); ?>
+
+<?php } ?>
</ul>
</div>
</div>
<h5><?php $this->msg('personaltools') ?></h5>
<div class="pBody">
<ul<?php $this->html('userlangattributes') ?>>
-<?php foreach($this->data['personal_urls'] as $key => $item) { ?>
- <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
- if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
- echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
- if(!empty($item['class'])) { ?> class="<?php
- echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
- echo htmlspecialchars($item['text']) ?></a></li>
-<?php } ?>
+<?php foreach($this->getPersonalTools() as $key => $item) { ?>
+ <?php echo $this->makeListItem($key, $item); ?>
+
+<?php } ?>
</ul>
</div>
</div>
$this->data['view_urls'] = $nav['views'];
$this->data['action_urls'] = $nav['actions'];
$this->data['variant_urls'] = $nav['variants'];
- // Build additional attributes for personal_urls
- foreach ( $this->data['personal_urls'] as $key => $item) {
- $this->data['personal_urls'][$key]['attributes'] =
- ' id="' . Sanitizer::escapeId( "pt-$key" ) . '"';
- if ( isset( $item['active'] ) && $item['active'] ) {
- $this->data['personal_urls'][$key]['attributes'] .=
- ' class="active"';
- }
- $this->data['personal_urls'][$key]['key'] =
- $this->skin->tooltipAndAccesskey('pt-'.$key);
- }
// Reverse horizontally rendered navigation elements
if ( $wgLang->isRTL() ) {
<div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
<h5><?php $this->msg('personaltools') ?></h5>
<ul<?php $this->html('userlangattributes') ?>>
- <?php foreach($this->data['personal_urls'] as $item): ?>
- <li <?php echo $item['attributes'] ?>><a href="<?php echo htmlspecialchars($item['href']) ?>"<?php echo $item['key'] ?><?php if(!empty($item['class'])): ?> class="<?php echo htmlspecialchars($item['class']) ?>"<?php endif; ?>><?php echo htmlspecialchars($item['text']) ?></a></li>
- <?php endforeach; ?>
+<?php foreach($this->getPersonalTools() as $key => $item) { ?>
+ <?php echo $this->makeListItem($key, $item); ?>
+
+<?php } ?>
</ul>
</div>
<?php