r22782 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22781‎ | r22782 | r22783 >
Date:00:11, 6 June 2007
Author:david
Status:old
Tags:
Comment:
Archiving and summary-requesting behavior is now correct. Archive browser still out of commision, code still a bit scary.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/monobook/main.css
@@ -78,9 +78,9 @@
7979
8080 .lqt_thread_permalink_summary {
8181 clear: both;
82 - border: solid 1px #ddd;
 82+/* border: solid 1px #ddd;*/
8383 padding-left: 1em; padding-right: 1em;
84 - margin: 2em 2em 0.7em 1em;
 84+ margin: 3em 2em 0.7em 1em;
8585 }
8686 .lqt_thread_permalink_summary_title {
8787 float: left;
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -61,6 +61,9 @@
6262
6363 protected $queries;
6464
 65+ public $archive_start_days = 14;
 66+ public $archive_recent_days = 5;
 67+
6568 function __construct(&$output, &$article, &$title, &$user, &$request) {
6669 $this->article = $article;
6770 $this->output = $output;
@@ -74,18 +77,21 @@
7578
7679 function initializeQueries() {
7780 $g = new QueryGroup();
78 - $startdate = Date::now()->nDaysAgo(14)->midnight();
 81+ $startdate = Date::now()->nDaysAgo($this->archive_start_days)->midnight();
7982 $g->addQuery('fresh',
8083 array('thread_article' => $this->article->getID(),
8184 'thread_subthread_of is null',
82 - 'thread_touched >= ' . $startdate->text() ),
 85+ '(thread_touched >= ' . $startdate->text() .
 86+ ' OR thread_summary_page is NULL)'),
8387 array('ORDER BY' => 'thread_touched DESC' ));
84 - $g->addQuery('recently-archived',
 88+ $g->addQuery('archived',
8589 array('thread_article' => $this->article->getID(),
8690 'thread_subthread_of is null',
87 - 'thread_touched < ' . $startdate->text(),
88 - 'thread_touched >=' . $startdate->nDaysAgo(5)->text()),
 91+ 'thread_summary_page is not null',
 92+ 'thread_touched < ' . $startdate->text()),
8993 array('ORDER BY' => 'thread_touched DESC'));
 94+ $g->extendQuery('archived', 'recently-archived',
 95+ array('thread_touched >=' . $startdate->nDaysAgo($this->archive_recent_days)->text()));
9096 return $g;
9197 }
9298
@@ -444,22 +450,19 @@
445451 // array('class'=>'lqt_header'),
446452 // $html) );
447453 }
448 - if ( !$thread->superthread() && !$thread->summary() ) {
449 - $url = $this->permalinkUrl( $thread, 'lqt_summarize=1' );
450 - $this->output->addHTML( <<<HTML
451 - <span class="lqt_summarize_command">[<a href="{$url}">Summarize</a>]</span>
452 -HTML
453 - );
454 - }
455454 }
456455
457456 function showThread( $thread, $suppress_summaries = false ) {
458457 $this->showThreadHeading( $thread );
459458
 459+ $touched = new Date($thread->touched());
460460 if( $thread->summary() && !$suppress_summaries ) {
461461 $this->showSummary($thread);
462462 $this->output->addHTML( "<a href=\"{$this->permalinkUrl($thread)}\" class=\"lqt_thread_show_summary\">Show this thread</a>" );
463463 return;
 464+ } else if ( $touched->isBefore(Date::now()->nDaysAgo($this->archive_start_days))
 465+ && !$thread->summary() && !$thread->superthread() ) {
 466+ $this->output->addHTML("<p class=\"lqt_summary_notice\">If this discussion seems to be concluded, you are encouraged to <a href=\"{$this->permalinkUrl($thread, 'lqt_summarize=1')}\">write a summary</a>. There have been no changed here for at least $this->archive_start_days days.</p>");
464467 }
465468
466469 $this->openDiv('lqt_thread', "lqt_thread_id_{$thread->id()}");
@@ -617,19 +620,22 @@
618621 you're editing the talkpage itself here.
619622 */
620623
621 - $action = $this->request->getVal('action');
 624+ $action = $this->request->getVal('lqt_header_action');
622625
623626 $article = new Article( $this->title );
624627 if( $action == 'edit' || $action=='submit' ) {
625628 $e = new EditPage($article);
626629 $e->suppressIntro = true;
 630+ $e->editFormTextBeforeContent .=
 631+ $this->perpetuate('lqt_header_action', 'hidden');
627632 $e->edit();
628633 } else if ( $action == 'history' ) {
 634+ $this->output->addHTML("Disclaimer: history doesn't really work yet.");
629635 $history = new PageHistory( $article );
630636 $history->history();
631637 } else if ( $article->exists() ) {
632 - $edit = $this->title->getFullURL( 'action=edit' );
633 - $history = $this->title->getFullURL( 'action=history' );
 638+ $edit = $this->title->getFullURL( 'lqt_header_action=edit' );
 639+ $history = $this->title->getFullURL( 'lqt_header_action=history' );
634640 $this->outputList('ul', 'lqt_header_commands', null, array(
635641 "<a href=\"$edit\">edit</a>",
636642 "<a href=\"$history\">history</a>"
@@ -712,8 +718,6 @@
713719 $this->showSummarizeForm($t);
714720 } else if ( $t->summary() ) {
715721 $this->showSummary($t);
716 - } else if ( !$t->superthread() ) {
717 - $this->output->addHTML("<p class=\"lqt_summary_notice\">If this discussion seems to be concluded, you are encouraged to <a href=\"{$this->permalinkUrl($t, 'lqt_summarize=1')}\">write a summary</a>.</p>");
718722 }
719723
720724 $this->showThread($t, true);
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -103,7 +103,7 @@
104104
105105 function setSuperthread($thread) {
106106 $this->superthreadId = $thread->id();
107 - $this->updateRecord();
 107+ $this->touch();
108108 }
109109
110110 function superthread() {
@@ -119,7 +119,7 @@
120120
121121 function setArticle($a) {
122122 $this->articleId = $a->getID();
123 - $this->updateRecord();
 123+ $this->touch();
124124 }
125125
126126 function article() {
@@ -185,7 +185,7 @@
186186
187187 function setSubject($s) {
188188 $this->subject = $s;
189 - $this->updateRecord();
 189+ $this->touch();
190190 }
191191
192192 function hasSubthreads() {
@@ -199,7 +199,8 @@
200200 }
201201
202202 function touch() {
203 - $this->updateRecord(); // TODO side-effect, ugly, etc.
 203+ $this->touched = wfTimestampNow();
 204+ $this->updateRecord();
204205 if ( $this->superthread() ) {
205206 $this->superthread()->touch();
206207 }
@@ -217,7 +218,7 @@
218219 'thread_subthread_of' => $this->superthreadId,
219220 'thread_summary_page' => $this->summaryId,
220221 'thread_subject' => $this->subject,
221 - 'thread_touched' => wfTimestampNow() ),
 222+ 'thread_touched' => $this->touched ),
222223 /* WHERE */ array( 'thread_id' => $this->id, ),
223224 __METHOD__);
224225 }
@@ -333,6 +334,14 @@
334335 $this->queries[$name] = array($where, $options);
335336 }
336337
 338+ function extendQuery( $original, $newname, $where, $options = array() ) {
 339+ if (!array_key_exists($original,$this->queries)) return;
 340+ $q = $this->queries[$original];
 341+ $q[0] += $where;
 342+ $q[1] += $options;
 343+ $this->queries[$newname] = $q;
 344+ }
 345+
337346 function deleteQuery( $name ) {
338347 unset ($this->queries[$name]);
339348 }

Status & tagging log