r47076 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47075‎ | r47076 | r47077 >
Date:10:32, 10 February 2009
Author:ialex
Status:deferred (Comments)
Tags:
Comment:
* Moved all styles to SpecialInterwiki.css, with mw-interwikitable (largely inspired by wikitable) for tables, so that it also work for sites that don't have wikitable definitions
* Parse messages in the introduction table instead of outputing them raw
* Whitespaces fixes
Modified paths:
  • /trunk/extensions/Interwiki/SpecialInterwiki.css (added) (history)
  • /trunk/extensions/Interwiki/SpecialInterwiki_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Interwiki/SpecialInterwiki_body.php
@@ -206,15 +206,19 @@
207207 }
208208 }
209209
210 - function trans_local($tl, $msg0, $msg1)
211 - {
212 - if($tl==='0') return ($msg0);
213 - if($tl==='1') return ($msg1);
214 - return ( htmlspecialchars( $tl ));
 210+ function trans_local( $tl, $msg0, $msg1 ) {
 211+ if( $tl==='0' )
 212+ return $msg0;
 213+ if( $tl==='1' )
 214+ return $msg1;
 215+ return htmlspecialchars( $tl );
215216 }
216217
217218 function showList( $admin ) {
218 - global $wgUser, $wgOut;
 219+ global $wgUser, $wgOut, $wgScriptPath;
 220+
 221+ $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/Interwiki/SpecialInterwiki.css" );
 222+
219223 $prefixmessage = wfMsgHtml( 'interwiki_prefix' );
220224 $urlmessage = wfMsgHtml( 'interwiki_url' );
221225 $localmessage = wfMsgHtml( 'interwiki_local' );
@@ -222,17 +226,16 @@
223227 $message_0 = wfMsgHtml( 'interwiki_0' );
224228 $message_1 = wfMsgHtml( 'interwiki_1' );
225229
226 - $sty='padding-right:1.4ex; vertical-align:top; text-align:';
227230 $out = '
228 -<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border:0" class="wikitable">
229 -<tr><th style="'.$sty.'left">'.$prefixmessage.'</th><td>'.wfMsg( 'interwiki_prefix_intro' ).'</td></tr>
230 -<tr><th style="'.$sty.'left">'.$urlmessage.'</th><td>'.wfMsg( 'interwiki_url_intro' ).'</td></tr>
231 -<tr><th style="'.$sty.'left">'.$localmessage.'</th><td>'.wfMsg( 'interwiki_local_intro' ).'</td></tr>
232 -<tr><th style="'.$sty.'right">'.$message_0.'</th><td>'.wfMsg( 'interwiki_local_0_intro' ).'</td></tr>
233 -<tr><th style="'.$sty.'right">'.$message_1.'</th><td>'.wfMsg( 'interwiki_local_1_intro' ).'</td></tr>
234 -<tr><th style="'.$sty.'left">'.$transmessage.'</th><td>'.wfMsg( 'interwiki_trans_intro' ).'</td></tr>
235 -<tr><th style="'.$sty.'right">'.$message_1.'</th><td>'.wfMsg( 'interwiki_trans_1_intro' ).'</td></tr>
236 -<tr><th style="'.$sty.'right">'.$message_0.'</th><td>'.wfMsg( 'interwiki_trans_0_intro' ).'</td></tr>
 231+<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border:0" class="mw-interwikitable intro">
 232+<tr><th class="mw-align-left">' . $prefixmessage . '</th><td>' . wfMsgExt( 'interwiki_prefix_intro', 'parseinline' ) . '</td></tr>
 233+<tr><th class="mw-align-left">' . $urlmessage . '</th><td>' . wfMsgExt( 'interwiki_url_intro', 'parseinline' ) . '</td></tr>
 234+<tr><th class="mw-align-left">' . $localmessage . '</th><td>' . wfMsgExt( 'interwiki_local_intro', 'parseinline' ) . '</td></tr>
 235+<tr><th class="mw-align-right">' . $message_0 . '</th><td>' . wfMsgExt( 'interwiki_local_0_intro', 'parseinline' ) . '</td></tr>
 236+<tr><th class="mw-align-right">' . $message_1 . '</th><td>' . wfMsgExt( 'interwiki_local_1_intro', 'parseinline' ) . '</td></tr>
 237+<tr><th class="mw-align-left">' . $transmessage . '</th><td>' . wfMsgExt( 'interwiki_trans_intro', 'parseinline' ) . '</td></tr>
 238+<tr><th class="mw-align-right">' . $message_1 . '</th><td>' . wfMsgExt( 'interwiki_trans_1_intro', 'parseinline' ) . '</td></tr>
 239+<tr><th class="mw-align-right">' . $message_0 . '</th><td>' . wfMsgExt( 'interwiki_trans_0_intro', 'parseinline' ) . '</td></tr>
237240 </table>
238241 ';
239242 $wgOut->addWikiMsg( 'interwiki_intro' );
@@ -244,7 +247,7 @@
245248 $skin = $wgUser->getSkin();
246249 $addtext = wfMsgHtml( 'interwiki_addtext' );
247250 $addlink = $skin->link( $selfTitle, $addtext, array(), array( 'action' => 'add' ) );
248 - $wgOut->addHTML( '<ul>' . '<li>' . $addlink . '</li>' . '</ul>' );
 251+ $wgOut->addHTML( '<p>' . $addlink . '</p>' );
249252 }
250253
251254 $dbr = wfGetDB( DB_SLAVE );
@@ -256,8 +259,7 @@
257260 }
258261
259262 $out = "
260 - <br />
261 - <table width='100%' style='border:1px solid #aaa;' class='wikitable'>
 263+ <table width='100%' class='mw-interwikitable body'>
