Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | $title->getDBkey()); |
24 | 24 | $article = new Article($article_title); |
25 | 25 | |
26 | | - if ( $request->getBool('lqt_show_archive') ) { |
| 26 | + if ( $request->getVal('lqt_method') == 'talkpage_archive' ) { |
27 | 27 | $view = new TalkpageArchiveView( $output, $article, $title, $user, $request ); |
28 | 28 | } else { |
29 | 29 | $view = new TalkpageView( $output, $article, $title, $user, $request ); |
— | — | @@ -119,30 +119,26 @@ |
120 | 120 | return $q; |
121 | 121 | } |
122 | 122 | |
123 | | - /** |
124 | | - * @return href for a link to the same page as is being currently viewed, |
125 | | - * but with additional query variables. |
126 | | - * @param $vars array( 'query_variable_name' => 'value', ... ). |
127 | | - */ |
128 | | - function selflink( $vars = null ) { |
129 | | - return $this->title->getFullURL( $this->queryStringFromArray($vars) ); |
| 123 | + function methodAppliesToThread( $method, $thread ) { |
| 124 | + return $this->request->getVal('lqt_method') == $method && |
| 125 | + $this->request->getVal('lqt_operand') == $thread->id(); |
130 | 126 | } |
131 | | - |
132 | | - /** |
133 | | - * @return true if the value of the give query variable name is equal to the given post's ID. |
134 | | - */ |
135 | | - function commandApplies( $command, $post ) { |
136 | | - return $this->request->getVal($command) == $post->getTitle()->getPrefixedURL(); |
| 127 | + function methodApplies( $method ) { |
| 128 | + return $this->request->getVal('lqt_method') == $method; |
137 | 129 | } |
138 | | - function commandAppliesToThread( $command, $thread ) { |
139 | | - return $this->request->getVal($command) == $thread->id(); |
| 130 | + |
| 131 | + function permalinkUrl( $thread, $method = null, $operand = null ) { |
| 132 | + $query = $method ? "lqt_method=$method" : ""; |
| 133 | + $query = $operand ? "$query&lqt_operand={$operand->id()}" : $query; |
| 134 | + return $thread->rootPost()->getTitle()->getFullUrl($query); |
140 | 135 | } |
141 | 136 | |
142 | | - function permalinkUrl( $thread, $query ='' ) { |
143 | | - return $thread->rootPost()->getTitle()->getFullURL($query); |
144 | | - return SpecialPage::getTitleFor('Thread', $thread->id())->getFullURL($query); |
| 137 | + function talkpageUrl( $title, $method = null, $operand = null ) { |
| 138 | + $query = $method ? "lqt_method=$method" : ""; |
| 139 | + $query = $operand ? "$query&lqt_operand={$operand->id()}" : $query; |
| 140 | + return $title->getFullURL( $query ); |
145 | 141 | } |
146 | | - |
| 142 | + |
147 | 143 | /************************* |
148 | 144 | * Simple HTML methods * |
149 | 145 | *************************/ |
— | — | @@ -217,10 +213,8 @@ |
218 | 214 | $e->suppressIntro = true; |
219 | 215 | |
220 | 216 | $e->editFormTextBeforeContent .= |
221 | | - $this->perpetuate('lqt_edit_post', 'hidden') . |
222 | | - $this->perpetuate('lqt_reply_to', 'hidden') . |
223 | | - $this->perpetuate('lqt_new_thread_form', 'hidden') . |
224 | | - $this->perpetuate('lqt_summarize', 'hidden'); |
| 217 | + $this->perpetuate('lqt_method', 'hidden') . |
| 218 | + $this->perpetuate('lqt_operand', 'hidden'); |
225 | 219 | |
226 | 220 | if ( /*$thread == null*/ $edit_type=='new' || ($thread && $thread->superthread() == null) ) { |
227 | 221 | // This is a top-level post; show the subject line. |
— | — | @@ -368,21 +362,6 @@ |
369 | 363 | } |
370 | 364 | } |
371 | 365 | |
372 | | - function talkpageUrl( $title, $operator = null, $operand = null ) { |
373 | | - if ( $operator == 'lqt_reply_to' ) { |
374 | | - $query = array( 'lqt_reply_to' => $operand ? $operand->id() : null ); |
375 | | - } else if ($operator == 'lqt_edit_post') { |
376 | | - $query = array( 'lqt_edit_post' => $operand ? $operand->id() : null ); |
377 | | - } else if ($operator == 'lqt_new_thread_form' ) { |
378 | | - $query = array( 'lqt_new_thread_form' => '1' ); |
379 | | - } else if ($operator == 'lqt_show_archive') { |
380 | | - $query = array( 'lqt_show_archive' => '1' ); |
381 | | - } else { |
382 | | - $query = array(); |
383 | | - } |
384 | | - return $title->getFullURL( $this->queryStringFromArray($query) ); |
385 | | - } |
386 | | - |
387 | 366 | function showThreadFooter( $thread ) { |
388 | 367 | $color_number = $this->selectNewUserColor( $thread->rootPost()->originalAuthor() ); |
389 | 368 | $this->output->addHTML(wfOpenElement('ul', array('class'=>"lqt_footer" ))); |
— | — | @@ -397,8 +376,8 @@ |
398 | 377 | $this->output->addHTML( $d->lastMonth()->text() ); |
399 | 378 | $this->output->addHTML( wfCloseElement( 'li' ) ); |
400 | 379 | |
401 | | - $commands = array( 'Edit' => $this->talkpageUrl( $this->title, 'lqt_edit_post', $thread ), |
402 | | - 'Reply' => $this->talkpageUrl( $this->title, 'lqt_reply_to', $thread ), |
| 380 | + $commands = array( 'Edit' => $this->talkpageUrl( $this->title, 'edit', $thread ), |
| 381 | + 'Reply' => $this->talkpageUrl( $this->title, 'reply', $thread ), |
403 | 382 | 'Permalink' => $this->permalinkUrl( $thread ) ); |
404 | 383 | |
405 | 384 | foreach( $commands as $label => $href ) { |
— | — | @@ -430,7 +409,7 @@ |
431 | 410 | $this->openDiv( "lqt_post lqt_post_color_$color_number" );*/ |
432 | 411 | $this->openDiv( 'lqt_post' ); |
433 | 412 | |
434 | | - if( $this->commandAppliesToThread( 'lqt_edit_post', $thread ) ) { |
| 413 | + if( $this->methodAppliesToThread( 'edit', $thread ) ) { |
435 | 414 | $this->showPostEditingForm( $thread ); |
436 | 415 | } else{ |
437 | 416 | $this->showPostBody( $post ); |
— | — | @@ -439,7 +418,7 @@ |
440 | 419 | |
441 | 420 | $this->closeDiv(); |
442 | 421 | |
443 | | - if( $this->commandAppliesToThread( 'lqt_reply_to', $thread ) ) { |
| 422 | + if( $this->methodAppliesToThread( 'reply', $thread ) ) { |
444 | 423 | $this->indent(); |
445 | 424 | $this->showReplyForm( $thread ); |
446 | 425 | $this->unindent(); |
— | — | @@ -464,7 +443,7 @@ |
465 | 444 | $this->showSummary($thread); |
466 | 445 | } else if ( $touched->isBefore(Date::now()->nDaysAgo($this->archive_start_days)) |
467 | 446 | && !$thread->summary() && !$thread->superthread() ) { |
468 | | - $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 changes here for at least $this->archive_start_days days.</p>"); |
| 447 | + $this->output->addHTML("<p class=\"lqt_summary_notice\">If this discussion seems to be concluded, you are encouraged to <a href=\"{$this->permalinkUrl($thread, 'summarize')}\">write a summary</a>. There have been no changes here for at least $this->archive_start_days days.</p>"); |
469 | 448 | } |
470 | 449 | |
471 | 450 | $this->openDiv('lqt_thread', "lqt_thread_id_{$thread->id()}"); |
— | — | @@ -496,7 +475,7 @@ |
497 | 476 | <span class="lqt_thread_permalink_summary_title"> |
498 | 477 | This thread has been summarized as follows: |
499 | 478 | </span><span class="lqt_thread_permalink_summary_edit"> |
500 | | - [<a href="{$this->permalinkUrl($t,'lqt_summarize=1')}">edit</a>] |
| 479 | + [<a href="{$this->permalinkUrl($t,'summarize')}">edit</a>] |
501 | 480 | </span> |
502 | 481 | HTML |
503 | 482 | ); |
— | — | @@ -525,10 +504,10 @@ |
526 | 505 | */ |
527 | 506 | } |
528 | 507 | |
529 | | - function permalinksForThreads($ts, $query = '') { |
| 508 | + function permalinksForThreads($ts, $method = null, $operand = null) { |
530 | 509 | $ps = array(); |
531 | 510 | foreach ($ts as $t) { |
532 | | - $u = $this->permalinkUrl($t, $query); |
| 511 | + $u = $this->permalinkUrl($t, $method, $operand); |
533 | 512 | $l = $t->subjectWithoutIncrement(); |
534 | 513 | $ps[] = "<a href=\"$u\">$l</a>"; |
535 | 514 | } |
— | — | @@ -546,7 +525,7 @@ |
547 | 526 | } else { |
548 | 527 | $this->openDiv(); |
549 | 528 | } |
550 | | - $url = $this->talkpageUrl($this->title, 'lqt_show_archive'); |
| 529 | + $url = $this->talkpageUrl($this->title, 'talkpage_archive'); |
551 | 530 | $this->output->addHTML(<<<HTML |
552 | 531 | <a href="$url" class="lqt_browse_archive">Browse the Archive</a> |
553 | 532 | HTML |
— | — | @@ -622,10 +601,10 @@ |
623 | 602 | |
624 | 603 | $this->showArchiveWidget(); |
625 | 604 | |
626 | | - if( $this->request->getBool('lqt_new_thread_form') ) { |
| 605 | + if( $this->methodApplies('talkpage_new_thread') ) { |
627 | 606 | $this->showNewThreadForm(); |
628 | 607 | } else { |
629 | | - $url = $this->talkpageUrl( $this->title, 'lqt_new_thread_form' ); |
| 608 | + $url = $this->talkpageUrl( $this->title, 'talkpage_new_thread' ); |
630 | 609 | $this->output->addHTML("<strong><a class=\"lqt_start_discussion\" href=\"$url\">Start a Discussion</a></strong>"); |
631 | 610 | } |
632 | 611 | |
— | — | @@ -797,7 +776,7 @@ |
798 | 777 | |
799 | 778 | $this->output->addHTML(<<<HTML |
800 | 779 | <form id="lqt_archive_search_form" action="{$this->title->getLocalURL()}"> |
801 | | - <input type="hidden" name="lqt_show_archive" value="1"> |
| 780 | + <input type="hidden" name="lqt_method" value="talkpage_archive"> |
802 | 781 | <input type="hidden" name="title" value="{$this->title->getPrefixedURL()}" |
803 | 782 | |
804 | 783 | <input type="radio" id="lqt_archive_filter_by_date_no" |
— | — | @@ -881,7 +860,7 @@ |
882 | 861 | $this->output->setSubtitle( "from " . $talkpage_link ); |
883 | 862 | } |
884 | 863 | |
885 | | - if( $this->request->getBool('lqt_summarize') ) { |
| 864 | + if( $this->methodApplies('summarize') ) { |
886 | 865 | $this->showSummarizeForm($t); |
887 | 866 | } |
888 | 867 | |