r24103 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24102‎ | r24103 | r24104 >
Date:02:30, 15 July 2007
Author:david
Status:old
Tags:
Comment:
actually showing old revisions works
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -71,7 +71,7 @@
7272
7373 $wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage');
7474
75 -
 75+
7676 class LqtView {
7777 protected $article;
7878 protected $output;
@@ -359,14 +359,15 @@
360360 * Output methods *
361361 *************************/
362362
363 - function showPostBody( $post ) {
 363+ function showPostBody( $post, $oldid = null ) {
 364+ /* Why isn't this all encapsulated in Article somewhere? TODO */
364365 global $wgEnableParserCache;
365366
366367 // Should the parser cache be used?
367368 $pcache = $wgEnableParserCache &&
368369 intval( $this->user->getOption( 'stubthreshold' ) ) == 0 &&
369370 $post->exists() &&
370 - empty( $oldid ); // FIXME oldid
 371+ $oldid === null;
371372 wfDebug( 'LqtView::showPostBody using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" );
372373 if ( $this->user->getOption( 'stubthreshold' ) ) {
373374 wfIncrStats( 'pcache_miss_stub' );
@@ -379,7 +380,7 @@
380381
381382 if (!$outputDone) {
382383 // Cache miss; parse and output it.
383 - $rev = Revision::newFromTitle( $post->getTitle() );
 384+ $rev = Revision::newFromTitle( $post->getTitle(), $oldid );
384385 $this->output->addWikiText( $rev->getText() );
385386 }
386387 }
@@ -432,6 +433,8 @@
433434 function showRootPost( $thread ) {
434435 $post = $thread->root();
435436
 437+ $oldid = $thread->isHistorical() ? $thread->rootRevision() : null;
 438+
436439 /* $color_number = $this->selectNewUserColor( $thread->root()->originalAuthor() );
437440 $this->openDiv( "lqt_post lqt_post_color_$color_number" );*/
438441 $this->openDiv( 'lqt_post' );
@@ -439,7 +442,7 @@
440443 if( $this->methodAppliesToThread( 'edit', $thread ) ) {
441444 $this->showPostEditingForm( $thread );
442445 } else{
443 - $this->showPostBody( $post );
 446+ $this->showPostBody( $post, $oldid );
444447 $this->showThreadFooter( $thread );
445448 }
446449
@@ -833,7 +836,6 @@
834837 </table>
835838 <input type="submit">
836839 $older $newer
837 -</table>
838840 </form>
839841 HTML
840842 );
@@ -975,9 +977,18 @@
976978 parent::showThreadHeading($thread);
977979 }
978980 }
 981+
 982+ function noSuchRevision() {
 983+ $this->output->addHTML("There is no such revision of this thread.");
 984+ }
979985
980986 function show() {
981987 $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+ }
982993 $this->thread = $t;
983994
984995 // TODO this is a holdover from the special page; not sure what's correct here.
@@ -1003,7 +1014,7 @@
10041015
10051016 if( $this->methodApplies('summarize') )
10061017 $this->showSummarizeForm($t);
1007 -
 1018+
10081019 $this->showThread($t);
10091020 }
10101021 }
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -101,6 +101,7 @@
102102 class HistoricalThread extends Thread {
103103 function __construct($t) {
104104 $this->rootId = $t->rootId;
 105+ $this->rootRevision = $t->rootRevision;
105106 $this->articleId = $t->articleId;
106107 $this->summaryId = $t->summaryId;
107108 $this->articleNamespace = $t->articleNamespace;
@@ -143,6 +144,7 @@
144145 else
145146 return null;
146147 }
 148+ function isHistorical() { return true; }
147149 }
148150
149151 class Thread {
@@ -178,10 +180,16 @@
179181
180182 protected $replies;
181183
 184+ function isHistorical() {return false;}
 185+
182186 function revisionNumber() {
183187 return $this->revisionNumber;
184188 }
185189
 190+ function atRevision($r) {
 191+ return HistoricalThread::withIdAtRevision($this->id(), $r);
 192+ }
 193+
186194 function historicalRevisions() {
187195 $dbr =& wfGetDB( DB_SLAVE );
188196 $res = $dbr->select(
@@ -322,7 +330,8 @@
323331
324332 function root() {
325333 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() );
327336 return $this->root;
328337 }
329338
@@ -334,6 +343,10 @@
335344 }
336345 }
337346
 347+ function rootRevision() {
 348+ return $this->rootRevision;
 349+ }
 350+
338351 function summary() {
339352 if ( !$this->summaryId ) return null;
340353 if ( !$this->summary ) $this->summary = new Post( Title::newFromID( $this->summaryId ) );

Status & tagging log