Index: branches/liquidthreads/extensions/LqtBaseView.php |
— | — | @@ -228,7 +228,8 @@ |
229 | 229 | $curr_rev_id = $changed_thread->rootRevision(); |
230 | 230 | $curr_rev = Revision::newFromTitle( $changed_thread->root()->getTitle(), $curr_rev_id ); |
231 | 231 | $prev_rev = $curr_rev->getPrevious(); |
232 | | - return self::permalinkUrlWithQuery( $changed_thread, array('diff'=>$curr_rev_id, 'oldid'=>$prev_rev->getId()) ); |
| 232 | + $oldid = $prev_rev ? $prev_rev->getId() : ""; |
| 233 | + return self::permalinkUrlWithQuery( $changed_thread, array('diff'=>$curr_rev_id, 'oldid'=>$oldid) ); |
233 | 234 | } |
234 | 235 | |
235 | 236 | static function talkpageUrl( $title, $method = null, $operand = null, $includeFragment = true ) { |
— | — | @@ -549,7 +550,8 @@ |
550 | 551 | |
551 | 552 | function showThread( $thread ) { |
552 | 553 | global $wgLang; # TODO global. |
553 | | - |
| 554 | + |
| 555 | + efVarDump($this->output, $thread->changeObject()->id()); |
554 | 556 | $is_changed_thread = $thread->isHistorical() && $thread->changeObject()->id() == $thread->id(); |
555 | 557 | |
556 | 558 | $this->showThreadHeading( $thread ); |
— | — | @@ -580,7 +582,7 @@ |
581 | 583 | |
582 | 584 | if ( $thread->type() == Threads::TYPE_DELETED ) { |
583 | 585 | if ( in_array('deletedhistory', $this->user->getRights()) ) { |
584 | | - $this->output->addHTML("<p>The following thread has been <b>deleted</b> and is not visible to non-sysops.</p>"); |
| 586 | + $this->output->addHTML("<p>The following thread has been <b>deleted</b> and is invisible to non-sysops.</p>"); |
585 | 587 | } |
586 | 588 | else { |
587 | 589 | $this->output->addHTML("<p><em>This thread was deleted.</em></p>"); |
Index: branches/liquidthreads/extensions/LqtPages.php |
— | — | @@ -556,17 +556,41 @@ |
557 | 557 | } |
558 | 558 | |
559 | 559 | class ThreadHistoryView extends ThreadPermalinkView { |
| 560 | + |
| 561 | + private function rowForThread($t) { |
| 562 | + global $wgLang, $wgOut; // TODO global. |
560 | 563 | |
| 564 | + /* TODO: best not to refer to LqtView class directly. */ |
| 565 | + /* We don't use oldid because that has side-effects. */ |
| 566 | + $result = array(); |
| 567 | + $change_names = array(Threads::CHANGE_EDITED_ROOT => "Comment text edited:", |
| 568 | + Threads::CHANGE_EDITED_SUMMARY => "Summary changed:", |
| 569 | + Threads::CHANGE_REPLY_CREATED => "New reply created:", |
| 570 | + Threads::CHANGE_NEW_THREAD => "New thread created:", |
| 571 | + Threads::CHANGE_DELETED => "Deleted:", |
| 572 | + Threads::CHANGE_UNDELETED => "Undeleted:"); |
| 573 | + $change_label = array_key_exists($t->changeType(), $change_names) ? $change_names[$t->changeType()] : ""; |
| 574 | + |
| 575 | + $url = LqtView::permalinkUrlWithQuery( $this->thread, 'lqt_oldid=' . $t->revisionNumber() ); |
| 576 | + |
| 577 | + $p = new Parser(); $sig = $wgOut->parse( $p->getUserSig( $t->changeUser() ), false ); |
| 578 | + |
| 579 | + $result[] = "<tr>"; |
| 580 | + $result[] = "<td><a href=\"$url\">" . $wgLang->timeanddate($t->timestamp()) . "</a></td>"; |
| 581 | + $result[] = "<td>" . $sig . "</td>"; |
| 582 | + $result[] = "<td>$change_label</td>"; |
| 583 | + $result[] = "<td>" . $t->changeComment() . "</td>"; |
| 584 | + $result[] = "</tr>"; |
| 585 | + return implode('', $result); |
| 586 | + } |
| 587 | + |
561 | 588 | function showHistoryListing($t) { |
562 | | - $pager = new ThreadHistoryPager( $this->thread ); |
563 | | - $this->linesonpage = $pager->getNumRows(); |
564 | | - $this->output->addHTML( |
565 | | - $pager->getNavigationBar() . |
566 | | -// $this->beginHistoryList() . |
567 | | - $pager->getBody() . |
568 | | -// $this->endHistoryList() . |
569 | | - $pager->getNavigationBar() |
570 | | - ); |
| 589 | + $revisions = new ThreadHistoryIterator($t, 10, 0); |
| 590 | + $this->output->addHTML('<table>'); |
| 591 | + foreach($revisions as $ht) { |
| 592 | + $this->output->addHTML($this->rowForThread($ht)); |
| 593 | + } |
| 594 | + $this->output->addHTML('</table>'); |
571 | 595 | } |
572 | 596 | |
573 | 597 | function show() { |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -77,6 +77,8 @@ |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
| 81 | + |
| 82 | +// TODO get rid of this class. sheesh. |
81 | 83 | class Post extends Article { |
82 | 84 | /** |
83 | 85 | * Return the User object representing the author of the first revision |
— | — | @@ -98,6 +100,40 @@ |
99 | 101 | } |
100 | 102 | } |
101 | 103 | |
| 104 | + |
| 105 | +class ThreadHistoryIterator extends ArrayIterator { |
| 106 | + |
| 107 | + function __construct($thread, $limit, $offset) { |
| 108 | + $this->thread = $thread; |
| 109 | + $this->limit = $limit; |
| 110 | + $this->offset = $offset; |
| 111 | + $this->loadRows(); |
| 112 | + } |
| 113 | + |
| 114 | + private function loadRows() { |
| 115 | + if( $this->offset == 0 ) { |
| 116 | + $this->append( $this->thread ); |
| 117 | + $this->limit -= 1; |
| 118 | + } else { |
| 119 | + $this->offset -= 1; |
| 120 | + } |
| 121 | + |
| 122 | + $dbr =& wfGetDB( DB_SLAVE ); |
| 123 | + $res = $dbr->select( |
| 124 | + 'historical_thread', |
| 125 | + 'hthread_contents, hthread_revision', |
| 126 | + array('hthread_id' => $this->thread->id()), |
| 127 | + __METHOD__, |
| 128 | + array('ORDER BY' => 'hthread_revision DESC', |
| 129 | + 'LIMIT' => $this->limit, |
| 130 | + 'OFFSET' => $this->offset)); |
| 131 | + while($l = $dbr->fetchObject($res)) { |
| 132 | + $this->append( HistoricalThread::fromTextRepresentation($l->hthread_contents) ); |
| 133 | + } |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | + |
102 | 138 | class HistoricalThread extends Thread { |
103 | 139 | function __construct($t) { |
104 | 140 | /* SCHEMA changes must be reflected here. */ |
— | — | @@ -129,16 +165,8 @@ |
130 | 166 | static function fromTextRepresentation($r) { |
131 | 167 | return unserialize($r); |
132 | 168 | } |
133 | | - private static function setChangeOnDescendents($thread, $change_type, $change_object) { |
134 | | - $thread->setChangeType($change_type); |
135 | | - $thread->setChangeObject($change_object); |
136 | | - foreach($thread->replies() as $r) |
137 | | - self::setChangeOnDescendents($r, $change_type, $change_object); |
138 | | - return $thread; |
139 | | - } |
140 | 169 | static function create( $t, $change_type, $change_object ) { |
141 | | - $tmt_tmp = $t->topmostThread(); |
142 | | - $tmt = self::setChangeOnDescendents( $tmt_tmp, $change_type, $change_object ); |
| 170 | + $tmt = $t->topmostThread(); |
143 | 171 | $contents = HistoricalThread::textRepresentation($tmt); |
144 | 172 | $dbr =& wfGetDB( DB_MASTER ); |
145 | 173 | $res = $dbr->insert( 'historical_thread', array( |
— | — | @@ -166,6 +194,7 @@ |
167 | 195 | } |
168 | 196 | } |
169 | 197 | |
| 198 | + |
170 | 199 | class Thread { |
171 | 200 | /* SCHEMA changes must be reflected here. */ |
172 | 201 | |
— | — | @@ -262,6 +291,14 @@ |
263 | 292 | __METHOD__); |
264 | 293 | } |
265 | 294 | |
| 295 | + private static function setChangeOnDescendents($thread, $change_type, $change_object) { |
| 296 | + $thread->setChangeType($change_type); |
| 297 | + $thread->setChangeObject($change_object); |
| 298 | + foreach($thread->replies() as $r) |
| 299 | + self::setChangeOnDescendents($r, $change_type, $change_object); |
| 300 | + return $thread; |
| 301 | + } |
| 302 | + |
266 | 303 | function commitRevision($change_type, $change_object = null, $reason = "") { |
267 | 304 | global $wgUser; // TODO global. |
268 | 305 | |
— | — | @@ -273,6 +310,7 @@ |
274 | 311 | HistoricalThread::create( $this->double, $change_type, $change_object ); |
275 | 312 | |
276 | 313 | $this->bumpRevisionsOnAncestors($change_type, $change_object); |
| 314 | + // self::setChangeOnDescendents($this->topmostThread(), $change_type, $change_object); |
277 | 315 | |
278 | 316 | /* SCHEMA changes must be reflected here. */ |
279 | 317 | |
— | — | @@ -837,6 +875,7 @@ |
838 | 876 | |
839 | 877 | } |
840 | 878 | |
| 879 | + |
841 | 880 | class QueryGroup { |
842 | 881 | protected $queries; |
843 | 882 | |