r22810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22809‎ | r22810 | r22811 >
Date:07:22, 7 June 2007
Author:david
Status:old
Tags:
Comment:
a most basic monthly browser form
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -666,17 +666,16 @@
667667 $r = $this->request;
668668
669669 /* START AND END DATES */
670 - $m = $r->getVal('lqt_archive_start_month');
671 - $y = $r->getVal('lqt_archive_start_year');
672 - if ($m && $y && ctype_digit($m.$y) && strlen($m) == 2 && strlen($y) == 4) {
673 - $start = "{$y}{$m}01010101";
 670+ $ignore_dates = ! $r->getVal('lqt_archive_filter_by_date', true);
 671+ $s = $r->getVal('lqt_archive_start');
 672+ if ($s && ctype_digit($s) && strlen($s) == 6 && !$ignore_dates) {
 673+ $start = "{$s}00000000";
674674 $where[] = 'thread_touched >= ' . $start;
675675 }
676 - $m = $r->getVal('lqt_archive_end_month');
677 - $y = $r->getVal('lqt_archive_end_year');
678 - if ($m && $y && ctype_digit($m.$y) && strlen($m) == 2 && strlen($y) == 4){
679 - $end = "{$y}{$m}01010101";
680 - $where[] = 'thread_touched < ' . $end;
 676+ $e = $r->getVal('lqt_archive_end');
 677+ if ($e && ctype_digit($e) && strlen($e) == 6 && !$ignore_dates) {
 678+ $end = "{$e}31235959";
 679+ $where[] = 'thread_touched <= ' . $end;
681680 }
682681 if ( isset($start) && isset($end) ) {
683682 $annotations[] = "from $start to $end";
@@ -693,9 +692,61 @@
694693 function threads() {
695694 return Thread::threadsWhere($this->where, $this->options);
696695 }
 696+ function formattedMonth($yyyymm) {
 697+ global $wgLang; // TODO global.
 698+ return $wgLang->getMonthName( substr($yyyymm, 4, 2) ).' '.substr($yyyymm, 0, 4);
 699+ }
 700+
 701+ function monthSelect($months, $name) {
 702+ $selection = $this->request->getVal($name);
 703+ $options = array();
 704+ foreach($months as $m) {
 705+ $options[$this->formattedMonth($m)] = $m;
 706+ }
 707+ $result = <<<HTML
 708+ <select name="$name" id="$name">
 709+HTML;
 710+ foreach( $options as $label => $value ) {
 711+ $selected = $selection == $value ? 'selected="true"' : '';
 712+ $result .= "<option value=\"$value\" $selected>$label";
 713+ }
 714+ $result .= "</select>";
 715+ return $result;
 716+ }
 717+
 718+ function showSearchForm() {
 719+ $months = Thread::monthsWhereArticleHasThreads($this->article);
 720+
 721+ $use_dates = $this->request->getVal('lqt_archive_filter_by_date', null);
 722+ if ( $use_dates === null ) {
 723+ $use_dates = $this->request->getBool('lqt_archive_start', false) ||
 724+ $this->request->getBool('lqt_archive_end', false);
 725+ }
 726+ $any_date_check = !$use_dates ? 'checked="1"' : '';
 727+ $these_dates_check = $use_dates ? 'checked="1"' : '';
 728+
 729+ $this->output->addHTML(<<<HTML
 730+<form id="lqt_archive_search_form" action="{$this->title->getLocalURL()}">
 731+ <input type="hidden" name="lqt_show_archive" value="1">
697732
 733+ <input type="radio" name="lqt_archive_filter_by_date" value="0" {$any_date_check}>
 734+ <label for="lqt_archive_filter_by_date_no">Any date</label> <br>
 735+ <input type="radio" name="lqt_archive_filter_by_date" value="1" {$these_dates_check}>
 736+ <label for="lqt_archive_filter_by_date_yes">Only these dates:</label> <br>
 737+
 738+ <label for="lqt_archive_start">Start</label>
 739+ {$this->monthSelect($months, 'lqt_archive_start')} <br>
 740+ <label for="lqt_archive_end">End</label>
 741+ {$this->monthSelect($months, 'lqt_archive_end')}
 742+ <input type="submit">
 743+</form>
 744+HTML
 745+);
 746+ }
 747+
698748 function show() {
699749 $this->output->setPageTitle( "Talk:" . $this->title->getText() ); // TODO non-main namespaces.
 750+ $this->showSearchForm();
700751 $this->output->addHTML("<p>" . $this->annotations . ".</p>");
701752 $this->output->addHTML('<table border="1">');
702753 foreach ($this->threads() as $t) {

Status & tagging log