Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -1110,6 +1110,24 @@ |
1111 | 1111 | return $link; |
1112 | 1112 | } |
1113 | 1113 | |
| 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 | + |
1114 | 1132 | function showThreadReplies( $thread, $startAt, $maxCount, $showThreads, |
1115 | 1133 | $cascadeOptions ) { |
1116 | 1134 | $repliesClass = 'lqt-thread-replies lqt-thread-replies-' . |
— | — | @@ -1193,6 +1211,16 @@ |
1194 | 1212 | // For cascading. |
1195 | 1213 | $options['mustShowThreads'] = $mustShowThreads; |
1196 | 1214 | |
| 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 | + |
1197 | 1225 | $sk = $this->user->getSkin(); |
1198 | 1226 | $html = ''; |
1199 | 1227 | |
— | — | @@ -1254,17 +1282,25 @@ |
1255 | 1283 | $cascadeOptions = $options; |
1256 | 1284 | unset( $cascadeOptions['startAt'] ); |
1257 | 1285 | |
1258 | | - $showThreads = ( $maxDepth == - 1 ) || ( $this->threadNestingLevel <= $maxDepth ); |
| 1286 | + $showThreads = ( $maxDepth == - 1 ) || |
| 1287 | + ( $this->threadNestingLevel <= $maxDepth ); |
1259 | 1288 | |
| 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 | + |
1260 | 1296 | // Show subthreads if one of the subthreads is on the must-show list |
1261 | 1297 | $showThreads = $showThreads || |
1262 | 1298 | count( array_intersect( |
1263 | 1299 | array_keys( $mustShowThreads ), array_keys( $thread->replies() ) |
1264 | 1300 | ) ); |
1265 | | - if ( $thread->hasSubthreads() && $showThreads ) { |
| 1301 | + if ( $hasSubthreads && $showThreads ) { |
1266 | 1302 | $this->showThreadReplies( $thread, $startAt, $maxCount, $showThreads, |
1267 | 1303 | $cascadeOptions ); |
1268 | | - } elseif ( $thread->hasSubthreads() && !$showThreads ) { |
| 1304 | + } elseif ( $hasSubthreads && !$showThreads ) { |
1269 | 1305 | // Add a "show subthreads" link. |
1270 | 1306 | $link = $this->getShowReplies( $thread ); |
1271 | 1307 | |
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | function postDivClass( $thread ) { |
13 | 13 | $changedObject = $this->mDisplayRevision->getChangeObject(); |
14 | 14 | $is_changed_thread = $changedObject && |
15 | | - ( $changedObject->id() == $thread->id() ); |
| 15 | + ( $changedObject->id() == $thread->id() ); |
16 | 16 | |
17 | 17 | $class = parent::postDivClass( $thread ); |
18 | 18 | |
— | — | @@ -91,7 +91,25 @@ |
92 | 92 | $this->thread = $this->mDisplayRevision->getThreadObj(); |
93 | 93 | |
94 | 94 | $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() ); |
96 | 114 | return false; |
97 | 115 | } |
98 | 116 | } |