r22871 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22870‎ | r22871 | r22872 >
Date:22:09, 9 June 2007
Author:david
Status:old
Tags:
Comment:
Correct behavior for 'older' and 'newer' buttons. Left to do proper date arithmetic when crossing year bounderies, and properly handle the end and beginning of the available date range. You'd think this would be easy.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -673,8 +673,9 @@
674674 }
675675 $e = $r->getVal('lqt_archive_end');
676676 if ($e && ctype_digit($e) && strlen($e) == 6 && !$ignore_dates) {
677 - $this->end = "{$e}31235959";
678 - $where[] = 'thread_touched <= ' . $this->end;
 677+ $this->end = "{$e}00000000";
 678+ $e += 1; // TODO addition on dates crossing years
 679+ $where[] = 'thread_touched < ' . "{$e}00000000";
679680 }
680681 if ( isset($this->start) && isset($this->end) ) {
681682 $annotations[] = "from $start to $end";
@@ -745,24 +746,30 @@
746747 $these_dates_check = $use_dates ? 'checked="1"' : '';
747748
748749 // bcsub() and bcadd() do arithmetic on strings.
749 - // wouldn't want to overflow any puny 32-bit machines with these
 750+ // Wouldn't want to overflow any puny 32-bit machines with these
750751 // giants numbers that reperesent dates.
751752
 753+ $one_month = '100000000';
752754 if( isset($this->start, $this->end) ) {
753755 var_dump($this->start, $this->end);
754 - $delta = bcsub($this->end, $this->start);
755 - $older_start = bcsub($this->start, $delta);
756 - $newer_start = bcadd($this->start, $delta);
757 - $older_end = bcsub($this->end, $delta);
758 - $newer_end = bcadd($this->end, $delta);
 756+
 757+ $older_end = bcsub($this->start,$one_month);
 758+ $older_start = bcsub($older_end, bcsub($this->end, $this->start));
 759+
 760+ $newer_start = bcadd($this->end, $one_month);
 761+ $newer_end = bcadd($newer_start, bcsub( $this->end, $this->start ));
 762+
 763+ var_dump($newer_start, $newer_end);
759764 }
760765
761 - var_dump($older_start, $older_end);
762 -
763766 $older = $this->queryReplace(array('lqt_archive_filter_by_date'=>'1',
764767 'lqt_archive_start' => substr($older_start, 0, 6),
765768 'lqt_archive_end' => substr($older_end, 0, 6) ));
 769+ $newer = $this->queryReplace(array('lqt_archive_filter_by_date'=>'1',
 770+ 'lqt_archive_start' => substr($newer_start, 0, 6),
 771+ 'lqt_archive_end' => substr($newer_end, 0, 6) ));
766772
 773+
767774 $this->output->addHTML(<<<HTML
768775 <form id="lqt_archive_search_form" action="{$this->title->getLocalURL()}">
769776 <input type="hidden" name="lqt_show_archive" value="1">
@@ -774,9 +781,9 @@
775782 name="lqt_archive_filter_by_date" value="1" {$these_dates_check}>
776783 <label for="lqt_archive_filter_by_date_yes">Only these dates:</label> <br>
777784
778 - <label for="lqt_archive_start">Start</label>
 785+ <label for="lqt_archive_start">From</label>
779786 {$this->monthSelect($months, 'lqt_archive_start')} <br>
780 - <label for="lqt_archive_end">End</label>
 787+ <label for="lqt_archive_end">To</label>
781788 {$this->monthSelect($months, 'lqt_archive_end')}
782789 <input type="submit">
783790

Status & tagging log