r22592 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22591‎ | r22592 | r22593 >
Date:05:52, 31 May 2007
Author:david
Status:old
Tags:
Comment:
Links back from permalinks to the main talk page now respect archiving.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -388,7 +388,7 @@
389389
390390 $this->openDiv('lqt_archive_widget');
391391 $this->output->addHTML(<<<HTML
392 - <form id="lqt_archive_browser_form"><select name="lqt_archive_month" id="lqt_archive_month">
 392+ <form id="lqt_archive_browser_form" action="{$this->title->getLocalURL()}"><select name="lqt_archive_month" id="lqt_archive_month">
393393 HTML
394394 );
395395 foreach( $options as $label => $value ) {
@@ -449,13 +449,16 @@
450450
451451 $this->output->setPageTitle( "Thread: #$thread_id" ); // Default if no subject line.
452452
453 -$talkpage_link = $this->user->getSkin()->makeKnownLinkObj($t->article()->getTitle()->getTalkpage());
 453+ // Make a link back to the talk page, including the correct archive month.
 454+ if (Date::now()->nDaysAgo(30)->midnight()->isBefore( new Date($t->touched()) ))
 455+ $query = '';
 456+ else
 457+ $query = 'lqt_archive_month=' . substr($t->touched(),0,6);
 458+
 459+ $talkpage = $t->article()->getTitle()->getTalkpage();
 460+ $talkpage_link = $this->user->getSkin()->makeKnownLinkObj($talkpage, '', $query);
 461+
454462 if ( $t->superthread() ) {
455 -/* $this->output->addHTML(<<<HTML
456 - <p class="lqt_context_message">You are viewing a reply to another post.
457 - <a href="{$this->permalinkUrl($t->topmostThread())}">View the entire discussion.</a></p>
458 -HTML
459 -);*/
460463 $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link );
461464 } else {
462465
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -46,9 +46,16 @@
4747 }
4848 function midnight() {
4949 $d = clone $this;
50 - $d->hours = $d->minutes = $d->seconds = 0;
 50+ $d->hour = $d->minute = $d->second = 0;
5151 return $d;
5252 }
 53+ function isBefore($d) {
 54+ foreach(array('year', 'month', 'day', 'hour', 'minute', 'second') as $part) {
 55+ if ( $this->$part < $d->$part ) return true;
 56+ if ( $this->$part > $d->$part ) return false;
 57+ }
 58+ return true; // exactly the same time; arguable.
 59+ }
5360 }
5461
5562 class Post extends Article {
@@ -244,7 +251,7 @@
245252 $startdate = Date::now()->nDaysAgo($n)->midnight();
246253 return Thread::threadsWhere( array('thread_article' => $article->getID(),
247254 'thread_subthread_of is null',
248 - 'thread_touched > ' . $startdate->text() ),
 255+ 'thread_touched >= ' . $startdate->text() ),
249256 array('ORDER BY' => 'thread_touched DESC' ) );
250257 }
251258