Index: trunk/extensions/Babel/Babel.class.php |
— | — | @@ -53,20 +53,6 @@ |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
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 | | - |
71 | 57 | $top = wfMsgExt( 'babel', array( 'parsemag', 'content' ), self::$title->getDBkey() ); |
72 | 58 | if ( strlen( $top ) == 0 ) { |
73 | 59 | $top = ''; |
— | — | @@ -89,6 +75,9 @@ |
90 | 76 | $footer = '! class="mw-babel-footer" | ' . $footer; |
91 | 77 | } |
92 | 78 | |
| 79 | + $cellspacing = Babel::mHtmlAttrib( 'cellspacing', 'babel-box-cellspacing' ); |
| 80 | + $cellpadding = Babel::mHtmlAttrib( 'cellpadding', 'babel-box-cellpadding' ); |
| 81 | + |
93 | 82 | $tower = <<<EOT |
94 | 83 | {|$cellspacing$cellpadding class="mw-babel-wrapper" |
95 | 84 | $top |
— | — | @@ -199,11 +188,13 @@ |
200 | 189 | |
201 | 190 | $dir_content = wfMsgForContent( 'babel-directionality' ); |
202 | 191 | $dir_current = wfMsgExt( 'babel-directionality', array( 'language' => $code ) ); |
203 | | - $cellspacing = wfMsgForContent( 'babel-cellspacing' ); |
204 | 192 | |
| 193 | + $cellspacing = Babel::mHtmlAttrib( 'cellspacing', 'babel-cellspacing' ); |
| 194 | + $cellpadding = Babel::mHtmlAttrib( 'cellpadding', 'babel-cellpadding' ); |
| 195 | + |
205 | 196 | $box = <<<EOT |
206 | 197 | <div class="mw-babel-box mw-babel-box-$level" dir="$dir_content"> |
207 | | -{| cellspacing="$cellspacing" |
| 198 | +{|$cellspacing$cellpadding |
208 | 199 | ! dir="$dir_content" | $header |
209 | 200 | | dir="$dir_current" lang="$lang" xml:lang="$lang" | $text |
210 | 201 | |} |
— | — | @@ -302,4 +293,22 @@ |
303 | 294 | } |
304 | 295 | return $category; |
305 | 296 | } |
| 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 | + } |
306 | 315 | } |