Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | } |
15 | 15 | |
16 | 16 | require_once('LqtModel.php'); |
| 17 | +require_once('Pager.php'); |
17 | 18 | |
18 | 19 | class LqtDispatch { |
19 | 20 | static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) { |
— | — | @@ -31,7 +32,13 @@ |
32 | 33 | } |
33 | 34 | |
34 | 35 | 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 | + } |
36 | 43 | $view->show(); |
37 | 44 | } |
38 | 45 | |
— | — | @@ -502,12 +509,7 @@ |
503 | 510 | $this->showPostBody($t->summary()); |
504 | 511 | $this->closeDiv(); |
505 | 512 | } |
506 | | - |
507 | | - function showHistoryListing($t) { |
508 | | - foreach( $t->historicalRevisions() as $r ) { |
509 | | - $this->output->addHTML($r->revisionNumber()); |
510 | | - } |
511 | | - } |
| 513 | + |
512 | 514 | } |
513 | 515 | |
514 | 516 | class TalkpageView extends LqtView { |
— | — | @@ -851,7 +853,88 @@ |
852 | 854 | $this->output->addHTML('</table>'); |
853 | 855 | } |
854 | 856 | } |
| 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 | + } |
855 | 878 | |
| 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 | + |
856 | 939 | class ThreadPermalinkView extends LqtView { |
857 | 940 | protected $thread; |
858 | 941 | |
— | — | @@ -864,7 +947,6 @@ |
865 | 948 | } |
866 | 949 | |
867 | 950 | function show() { |
868 | | - |
869 | 951 | $t = Threads::withRoot( $this->article ); |
870 | 952 | $this->thread = $t; |
871 | 953 | |
— | — | @@ -889,17 +971,9 @@ |
890 | 972 | $this->output->setSubtitle( "from " . $talkpage_link ); |
891 | 973 | } |
892 | 974 | |
893 | | - if( $this->methodApplies('summarize') ) { |
| 975 | + if( $this->methodApplies('summarize') ) |
894 | 976 | $this->showSummarizeForm($t); |
895 | 977 | |
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 | | - |
903 | 978 | $this->showThread($t); |
904 | 979 | } |
905 | | - |
906 | 980 | } |