r52360 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52359‎ | r52360 | r52361 >
Date:16:20, 24 June 2009
Author:werdna
Status:deferred
Tags:
Comment:
LiquidThreads stuff:
* Fix bug in thread causing all threads to have a thread_ancestor of 0, making the software think it was a top-level thread.
* Add backwards-compatibility code, recursively follows thread_parent until it gets to thread_parent=0 to deduce the correct thread_ancestor.
* Break permalink link out from Actions drop-down to beside the Actions text.
* Fix backlinks from thread permalinks to include anchors to where you were, making it a nice context link.
* Change another instance of hard-coded HTML into generated HTML.
* Fix Actions drop-down to properly hug the RHS, instead of using a weird margin-right hack.
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/LqtThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.css (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/lqt.css
@@ -493,13 +493,6 @@
494494 text-align: right;
495495 }
496496
497 -.lqt-thread-header-commands {
498 - float: right;
499 - font-size: 85%;
500 - margin: 0;
501 - margin-right: 2em;
502 -}
503 -
504497 .lqt-thread-header-commands:hover {
505498 background-color: #eeeeee;
506499 }
@@ -559,3 +552,16 @@
560553 margin: 0.3em;
561554 margin-left: 2em;
562555 }
 556+
 557+.lqt-thread-header-rhs {
 558+ float: right;
 559+ font-size: 85%;
 560+ margin: 0;
 561+ text-wrap: suppress;
 562+}
 563+
 564+.lqt-thread-header-commands {
 565+ padding: 0;
 566+ margin: 0;
 567+ display: inline-block;
 568+}
Index: trunk/extensions/LiquidThreads/classes/LqtView.php
@@ -297,9 +297,7 @@
298298 function perpetuate( $name, $as ) {
299299 $value = $this->request->getVal( $name, '' );
300300 if ( $as == 'hidden' ) {
301 - return <<<HTML
302 - <input type="hidden" name="$name" id="$name" value="$value">
303 -HTML;
 301+ return Xml::hidden( $name, $value );
304302 }
305303 }
306304
@@ -572,10 +570,6 @@
573571 'href' => $history_url,
574572 'enabled' => true );
575573
576 - $commands['permalink'] = array( 'label' => wfMsgExt( 'lqt_permalink', 'parseinline' ),
577 - 'href' => self::permalinkUrl( $thread ),
578 - 'enabled' => true );
579 -
580574 if ( $this->user->isAllowed( 'delete' ) ) {
581575 $threadText = $thread->title()->getPrefixedText();
582576 $deleteTitle = SpecialPage::getTitleFor( 'DeleteThread', $threadText );
@@ -724,15 +718,26 @@
725719 $commandHTML = Xml::tags( 'ul', array( 'class' => 'lqt-thread-header-command-list' ),
726720 $this->listItemsForCommands( $commands ) );
727721
 722+ $headerParts = array();
 723+
 724+ $permalink = $this->permalink( $thread, wfMsgExt( 'lqt_permalink', 'parseinline' ) );
 725+ $permalink = Xml::tags( 'span', array( 'class' => 'lqt-thread-permalink' ), $permalink );
 726+ $headerParts[] = $permalink;
 727+
 728+ // Drop-down menu
728729 $triggerText = wfMsgExt( 'lqt-header-actions', 'parseinline' ) .
729730 Xml::tags( 'span', array('class' => 'lqt-thread-actions-icon'),
730731 '&nbsp;');
731732 $dropDownTrigger = Xml::tags( 'span',
732733 array( 'class' => 'lqt-thread-actions-trigger' ),
733734 $triggerText );
 735+ $headerParts[] = Xml::tags( 'div',
 736+ array( 'class' => 'lqt-thread-header-commands' ),
 737+ $dropDownTrigger . $commandHTML );
 738+
734739 $dropDown = Xml::tags( 'div',
735 - array( 'class' => 'lqt-thread-header-commands' ),
736 - $dropDownTrigger . $commandHTML );
 740+ array( 'class' => 'lqt-thread-header-rhs' ),
 741+ $wgLang->pipeList( $headerParts ) );
