Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -128,7 +128,14 @@ |
129 | 129 | display: inline; |
130 | 130 | } |
131 | 131 | |
| 132 | +.lqt_search_annotations { |
| 133 | + float: left; |
| 134 | + text-align: right; |
| 135 | + font-style: italic; |
| 136 | +} |
| 137 | + |
132 | 138 | #lqt_archive_search_form { |
| 139 | + clear:left; |
133 | 140 | border: 1px solid #ddd; |
134 | 141 | margin: 0.5em 0; |
135 | 142 | background-color: #eee; |
— | — | @@ -138,7 +145,9 @@ |
139 | 146 | #lqt_archive_search_form table { |
140 | 147 | background-color: transparent; |
141 | 148 | } |
142 | | - |
| 149 | +.lqt_archive_listing { |
| 150 | + clear: left; |
| 151 | +} |
143 | 152 | .lqt_archive_listing td { |
144 | 153 | padding-right: 2em; |
145 | 154 | padding-bottom: 1em; |
Index: branches/liquidthreads/skins/common/lqt.js |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | // In order for this instance to recieve the events, we need to capture the |
40 | 40 | // current value of 'this' with a closure, because this = the target object |
41 | 41 | // in event handlers. |
42 | | - me = this; |
| 42 | + var me = this; |
43 | 43 | lqt_add_event( this.startsel, 'change', function(e) { me.handle_start_changed(e) }); |
44 | 44 | lqt_add_event( this.endsel, 'change', function(e) { me.handle_end_changed(e) }); |
45 | 45 | } |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -670,26 +670,36 @@ |
671 | 671 | $r = $this->request; |
672 | 672 | |
673 | 673 | /* START AND END DATES */ |
| 674 | + // $this->start and $this->end are clipped into the range of available |
| 675 | + // months, for use in the actual query and the selects. $this->raw* are |
| 676 | + // as actually provided, for use by the 'older' and 'newer' buttons. |
674 | 677 | $ignore_dates = ! $r->getVal('lqt_archive_filter_by_date', true); |
| 678 | + if ( !$ignore_dates ) { |
| 679 | + $months = Thread::monthsWhereArticleHasThreads($this->article); |
| 680 | + } |
675 | 681 | $s = $r->getVal('lqt_archive_start'); |
676 | 682 | if ($s && ctype_digit($s) && strlen($s) == 6 && !$ignore_dates) { |
677 | | - $this->start = new Date( "{$s}01000000" ); |
678 | | - $where[] = 'thread_touched >= ' . $this->start->text(); |
| 683 | + $this->selstart = new Date( "{$s}01000000" ); |
| 684 | + $this->starti = array_search($s, $months); |
| 685 | + $where[] = 'thread_touched >= ' . $this->selstart->text(); |
679 | 686 | } |
680 | 687 | $e = $r->getVal('lqt_archive_end'); |
681 | 688 | if ($e && ctype_digit($e) && strlen($e) == 6 && !$ignore_dates) { |
682 | | - $end = new Date("{$e}01000000"); |
683 | | - $this->end = $end->nextMonth(); |
684 | | - $where[] = 'thread_touched < ' . $this->end->text(); |
| 689 | + $this->selend = new Date("{$e}01000000"); |
| 690 | + $this->endi = array_search($e, $months); |
| 691 | + $where[] = 'thread_touched < ' . $this->selend->nextMonth()->text(); |
685 | 692 | } |
686 | | - if ( isset($this->start) && isset($this->end) ) { |
687 | | - $annotations[] = "from {$this->start->text()} to {$this->end->text()}"; |
688 | | - } else if (isset($this->start)) { |
689 | | - $annotations[] = "after {$this->start->text()}"; |
690 | | - } else if (isset($this->end)) { |
691 | | - $annotations[] = "before {$this->end->text()}"; |
| 693 | + if ( isset($this->selstart) && isset($this->selend) ) { |
| 694 | + |
| 695 | + $this->datespan = $this->starti - $this->endi; |
| 696 | + |
| 697 | + $annotations[] = "from {$this->selstart->text()} to {$this->selend->text()}"; |
| 698 | + } else if (isset($this->selstart)) { |
| 699 | + $annotations[] = "after {$this->selstart->text()}"; |
| 700 | + } else if (isset($this->selend)) { |
| 701 | + $annotations[] = "before {$this->selend->text()}"; |
692 | 702 | } |
693 | | - |
| 703 | + |
694 | 704 | $this->where = $where; |
695 | 705 | $this->options = $options; |
696 | 706 | $this->annotations = implode("<br>\n", $annotations); |
— | — | @@ -706,6 +716,10 @@ |
707 | 717 | |
708 | 718 | function monthSelect($months, $name) { |
709 | 719 | $selection = $this->request->getVal($name); |
| 720 | + |
| 721 | + // Silently adjust to stay in range. |
| 722 | + $selection = max( min( $selection, $months[0] ), $months[count($months)-1] ); |
| 723 | + |
710 | 724 | $options = array(); |
711 | 725 | foreach($months as $m) { |
712 | 726 | $options[$this->formattedMonth($m)] = $m; |
— | — | @@ -737,9 +751,15 @@ |
738 | 752 | return $this->title->getFullURL($this->queryStringFromArray($rs)); |
739 | 753 | } |
740 | 754 | |
| 755 | + function clip( $vals, $min, $max ) { |
| 756 | + $res = array(); |
| 757 | + foreach($vals as $val) $res[] = max( min( $val, $max ), $min ); |
| 758 | + return $res; |
| 759 | + } |
| 760 | + |
741 | 761 | function showSearchForm() { |
742 | 762 | $months = Thread::monthsWhereArticleHasThreads($this->article); |
743 | | - |
| 763 | + |
744 | 764 | $use_dates = $this->request->getVal('lqt_archive_filter_by_date', null); |
745 | 765 | if ( $use_dates === null ) { |
746 | 766 | $use_dates = $this->request->getBool('lqt_archive_start', false) || |
— | — | @@ -748,27 +768,31 @@ |
749 | 769 | $any_date_check = !$use_dates ? 'checked="1"' : ''; |
750 | 770 | $these_dates_check = $use_dates ? 'checked="1"' : ''; |
751 | 771 | |
752 | | - if( isset($this->start, $this->end) ) { |
753 | | - $older_end = $this->start->lastMonth(); |
754 | | - $older_start = $older_end->moved( $this->start->delta( $this->end ) )->nextMonth(); |
| 772 | + if( isset($this->datespan) ) { |
| 773 | + $oatte = $this->starti + 1; |
| 774 | + $oatts = $this->starti + 1 + $this->datespan; |
755 | 775 | |
756 | | - $newer_start = $this->end; |
757 | | - $newer_end = $newer_start->moved( $this->end->delta( $this->start ) )->lastMonth(); |
| 776 | + $natts = $this->endi - 1; |
| 777 | + $natte = $this->endi - 1 - $this->datespan; |
758 | 778 | |
| 779 | + list($oe, $os, $ns, $ne) = |
| 780 | + $this->clip( array($oatte, $oatts, $natts, $natte), |
| 781 | + 0, count($months)-1 ); |
| 782 | + |
759 | 783 | $older = '<a href="' . $this->queryReplace(array( |
760 | 784 | 'lqt_archive_filter_by_date'=>'1', |
761 | | - 'lqt_archive_start' => substr($older_start->text(), 0, 6), |
762 | | - 'lqt_archive_end' => substr($older_end->text(), 0, 6) )) |
| 785 | + 'lqt_archive_start' => $months[$os], |
| 786 | + 'lqt_archive_end' => $months[$oe])) |
763 | 787 | . '">«older</a>'; |
764 | 788 | $newer = '<a href="' . $this->queryReplace(array( |
765 | 789 | 'lqt_archive_filter_by_date'=>'1', |
766 | | - 'lqt_archive_start' => substr($newer_start->text(), 0, 6), |
767 | | - 'lqt_archive_end' => substr($newer_end->text(), 0, 6) )) |
| 790 | + 'lqt_archive_start' => $months[$ns], |
| 791 | + 'lqt_archive_end' => $months[$ne])) |
768 | 792 | . '">newer»</a>'; |
769 | 793 | } |
770 | 794 | else { |
771 | | - $older = '<span class="lqt_disabled_link">«older</span>'; |
772 | | - $newer = '<span class="lqt_disabled_link">newer»</span>'; |
| 795 | + $older = '<span class="lqt_disabled_link" title="This link is disabled because you are viewing threads from all dates.">«older</span>'; |
| 796 | + $newer = '<span class="lqt_disabled_link" title="This link is disabled because you are viewing threads from all dates.">newer»</span>'; |
773 | 797 | } |
774 | 798 | |
775 | 799 | $this->output->addHTML(<<<HTML |
— | — | @@ -805,8 +829,9 @@ |
806 | 830 | $this->addJSandCSS(); |
807 | 831 | |
808 | 832 | $this->showSearchForm(); |
809 | | - $this->output->addHTML("<p>" . $this->annotations . ".</p>"); |
| 833 | + |
810 | 834 | $this->output->addHTML(<<<HTML |
| 835 | +<p class="lqt_search_annotations">{$this->annotations}</p> |
811 | 836 | <table class="lqt_archive_listing"> |
812 | 837 | <col class="lqt_titles" /> |
813 | 838 | <col class="lqt_summaries" /> |