Index: trunk/phase3/skins/Vector.php |
— | — | @@ -411,37 +411,6 @@ |
412 | 412 | $this->skin->tooltipAndAccesskey('pt-'.$key); |
413 | 413 | } |
414 | 414 | |
415 | | - // Generate additional footer links |
416 | | - $footerlinks = $this->data["footerlinks"]; |
417 | | - |
418 | | - // Reduce footer links down to only those which are being used |
419 | | - $validFooterLinks = array(); |
420 | | - foreach( $footerlinks as $category => $links ) { |
421 | | - $validFooterLinks[$category] = array(); |
422 | | - foreach( $links as $link ) { |
423 | | - if( isset( $this->data[$link] ) && $this->data[$link] ) { |
424 | | - $validFooterLinks[$category][] = $link; |
425 | | - } |
426 | | - } |
427 | | - } |
428 | | - |
429 | | - // Generate additional footer icons |
430 | | - $footericons = $this->data["footericons"]; |
431 | | - // Unset any icons which don't have an image |
432 | | - foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) { |
433 | | - foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) { |
434 | | - if ( !is_string($footerIcon) && !isset($footerIcon["src"]) ) { |
435 | | - unset($footerIconsBlock[$footerIconKey]); |
436 | | - } |
437 | | - } |
438 | | - } |
439 | | - // Redo removal of any empty blocks |
440 | | - foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) { |
441 | | - if ( count($footerIconsBlock) <= 0 ) { |
442 | | - unset($footericons[$footerIconsKey]); |
443 | | - } |
444 | | - } |
445 | | - |
446 | 415 | // Reverse horizontally rendered navigation elements |
447 | 416 | if ( $wgLang->isRTL() ) { |
448 | 417 | $this->data['view_urls'] = |
— | — | @@ -533,18 +502,15 @@ |
534 | 503 | <!-- /panel --> |
535 | 504 | <!-- footer --> |
536 | 505 | <div id="footer"<?php $this->html('userlangattributes') ?>> |
537 | | - <?php foreach( $validFooterLinks as $category => $links ): ?> |
538 | | - <?php if ( count( $links ) > 0 ): ?> |
| 506 | + <?php foreach( $this->getFooterLinks() as $category => $links ): ?> |
539 | 507 | <ul id="footer-<?php echo $category ?>"> |
540 | 508 | <?php foreach( $links as $link ): ?> |
541 | | - <?php if( isset( $this->data[$link] ) && $this->data[$link] ): ?> |
542 | 509 | <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li> |
543 | | - <?php endif; ?> |
544 | 510 | <?php endforeach; ?> |
545 | 511 | </ul> |
546 | | - <?php endif; ?> |
547 | 512 | <?php endforeach; ?> |
548 | | -<?php if ( count( $footericons ) > 0 ): ?> |
| 513 | + <?php $footericons = $this->getFooterIcons("icononly"); |
| 514 | + if ( count( $footericons ) > 0 ): ?> |
549 | 515 | <ul id="footer-icons" class="noprint"> |
550 | 516 | <?php foreach ( $footericons as $blockName => $footerIcons ): ?> |
551 | 517 | <li id="footer-<?php echo htmlspecialchars($blockName); ?>ico"> |
Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -70,10 +70,6 @@ |
71 | 71 | // Suppress warnings to prevent notices about missing indexes in $this->data |
72 | 72 | wfSuppressWarnings(); |
73 | 73 | |
74 | | - // Generate additional footer links |
75 | | - $footerlinks = $this->data["footerlinks"]; |
76 | | - // fold footerlinks into a single array using a bit of trickery |
77 | | - $footerlinks = call_user_func_array('array_merge', array_values($footerlinks)); |
78 | 74 | // Generate additional footer icons |
79 | 75 | $footericons = $this->data["footericons"]; |
80 | 76 | // Unset any icons which don't have an image |
— | — | @@ -198,19 +194,14 @@ |
199 | 195 | <?php } |
200 | 196 | |
201 | 197 | // Generate additional footer links |
202 | | - $validFooterLinks = array(); |
203 | | - foreach( $footerlinks as $aLink ) { |
204 | | - if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { |
205 | | - $validFooterLinks[] = $aLink; |
206 | | - } |
207 | | - } |
| 198 | + $validFooterLinks = $this->getFooterLinks("flat"); |
208 | 199 | if ( count( $validFooterLinks ) > 0 ) { |
209 | 200 | ?> <ul id="f-list"> |
210 | 201 | <?php |
211 | | - foreach( $validFooterLinks as $aLink ) { |
212 | | - if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { |
213 | | -?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li> |
214 | | -<?php } |
| 202 | + foreach( $validFooterLinks as $aLink ) { ?> |
| 203 | + <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li> |
| 204 | + |
| 205 | +<?php |
215 | 206 | } |
216 | 207 | ?> |
217 | 208 | </ul> |
Index: trunk/phase3/skins/Modern.php |
— | — | @@ -52,18 +52,6 @@ |
53 | 53 | // Suppress warnings to prevent notices about missing indexes in $this->data |
54 | 54 | wfSuppressWarnings(); |
55 | 55 | |
56 | | - // Generate additional footer links |
57 | | - $footerlinks = $this->data["footerlinks"]; |
58 | | - // fold footerlinks into a single array using a bit of trickery |
59 | | - $footerlinks = call_user_func_array('array_merge', array_values($footerlinks)); |
60 | | - // Generate additional footer icons |
61 | | - $footericons = $this->data["footericons"]; |
62 | | - // Unset copyright.copyright since we don't need the icon and already output a copyright from footerlinks |
63 | | - unset($footericons["copyright"]["copyright"]); |
64 | | - if ( count($footericons["copyright"]) <= 0 ) { |
65 | | - unset($footericons["copyright"]); |
66 | | - } |
67 | | - |
68 | 56 | $this->html( 'headelement' ); |
69 | 57 | ?> |
70 | 58 | |
— | — | @@ -183,7 +171,7 @@ |
184 | 172 | <div id="footer"<?php $this->html('userlangattributes') ?>> |
185 | 173 | <ul id="f-list"> |
186 | 174 | <?php |
187 | | - foreach( $footerlinks as $aLink ) { |
| 175 | + foreach( $this->getFooterLinks("flat") as $aLink ) { |
188 | 176 | if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) { |
189 | 177 | ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li> |
190 | 178 | <?php } |
— | — | @@ -191,7 +179,7 @@ |
192 | 180 | ?> |
193 | 181 | </ul> |
194 | 182 | <?php |
195 | | - foreach ( $footericons as $blockName => $footerIcons ) { ?> |
| 183 | + foreach ( $this->getFooterIcons("nocopyright") as $blockName => $footerIcons ) { ?> |
196 | 184 | <div id="mw_<?php echo htmlspecialchars($blockName); ?>"> |
197 | 185 | <?php |
198 | 186 | foreach ( $footerIcons as $icon ) { ?> |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -1394,5 +1394,78 @@ |
1395 | 1395 | } |
1396 | 1396 | } |
1397 | 1397 | |
| 1398 | + /** |
| 1399 | + * Returns an array of footerlinks trimmed down to only those footer links that |
| 1400 | + * are valid. |
| 1401 | + * If you pass "flat" as an option then the returned array will be a flat array |
| 1402 | + * of footer icons instead of a key/value array of footerlinks arrays broken |
| 1403 | + * up into categories. |
| 1404 | + */ |
| 1405 | + function getFooterLinks($option = null) { |
| 1406 | + $footerlinks = $this->data["footerlinks"]; |
| 1407 | + |
| 1408 | + // Reduce footer links down to only those which are being used |
| 1409 | + $validFooterLinks = array(); |
| 1410 | + foreach( $footerlinks as $category => $links ) { |
| 1411 | + $validFooterLinks[$category] = array(); |
| 1412 | + foreach( $links as $link ) { |
| 1413 | + if( isset( $this->data[$link] ) && $this->data[$link] ) { |
| 1414 | + $validFooterLinks[$category][] = $link; |
| 1415 | + } |
| 1416 | + } |
| 1417 | + if ( count( $validFooterLinks[$category] ) <= 0 ) { |
| 1418 | + unset($validFooterLinks[$category]); |
| 1419 | + } |
| 1420 | + } |
| 1421 | + |
| 1422 | + if ( $option == "flat" ) { |
| 1423 | + // fold footerlinks into a single array using a bit of trickery |
| 1424 | + $validFooterLinks = call_user_func_array('array_merge', array_values($validFooterLinks)); |
| 1425 | + } |
| 1426 | + |
| 1427 | + return $validFooterLinks; |
| 1428 | + } |
| 1429 | + |
| 1430 | + /** |
| 1431 | + * Returns an array of footer icons filtered down by options relevant to how |
| 1432 | + * the skin wishes to display them. |
| 1433 | + * If you pass "icononly" as the option all footer icons which do not have an |
| 1434 | + * image icon set will be filtered out. |
| 1435 | + * If you pass "nocopyright" then MediaWiki's copyright icon will not be included |
| 1436 | + * in the list of footer icons. This is mostly useful for skins which only |
| 1437 | + * display the text from footericons instead of the images and don't want a |
| 1438 | + * duplicate copyright statement because footerlinks already rendered one. |
| 1439 | + */ |
| 1440 | + function getFooterIcons($option = null) { |
| 1441 | + // Generate additional footer icons |
| 1442 | + $footericons = $this->data["footericons"]; |
| 1443 | + |
| 1444 | + if ( $option == "icononly" ) { |
| 1445 | + // Unset any icons which don't have an image |
| 1446 | + foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) { |
| 1447 | + foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) { |
| 1448 | + if ( !is_string($footerIcon) && !isset($footerIcon["src"]) ) { |
| 1449 | + unset($footerIconsBlock[$footerIconKey]); |
| 1450 | + } |
| 1451 | + } |
| 1452 | + } |
| 1453 | + // Redo removal of any empty blocks |
| 1454 | + foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) { |
| 1455 | + if ( count($footerIconsBlock) <= 0 ) { |
| 1456 | + unset($footericons[$footerIconsKey]); |
| 1457 | + } |
| 1458 | + } |
| 1459 | + } else if ( $option == "nocopyright" ) { |
| 1460 | + $footericons = $this->data["footericons"]; |
| 1461 | + unset($footericons["copyright"]["copyright"]); |
| 1462 | + if ( count($footericons["copyright"]) <= 0 ) { |
| 1463 | + unset($footericons["copyright"]); |
| 1464 | + } |
| 1465 | + } |
| 1466 | + |
| 1467 | + return $footericons; |
| 1468 | + } |
| 1469 | + |
| 1470 | + |
1398 | 1471 | } |
1399 | 1472 | |