Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | |
73 | 73 | $wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage'); |
74 | 74 | |
75 | | - |
| 75 | + |
76 | 76 | class LqtView { |
77 | 77 | protected $article; |
78 | 78 | protected $output; |
— | — | @@ -359,14 +359,15 @@ |
360 | 360 | * Output methods * |
361 | 361 | *************************/ |
362 | 362 | |
363 | | - function showPostBody( $post ) { |
| 363 | + function showPostBody( $post, $oldid = null ) { |
| 364 | + /* Why isn't this all encapsulated in Article somewhere? TODO */ |
364 | 365 | global $wgEnableParserCache; |
365 | 366 | |
366 | 367 | // Should the parser cache be used? |
367 | 368 | $pcache = $wgEnableParserCache && |
368 | 369 | intval( $this->user->getOption( 'stubthreshold' ) ) == 0 && |
369 | 370 | $post->exists() && |
370 | | - empty( $oldid ); // FIXME oldid |
| 371 | + $oldid === null; |
371 | 372 | wfDebug( 'LqtView::showPostBody using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" ); |
372 | 373 | if ( $this->user->getOption( 'stubthreshold' ) ) { |
373 | 374 | wfIncrStats( 'pcache_miss_stub' ); |
— | — | @@ -379,7 +380,7 @@ |
380 | 381 | |
381 | 382 | if (!$outputDone) { |
382 | 383 | // Cache miss; parse and output it. |
383 | | - $rev = Revision::newFromTitle( $post->getTitle() ); |
| 384 | + $rev = Revision::newFromTitle( $post->getTitle(), $oldid ); |
384 | 385 | $this->output->addWikiText( $rev->getText() ); |
385 | 386 | } |
386 | 387 | } |
— | — | @@ -432,6 +433,8 @@ |
433 | 434 | function showRootPost( $thread ) { |
434 | 435 | $post = $thread->root(); |
435 | 436 | |
| 437 | + $oldid = $thread->isHistorical() ? $thread->rootRevision() : null; |
| 438 | + |
436 | 439 | /* $color_number = $this->selectNewUserColor( $thread->root()->originalAuthor() ); |
437 | 440 | $this->openDiv( "lqt_post lqt_post_color_$color_number" );*/ |
438 | 441 | $this->openDiv( 'lqt_post' ); |
— | — | @@ -439,7 +442,7 @@ |
440 | 443 | if( $this->methodAppliesToThread( 'edit', $thread ) ) { |
441 | 444 | $this->showPostEditingForm( $thread ); |
442 | 445 | } else{ |
443 | | - $this->showPostBody( $post ); |
| 446 | + $this->showPostBody( $post, $oldid ); |
444 | 447 | $this->showThreadFooter( $thread ); |
445 | 448 | } |
446 | 449 | |
— | — | @@ -833,7 +836,6 @@ |
834 | 837 | </table> |
835 | 838 | <input type="submit"> |
836 | 839 | $older $newer |
837 | | -</table> |
838 | 840 | </form> |
839 | 841 | HTML |
840 | 842 | ); |
— | — | @@ -975,9 +977,18 @@ |
976 | 978 | parent::showThreadHeading($thread); |
977 | 979 | } |
978 | 980 | } |
| 981 | + |
| 982 | + function noSuchRevision() { |
| 983 | + $this->output->addHTML("There is no such revision of this thread."); |
| 984 | + } |
979 | 985 | |
980 | 986 | function show() { |
981 | 987 | $t = Threads::withRoot( $this->article ); |
| 988 | + $r = $this->request->getVal('lqt_oldid', null); if( $r ) { |
| 989 | + $t = $t->atRevision($r); |
| 990 | + if( !$t ) { $this->noSuchRevision(); return; } |
| 991 | + |
| 992 | + } |
982 | 993 | $this->thread = $t; |
983 | 994 | |
984 | 995 | // TODO this is a holdover from the special page; not sure what's correct here. |
— | — | @@ -1003,7 +1014,7 @@ |
1004 | 1015 | |
1005 | 1016 | if( $this->methodApplies('summarize') ) |
1006 | 1017 | $this->showSummarizeForm($t); |
1007 | | - |
| 1018 | + |
1008 | 1019 | $this->showThread($t); |
1009 | 1020 | } |
1010 | 1021 | } |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -101,6 +101,7 @@ |
102 | 102 | class HistoricalThread extends Thread { |
103 | 103 | function __construct($t) { |
104 | 104 | $this->rootId = $t->rootId; |
| 105 | + $this->rootRevision = $t->rootRevision; |
105 | 106 | $this->articleId = $t->articleId; |
106 | 107 | $this->summaryId = $t->summaryId; |
107 | 108 | $this->articleNamespace = $t->articleNamespace; |
— | — | @@ -143,6 +144,7 @@ |
144 | 145 | else |
145 | 146 | return null; |
146 | 147 | } |
| 148 | + function isHistorical() { return true; } |
147 | 149 | } |
148 | 150 | |
149 | 151 | class Thread { |
— | — | @@ -178,10 +180,16 @@ |
179 | 181 | |
180 | 182 | protected $replies; |
181 | 183 | |
| 184 | + function isHistorical() {return false;} |
| 185 | + |
182 | 186 | function revisionNumber() { |
183 | 187 | return $this->revisionNumber; |
184 | 188 | } |
185 | 189 | |
| 190 | + function atRevision($r) { |
| 191 | + return HistoricalThread::withIdAtRevision($this->id(), $r); |
| 192 | + } |
| 193 | + |
186 | 194 | function historicalRevisions() { |
187 | 195 | $dbr =& wfGetDB( DB_SLAVE ); |
188 | 196 | $res = $dbr->select( |
— | — | @@ -322,7 +330,8 @@ |
323 | 331 | |
324 | 332 | function root() { |
325 | 333 | if ( !$this->rootId ) return null; |
326 | | - if ( !$this->root ) $this->root = new Post( Title::newFromID( $this->rootId ) ); |
| 334 | + if ( !$this->root ) $this->root = new Post( Title::newFromID( $this->rootId ), |
| 335 | + $this->rootRevision() ); |
327 | 336 | return $this->root; |
328 | 337 | } |
329 | 338 | |
— | — | @@ -334,6 +343,10 @@ |
335 | 344 | } |
336 | 345 | } |
337 | 346 | |
| 347 | + function rootRevision() { |
| 348 | + return $this->rootRevision; |
| 349 | + } |
| 350 | + |
338 | 351 | function summary() { |
339 | 352 | if ( !$this->summaryId ) return null; |
340 | 353 | if ( !$this->summary ) $this->summary = new Post( Title::newFromID( $this->summaryId ) ); |