r57563 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57562‎ | r57563 | r57564 >
Date:15:45, 9 October 2009
Author:werdna
Status:deferred
Tags:
Comment:
Allow any user to hide a LiquidThreads post by blanking it.
* TODO: Make this discoverable, either by adding our own interface for it, or by putting a note somewhere.
* Messages will still appear if they have replies with content in them, to preserve the tree structure.
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1110,6 +1110,24 @@
11111111 return $link;
11121112 }
11131113
 1114+ static function threadContainsRepliesWithContent( $thread ) {
 1115+ $replies = $thread->replies();
 1116+
 1117+ foreach( $replies as $reply ) {
 1118+ $content = $reply->root()->getContent();
 1119+
 1120+ if ( trim($content) != '' ) {
 1121+ return true;
 1122+ }
 1123+
 1124+ if ( self::threadContainsRepliesWithContent( $reply ) ) {
 1125+ return true;
 1126+ }
 1127+ }
 1128+
 1129+ return false;
 1130+ }
 1131+
11141132 function showThreadReplies( $thread, $startAt, $maxCount, $showThreads,
11151133 $cascadeOptions ) {
11161134 $repliesClass = 'lqt-thread-replies lqt-thread-replies-' .
@@ -1193,6 +1211,16 @@
11941212 // For cascading.
11951213 $options['mustShowThreads'] = $mustShowThreads;
11961214
 1215+ // Don't show blank posts unless we have to
 1216+ $content = $thread->root()->getContent();
 1217+ if ( trim($content) == '' &&
 1218+ ! self::threadContainsRepliesWithContent( $thread ) &&
 1219+ ! array_key_exists( $thread->id(), $mustShowThreads ) ) {
 1220+
 1221+ $this->threadNestingLevel--;
 1222+ return;
 1223+ }
 1224+
11971225 $sk = $this->user->getSkin();
11981226 $html = '';
11991227
@@ -1254,17 +1282,25 @@
12551283 $cascadeOptions = $options;
12561284 unset( $cascadeOptions['startAt'] );
12571285
1258 - $showThreads = ( $maxDepth == - 1 ) || ( $this->threadNestingLevel <= $maxDepth );
 1286+ $showThreads = ( $maxDepth == - 1 ) ||
 1287+ ( $this->threadNestingLevel <= $maxDepth );
12591288
 1289+ $mustShowThreadIds = array_keys( $mustShowThreads );
 1290+ $subthreadIds = array_keys( $thread->replies() );
 1291+ $mustShowSubthreadIds = array_intersect( $mustShowThreadIds, $subthreadIds );
 1292+
 1293+ $hasSubthreads = self::threadContainsRepliesWithContent( $thread );
 1294+ $hasSubthreads = $hasSubthreads || count( $mustShowSubthreadIds );
 1295+
12601296 // Show subthreads if one of the subthreads is on the must-show list
12611297 $showThreads = $showThreads ||
12621298 count( array_intersect(
12631299 array_keys( $mustShowThreads ), array_keys( $thread->replies() )
12641300 ) );
1265 - if ( $thread->hasSubthreads() && $showThreads ) {
 1301+ if ( $hasSubthreads && $showThreads ) {
12661302 $this->showThreadReplies( $thread, $startAt, $maxCount, $showThreads,
12671303 $cascadeOptions );
1268 - } elseif ( $thread->hasSubthreads() && !$showThreads ) {
 1304+ } elseif ( $hasSubthreads && !$showThreads ) {
12691305 // Add a "show subthreads" link.
12701306 $link = $this->getShowReplies( $thread );
12711307
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php
@@ -11,7 +11,7 @@
1212 function postDivClass( $thread ) {
1313 $changedObject = $this->mDisplayRevision->getChangeObject();
1414 $is_changed_thread = $changedObject &&
15 - ( $changedObject->id() == $thread->id() );
 15+ ( $changedObject->id() == $thread->id() );
1616
1717 $class = parent::postDivClass( $thread );
1818
@@ -91,7 +91,25 @@
9292 $this->thread = $this->mDisplayRevision->getThreadObj();
9393
9494 $this->showHistoryInfo();
95 - parent::show();
 95+
 96+ global $wgHooks;
 97+ $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
 98+
 99+ if ( !$this->thread ) {
 100+ $this->showMissingThreadPage();
 101+ return false;
 102+ }
 103+
 104+ self::addJSandCSS();
 105+ $this->output->setSubtitle( $this->getSubtitle() );
 106+
 107+ $changedObject = $this->mDisplayRevision->getChangeObject();
 108+
 109+ $this->showThread( $this->thread, 1, 1,
 110+ array( 'maxDepth' => - 1, 'maxCount' => - 1,
 111+ 'mustShowThreads' => array( $changedObject->id() ) ) );
 112+
 113+ $this->output->setPageTitle( $this->thread->subject() );
96114 return false;
97115 }
98116 }

Status & tagging log