r23488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23487‎ | r23488 | r23489 >
Date:20:21, 27 June 2007
Author:david
Status:old
Tags:
Comment:
more schema changes... diving into view/pager code...
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -380,6 +380,10 @@
381381 'Reply' => $this->talkpageUrl( $this->title, 'reply', $thread ),
382382 'Permalink' => $this->permalinkUrl( $thread ) );
383383
 384+ if( !$thread->hasSuperthread() ) {
 385+ $commands['History'] = $this->permalinkUrl($thread, 'history_listing');
 386+ }
 387+
384388 foreach( $commands as $label => $href ) {
385389 $this->output->addHTML( wfOpenElement( 'li' ) );
386390 $this->output->addHTML( wfElement('a', array('href'=>$href), $label) );
@@ -437,7 +441,7 @@
438442
439443 function showThread( $thread ) {
440444 $this->showThreadHeading( $thread );
441 -
 445+
442446 $timestamp = new Date($thread->timestamp());
443447 if( $thread->summary() ) {
444448 $this->showSummary($thread);
@@ -491,6 +495,12 @@
492496 $this->showPostBody($t->summary());
493497 $this->closeDiv();
494498 }
 499+
 500+ function showHistoryListing($t) {
 501+ foreach( $t->historicalRevisions() as $r ) {
 502+ $this->output->addHTML($r->revisionNumber());
 503+ }
 504+ }
495505 }
496506
497507 class TalkpageView extends LqtView {
@@ -610,7 +620,7 @@
611621
612622 $this->showArchiveWidget();
613623
614 -// var_dump(HistoricalThread::withIdAtRevision(3,9));
 624+ var_dump(HistoricalThread::withIdAtRevision(3,11));
615625
616626 if( $this->methodApplies('talkpage_new_thread') ) {
617627 $this->showNewThreadForm();
@@ -865,12 +875,14 @@
866876 if ( $t->hasSuperthread() ) {
867877 $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link );
868878 } else {
869 -
870879 $this->output->setSubtitle( "from " . $talkpage_link );
871880 }
872881
873882 if( $this->methodApplies('summarize') ) {
874883 $this->showSummarizeForm($t);
 884+
 885+ } else if( $this->methodApplies('history_listing') ) {
 886+ $this->showHistoryListing($t);
875887 }
876888
877889 $this->showThread($t);
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -98,9 +98,26 @@
9999 }
100100 }
101101
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+ }
103119 static function textRepresentation($t) {
104 - return serialize($t);
 120+ $ht = new HistoricalThread($t);
 121+ return serialize($ht);
105122 }
106123 static function fromTextRepresentation($r) {
107124 return unserialize($r);
@@ -128,7 +145,7 @@
129146 }
130147 }
131148
132 -class LiveThread {
 149+class Thread {
133150 /* ID references to other objects that are loaded on demand: */
134151 protected $rootId;
135152 protected $articleId;
@@ -159,10 +176,26 @@
160177 we will write to the history if a new revision is commited. */
161178 protected $double;
162179
 180+ protected $replies;
 181+
163182 function revisionNumber() {
164183 return $this->revisionNumber;
165184 }
166185
 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+
167200 function commitRevision() {
168201 // TODO open a transaction.
169202 HistoricalThread::create( $this->double );
@@ -339,7 +372,7 @@
340373 /** Module of factory methods. */
341374 class Threads {
342375
343 - static $loadedLiveThreads = array();
 376+ static $loadedThreads = array();
344377
345378 static function newThread( $root, $article, $superthread = null ) {
346379 $dbr =& wfGetDB( DB_MASTER );
@@ -412,23 +445,23 @@
413446 foreach( $lines as $key => $l ) {
414447 if( $l->is_root ) {
415448 // unset($lines[$key]);
416 - $threads[] = Threads::buildLiveThread( &$lines, $l );
 449+ $threads[] = Threads::buildThread( &$lines, $l );
417450 }
418451 }
419452 return $threads;
420453 }
421454
422 - private static function buildLiveThread( $lines, $l ) {
 455+ private static function buildThread( $lines, $l ) {
423456 $children = array();
424457 $l_path = preg_quote($l->thread_path);
425458 foreach( $lines as $key => $m ) {
426459 if ( preg_match( "/^{$l_path}\.\d+$/", $m->thread_path ) ) {
427460 // unset($lines[$key]);
428 - $children[] = Threads::buildLiveThread( &$lines, $m );
 461+ $children[] = Threads::buildThread( &$lines, $m );
429462 }
430463 }
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;
433466 return $t;
434467 }
435468
@@ -448,8 +481,8 @@
449482 }
450483
451484 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 ];
454487 }
455488
456489 $ts = Threads::where( array('thread.thread_id' => $id ) );

Status & tagging log