r51471 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51470‎ | r51471 | r51472 >
Date:17:17, 4 June 2009
Author:werdna
Status:deferred
Tags:
Comment:
Fixes for LqtFunctions. Specifically:
* Use proper linking and HTML generation functions from MediaWiki itself.
* Move little arrow inside message.
* Remove duplicated code.
* Use valid HTML.
* Improve variable naming, two-character variable names suck.
Modified paths:
  • /trunk/extensions/LiquidThreads/Lqt.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -38,31 +38,33 @@
3939 }
4040
4141 function efVarDump( $value ) {
42 - global $wgOut;
43 - ob_start();
44 - var_dump( $value );
45 - $tmp = ob_get_contents();
46 - ob_end_clean();
47 - $wgOut->addHTML( /*'<pre>' . htmlspecialchars($tmp,ENT_QUOTES) . '</pre>'*/ $tmp );
 42+ wfVarDump( $value );
4843 }
4944
5045 function efThreadTable( $ts ) {
5146 global $wgOut;
52 - $wgOut->addHTML( '<table>' );
53 - foreach ( $ts as $t )
54 - efThreadTableHelper( $t, 0 );
55 - $wgOut->addHTML( '</table>' );
 47+ $html = '';
 48+ foreach ( $ts as $t ) {
 49+ $html .= efThreadTableHelper( $t, 0 );
 50+ }
 51+ $html = "<table><tbody>\n$html\n</tbody></table>";
 52+ $wgOut->addHTML( $html );
5653 }
5754
58 -function efThreadTableHelper( $t, $indent ) {
59 - global $wgOut;
60 - $wgOut->addHTML( '<tr>' );
61 - $wgOut->addHTML( '<td>' . $indent );
62 - $wgOut->addHTML( '<td>' . $t->id() );
63 - $wgOut->addHTML( '<td>' . $t->title()->getPrefixedText() );
64 - $wgOut->addHTML( '</tr>' );
65 - foreach ( $t->subthreads() as $st )
66 - efThreadTableHelper( $st, $indent + 1 );
 55+function efThreadTableHelper( $thread, $indent ) {
 56+ $html = '';
 57+
 58+ $html .= Xml::tags( '<td>', null, $indent );
 59+ $html .= Xml::tags( '<td>', null, $thread->id() );
 60+ $html .= Xml::tags( '<td>', null, $thread->title()->getPrefixedText() );
 61+
 62+ $html = Xml::tags( 'tr', null, $html );
 63+
 64+ foreach ( $t->subthreads() as $subthread ) {
 65+ $html .= efThreadTableHelper( $subthread, $indent + 1 );
 66+ }
 67+
 68+ return $html;
6769 }
6870
6971 function wfLqtBeforeWatchlistHook( &$conds, &$tables, &$join_conds, &$fields ) {
@@ -85,14 +87,13 @@
8688
8789 LqtView::addJSandCSS();
8890 wfLoadExtensionMessages( 'LiquidThreads' );
89 - $messages_url = SpecialPage::getPage( 'NewMessages' )->getTitle()->getFullURL();
 91+ $messages_title = SpecialPage::getPage( 'NewMessages' )->getTitle();
9092 $new_messages = wfMsg ( 'lqt-new-messages' );
91 - $wgOut->addHTML( <<< HTML
92 - <a href="$messages_url" class="lqt_watchlist_messages_notice">
93 - &#x2712; {$new_messages}
94 - </a>
95 -HTML
96 - );
 93+
 94+ $sk = $wgUser->getSkin();
 95+ $link = $sk->link( $messages_title, $new_messages,
 96+ array( 'class' => 'lqt_watchlist_messages_notice' ) );
 97+ $wgOut->addHTML( $link );
9798
9899 return true;
99100 }
Index: trunk/extensions/LiquidThreads/Lqt.i18n.php
@@ -134,7 +134,7 @@
135135 'lqt-messages-sent' => 'Messages sent to you:',
136136 'lqt-other-messages' => 'Messages on other talk pages:',
137137 'lqt-no-new-messages' => 'There are no new messages for you.',
138 - 'lqt-new-messages' => 'There are new messages for you.',
 138+ 'lqt-new-messages' => '&#x2712; There are new messages for you.',
139139 'lqt-email-info-undo' => 'Bring back the thread you just dismissed.',
140140 'lqt-date-info' => 'This link is disabled because you are viewing threads from all dates.',
141141 'lqt_rc_new_discussion' => "New discussion, $1, on $2. &bull; $3 writes:",

Status & tagging log