r23663 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23662‎ | r23663 | r23664 >
Date:03:55, 3 July 2007
Author:david
Status:old
Tags:
Comment:
split history into new view class; use pager, but not pagehistorypager; trying to reuse PageHistory.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -13,6 +13,7 @@
1414 }
1515
1616 require_once('LqtModel.php');
 17+require_once('Pager.php');
1718
1819 class LqtDispatch {
1920 static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) {
@@ -31,7 +32,13 @@
3233 }
3334
3435 static function threadPermalinkMain(&$output, &$article, &$title, &$user, &$request) {
35 - $view = new ThreadPermalinkView( $output, $article, $title, $user, $request );
 36+ /* breaking the lqt_method paradigm to make the history tab work.
 37+ (just changing the href doesn't make the highlighting correct.) */
 38+ if( $request->getVal('action') == 'history' ) {
 39+ $view = new ThreadHistoryView( $output, $article, $title, $user, $request );
 40+ } else {
 41+ $view = new ThreadPermalinkView( $output, $article, $title, $user, $request );
 42+ }
3643 $view->show();
3744 }
3845
@@ -502,12 +509,7 @@
503510 $this->showPostBody($t->summary());
504511 $this->closeDiv();
505512 }
506 -
507 - function showHistoryListing($t) {
508 - foreach( $t->historicalRevisions() as $r ) {
509 - $this->output->addHTML($r->revisionNumber());
510 - }
511 - }
 513+
512514 }
513515
514516 class TalkpageView extends LqtView {
@@ -851,7 +853,88 @@
852854 $this->output->addHTML('</table>');
853855 }
854856 }
 857+/*
 858+CREATE TABLE historical_thread (
 859+ -- Note that many hthreads can share an id, which is the same as the id
 860+ -- of the live thread. It is only the id/revision combo which must be unique.
 861+ hthread_id int(8) unsigned NOT NULL,
 862+ hthread_revision int(8) unsigned NOT NULL,
 863+ hthread_contents BLOB NOT NULL,
 864+ PRIMARY KEY hthread_id_revision (hthread_id, hthread_revision)
 865+) TYPE=InnoDB;
 866+*/
 867+/**
 868+ * @addtogroup Pager
 869+ */
 870+class ThreadHistoryPager extends ReverseChronologicalPager {
 871+ public $mLastRow = false;
 872+ protected $thread;
 873+
 874+ function __construct( $thread ) {
 875+ parent::__construct();
 876+ $this->thread = $thread;
 877+ }
855878
 879+ function getQueryInfo() {
 880+ return array(
 881+ 'tables' => 'historical_thread',
 882+ 'fields' => 'hthread_id, hthread_revision, hthread_contents',
 883+ 'conds' => array('hthread_id' => $this->thread->id() ),
 884+ 'options' => array()
 885+ );
 886+ }
 887+
 888+ function getIndexField() {
 889+ return 'hthread_revision';
 890+ }
 891+
 892+ function formatRow( $row ) {
 893+ return '<li>' . $row->hthread_revision;
 894+ }
 895+
 896+ function getStartBody() {
 897+ $this->mLastRow = false;
 898+ $this->mCounter = 1;
 899+ return 'start';
 900+ }
 901+
 902+ function getEndBody() {
 903+ return "";
 904+ }
 905+}
 906+
 907+class ThreadHistoryView extends ThreadPermalinkView {
 908+
 909+ function showHistoryListing($t) {
 910+ $pager = new ThreadHistoryPager( $this->thread );
 911+ $this->linesonpage = $pager->getNumRows();
 912+ $this->output->addHTML(
 913+ $pager->getNavigationBar() .
 914+// $this->beginHistoryList() .
 915+ $pager->getBody() .
 916+// $this->endHistoryList() .
 917+ $pager->getNavigationBar()
 918+ );
 919+ }
 920+
 921+ function show() {
 922+ $t = Threads::withRoot( $this->article );
 923+ $this->thread = $t;
 924+
 925+ // TODO this is a holdover from the special page; not sure what's correct here.
 926+ // we now have a real true $this->article that makes some sense.
 927+ // but we still want to know about $t->article.
 928+ $this->article = $t->article(); # for creating reply threads.
 929+
 930+ $this->output->setSubtitle("viewing a historical thread...");
 931+
 932+ $this->showThreadHeading($t);
 933+ $this->showHistoryListing($t);
 934+
 935+ $this->showThread($t);
 936+ }
 937+}
 938+
856939 class ThreadPermalinkView extends LqtView {
857940 protected $thread;
858941
@@ -864,7 +947,6 @@
865948 }
866949
867950 function show() {
868 -
869951 $t = Threads::withRoot( $this->article );
870952 $this->thread = $t;
871953
@@ -889,17 +971,9 @@
890972 $this->output->setSubtitle( "from " . $talkpage_link );
891973 }
892974
893 - if( $this->methodApplies('summarize') ) {
 975+ if( $this->methodApplies('summarize') )
894976 $this->showSummarizeForm($t);
895977
896 - /* breaking the lqt_method paradigm to make the history tab work. */
897 - } else if( $this->request->getVal('action') === 'history') {
898 - $this->showThreadHeading($t);
899 - $this->showHistoryListing($t);
900 - return;
901 - }
902 -
903978 $this->showThread($t);
904979 }
905 -
906980 }

Status & tagging log