r23150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23149‎ | r23150 | r23151 >
Date:02:18, 21 June 2007
Author:david
Status:old
Tags:
Comment:
archive browser works again, still sucks though.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -640,11 +640,11 @@
641641 function loadQueryFromRequest() {
642642 // Begin with with the requirements for being *in* the archive.
643643 $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');
649649
650650 $annotations = array("Searching for threads");
651651
@@ -656,7 +656,7 @@
657657 // as actually provided, for use by the 'older' and 'newer' buttons.
658658 $ignore_dates = ! $r->getVal('lqt_archive_filter_by_date', true);
659659 if ( !$ignore_dates ) {
660 - $months = Thread::monthsWhereArticleHasThreads($this->article);
 660+ $months = Threads::monthsWhereArticleHasThreads($this->article);
661661 }
662662 $s = $r->getVal('lqt_archive_start');
663663 if ($s && ctype_digit($s) && strlen($s) == 6 && !$ignore_dates) {
@@ -687,7 +687,7 @@
688688 }
689689
690690 function threads() {
691 - return Thread::where($this->where, $this->options);
 691+ return Threads::where($this->where, $this->options);
692692 }
693693
694694 function formattedMonth($yyyymm) {
@@ -739,7 +739,7 @@
740740 }
741741
742742 function showSearchForm() {
743 - $months = Thread::monthsWhereArticleHasThreads($this->article);
 743+ $months = Threads::monthsWhereArticleHasThreads($this->article);
744744
745745 $use_dates = $this->request->getVal('lqt_archive_filter_by_date', null);
746746 if ( $use_dates === null ) {
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -400,6 +400,21 @@
401401 }
402402 return $ts[0];
403403 }
 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+ }
404419
405420 }
406421

Status & tagging log