Index: trunk/phase3/skins/Vector.php |
— | — | @@ -401,17 +401,6 @@ |
402 | 402 | $this->data['view_urls'] = $nav['views']; |
403 | 403 | $this->data['action_urls'] = $nav['actions']; |
404 | 404 | $this->data['variant_urls'] = $nav['variants']; |
405 | | - // Build additional attributes for personal_urls |
406 | | - foreach ( $this->data['personal_urls'] as $key => $item) { |
407 | | - $this->data['personal_urls'][$key]['attributes'] = |
408 | | - ' id="' . Sanitizer::escapeId( "pt-$key" ) . '"'; |
409 | | - if ( isset( $item['active'] ) && $item['active'] ) { |
410 | | - $this->data['personal_urls'][$key]['attributes'] .= |
411 | | - ' class="active"'; |
412 | | - } |
413 | | - $this->data['personal_urls'][$key]['key'] = |
414 | | - $this->skin->tooltipAndAccesskey('pt-'.$key); |
415 | | - } |
416 | 405 | |
417 | 406 | // Reverse horizontally rendered navigation elements |
418 | 407 | if ( $wgLang->isRTL() ) { |
— | — | @@ -687,9 +676,10 @@ |
688 | 677 | <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>"> |
689 | 678 | <h5><?php $this->msg('personaltools') ?></h5> |
690 | 679 | <ul<?php $this->html('userlangattributes') ?>> |
691 | | - <?php foreach($this->data['personal_urls'] as $item): ?> |
692 | | - <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> |
693 | | - <?php endforeach; ?> |
| 680 | +<?php foreach($this->getPersonalTools() as $key => $item) { ?> |
| 681 | + <?php echo $this->makeListItem($key, $item); ?> |
| 682 | + |
| 683 | +<?php } ?> |
694 | 684 | </ul> |
695 | 685 | </div> |
696 | 686 | <?php |
Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -129,14 +129,10 @@ |
130 | 130 | <h5><?php $this->msg('personaltools') ?></h5> |
131 | 131 | <div class="pBody"> |
132 | 132 | <ul<?php $this->html('userlangattributes') ?>> |
133 | | -<?php foreach($this->data['personal_urls'] as $key => $item) { ?> |
134 | | - <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php |
135 | | - if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php |
136 | | - echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php |
137 | | - if(!empty($item['class'])) { ?> class="<?php |
138 | | - echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php |
139 | | - echo htmlspecialchars($item['text']) ?></a></li> |
140 | | -<?php } ?> |
| 133 | +<?php foreach($this->getPersonalTools() as $key => $item) { ?> |
| 134 | + <?php echo $this->makeListItem($key, $item); ?> |
| 135 | + |
| 136 | +<?php } ?> |
141 | 137 | </ul> |
142 | 138 | </div> |
143 | 139 | </div> |
Index: trunk/phase3/skins/Modern.php |
— | — | @@ -154,14 +154,10 @@ |
155 | 155 | <h5><?php $this->msg('personaltools') ?></h5> |
156 | 156 | <div class="pBody"> |
157 | 157 | <ul> |
158 | | -<?php foreach($this->data['personal_urls'] as $key => $item) { ?> |
159 | | - <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php |
160 | | - if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php |
161 | | - echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php |
162 | | - if(!empty($item['class'])) { ?> class="<?php |
163 | | - echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php |
164 | | - echo htmlspecialchars($item['text']) ?></a></li> |
165 | | -<?php } ?> |
| 158 | +<?php foreach($this->getPersonalTools() as $key => $item) { ?> |
| 159 | + <?php echo $this->makeListItem($key, $item); ?> |
| 160 | + |
| 161 | +<?php } ?> |
166 | 162 | </ul> |
167 | 163 | </div> |
168 | 164 | </div> |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -1290,6 +1290,33 @@ |
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | /** |
| 1294 | + * Create an array of personal tools items from the data in the quicktemplate |
| 1295 | + * stored by SkinTemplate. |
| 1296 | + * The resulting array is built acording to a format intended to be passed |
| 1297 | + * through makeListItem to generate the html. |
| 1298 | + * This is in reality the same list as already stored in personal_urls |
| 1299 | + * however it is reformatted so that you can just pass the individual items |
| 1300 | + * to makeListItem instead of hardcoding the element creation boilerplate. |
| 1301 | + */ |
| 1302 | + function getPersonalTools() { |
| 1303 | + $personal_tools = array(); |
| 1304 | + foreach( $this->data['personal_urls'] as $key => $ptool ) { |
| 1305 | + # The class on a personal_urls item is meant to go on the <a> instead |
| 1306 | + # of the <li> so we have to use a single item "links" array instead |
| 1307 | + # of using most of the personal_url's keys directly |
| 1308 | + $personal_tools[$key] = array(); |
| 1309 | + $personal_tools[$key]["links"][] = array(); |
| 1310 | + $personal_tools[$key]["links"][0]["single-id"] = $personal_tools[$key]["id"] = "pt-$key"; |
| 1311 | + $personal_tools[$key]["active"] = $ptool["active"]; |
| 1312 | + foreach ( array("href", "class", "text") as $k ) { |
| 1313 | + if ( isset($ptool[$k]) ) |
| 1314 | + $personal_tools[$key]["links"][0][$k] = $ptool[$k]; |
| 1315 | + } |
| 1316 | + } |
| 1317 | + return $personal_tools; |
| 1318 | + } |
| 1319 | + |
| 1320 | + /** |
1294 | 1321 | * Makes a link, usually used by makeListItem to generate a link for an item |
1295 | 1322 | * in a list used in navigation lists, portlets, portals, sidebars, etc... |
1296 | 1323 | * |
— | — | @@ -1380,7 +1407,7 @@ |
1381 | 1408 | // generating tooltips and accesskeys. |
1382 | 1409 | $link['single-id'] = $item['id']; |
1383 | 1410 | } |
1384 | | - $html = $this->makeLink( $key, $link ); |
| 1411 | + $html = $this->makeLink( $key, $link ); |
1385 | 1412 | } |
1386 | 1413 | |
1387 | 1414 | $attrs = array(); |
— | — | @@ -1390,6 +1417,9 @@ |
1391 | 1418 | } |
1392 | 1419 | } |
1393 | 1420 | if ( isset( $item['active'] ) && $item['active'] ) { |
| 1421 | + if ( !isset( $attrs['class'] ) ) { |
| 1422 | + $attrs['class'] = ''; |
| 1423 | + } |
1394 | 1424 | $attrs['class'] .= ' active'; |
1395 | 1425 | $attrs['class'] = trim( $attrs['class'] ); |
1396 | 1426 | } |