r22921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22920‎ | r22921 | r22922 >
Date:00:22, 12 June 2007
Author:david
Status:old
Tags:
Comment:
older and newer links disable correctly. attepted to clean up some of the wreck emacs made of indentation.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/monobook/main.css
@@ -33,6 +33,10 @@
3434 margin-bottom: .1em;
3535 }*/
3636
 37+.lqt_disabled_link {
 38+ color: #999;
 39+}
 40+
3741 .lqt_start_discussion {
3842 vertical-align: center;
3943 }
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -673,13 +673,13 @@
674674 $ignore_dates = ! $r->getVal('lqt_archive_filter_by_date', true);
675675 $s = $r->getVal('lqt_archive_start');
676676 if ($s && ctype_digit($s) && strlen($s) == 6 && !$ignore_dates) {
677 - $this->start = new Date( "{$s}01000000" );
 677+ $this->start = new Date( "{$s}01000000" );
678678 $where[] = 'thread_touched >= ' . $this->start->text();
679679 }
680680 $e = $r->getVal('lqt_archive_end');
681681 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();
684684 $where[] = 'thread_touched < ' . $this->end->text();
685685 }
686686 if ( isset($this->start) && isset($this->end) ) {
@@ -699,23 +699,21 @@
700700 return Thread::threadsWhere($this->where, $this->options);
701701 }
702702
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+ }
707707
708708 function monthSelect($months, $name) {
709709 $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\">";
717715 foreach( $options as $label => $value ) {
718716 $selected = $selection == $value ? 'selected="true"' : '';
719 - $result .= "<option value=\"$value\" $selected>$label";
 717+ $result .= "<option value=\"$value\" $selected>$label";
720718 }
721719 $result .= "</select>";
722720 return $result;
@@ -727,20 +725,20 @@
728726 * @param $repls array( 'name'=>new_value, ... )
729727 */
730728 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));
741739 }
742740
743741 function showSearchForm() {
744 - $months = Thread::monthsWhereArticleHasThreads($this->article);
 742+ $months = Thread::monthsWhereArticleHasThreads($this->article);
745743
746744 $use_dates = $this->request->getVal('lqt_archive_filter_by_date', null);
747745 if ( $use_dates === null ) {
@@ -749,12 +747,7 @@
750748 }
751749 $any_date_check = !$use_dates ? 'checked="1"' : '';
752750 $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.
757751
758 - $one_month = '100000000';
759752 if( isset($this->start, $this->end) ) {
760753 $older_end = $this->start->lastMonth();
761754 $older_start = $older_end->moved( $this->start->delta( $this->end ) )->nextMonth();
@@ -762,36 +755,43 @@
763756 $newer_start = $this->end;
764757 $newer_end = $newer_start->moved( $this->end->delta( $this->start ) )->lastMonth();
765758
766 - $older = $this->queryReplace(array(
 759+ $older = '<a href="' . $this->queryReplace(array(
767760 'lqt_archive_filter_by_date'=>'1',
768761 '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(
771765 'lqt_archive_filter_by_date'=>'1',
772766 '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>';
775769 }
 770+ else {
 771+ $older = '<span class="lqt_disabled_link">«older</span>';
 772+ $newer = '<span class="lqt_disabled_link">newer»</span>';
 773+ }
776774
777775 $this->output->addHTML(<<<HTML
778776 <form id="lqt_archive_search_form" action="{$this->title->getLocalURL()}">
779777 <input type="hidden" name="lqt_show_archive" value="1">
780778 <input type="hidden" name="title" value="{$this->title->getPrefixedURL()}"
 779+
781780 <input type="radio" id="lqt_archive_filter_by_date_no"
782781 name="lqt_archive_filter_by_date" value="0" {$any_date_check}>
783782 <label for="lqt_archive_filter_by_date_no">Any date</label> <br>
784783 <input type="radio" id="lqt_archive_filter_by_date_yes"
785784 name="lqt_archive_filter_by_date" value="1" {$these_dates_check}>
786785 <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>
792793 <input type="submit">
793 -
794 - <a href="$older">«older</a>
795 - <a href="$newer">newer»</a>
 794+ $older $newer
 795+</table>
796796 </form>
797797 HTML
798798 );

Status & tagging log