r22586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22585‎ | r22586 | r22587 >
Date:03:12, 31 May 2007
Author:david
Status:old
Tags:
Comment:
Made it actually be the last 30 days instead of faking it.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/skins/common/lqt.js (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/common/lqt.js
@@ -12,14 +12,17 @@
1313 }
1414
1515 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;
1917
 18+ // Hide the Go button and turn on automatic submission on the archive browser.
 19+
2020 var dropdown = document.getElementById('lqt_archive_month');
21 - lqt_add_event(dropdown, 'change', function(){
 21+ var success = lqt_add_event(dropdown, 'change', function(){
2222 document.getElementById('lqt_archive_browser_form').submit();
2323 });
 24+ if (success) {
 25+ document.getElementById('lqt_archive_go_button').className = "lqt_hidden";
 26+ }
2427 }
2528
2629 addOnloadHook(lqt_on_load);
\ No newline at end of file
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -363,7 +363,7 @@
364364 $this->output->addHTML("<strong><a href=\"$url\">Start a Discussion</a></strong>");
365365 }
366366
367 - $threads = Thread::latestNThreadsOfArticle($this->article, 10);
 367+ $threads = Thread::threadsOfArticleInLastNDays($this->article, 30);
368368 foreach($threads as $t) {
369369 $this->showThread($t);
370370 }
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -36,6 +36,19 @@
3737 return sprintf( '%04d%02d%02d%02d%02d%02d', $this->year, $this->month, $this->day,
3838 $this->hour, $this->minute, $this->second );
3939 }
 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+ }
4053 }
4154
4255 class Post extends Article {
@@ -227,13 +240,13 @@
228241 array('ORDER BY' => 'thread_touched DESC') );
229242 }
230243
231 - /*
232244 static function threadsOfArticleInLastNDays( $article, $n ) {
 245+ $startdate = Date::now()->nDaysAgo($n)->midnight();
233246 return Thread::threadsWhere( array('thread_article' => $article->getID(),
234247 '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+ }
238251
239252 static function threadsWhoseRootPostIs( $post ) {
240253 return Thread::threadsWhere( array('thread_root_post' => $post->getID()) );