Index: branches/liquidthreads/extensions/LqtPages.php |
— | — | @@ -386,31 +386,14 @@ |
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | | - function showHistoryInfo() { |
391 | | - global $wgLang; // TODO global. |
392 | | - $this->openDiv('lqt_history_info'); |
393 | | - $this->output->addHTML('Revision as of ' . $wgLang->timeanddate($this->thread->timestamp()) . '.<br>' ); |
394 | | - if( $this->thread->changeType() == Threads::CHANGE_NEW_THREAD ) { |
395 | | - $this->output->addHTML('This is the thread\'s initial revision.'); |
396 | | - } |
397 | | - else if( $this->thread->changeType() == Threads::CHANGE_REPLY_CREATED ) { |
398 | | - $this->output->addHTML('The highlighted comment was created in this revision.'); |
399 | | - } else if( $this->thread->changeType() == Threads::CHANGE_EDITED_ROOT ) { |
400 | | - $diff_url = $this->permalinkUrlWithDiff($this->thread); |
401 | | - $this->output->addHTML('The highlighted comment was edited in this revision. '); |
402 | | - $this->output->addHTML( "[<a href=\"$diff_url\">show diffs</a>]" ); |
403 | | - } |
404 | | - $this->closeDiv(); |
405 | | - } |
406 | | - |
407 | 390 | function noSuchRevision() { |
408 | 391 | $this->output->addHTML("There is no such revision of this thread."); |
409 | 392 | } |
410 | | - |
411 | | - function show() { |
412 | | - global $wgHooks; |
413 | | - $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs'); |
| 393 | + |
| 394 | + function __construct(&$output, &$article, &$title, &$user, &$request) { |
414 | 395 | |
| 396 | + parent::__construct($output, $article, $title, $user, $request); |
| 397 | + |
415 | 398 | $t = Threads::withRoot( $this->article ); |
416 | 399 | $r = $this->request->getVal('lqt_oldid', null); if( $r ) { |
417 | 400 | $t = $t->atRevision($r); |
— | — | @@ -422,32 +405,34 @@ |
423 | 406 | // TODO this is a holdover from the special page; not sure what's correct here. |
424 | 407 | // we now have a real true $this->article that makes some sense. |
425 | 408 | // but we still want to know about $t->article. |
426 | | - $this->article = $t->article(); # for creating reply threads. |
| 409 | +// $this->article = $t->article(); # for creating reply threads. |
427 | 410 | |
| 411 | + } |
| 412 | + |
| 413 | + function show() { |
| 414 | + global $wgHooks; |
| 415 | + $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs'); |
| 416 | + |
428 | 417 | // Make a link back to the talk page, including the correct archive month. |
429 | 418 | // TODO this is obsolete. |
430 | | - if (Date::now()->nDaysAgo(30)->midnight()->isBefore( new Date($t->timestamp()) )) |
| 419 | + if (Date::now()->nDaysAgo(30)->midnight()->isBefore( new Date($this->thread->timestamp()) )) |
431 | 420 | $query = ''; |
432 | 421 | else |
433 | | - $query = 'lqt_archive_month=' . substr($t->timestamp(),0,6); |
| 422 | + $query = 'lqt_archive_month=' . substr($this->thread->timestamp(),0,6); |
434 | 423 | |
435 | | - $talkpage = $t->article()->getTitle()->getTalkpage(); |
| 424 | + $talkpage = $this->thread->article()->getTitle()->getTalkpage(); |
436 | 425 | $talkpage_link = $this->user->getSkin()->makeKnownLinkObj($talkpage, '', $query); |
437 | 426 | |
438 | | - if ( $t->hasSuperthread() ) { |
439 | | - $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link ); |
| 427 | + if ( $this->thread->hasSuperthread() ) { |
| 428 | + $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($this->thread->topmostThread())}\">a discussion</a> from " . $talkpage_link ); |
440 | 429 | } else { |
441 | 430 | $this->output->setSubtitle( "from " . $talkpage_link ); |
442 | 431 | } |
443 | 432 | |
444 | 433 | if( $this->methodApplies('summarize') ) |
445 | | - $this->showSummarizeForm($t); |
| 434 | + $this->showSummarizeForm($this->thread); |
446 | 435 | |
447 | | - if($t->isHistorical()) { |
448 | | - $this->showHistoryInfo(); |
449 | | - } |
450 | | - |
451 | | - $this->showThread($t); |
| 436 | + $this->showThread($this->thread); |
452 | 437 | } |
453 | 438 | } |
454 | 439 | |
— | — | @@ -555,7 +540,7 @@ |
556 | 541 | } |
557 | 542 | } |
558 | 543 | |
559 | | -class ThreadHistoryView extends ThreadPermalinkView { |
| 544 | +class ThreadHistoryListingView extends ThreadPermalinkView { |
560 | 545 | |
561 | 546 | private function rowForThread($t) { |
562 | 547 | global $wgLang, $wgOut; // TODO global. |
— | — | @@ -596,26 +581,65 @@ |
597 | 582 | function show() { |
598 | 583 | global $wgHooks; |
599 | 584 | $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs'); |
600 | | - |
| 585 | + |
| 586 | +/* var_dump($this->article); |
601 | 587 | $t = Threads::withRoot( $this->article ); |
602 | 588 | $this->thread = $t; |
603 | | - |
| 589 | +*/ |
604 | 590 | // TODO this is a holdover from the special page; not sure what's correct here. |
605 | 591 | // we now have a real true $this->article that makes some sense. |
606 | 592 | // but we still want to know about $t->article. |
607 | | - $this->article = $t->article(); # for creating reply threads. |
| 593 | +// $this->article = $t->article(); # for creating reply threads. |
608 | 594 | |
609 | 595 | $this->output->setSubtitle("Viewing a history listing."); |
610 | 596 | |
611 | | - $this->showThreadHeading($t); |
612 | | - $this->showHistoryListing($t); |
| 597 | + $this->showThreadHeading($this->thread); |
| 598 | + $this->showHistoryListing($this->thread); |
613 | 599 | |
614 | | - $this->showThread($t); |
| 600 | + $this->showThread($this->thread); |
615 | 601 | } |
616 | 602 | } |
617 | 603 | |
| 604 | +class ThreadHistoricalRevisionView extends ThreadPermalinkView { |
| 605 | + |
| 606 | + /* TOOD: customize tabs so that History is highlighted. */ |
618 | 607 | |
| 608 | + function threadDivClass($thread) { |
| 609 | + // efVarDump($this->output, $thread->changeObject()->id()); |
| 610 | + $is_changed_thread = $thread->changeObject() && |
| 611 | + $thread->changeObject()->id() == $thread->id(); |
619 | 612 | |
| 613 | + if ( $is_changed_thread ) |
| 614 | + return 'lqt_thread lqt_thread_changed_by_history'; |
| 615 | + else |
| 616 | + return 'lqt_thread'; |
| 617 | + } |
| 618 | + |
| 619 | + |
| 620 | + function showHistoryInfo() { |
| 621 | + global $wgLang; // TODO global. |
| 622 | + $this->openDiv('lqt_history_info'); |
| 623 | + $this->output->addHTML('Revision as of ' . $wgLang->timeanddate($this->thread->timestamp()) . '.<br>' ); |
| 624 | + if( $this->thread->changeType() == Threads::CHANGE_NEW_THREAD ) { |
| 625 | + $this->output->addHTML('This is the thread\'s initial revision.'); |
| 626 | + } |
| 627 | + else if( $this->thread->changeType() == Threads::CHANGE_REPLY_CREATED ) { |
| 628 | + $this->output->addHTML('The highlighted comment was created in this revision.'); |
| 629 | + } else if( $this->thread->changeType() == Threads::CHANGE_EDITED_ROOT ) { |
| 630 | + $diff_url = $this->permalinkUrlWithDiff($this->thread); |
| 631 | + $this->output->addHTML('The highlighted comment was edited in this revision. '); |
| 632 | + $this->output->addHTML( "[<a href=\"$diff_url\">show diffs</a>]" ); |
| 633 | + } |
| 634 | + $this->closeDiv(); |
| 635 | + } |
| 636 | + |
| 637 | + function show() { |
| 638 | + $this->showHistoryInfo(); |
| 639 | + parent::show(); |
| 640 | + } |
| 641 | +} |
| 642 | + |
| 643 | + |
620 | 644 | /* We have to do this goofy wgExtensionFunctions run-around because |
621 | 645 | the files required by SpecialPage aren't required_onced() yet by |
622 | 646 | the time this file is. Don't ask me why. */ |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -292,8 +292,16 @@ |
293 | 293 | } |
294 | 294 | |
295 | 295 | private static function setChangeOnDescendents($thread, $change_type, $change_object) { |
| 296 | + // TODO this is ludicrously inefficient. |
296 | 297 | $thread->setChangeType($change_type); |
297 | 298 | $thread->setChangeObject($change_object); |
| 299 | + $dbr =& wfGetDB( DB_MASTER ); |
| 300 | + $res = $dbr->update( 'thread', |
| 301 | + /* SET */ array('thread_revision' => $thread->revisionNumber, |
| 302 | + 'thread_change_type'=>$thread->changeType, |
| 303 | + 'thread_change_object'=>$thread->changeObject), |
| 304 | + /* WHERE */ array( 'thread_id' => $thread->id ), |
| 305 | + __METHOD__); |
298 | 306 | foreach($thread->replies() as $r) |
299 | 307 | self::setChangeOnDescendents($r, $change_type, $change_object); |
300 | 308 | return $thread; |
— | — | @@ -310,7 +318,7 @@ |
311 | 319 | HistoricalThread::create( $this->double, $change_type, $change_object ); |
312 | 320 | |
313 | 321 | $this->bumpRevisionsOnAncestors($change_type, $change_object); |
314 | | - // self::setChangeOnDescendents($this->topmostThread(), $change_type, $change_object); |
| 322 | + self::setChangeOnDescendents($this->topmostThread(), $change_type, $change_object); |
315 | 323 | |
316 | 324 | /* SCHEMA changes must be reflected here. */ |
317 | 325 | |
— | — | @@ -461,6 +469,18 @@ |
462 | 470 | |
463 | 471 | $this->double = clone $this; |
464 | 472 | } |
| 473 | + |
| 474 | + function __clone() { |
| 475 | + // Cloning does not normally create a new array (but the clone keyword doesn't |
| 476 | + // work on arrays -- go figure). |
| 477 | + |
| 478 | + // Update: this doesn't work for some reason, but why do we update the replies array |
| 479 | + // in the first place after creating a new reply? |
| 480 | + $new_array = array(); |
| 481 | + foreach( $this->replies as $r ) |
| 482 | + $new_array[] = $r; |
| 483 | + $this->replies = $new_array; |
| 484 | + } |
465 | 485 | |
466 | 486 | /* |
467 | 487 | More evidence that the way I'm doing history is totally screwed. |
— | — | @@ -468,7 +488,9 @@ |
469 | 489 | is make sure the latest info gets into any historicalthreads we commit. |
470 | 490 | */ |
471 | 491 | function addReply($thread) { |
472 | | - $this->replies[] = $thread; |
| 492 | + // TODO: question for myself to ponder: We don't want the latest info in the |
| 493 | + // historical thread, duh. Why were we doing this? |
| 494 | +// $this->replies[] = $thread; |
473 | 495 | } |
474 | 496 | function removeReplyWithId($id) { |
475 | 497 | $target = null; |
Index: branches/liquidthreads/extensions/LqtBaseView.php |
— | — | @@ -30,7 +30,8 @@ |
31 | 31 | 'TalkpageArchiveView' => 'TalkpageArchiveView', |
32 | 32 | 'TalkpageHeaderView' => 'TalkpageHeaderView', |
33 | 33 | 'TalkpageView' => 'TalkpageView', |
34 | | - 'ThreadHistoryView' => 'ThreadHistoryView', |
| 34 | + 'ThreadHistoryListingView' => 'ThreadHistoryListingView', |
| 35 | + 'ThreadHistoricalRevisionView' => 'ThreadHistoricalRevisionView', |
35 | 36 | 'ThreadPermalinkView' => 'ThreadPermalinkView' |
36 | 37 | ); |
37 | 38 | |
— | — | @@ -66,7 +67,9 @@ |
67 | 68 | /* breaking the lqt_method paradigm to make the history tab work. |
68 | 69 | (just changing the href doesn't make the highlighting correct.) */ |
69 | 70 | if( $request->getVal('action') == 'history' ) { |
70 | | - $viewname = self::$views['ThreadHistoryView']; |
| 71 | + $viewname = self::$views['ThreadHistoryListingView']; |
| 72 | + } else if ( $request->getVal('lqt_oldid', null) !== null ) { |
| 73 | + $viewname = self::$views['ThreadHistoricalRevisionView']; |
71 | 74 | } else { |
72 | 75 | $viewname = self::$views['ThreadPermalinkView']; |
73 | 76 | } |
— | — | @@ -547,21 +550,16 @@ |
548 | 551 | $html . wfCloseElement("h{$this->headerLevel}") ); |
549 | 552 | } |
550 | 553 | } |
| 554 | + |
| 555 | + function threadDivClass( $thread ) { |
| 556 | + return 'lqt_thread'; |
| 557 | + } |
551 | 558 | |
552 | 559 | function showThread( $thread ) { |
553 | 560 | global $wgLang; # TODO global. |
554 | 561 | |
555 | | - efVarDump($this->output, $thread->changeObject()->id()); |
556 | | - $is_changed_thread = $thread->isHistorical() && $thread->changeObject()->id() == $thread->id(); |
557 | | - |
558 | 562 | $this->showThreadHeading( $thread ); |
559 | 563 | |
560 | | - |
561 | | - |
562 | | -/* efVarDump($this->output, $thread->isHistorical()); |
563 | | - efVarDump($this->output, $thread->id()); |
564 | | - efVarDump($this->output, $thread->changeObject()->id()); |
565 | | -*/ |
566 | 564 | $this->output->addHTML( "<a name=\"lqt_thread_{$thread->id()}\" ></a>" ); |
567 | 565 | |
568 | 566 | if ($thread->type() == Threads::TYPE_MOVED) { |
— | — | @@ -597,13 +595,9 @@ |
598 | 596 | && !$thread->summary() && !$thread->hasSuperthread() && !$thread->isHistorical() ) { |
599 | 597 | $this->output->addHTML("<p class=\"lqt_summary_notice\">If this discussion seems to be concluded, you are encouraged to <a href=\"{$this->permalinkUrl($thread, 'summarize')}\">write a summary</a>. There have been no changes here for at least $this->archive_start_days days.</p>"); |
600 | 598 | } |
| 599 | + |
| 600 | + $this->openDiv($this->threadDivClass($thread), "lqt_thread_id_{$thread->id()}"); |
601 | 601 | |
602 | | - if( $is_changed_thread ) { |
603 | | - $this->openDiv('lqt_thread lqt_thread_changed_by_history', "lqt_thread_id_{$thread->id()}"); |
604 | | - } else { |
605 | | - $this->openDiv('lqt_thread', "lqt_thread_id_{$thread->id()}"); |
606 | | - } |
607 | | - |
608 | 602 | $this->showRootPost( $thread ); |
609 | 603 | $this->indent(); |
610 | 604 | foreach( $thread->subthreads() as $st ) { |