r84078 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84077‎ | r84078 | r84079 >
Date:03:21, 16 March 2011
Author:purodha
Status:ok
Tags:
Comment:
Fixing r84027.
Modified paths:
  • /trunk/extensions/Babel/Babel.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Babel/Babel.class.php
@@ -53,20 +53,6 @@
5454 }
5555 }
5656
57 - $cellspacing = wfMsgForContent( 'babel-box-cellspacing' );
58 - if ( strlen( $cellspacing ) == 0 ) {
59 - $cellspacing = '';
60 - } else {
61 - $cellspacing = ' cellspacing="'.$cellspacing.'"';
62 - }
63 -
64 - $cellpadding = wfMsgForContent( 'babel-box-cellpadding' );
65 - if ( strlen( $cellpadding ) == 0 ) {
66 - $cellpadding = '';
67 - } else {
68 - $cellpadding = ' cellpadding="'.$cellpadding.'"';
69 - }
70 -
7157 $top = wfMsgExt( 'babel', array( 'parsemag', 'content' ), self::$title->getDBkey() );
7258 if ( strlen( $top ) == 0 ) {
7359 $top = '';
@@ -89,6 +75,9 @@
9076 $footer = '! class="mw-babel-footer" | ' . $footer;
9177 }
9278
 79+ $cellspacing = Babel::mHtmlAttrib( 'cellspacing', 'babel-box-cellspacing' );
 80+ $cellpadding = Babel::mHtmlAttrib( 'cellpadding', 'babel-box-cellpadding' );
 81+
9382 $tower = <<<EOT
9483 {|$cellspacing$cellpadding class="mw-babel-wrapper"
9584 $top
@@ -199,11 +188,13 @@
200189
201190 $dir_content = wfMsgForContent( 'babel-directionality' );
202191 $dir_current = wfMsgExt( 'babel-directionality', array( 'language' => $code ) );
203 - $cellspacing = wfMsgForContent( 'babel-cellspacing' );
204192
 193+ $cellspacing = Babel::mHtmlAttrib( 'cellspacing', 'babel-cellspacing' );
 194+ $cellpadding = Babel::mHtmlAttrib( 'cellpadding', 'babel-cellpadding' );
 195+
205196 $box = <<<EOT
206197 <div class="mw-babel-box mw-babel-box-$level" dir="$dir_content">
207 -{| cellspacing="$cellspacing"
 198+{|$cellspacing$cellpadding
208199 ! dir="$dir_content" | $header
209200 | dir="$dir_current" lang="$lang" xml:lang="$lang" | $text
210201 |}
@@ -302,4 +293,22 @@
303294 }
304295 return $category;
305296 }
 297+
 298+ /**
 299+ * Determine a HTML attribute, such as "cellspacing" or "cellpadding".
 300+ *
 301+ * @param $name String: name of HTML attribute.
 302+ * @param $key String: Message key of attribute value.
 303+ * TODO: move this function to a more appropriate place, likely outside the class.
 304+ */
 305+ protected static function mHtmlAttrib( $name, $key ) {
 306+ $value = wfMessage( $key )->inContentLanguage();
 307+ if ( $value->isDisabled() ) {
 308+ $value = '';
 309+ } else {
 310+ $value = ' ' . $name . '="' . htmlentities( $value->text(), ENT_COMPAT, 'UTF-8' ) .
 311+ '"'; // must get rid of > and " inside value
 312+ }
 313+ return $value;
 314+ }
306315 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r84248Minor enhancements and fixes following up r84229, r84078, 84027, 84015.purodha14:17, 18 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84027More systematic handling of cellspacing and cellpadding attributes.purodha15:56, 15 March 2011

Status & tagging log