Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -380,6 +380,10 @@ |
381 | 381 | 'Reply' => $this->talkpageUrl( $this->title, 'reply', $thread ), |
382 | 382 | 'Permalink' => $this->permalinkUrl( $thread ) ); |
383 | 383 | |
| 384 | + if( !$thread->hasSuperthread() ) { |
| 385 | + $commands['History'] = $this->permalinkUrl($thread, 'history_listing'); |
| 386 | + } |
| 387 | + |
384 | 388 | foreach( $commands as $label => $href ) { |
385 | 389 | $this->output->addHTML( wfOpenElement( 'li' ) ); |
386 | 390 | $this->output->addHTML( wfElement('a', array('href'=>$href), $label) ); |
— | — | @@ -437,7 +441,7 @@ |
438 | 442 | |
439 | 443 | function showThread( $thread ) { |
440 | 444 | $this->showThreadHeading( $thread ); |
441 | | - |
| 445 | + |
442 | 446 | $timestamp = new Date($thread->timestamp()); |
443 | 447 | if( $thread->summary() ) { |
444 | 448 | $this->showSummary($thread); |
— | — | @@ -491,6 +495,12 @@ |
492 | 496 | $this->showPostBody($t->summary()); |
493 | 497 | $this->closeDiv(); |
494 | 498 | } |
| 499 | + |
| 500 | + function showHistoryListing($t) { |
| 501 | + foreach( $t->historicalRevisions() as $r ) { |
| 502 | + $this->output->addHTML($r->revisionNumber()); |
| 503 | + } |
| 504 | + } |
495 | 505 | } |
496 | 506 | |
497 | 507 | class TalkpageView extends LqtView { |
— | — | @@ -610,7 +620,7 @@ |
611 | 621 | |
612 | 622 | $this->showArchiveWidget(); |
613 | 623 | |
614 | | -// var_dump(HistoricalThread::withIdAtRevision(3,9)); |
| 624 | + var_dump(HistoricalThread::withIdAtRevision(3,11)); |
615 | 625 | |
616 | 626 | if( $this->methodApplies('talkpage_new_thread') ) { |
617 | 627 | $this->showNewThreadForm(); |
— | — | @@ -865,12 +875,14 @@ |
866 | 876 | if ( $t->hasSuperthread() ) { |
867 | 877 | $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link ); |
868 | 878 | } else { |
869 | | - |
870 | 879 | $this->output->setSubtitle( "from " . $talkpage_link ); |
871 | 880 | } |
872 | 881 | |
873 | 882 | if( $this->methodApplies('summarize') ) { |
874 | 883 | $this->showSummarizeForm($t); |
| 884 | + |
| 885 | + } else if( $this->methodApplies('history_listing') ) { |
| 886 | + $this->showHistoryListing($t); |
875 | 887 | } |
876 | 888 | |
877 | 889 | $this->showThread($t); |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -98,9 +98,26 @@ |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | | -class HistoricalThread { |
| 102 | +class HistoricalThread extends Thread { |
| 103 | + function __construct($t) { |
| 104 | + $this->rootId = $t->rootId; |
| 105 | + $this->articleId = $t->articleId; |
| 106 | + $this->summaryId = $t->summaryId; |
| 107 | + $this->articleNamespace = $t->articleNamespace; |
| 108 | + $this->articleTitle = $t->articleTitle; |
| 109 | + $this->timestamp = $t->timestamp; |
| 110 | + $this->path = $t->path; |
| 111 | + $this->id = $t->id; |
| 112 | + $this->revisionNumber = $t->revisionNumber; |
| 113 | + |
| 114 | + $this->replies = array(); |
| 115 | + foreach ($t->replies as $r) { |
| 116 | + $this->replies[] = new HistoricalThread($r); |
| 117 | + } |
| 118 | + } |
103 | 119 | static function textRepresentation($t) { |
104 | | - return serialize($t); |
| 120 | + $ht = new HistoricalThread($t); |
| 121 | + return serialize($ht); |
105 | 122 | } |
106 | 123 | static function fromTextRepresentation($r) { |
107 | 124 | return unserialize($r); |
— | — | @@ -128,7 +145,7 @@ |
129 | 146 | } |
130 | 147 | } |
131 | 148 | |
132 | | -class LiveThread { |
| 149 | +class Thread { |
133 | 150 | /* ID references to other objects that are loaded on demand: */ |
134 | 151 | protected $rootId; |
135 | 152 | protected $articleId; |
— | — | @@ -159,10 +176,26 @@ |
160 | 177 | we will write to the history if a new revision is commited. */ |
161 | 178 | protected $double; |
162 | 179 | |
| 180 | + protected $replies; |
| 181 | + |
163 | 182 | function revisionNumber() { |
164 | 183 | return $this->revisionNumber; |
165 | 184 | } |
166 | 185 | |
| 186 | + function historicalRevisions() { |
| 187 | + $dbr =& wfGetDB( DB_SLAVE ); |
| 188 | + $res = $dbr->select( |
| 189 | + 'historical_thread', |
| 190 | + 'hthread_contents', |
| 191 | + array('hthread_id' => $this->id()), |
| 192 | + __METHOD__); |
| 193 | + $results = array(); |
| 194 | + while($l = $dbr->fetchObject($res)) { |
| 195 | + $results[] = HistoricalThread::fromTextRepresentation($l->hthread_contents); |
| 196 | + } |
| 197 | + return $results; |
| 198 | + } |
| 199 | + |
167 | 200 | function commitRevision() { |
168 | 201 | // TODO open a transaction. |
169 | 202 | HistoricalThread::create( $this->double ); |
— | — | @@ -339,7 +372,7 @@ |
340 | 373 | /** Module of factory methods. */ |
341 | 374 | class Threads { |
342 | 375 | |
343 | | - static $loadedLiveThreads = array(); |
| 376 | + static $loadedThreads = array(); |
344 | 377 | |
345 | 378 | static function newThread( $root, $article, $superthread = null ) { |
346 | 379 | $dbr =& wfGetDB( DB_MASTER ); |
— | — | @@ -412,23 +445,23 @@ |
413 | 446 | foreach( $lines as $key => $l ) { |
414 | 447 | if( $l->is_root ) { |
415 | 448 | // unset($lines[$key]); |
416 | | - $threads[] = Threads::buildLiveThread( &$lines, $l ); |
| 449 | + $threads[] = Threads::buildThread( &$lines, $l ); |
417 | 450 | } |
418 | 451 | } |
419 | 452 | return $threads; |
420 | 453 | } |
421 | 454 | |
422 | | - private static function buildLiveThread( $lines, $l ) { |
| 455 | + private static function buildThread( $lines, $l ) { |
423 | 456 | $children = array(); |
424 | 457 | $l_path = preg_quote($l->thread_path); |
425 | 458 | foreach( $lines as $key => $m ) { |
426 | 459 | if ( preg_match( "/^{$l_path}\.\d+$/", $m->thread_path ) ) { |
427 | 460 | // unset($lines[$key]); |
428 | | - $children[] = Threads::buildLiveThread( &$lines, $m ); |
| 461 | + $children[] = Threads::buildThread( &$lines, $m ); |
429 | 462 | } |
430 | 463 | } |
431 | | - $t = new LiveThread($l, $children); |
432 | | - Threads::$loadedLiveThreads[$l->thread_id] = $t; |
| 464 | + $t = new Thread($l, $children); |
| 465 | + Threads::$loadedThreads[$l->thread_id] = $t; |
433 | 466 | return $t; |
434 | 467 | } |
435 | 468 | |
— | — | @@ -448,8 +481,8 @@ |
449 | 482 | } |
450 | 483 | |
451 | 484 | static function withId( $id ) { |
452 | | - if( array_key_exists( $id, Threads::$loadedLiveThreads ) ) { |
453 | | - return Threads::$loadedLiveThreads[ $id ]; |
| 485 | + if( array_key_exists( $id, Threads::$loadedThreads ) ) { |
| 486 | + return Threads::$loadedThreads[ $id ]; |
454 | 487 | } |
455 | 488 | |
456 | 489 | $ts = Threads::where( array('thread.thread_id' => $id ) ); |