r25268 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25267‎ | r25268 | r25269 >
Date:07:17, 29 August 2007
Author:david
Status:old
Tags:
Comment:
history closer to working. note to erik: don't try it yet. ripped out paging temoprarily.
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtPages.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -228,7 +228,8 @@
229229 $curr_rev_id = $changed_thread->rootRevision();
230230 $curr_rev = Revision::newFromTitle( $changed_thread->root()->getTitle(), $curr_rev_id );
231231 $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) );
233234 }
234235
235236 static function talkpageUrl( $title, $method = null, $operand = null, $includeFragment = true ) {
@@ -549,7 +550,8 @@
550551
551552 function showThread( $thread ) {
552553 global $wgLang; # TODO global.
553 -
 554+
 555+ efVarDump($this->output, $thread->changeObject()->id());
554556 $is_changed_thread = $thread->isHistorical() && $thread->changeObject()->id() == $thread->id();
555557
556558 $this->showThreadHeading( $thread );
@@ -580,7 +582,7 @@
581583
582584 if ( $thread->type() == Threads::TYPE_DELETED ) {
583585 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>");
585587 }
586588 else {
587589 $this->output->addHTML("<p><em>This thread was deleted.</em></p>");
Index: branches/liquidthreads/extensions/LqtPages.php
@@ -556,17 +556,41 @@
557557 }
558558
559559 class ThreadHistoryView extends ThreadPermalinkView {
 560+
 561+ private function rowForThread($t) {
 562+ global $wgLang, $wgOut; // TODO global.
560563
 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+
561588 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>');
571595 }
572596
573597 function show() {
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -77,6 +77,8 @@
7878 }
7979 }
8080
 81+
 82+// TODO get rid of this class. sheesh.
8183 class Post extends Article {
8284 /**
8385 * Return the User object representing the author of the first revision
@@ -98,6 +100,40 @@
99101 }
100102 }
101103
 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+
102138 class HistoricalThread extends Thread {
103139 function __construct($t) {
104140 /* SCHEMA changes must be reflected here. */
@@ -129,16 +165,8 @@
130166 static function fromTextRepresentation($r) {
131167 return unserialize($r);
132168 }
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 - }
140169 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();
143171 $contents = HistoricalThread::textRepresentation($tmt);
144172 $dbr =& wfGetDB( DB_MASTER );
145173 $res = $dbr->insert( 'historical_thread', array(
@@ -166,6 +194,7 @@
167195 }
168196 }
169197
 198+
170199 class Thread {
171200 /* SCHEMA changes must be reflected here. */
172201
@@ -262,6 +291,14 @@
263292 __METHOD__);
264293 }
265294
 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+
266303 function commitRevision($change_type, $change_object = null, $reason = "") {
267304 global $wgUser; // TODO global.
268305
@@ -273,6 +310,7 @@
274311 HistoricalThread::create( $this->double, $change_type, $change_object );
275312
276313 $this->bumpRevisionsOnAncestors($change_type, $change_object);
 314+ // self::setChangeOnDescendents($this->topmostThread(), $change_type, $change_object);
277315
278316 /* SCHEMA changes must be reflected here. */
279317
@@ -837,6 +875,7 @@
838876
839877 }
840878
 879+
841880 class QueryGroup {
842881 protected $queries;
843882

Status & tagging log