737742 $html .= $dropDown;
738743
739744 $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-header' ), $html );
Index: trunk/extensions/LiquidThreads/classes/LqtThread.php
@@ -337,7 +337,12 @@
338338
339339 function setSuperthread( $thread ) {
340340 $this->parentId = $thread->id();
341 - $this->ancestorId = $thread->ancestorId();
 341+
 342+ if ( $thread->isTopmostThread() ) {
 343+ $this->ancestorId = $thread->id();
 344+ } else {
 345+ $this->ancestorId = $thread->ancestorId();
 346+ }
342347 }
343348
344349 function superthread() {
@@ -360,12 +365,37 @@
361366 if ( $this->isTopmostThread() ) {
362367 return $this;
363368 } else {
364 - return Threads::withId( $this->ancestorId );
 369+ $thread = Threads::withId( $this->ancestorId );
 370+
 371+ if (!$thread) {
 372+ $thread = $this->fixMissingAncestor();
 373+ }
 374+
 375+ return $thread;
365376 }
366377 }
367378
 379+ // Due to a bug in earlier versions, the topmost thread sometimes isn't there.
 380+ // Fix the corruption by repeatedly grabbing the parent until we hit the topmost thread.
 381+ function fixMissingAncestor() {
 382+ $thread = $this;
 383+
 384+ while ( !$thread->isTopmostThread() ) {
 385+ $thread = $thread->superthread();
 386+ }
 387+
 388+ $this->ancestorId = $thread->id();
 389+
 390+ $dbw = wfGetDB( DB_MASTER );
 391+ $dbw->update( 'thread', array( 'thread_ancestor' => $thread->id() ),
 392+ array( 'thread_id' => $this->id() ), __METHOD__ );
 393+
 394+ return $thread;
 395+ }
 396+
368397 function isTopmostThread() {
369 - return $this->ancestorId == $this->id || intval($this->ancestorId) === 0;
 398+ return $this->ancestorId == $this->id ||
 399+ $this->parentId == 0;
370400 }
371401
372402 function setArticle( $a ) {
Index: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
@@ -82,6 +82,9 @@
8383 function getSubtitle() {
8484 wfLoadExtensionMessages( 'LiquidThreads' );
8585
 86+ $sk = $this->user->getSkin();
 87+ $fragment = '#'.$this->anchorName( $this->thread );
 88+
8689 if ( $this->thread->isHistorical() ) {
8790 // TODO: Point to the relevant part of the archive.
8891 $query = '';
@@ -90,15 +93,21 @@
9194 }
9295
9396 $talkpage = $this->thread->article()->getTitle();
94 - $talkpage_link = $this->user->getSkin()->link( $talkpage );
 97+ $talkpage->setFragment( $fragment );
 98+ $talkpage_link = $sk->link( $talkpage );
9599
96100 if ( $this->thread->hasSuperthread() ) {
97 - $permalink = self::permalink( $this->thread->topmostThread(),
98 - wfMsg( 'lqt_discussion_link' ) );
 101+ $topmostTitle = $this->thread->topmostThread()->title();
 102+ $topmostTitle->setFragment( $fragment );
 103+
 104+ $linkText = wfMsgExt( 'lqt_discussion_link', 'parseinline' );
 105+ $permalink = $sk->link( $topmostTitle, $linkText );
99106
100 - return wfMsg( 'lqt_fragment', $permalink, $talkpage_link );
 107+ return wfMsgExt( 'lqt_fragment', array('parseinline', 'replaceafter'),
 108+ array( $permalink, $talkpage_link ) );
101109 } else {
102 - return wfMsg( 'lqt_from_talk', $talkpage_link );
 110+ return wfMsgExt( 'lqt_from_talk', array('parseinline', 'replaceafter'),
 111+ array($talkpage_link) );
103112 }
104113 }
105114

Status & tagging log