Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -640,11 +640,11 @@ |
641 | 641 | function loadQueryFromRequest() { |
642 | 642 | // Begin with with the requirements for being *in* the archive. |
643 | 643 | $startdate = Date::now()->nDaysAgo($this->archive_start_days)->midnight(); |
644 | | - $where = array('thread_article' => $this->article->getID(), |
645 | | - 'thread_subthread_of is null', |
646 | | - 'thread_summary_page is not null', |
647 | | - 'thread_timestamp < ' . $startdate->text()); |
648 | | - $options = array('ORDER BY' => 'thread_timestamp DESC'); |
| 644 | + $where = array('thread.thread_article' => $this->article->getID(), |
| 645 | + 'instr(thread.thread_path, ".")' => '0', |
| 646 | + 'thread.thread_summary_page is not null', |
| 647 | + 'thread.thread_timestamp < ' . $startdate->text()); |
| 648 | + $options = array('ORDER BY thread.thread_timestamp DESC'); |
649 | 649 | |
650 | 650 | $annotations = array("Searching for threads"); |
651 | 651 | |
— | — | @@ -656,7 +656,7 @@ |
657 | 657 | // as actually provided, for use by the 'older' and 'newer' buttons. |
658 | 658 | $ignore_dates = ! $r->getVal('lqt_archive_filter_by_date', true); |
659 | 659 | if ( !$ignore_dates ) { |
660 | | - $months = Thread::monthsWhereArticleHasThreads($this->article); |
| 660 | + $months = Threads::monthsWhereArticleHasThreads($this->article); |
661 | 661 | } |
662 | 662 | $s = $r->getVal('lqt_archive_start'); |
663 | 663 | if ($s && ctype_digit($s) && strlen($s) == 6 && !$ignore_dates) { |
— | — | @@ -687,7 +687,7 @@ |
688 | 688 | } |
689 | 689 | |
690 | 690 | function threads() { |
691 | | - return Thread::where($this->where, $this->options); |
| 691 | + return Threads::where($this->where, $this->options); |
692 | 692 | } |
693 | 693 | |
694 | 694 | function formattedMonth($yyyymm) { |
— | — | @@ -739,7 +739,7 @@ |
740 | 740 | } |
741 | 741 | |
742 | 742 | function showSearchForm() { |
743 | | - $months = Thread::monthsWhereArticleHasThreads($this->article); |
| 743 | + $months = Threads::monthsWhereArticleHasThreads($this->article); |
744 | 744 | |
745 | 745 | $use_dates = $this->request->getVal('lqt_archive_filter_by_date', null); |
746 | 746 | if ( $use_dates === null ) { |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -400,6 +400,21 @@ |
401 | 401 | } |
402 | 402 | return $ts[0]; |
403 | 403 | } |
| 404 | + |
| 405 | + /** |
| 406 | + * Horrible, horrible! |
| 407 | + * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth. */ |
| 408 | + static function monthsWhereArticleHasThreads( $article ) { |
| 409 | + $threads = Threads::where( array('thread.thread_article' => $article->getID()) ); |
| 410 | + $months = array(); |
| 411 | + foreach( $threads as $t ) { |
| 412 | + $m = substr( $t->timestamp(), 0, 6 ); |
| 413 | + if ( !array_key_exists( $m, $months ) ) { |
| 414 | + if (!in_array( $m, $months )) $months[] = $m; |
| 415 | + } |
| 416 | + } |
| 417 | + return $months; |
| 418 | + } |
404 | 419 | |
405 | 420 | } |
406 | 421 | |