r77763 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77762‎ | r77763 | r77764 >
Date:04:44, 5 December 2010
Author:dantman
Status:ok (Comments)
Tags:
Comment:
Take the footer icon html building common to all 3 skins using r77741 $wgFooterIcons and turn it into a common makeFooterIcon method they can share.
Also fix the location of the noprint class meant to be on footer-icons in vector.
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/skins/Modern.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/Vector.php
@@ -545,26 +545,13 @@
546546 <?php endif; ?>
547547 <?php endforeach; ?>
548548 <?php if ( count( $footericons ) > 0 ): ?>
549 - <ul id="footer-icons">
 549+ <ul id="footer-icons" class="noprint">
550550 <?php foreach ( $footericons as $blockName => $footerIcons ): ?>
551 - <li id="footer-<?php echo htmlspecialchars($blockName); ?>ico" class="noprint">
552 -<?php foreach ( $footerIcons as $icon ):
553 - if ( is_string($icon) ) {
554 - $html = $icon;
555 - } else {
556 - $url = $icon["url"];
557 - unset($icon["url"]);
558 - if ( isset($icon["src"]) ) {
559 - $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
560 - } else {
561 - $html = htmlspecialchars($icon["alt"]);
562 - }
563 - if ( $url ) {
564 - $html = Html::rawElement( 'a', array( "href" => $url ), $html );
565 - }
566 - }
567 - echo " $html\n";
568 - endforeach; ?>
 551+ <li id="footer-<?php echo htmlspecialchars($blockName); ?>ico">
 552+<?php foreach ( $footerIcons as $icon ): ?>
 553+ <?php echo $this->skin->makeFooterIcon( $icon ); ?>
 554+
 555+<?php endforeach; ?>
569556 </li>
570557 <?php endforeach; ?>
571558 </ul>
Index: trunk/phase3/skins/MonoBook.php
@@ -189,23 +189,11 @@
190190 <div id="footer"<?php $this->html('userlangattributes') ?>>
191191 <?php foreach ( $footericons as $blockName => $footerIcons ) { ?>
192192 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
193 -<?php foreach ( $footerIcons as $icon ) {
194 - if ( is_string($icon) ) {
195 - $html = $icon;
196 - } else {
197 - $url = $icon["url"];
198 - unset($icon["url"]);
199 - if ( isset($icon["src"]) ) {
200 - $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
201 - } else {
202 - $html = htmlspecialchars($icon["alt"]);
203 - }
204 - if ( $url ) {
205 - $html = Html::rawElement( 'a', array( "href" => $url ), $html );
206 - }
207 - }
208 - echo " $html\n";
209 - } ?>
 193+<?php foreach ( $footerIcons as $icon ) { ?>
 194+ <?php echo $this->skin->makeFooterIcon( $icon ); ?>
 195+
 196+<?php }
 197+?>
210198 </div>
211199 <?php }
212200
Index: trunk/phase3/skins/Modern.php
@@ -194,16 +194,10 @@
195195 foreach ( $footericons as $blockName => $footerIcons ) { ?>
196196 <div id="mw_<?php echo htmlspecialchars($blockName); ?>">
197197 <?php
198 - foreach ( $footerIcons as $icon ) {
199 - if ( is_string($icon) ) {
200 - $html = $icon;
201 - } else {
202 - $html = htmlspecialchars($icon["alt"]);
203 - if ( $icon["url"] ) {
204 - $html = Html::element( 'a', array( "href" => $icon["url"] ), $html );
205 - }
206 - }
207 - echo " $html\n";
 198+ foreach ( $footerIcons as $icon ) { ?>
 199+ <?php echo $this->skin->makeFooterIcon( $icon, false ); ?>
 200+
 201+<?php
208202 } ?>
209203 </div>
210204 <?php
Index: trunk/phase3/includes/Skin.php
@@ -1631,6 +1631,29 @@
16321632 }
16331633
16341634 /**
 1635+ * Renders a $wgFooterIcons icon acording to the method's arguments
 1636+ * @param $icon Array: The icon to build the html for
 1637+ * @param $useImg Boolean: Whether to use the icon's image or output a text-only footericon
 1638+ */
 1639+ function makeFooterIcon( $icon, $useImg = true ) {
 1640+ if ( is_string($icon) ) {
 1641+ $html = $icon;
 1642+ } else {
 1643+ $url = $icon["url"];
 1644+ unset($icon["url"]);
 1645+ if ( isset($icon["src"]) && $useImg ) {
 1646+ $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
 1647+ } else {
 1648+ $html = htmlspecialchars($icon["alt"]);
 1649+ }
 1650+ if ( $url ) {
 1651+ $html = Html::rawElement( 'a', array( "href" => $url ), $html );
 1652+ }
 1653+ }
 1654+ return $html;
 1655+ }
 1656+
 1657+ /**
16351658 * Gets the link to the wiki's main page.
16361659 * @return string
16371660 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r77791Follow-up r77763, get rid of boolean param and whitespace fixesnikerabbit10:41, 5 December 2010
r77793Folowup r77763, add documentation for $wgFooterIcons.dantman10:58, 5 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77741Implement $wgFooterIcons to replace copyrightico and poweredbyico with a flex...dantman20:55, 4 December 2010

Comments

#Comment by Nikerabbit (talk | contribs)   10:42, 5 December 2010

Yay for less code duplication. The documentation for $icon param doesn't seem to be complete.

#Comment by Dantman (talk | contribs)   11:03, 5 December 2010

Done... ;) if you don't like it, you'd best not convince my verboseness to do documentation, I'm not a writer.

Status & tagging log