Index: branches/liquidthreads/skins/common/lqt.js |
— | — | @@ -12,14 +12,17 @@ |
13 | 13 | } |
14 | 14 | |
15 | 15 | function lqt_on_load() { |
16 | | - /* Hide the Go button on the archive widget, because we will |
17 | | - automatically go when a selection is made. */ |
18 | | - document.getElementById('lqt_archive_go_button').className = "lqt_hidden"; |
| 16 | + if(!document.getElementById) return; |
19 | 17 | |
| 18 | + // Hide the Go button and turn on automatic submission on the archive browser. |
| 19 | + |
20 | 20 | var dropdown = document.getElementById('lqt_archive_month'); |
21 | | - lqt_add_event(dropdown, 'change', function(){ |
| 21 | + var success = lqt_add_event(dropdown, 'change', function(){ |
22 | 22 | document.getElementById('lqt_archive_browser_form').submit(); |
23 | 23 | }); |
| 24 | + if (success) { |
| 25 | + document.getElementById('lqt_archive_go_button').className = "lqt_hidden"; |
| 26 | + } |
24 | 27 | } |
25 | 28 | |
26 | 29 | addOnloadHook(lqt_on_load); |
\ No newline at end of file |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -363,7 +363,7 @@ |
364 | 364 | $this->output->addHTML("<strong><a href=\"$url\">Start a Discussion</a></strong>"); |
365 | 365 | } |
366 | 366 | |
367 | | - $threads = Thread::latestNThreadsOfArticle($this->article, 10); |
| 367 | + $threads = Thread::threadsOfArticleInLastNDays($this->article, 30); |
368 | 368 | foreach($threads as $t) { |
369 | 369 | $this->showThread($t); |
370 | 370 | } |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -36,6 +36,19 @@ |
37 | 37 | return sprintf( '%04d%02d%02d%02d%02d%02d', $this->year, $this->month, $this->day, |
38 | 38 | $this->hour, $this->minute, $this->second ); |
39 | 39 | } |
| 40 | + static function now() { |
| 41 | + return new Date(wfTimestampNow()); |
| 42 | + } |
| 43 | + function nDaysAgo($n) { |
| 44 | + $d = new DateTime($this->text()); |
| 45 | + $d->modify("-$n days"); |
| 46 | + return new Date( $d->format('YmdHis') ); |
| 47 | + } |
| 48 | + function midnight() { |
| 49 | + $d = clone $this; |
| 50 | + $d->hours = $d->minutes = $d->seconds = 0; |
| 51 | + return $d; |
| 52 | + } |
40 | 53 | } |
41 | 54 | |
42 | 55 | class Post extends Article { |
— | — | @@ -227,13 +240,13 @@ |
228 | 241 | array('ORDER BY' => 'thread_touched DESC') ); |
229 | 242 | } |
230 | 243 | |
231 | | - /* |
232 | 244 | static function threadsOfArticleInLastNDays( $article, $n ) { |
| 245 | + $startdate = Date::now()->nDaysAgo($n)->midnight(); |
233 | 246 | return Thread::threadsWhere( array('thread_article' => $article->getID(), |
234 | 247 | 'thread_subthread_of is null', |
235 | | - 'thread_touched > ' . 'foo' ), |
236 | | - array('ORDER BY' => 'thread_touched DESC' ); |
237 | | - }*/ |
| 248 | + 'thread_touched > ' . $startdate->text() ), |
| 249 | + array('ORDER BY' => 'thread_touched DESC' ) ); |
| 250 | + } |
238 | 251 | |
239 | 252 | static function threadsWhoseRootPostIs( $post ) { |
240 | 253 | return Thread::threadsWhere( array('thread_root_post' => $post->getID()) ); |