262264 <tr id='interwikitable-header'><th>$prefixmessage</th> <th>$urlmessage</th> <th>$localmessage</th> <th>$transmessage</th>";
263265 if( $admin ) {
264266 $deletemessage = wfMsgHtml( 'delete' );
@@ -274,8 +276,8 @@
275277 $out .= "<tr class='mw-interwikitable-row'>
276278 <td class='mw-interwikitable-prefix'>$prefix</td>
277279 <td class='mw-interwikitable-url'>$url</td>
278 - <td class='center mw-interwikitable-local'>$local</td>
279 - <td class='center mw-interwikitable-trans'>$trans</td>";
 280+ <td class='mw-interwikitable-local'>$local</td>
 281+ <td class='mw-interwikitable-trans'>$trans</td>";
280282 if( $admin ) {
281283 $out .= '<td class="mw-interwikitable-modify">';
282284 $out .= $skin->link( $selfTitle, $editmessage, array(),
Index: trunk/extensions/Interwiki/SpecialInterwiki.css
@@ -0,0 +1,41 @@
 2+
 3+/**
 4+ * CSS for Special:Interwiki
 5+ */
 6+
 7+table.mw-interwikitable {
 8+ margin: 1em 1em 1em 0;
 9+ background: #fdfdfd;
 10+ border: 1px #aaa solid;
 11+ border-collapse: collapse;
 12+}
 13+
 14+table.mw-interwikitable th,
 15+table.mw-interwikitable td {
 16+ border: 1px #aaa solid;
 17+ padding: 0.2em;
 18+}
 19+
 20+table.mw-interwikitable th {
 21+ background: #f2f2f2;
 22+ text-align: center;
 23+}
 24+
 25+table.mw-interwikitable.intro th {
 26+ padding-right: 1.4ex;
 27+ vertical-align: top;
 28+}
 29+
 30+table.mw-interwikitable.intro th.mw-align-left {
 31+ text-align: left;
 32+}
 33+
 34+table.mw-interwikitable.intro th.mw-align-right {
 35+ text-align: right;
 36+}
 37+
 38+table.mw-interwikitable.body td.mw-interwikitable-local,
 39+table.mw-interwikitable.body td.mw-interwikitable-trans {
 40+ text-align: center;
 41+}
 42+
Property changes on: trunk/extensions/Interwiki/SpecialInterwiki.css
___________________________________________________________________
Name: svn:eol-style
143 + native

Comments

#Comment by Simetrical (talk | contribs)   14:19, 10 February 2009

I've long considered that we should just move the wikitable CSS definition into shared.css. It's a generally useful class and it should improve out-of-the-box compatibility with Wikipedia content. If you have a use for it in an extension, maybe now would be a good time to move it into core.

#Comment by IAlex (talk | contribs)   20:11, 25 March 2009

Done by raymond in r48842; modified the extension in r48844.

Status & tagging log