Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -33,6 +33,10 @@ |
34 | 34 | margin-bottom: .1em; |
35 | 35 | }*/ |
36 | 36 | |
| 37 | +.lqt_disabled_link { |
| 38 | + color: #999; |
| 39 | +} |
| 40 | + |
37 | 41 | .lqt_start_discussion { |
38 | 42 | vertical-align: center; |
39 | 43 | } |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -673,13 +673,13 @@ |
674 | 674 | $ignore_dates = ! $r->getVal('lqt_archive_filter_by_date', true); |
675 | 675 | $s = $r->getVal('lqt_archive_start'); |
676 | 676 | if ($s && ctype_digit($s) && strlen($s) == 6 && !$ignore_dates) { |
677 | | - $this->start = new Date( "{$s}01000000" ); |
| 677 | + $this->start = new Date( "{$s}01000000" ); |
678 | 678 | $where[] = 'thread_touched >= ' . $this->start->text(); |
679 | 679 | } |
680 | 680 | $e = $r->getVal('lqt_archive_end'); |
681 | 681 | if ($e && ctype_digit($e) && strlen($e) == 6 && !$ignore_dates) { |
682 | | - $end = new Date("{$e}01000000"); |
683 | | - $this->end = $end->nextMonth(); |
| 682 | + $end = new Date("{$e}01000000"); |
| 683 | + $this->end = $end->nextMonth(); |
684 | 684 | $where[] = 'thread_touched < ' . $this->end->text(); |
685 | 685 | } |
686 | 686 | if ( isset($this->start) && isset($this->end) ) { |
— | — | @@ -699,23 +699,21 @@ |
700 | 700 | return Thread::threadsWhere($this->where, $this->options); |
701 | 701 | } |
702 | 702 | |
703 | | - function formattedMonth($yyyymm) { |
704 | | - global $wgLang; // TODO global. |
705 | | - return $wgLang->getMonthName( substr($yyyymm, 4, 2) ).' '.substr($yyyymm, 0, 4); |
706 | | - } |
| 703 | + function formattedMonth($yyyymm) { |
| 704 | + global $wgLang; // TODO global. |
| 705 | + return $wgLang->getMonthName( substr($yyyymm, 4, 2) ).' '.substr($yyyymm, 0, 4); |
| 706 | + } |
707 | 707 | |
708 | 708 | function monthSelect($months, $name) { |
709 | 709 | $selection = $this->request->getVal($name); |
710 | | - $options = array(); |
711 | | - foreach($months as $m) { |
712 | | - $options[$this->formattedMonth($m)] = $m; |
713 | | - } |
714 | | - $result = <<<HTML |
715 | | - <select name="$name" id="$name"> |
716 | | -HTML; |
| 710 | + $options = array(); |
| 711 | + foreach($months as $m) { |
| 712 | + $options[$this->formattedMonth($m)] = $m; |
| 713 | + } |
| 714 | + $result = "<select name=\"$name\" id=\"$name\">"; |
717 | 715 | foreach( $options as $label => $value ) { |
718 | 716 | $selected = $selection == $value ? 'selected="true"' : ''; |
719 | | - $result .= "<option value=\"$value\" $selected>$label"; |
| 717 | + $result .= "<option value=\"$value\" $selected>$label"; |
720 | 718 | } |
721 | 719 | $result .= "</select>"; |
722 | 720 | return $result; |
— | — | @@ -727,20 +725,20 @@ |
728 | 726 | * @param $repls array( 'name'=>new_value, ... ) |
729 | 727 | */ |
730 | 728 | function queryReplace( $repls ) { |
731 | | - $vs = $this->request->getValues(); |
732 | | - $rs = array(); |
733 | | - foreach ($vs as $k => $v) { |
734 | | - if ( array_key_exists( $k, $repls ) ) { |
735 | | - $rs[$k] = $repls[$k]; |
736 | | - } else { |
737 | | - $rs[$k] = $vs[$k]; |
738 | | - } |
739 | | - } |
740 | | - return $this->title->getFullURL($this->queryStringFromArray($rs)); |
| 729 | + $vs = $this->request->getValues(); |
| 730 | + $rs = array(); |
| 731 | + foreach ($vs as $k => $v) { |
| 732 | + if ( array_key_exists( $k, $repls ) ) { |
| 733 | + $rs[$k] = $repls[$k]; |
| 734 | + } else { |
| 735 | + $rs[$k] = $vs[$k]; |
| 736 | + } |
| 737 | + } |
| 738 | + return $this->title->getFullURL($this->queryStringFromArray($rs)); |
741 | 739 | } |
742 | 740 | |
743 | 741 | function showSearchForm() { |
744 | | - $months = Thread::monthsWhereArticleHasThreads($this->article); |
| 742 | + $months = Thread::monthsWhereArticleHasThreads($this->article); |
745 | 743 | |
746 | 744 | $use_dates = $this->request->getVal('lqt_archive_filter_by_date', null); |
747 | 745 | if ( $use_dates === null ) { |
— | — | @@ -749,12 +747,7 @@ |
750 | 748 | } |
751 | 749 | $any_date_check = !$use_dates ? 'checked="1"' : ''; |
752 | 750 | $these_dates_check = $use_dates ? 'checked="1"' : ''; |
753 | | - |
754 | | - // bcsub() and bcadd() do arithmetic on strings. |
755 | | - // Wouldn't want to overflow any puny 32-bit machines with these |
756 | | - // giants numbers that reperesent dates. |
757 | 751 | |
758 | | - $one_month = '100000000'; |
759 | 752 | if( isset($this->start, $this->end) ) { |
760 | 753 | $older_end = $this->start->lastMonth(); |
761 | 754 | $older_start = $older_end->moved( $this->start->delta( $this->end ) )->nextMonth(); |
— | — | @@ -762,36 +755,43 @@ |
763 | 756 | $newer_start = $this->end; |
764 | 757 | $newer_end = $newer_start->moved( $this->end->delta( $this->start ) )->lastMonth(); |
765 | 758 | |
766 | | - $older = $this->queryReplace(array( |
| 759 | + $older = '<a href="' . $this->queryReplace(array( |
767 | 760 | 'lqt_archive_filter_by_date'=>'1', |
768 | 761 | 'lqt_archive_start' => substr($older_start->text(), 0, 6), |
769 | | - 'lqt_archive_end' => substr($older_end->text(), 0, 6) )); |
770 | | - $newer = $this->queryReplace(array( |
| 762 | + 'lqt_archive_end' => substr($older_end->text(), 0, 6) )) |
| 763 | + . '">«older</a>'; |
| 764 | + $newer = '<a href="' . $this->queryReplace(array( |
771 | 765 | 'lqt_archive_filter_by_date'=>'1', |
772 | 766 | 'lqt_archive_start' => substr($newer_start->text(), 0, 6), |
773 | | - 'lqt_archive_end' => substr($newer_end->text(), 0, 6) )); |
774 | | - |
| 767 | + 'lqt_archive_end' => substr($newer_end->text(), 0, 6) )) |
| 768 | + . '">newer»</a>'; |
775 | 769 | } |
| 770 | + else { |
| 771 | + $older = '<span class="lqt_disabled_link">«older</span>'; |
| 772 | + $newer = '<span class="lqt_disabled_link">newer»</span>'; |
| 773 | + } |
776 | 774 | |
777 | 775 | $this->output->addHTML(<<<HTML |
778 | 776 | <form id="lqt_archive_search_form" action="{$this->title->getLocalURL()}"> |
779 | 777 | <input type="hidden" name="lqt_show_archive" value="1"> |
780 | 778 | <input type="hidden" name="title" value="{$this->title->getPrefixedURL()}" |
| 779 | + |
781 | 780 | <input type="radio" id="lqt_archive_filter_by_date_no" |
782 | 781 | name="lqt_archive_filter_by_date" value="0" {$any_date_check}> |
783 | 782 | <label for="lqt_archive_filter_by_date_no">Any date</label> <br> |
784 | 783 | <input type="radio" id="lqt_archive_filter_by_date_yes" |
785 | 784 | name="lqt_archive_filter_by_date" value="1" {$these_dates_check}> |
786 | 785 | <label for="lqt_archive_filter_by_date_yes">Only these dates:</label> <br> |
787 | | - |
788 | | - <label for="lqt_archive_start">From</label> |
789 | | - {$this->monthSelect($months, 'lqt_archive_start')} <br> |
790 | | - <label for="lqt_archive_end">To</label> |
791 | | - {$this->monthSelect($months, 'lqt_archive_end')} |
| 786 | + |
| 787 | +<table> |
| 788 | +<tr><td><label for="lqt_archive_start">From</label> |
| 789 | + <td>{$this->monthSelect($months, 'lqt_archive_start')} <br> |
| 790 | +<tr><td><label for="lqt_archive_end">To</label> |
| 791 | + <td>{$this->monthSelect($months, 'lqt_archive_end')} |
| 792 | +</table> |
792 | 793 | <input type="submit"> |
793 | | - |
794 | | - <a href="$older">«older</a> |
795 | | - <a href="$newer">newer»</a> |
| 794 | + $older $newer |
| 795 | +</table> |
796 | 796 | </form> |
797 | 797 | HTML |
798 | 798 | ); |