r59429 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59428‎ | r59429 | r59430 >
Date:18:05, 25 November 2009
Author:werdna
Status:deferred
Tags:
Comment:
Update LiquidThreads alpha to trunk state
Modified paths:
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/LiquidThreads.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/api/ApiThreadAction.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Dispatch.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Hooks.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Thread.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Threads.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/View.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/i18n/Lqt.i18n.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/lqt.css (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/lqt.js (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/IndividualThreadHistoryView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/TalkpageHeaderView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/TalkpageHistoryView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/TalkpageView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadDiffView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadHistoricalRevisionView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadHistoryListingView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadPermalinkView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadProtectionFormView.php (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadWatchView.php (modified) (history)

Diff [purge]

Property changes on: branches/wmf-deployment/extensions/LiquidThreads_alpha/i18n/Lqt.i18n.php
___________________________________________________________________
Deleted: svn:mergeinfo
11 Reverse-merged /trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php:r57390,58990-59196,59198-59218,59221-59351,59353,59356-59424
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/lqt.css
@@ -1,11 +1,3 @@
2 -
3 -#wpTextbox1 {
4 - /* Textareas in lqt use auto-sizing based on these properties */
5 - height: 7.5em;
6 - max-height: 30em;
7 - min-height: 7.5em;
8 -}
9 -
102 .lqt_watchlist_messages_notice {
113 background-color: #eee;
124 border: 1px solid #ddd;
@@ -312,7 +304,6 @@
313305 }
314306
315307 div.lqt-post-sep {
316 - height: 1px;
317308 padding: 0;
318309 margin: 0;
319310 margin-left: 1em;
@@ -321,6 +312,7 @@
322313 background-position: bottom;
323314 background-repeat: repeat-x;
324315 clear: both;
 316+ line-height: 1em;
325317 }
326318
327319 .lqt-thread-first > .lqt-post-wrapper {
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/LiquidThreads.php
@@ -47,6 +47,8 @@
4848 // Hooks
4949 // Main dispatch hook
5050 $wgHooks['MediaWikiPerformAction'][] = 'LqtDispatch::tryPage';
 51+$wgHooks['SkinTemplateTabs'][] = 'LqtDispatch::onSkinTemplateTabs';
 52+$wgHooks['SkinTemplateNavigation'][] = 'LqtDispatch::onSkinTemplateNavigation';
5153
5254 // Customisation of recentchanges
5355 //$wgHooks['OldChangesListRecentChangesLine'][] = 'LqtHooks::customizeOldChangesList';
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Threads.php
@@ -51,11 +51,6 @@
5252 static $cache_by_id = array();
5353 static $occupied_titles = array();
5454
55 - static function newThread( $root, $article, $superthread = null,
56 - $type = self::TYPE_NORMAL, $subject = '' ) {
57 - return Thread::create( $root, $article, $superthread, $type, $subject );
58 - }
59 -
6055 /**
6156 * Create the talkpage if it doesn't exist so that links to it
6257 * will show up blue instead of red. For use upon new thread creation.
@@ -196,7 +191,7 @@
197192 static function newReplyTitle( $thread, $user ) {
198193 $topThread = $thread->topmostThread();
199194
200 - $base = $topThread->title()->getText() . '/' . $user->getName();
 195+ $base = $topThread->title()->getText() . '/reply';
201196
202197 return self::incrementedTitle( $base, NS_LQT_THREAD );
203198 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/View.php
@@ -419,13 +419,30 @@
420420 wfMsgExt( $msg, 'parse' ) );
421421 }
422422
 423+ global $wgRequest;
423424 // Quietly force a preview if no subject has been specified.
424425 if ( ( !$valid_subject && $subject ) || ( $subject_expected && !$subject ) ) {
425426 // Dirty hack to prevent saving from going ahead
426 - global $wgRequest;
427427 $wgRequest->setVal( 'wpPreview', true );
428428 }
429429
 430+ // For new posts and replies, remove the summary field and use a boilerplate
 431+ // default.
 432+ if ( $edit_type == 'new' ) {
 433+ $e->mShowSummaryField = false;
 434+
 435+ $summary = wfMsgForContent( 'lqt-newpost-summary', $subject );
 436+ $wgRequest->setVal( 'wpSummary', $summary );
 437+ } elseif ( $edit_type == 'reply' ) {
 438+ $e->mShowSummaryField = false;
 439+
 440+ $reply_subject = $edit_applies_to->subject();
 441+ $reply_title = $edit_applies_to->title()->getPrefixedText();
 442+ $summary = wfMsgForContent( 'lqt-reply-summary',
 443+ $reply_subject, $reply_title );
 444+ $wgRequest->setVal( 'wpSummary', $summary );
 445+ }
 446+
430447 // Add an offset so it works if it's on the wrong page.
431448 if ( $edit_applies_to ) {
432449 $dbr = wfGetDB( DB_SLAVE );
@@ -493,10 +510,12 @@
494511 // $this->renameThread( $thread, $subject, $e->summary );
495512 }
496513
 514+ $bump = $this->request->getBool( 'wpBumpThread' );
 515+
497516 $thread = self::postEditUpdates(
498517 $edit_type, $edit_applies_to, $article,
499518 $this->article, $subject, $e->summary, $thread,
500 - $e->textbox1
 519+ $e->textbox1, $bump
501520 );
502521
503522 if ( $submitted_nonce && $nonce_key ) {
@@ -520,22 +539,25 @@
521540 }
522541
523542 static function postEditUpdates( $edit_type, $edit_applies_to, $edit_page, $article,
524 - $subject, $edit_summary, $thread, $new_text ) {
 543+ $subject, $edit_summary, $thread, $new_text,
 544+ $bump = null ) {
525545 // Update metadata - create and update thread and thread revision objects as
526546 // appropriate.
527547
528548 if ( $edit_type == 'reply' ) {
529549 $subject = $edit_applies_to->subject();
530550
531 - $thread = Threads::newThread( $edit_page, $article, $edit_applies_to,
532 - Threads::TYPE_NORMAL, $subject );
 551+ $thread = Thread::create( $edit_page, $article, $edit_applies_to,
 552+ Threads::TYPE_NORMAL, $subject,
 553+ $edit_summary, $bump );
533554
534555 global $wgUser;
535556 NewMessages::markThreadAsReadByUser( $edit_applies_to, $wgUser );
536557 } elseif ( $edit_type == 'summarize' ) {
537558 $edit_applies_to->setSummary( $edit_page );
538559 $edit_applies_to->commitRevision( Threads::CHANGE_EDITED_SUMMARY,
539 - $edit_applies_to, $edit_summary );
 560+ $edit_applies_to, $edit_summary,
 561+ $bump);
540562 } elseif ( $edit_type == 'editExisting' ) {
541563 // Use a separate type if the content is blanked.
542564 $type = strlen( trim( $new_text ) )
@@ -543,10 +565,11 @@
544566 : Threads::CHANGE_ROOT_BLANKED;
545567
546568 // Add the history entry.
547 - $thread->commitRevision( $type, $thread, $edit_summary );
 569+ $thread->commitRevision( $type, $thread, $edit_summary, $bump );
548570 } else {
549 - $thread = Threads::newThread( $edit_page, $article, null,
550 - Threads::TYPE_NORMAL, $subject );
 571+ $thread = Thread::create( $edit_page, $article, null,
 572+ Threads::TYPE_NORMAL, $subject,
 573+ $edit_summary );
551574 }
552575
553576 return $thread;
@@ -1279,7 +1302,7 @@
12801303 $repliesClass = 'lqt-thread-replies lqt-thread-replies-' .
12811304 $this->threadNestingLevel;
12821305 $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) );
1283 - $this->output->addHTML( $div );
 1306+ $sep = Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' );
12841307
12851308 $subthreadCount = count( $thread->subthreads() );
12861309 $i = 0;
@@ -1303,7 +1326,7 @@
13041327 // We've shown too many threads.
13051328 $link = $this->getShowMore( $thread, $st, $i );
13061329
1307 - $this->output->addHTML( $link );
 1330+ $this->output->addHTML( $div.$link );
13081331 $showThreads = false;
13091332 continue;
13101333 }
@@ -1312,10 +1335,7 @@
13131336 if ( $showCount == 1 ) {
13141337 // There's a post sep before each reply group to
13151338 // separate from the parent thread.
1316 - $this->output->addHTML(
1317 - Xml::tags( 'div',
1318 - array( 'class' => 'lqt-post-sep' ),
1319 - ' ' ) );
 1339+ $this->output->addHTML( $sep.$div );
13201340 }
13211341
13221342 $this->showThread( $st, $i, $subthreadCount, $cascadeOptions );
@@ -1583,4 +1603,16 @@
15841604
15851605 return $sig;
15861606 }
 1607+
 1608+ function customizeTabs( $skin, &$links ) {
 1609+ // No-op
 1610+ }
 1611+
 1612+ function customizeNavigation( $skin, &$links ) {
 1613+ // No-op
 1614+ }
 1615+
 1616+ function show() {
 1617+ return true; // No-op
 1618+ }
15871619 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Dispatch.php
@@ -3,6 +3,7 @@
44 class LqtDispatch {
55 /** static cache of per-page LiquidThreads activation setting */
66 static $userLqtOverride;
 7+ static $primaryView = null;
78
89 static function talkpageMain( &$output, &$article, &$title, &$user, &$request ) {
910 // We are given a talkpage article and title. Fire up a TalkpageView
@@ -48,7 +49,9 @@
4950 } else {
5051 $viewname = 'TalkpageView';
5152 }
 53+
5254 $view = new $viewname( $output, $article, $title, $user, $request );
 55+ self::$primaryView = $view;
5356 return $view->show();
5457 }
5558
@@ -79,12 +82,14 @@
8083 }
8184
8285 $view = new $viewname( $output, $article, $title, $user, $request );
 86+ self::$primaryView = $view;
8387 return $view->show();
8488 }
8589
8690 static function threadSummaryMain( &$output, &$article, &$title, &$user, &$request ) {
8791 $viewname = 'SummaryPageView';
8892 $view = new $viewname( $output, $article, $title, $user, $request );
 93+ self::$primaryView = $view;
8994 return $view->show();
9095 }
9196
@@ -167,4 +172,20 @@
168173 }
169174 return true;
170175 }
 176+
 177+ static function onSkinTemplateNavigation( $skinTemplate, &$links ) {
 178+ if ( !self::$primaryView ) return true;
 179+
 180+ self::$primaryView->customizeNavigation( $skinTemplate, $links );
 181+
 182+ return true;
 183+ }
 184+
 185+ static function onSkinTemplateTabs( $skinTemplate, &$links ) {
 186+ if ( !self::$primaryView ) return true;
 187+
 188+ self::$primaryView->customizeTabs( $skinTemplate, $links );
 189+
 190+ return true;
 191+ }
171192 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Hooks.php
@@ -283,6 +283,7 @@
284284 }
285285
286286 static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) {
 287+ global $wgRequest;
287288 $article = $editPage->getArticle();
288289 $title = $article->getTitle();
289290
@@ -290,6 +291,25 @@
291292 unset( $checkboxes['minor'] );
292293 }
293294
 295+ if ( $title->getNamespace() == NS_LQT_THREAD && self::$editType != 'new' ) {
 296+ wfLoadExtensionMessages( 'LiquidThreads' );
 297+ $label = wfMsgExt( 'lqt-edit-bump', 'parseinline' );
 298+ $tooltip = wfMsgExt( 'lqt-edit-bump-tooltip', 'parsemag' );
 299+
 300+ $checked = ! $wgRequest->wasPosted() ||
 301+ $wgRequest->getBool( 'wpBumpThread' );
 302+
 303+ $html =
 304+ Xml::check( 'wpBumpThread', $checked, array(
 305+ 'title' => $tooltip, 'id' => 'wpBumpThread'
 306+ ) );
 307+
 308+ $html .= Xml::tags( 'label', array( 'for' => 'wpBumpThread',
 309+ 'title' => $tooltip ), $label );
 310+
 311+ $checkboxes['bump'] = $html;
 312+ }
 313+
294314 return true;
295315 }
296316
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/classes/Thread.php
@@ -55,7 +55,8 @@
5656 }
5757
5858 static function create( $root, $article, $superthread = null,
59 - $type = Threads::TYPE_NORMAL, $subject = '' ) {
 59+ $type = Threads::TYPE_NORMAL, $subject = '',
 60+ $summary = '', $bump = null ) {
6061
6162 $dbw = wfGetDB( DB_MASTER );
6263
@@ -91,7 +92,7 @@
9293 if ( $superthread ) {
9394 $superthread->addReply( $thread );
9495
95 - $superthread->commitRevision( $change_type, $thread );
 96+ $superthread->commitRevision( $change_type, $thread, $summary, $bump );
9697 } else {
9798 $hthread = ThreadRevision::create( $thread, $change_type );
9899 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadWatchView.php
@@ -3,9 +3,4 @@
44 if ( !defined( 'MEDIAWIKI' ) ) die;
55
66 class ThreadWatchView extends ThreadPermalinkView {
7 - function show() {
8 - global $wgHooks;
9 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
10 - return true;
11 - }
127 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadDiffView.php
@@ -3,20 +3,22 @@
44 if ( !defined( 'MEDIAWIKI' ) ) die;
55
66 class ThreadDiffView {
7 - function customizeTabs( $skintemplate, $content_actions ) {
 7+ function customizeTabs( $skintemplate, &$content_actions ) {
88 unset( $content_actions['edit'] );
99 unset( $content_actions['viewsource'] );
1010 unset( $content_actions['talk'] );
1111
12 - $content_actions['talk']['class'] = false;
1312 $content_actions['history']['class'] = 'selected';
14 -
15 - return true;
1613 }
 14+
 15+ function customizeNavigation( $skin, &$links ) {
 16+ $remove = array( 'views/edit', 'views/viewsource' );
1717
18 - function show() {
19 - global $wgHooks;
20 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
21 - return true;
 18+ foreach( $remove as $rem ) {
 19+ list($section, $item) = explode( '/', $rem, 2 );
 20+ unset( $links[$section][$item] );
 21+ }
 22+
 23+ $links['views']['history']['class'] = 'selected';
2224 }
2325 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/TalkpageHeaderView.php
@@ -4,7 +4,7 @@
55 // Pass-through wrapper with an extra note at the top
66
77 class TalkpageHeaderView extends LqtView {
8 - function customizeTabs( $skintemplate, $content_actions ) {
 8+ function customizeTabs( $skintemplate, &$content_actions ) {
99 unset( $content_actions['edit'] );
1010 unset( $content_actions['addsection'] );
1111 unset( $content_actions['history'] );
@@ -15,16 +15,28 @@
1616 $content_actions['header'] = array(
1717 'class' => 'selected',
1818 'text' => wfMsg( 'lqt-talkpage-history-tab' ),
19 - 'href' => ''
 19+ 'href' => '',
2020 );
21 -
22 - return true;
2321 }
 22+
 23+ function customizeNavigation( $skin, &$links ) {
 24+ $remove = array( 'actions/edit', 'actions/addsection', 'views/history',
 25+ 'actions/watch', 'actions/move' );
 26+
 27+ foreach( $remove as $rem ) {
 28+ list($section, $item) = explode( '/', $rem, 2 );
 29+ unset( $links[$section][$item] );
 30+ }
 31+
 32+ $links['views']['header'] = array(
 33+ 'class' => 'selected',
 34+ 'text' => wfMsg( 'lqt-talkpage-history-tab' ),
 35+ 'href' => '',
 36+ );
 37+ }
2438
2539 function show() {
26 - global $wgHooks, $wgOut, $wgTitle, $wgRequest;
27 - // Why is a hook added here?
28 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
 40+ global $wgOut, $wgTitle, $wgRequest;
2941
3042 if ( $wgRequest->getVal( 'action' ) === 'edit' ) {
3143 wfLoadExtensionMessages( 'LiquidThreads' );
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadProtectionFormView.php
@@ -3,25 +3,38 @@
44 if ( !defined( 'MEDIAWIKI' ) ) die;
55
66 // Pass-through wrapper
7 -class ThreadProtectionFormView {
8 - function customizeTabs( $skintemplate, $content_actions ) {
9 - unset( $content_actions['edit'] );
10 - unset( $content_actions['addsection'] );
11 - unset( $content_actions['viewsource'] );
12 - unset( $content_actions['talk'] );
13 -
14 - $content_actions['talk']['class'] = false;
 7+class ThreadProtectionFormView extends LqtView {
 8+ function customizeTabs( $skintemplate, &$content_actions ) {
 9+ ThreadPermalinkView::customizeThreadTabs( $skintemplate, $content_actions, $this );
 10+
1511 if ( array_key_exists( 'protect', $content_actions ) )
1612 $content_actions['protect']['class'] = 'selected';
1713 else if ( array_key_exists( 'unprotect', $content_actions ) )
1814 $content_actions['unprotect']['class'] = 'selected';
19 -
20 - return true;
2115 }
 16+
 17+ function customizeNavigation( $skintemplate, &$links ) {
 18+ ThreadPermalinkView::customizeThreadNavigation( $skintemplate, $links, $this );
 19+
 20+ if ( isset( $links['actions']['protect'] ) ) {
 21+ $links['actions']['protect']['class'] = 'selected';
 22+ }
 23+
 24+ if ( isset( $links['actions']['unprotect'] ) ) {
 25+ $links['actions']['unprotect']['class'] = 'selected';
 26+ }
 27+ }
 28+
 29+ function __construct( &$output, &$article, &$title, &$user, &$request ) {
 30+ parent::__construct( $output, $article, $title, $user, $request );
2231
23 - function show() {
24 - global $wgHooks;
25 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
26 - return true;
 32+ $t = Threads::withRoot( $this->article );
 33+
 34+ $this->thread = $t;
 35+ if ( !$t ) {
 36+ return;
 37+ }
 38+
 39+ $this->article = $t->article();
2740 }
2841 }
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/IndividualThreadHistoryView.php
@@ -5,11 +5,17 @@
66 class IndividualThreadHistoryView extends ThreadPermalinkView {
77 protected $oldid;
88
9 - function customizeTabs( $skintemplate, $content_actions ) {
 9+ function customizeTabs( $skintemplate, &$content_actions ) {
1010 $content_actions['history']['class'] = 'selected';
1111 parent::customizeTabs( $skintemplate, $content_actions );
1212 return true;
1313 }
 14+
 15+ function customizeNavigation( $skin, &$links ) {
 16+ $links['views']['history']['class'] = 'selected';
 17+ parent::customizeNavigation( $skin, $links );
 18+ return true;
 19+ }
1420
1521 /* This customizes the subtitle of a history *listing* from the hook,
1622 and of an old revision from getSubtitle() below. */
@@ -40,8 +46,6 @@
4147 return false;
4248 }
4349
44 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
45 -
4650 $wgHooks['PageHistoryBeforeList'][] = array( $this, 'customizeSubtitle' );
4751
4852 return true;
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadHistoricalRevisionView.php
@@ -114,9 +114,6 @@
115115
116116 $this->showHistoryInfo();
117117
118 - global $wgHooks;
119 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
120 -
121118 if ( !$this->thread ) {
122119 $this->showMissingThreadPage();
123120 return false;
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/TalkpageHistoryView.php
@@ -4,9 +4,8 @@
55
66 class TalkpageHistoryView extends TalkpageView {
77 function show() {
8 - global $wgHooks, $wgUser;
9 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
10 -
 8+ global $wgUser;
 9+
1110 self::addJSandCSS();
1211 wfLoadExtensionMessages( 'LiquidThreads' );
1312
@@ -32,6 +31,19 @@
3332
3433 return false;
3534 }
 35+
 36+ function customizeTabs( $skin, &$links ) {
 37+ TalkpageView::customizeTalkpageTabs( $skin, $links, $this );
 38+
 39+ $tabid = $this->article->getTitle()->getNamespaceKey();
 40+ $links['history']['class'] = 'selected';
 41+ }
 42+
 43+ function customizeNavigation( $skin, &$links ) {
 44+ TalkpageView::customizeTalkpageNavigation( $skin, $links, $this );
 45+ $links['views']['history']['class'] = 'selected';
 46+ $links['views']['view']['class'] = '';
 47+ }
3648 }
3749
3850 class TalkpageHistoryPager extends ThreadHistoryPager {
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadPermalinkView.php
@@ -4,62 +4,131 @@
55
66 class ThreadPermalinkView extends LqtView {
77 protected $thread;
 8+
 9+ function customizeTabs( $skin, &$links ) {
 10+ self::customizeThreadTabs( $skin, $links, $this );
 11+ }
 12+
 13+ function customizeNavigation( $skin, &$links ) {
 14+ self::customizeThreadNavigation( $skin, $links, $this );
 15+ }
816
9 - function customizeTabs( $skintemplate, $content_actions ) {
 17+ static function customizeThreadTabs( $skintemplate, &$content_actions, $view ) {
1018 wfLoadExtensionMessages( 'LiquidThreads' );
11 - // Insert fake 'article' and 'discussion' tabs before the thread tab.
12 - // If you call the key 'talk', the url gets re-set later. TODO:
13 - // the access key for the talk tab doesn't work.
14 - if ( $this->thread ) {
15 - $article_t = $this->thread->article()->getTitle();
16 - $talk_t = $this->thread->article()->getTitle();
17 - } else {
 19+
 20+ if ( !$view->thread ) {
1821 return true;
1922 }
2023
21 - $articleTab =
22 - array(
23 - 'text' => wfMsg( $article_t->getNamespaceKey() ),
24 - 'href' => $article_t->getFullURL(),
25 - 'class' => $article_t->exists() ? '' : 'new'
26 - );
27 - efInsertIntoAssoc( 'article', $articleTab, 'nstab-thread', $content_actions );
 24+ // Insert 'article' and 'discussion' tabs before the thread tab.
2825
29 - $talkTab =
30 - array(
31 - // talkpage certainly exists since this thread is from it.
32 - 'text' => wfMsg( 'talk' ),
33 - 'href' => $talk_t->getFullURL()
34 - );
35 -
36 - efInsertIntoAssoc( 'not_talk', $talkTab, 'nstab-thread', $content_actions );
 26+ $tabs = self::getCustomTabs( $view );
 27+ $content_actions = $tabs + $content_actions;
3728
3829 unset( $content_actions['edit'] );
3930 unset( $content_actions['viewsource'] );
4031 unset( $content_actions['talk'] );
4132
42 - $subpage = $this->thread->title()->getPrefixedText();
 33+ $subpage = $view->thread->title()->getPrefixedText();
4334
44 - if ( array_key_exists( 'move', $content_actions ) && $this->thread ) {
 35+ // Repoint move/delete/history tabs
 36+ if ( array_key_exists( 'move', $content_actions ) && $view->thread ) {
4537 $content_actions['move']['href'] =
46 - SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL();
 38+ SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL();
4739 }
4840
49 - if ( array_key_exists( 'delete', $content_actions ) && $this->thread ) {
 41+ if ( array_key_exists( 'delete', $content_actions ) && $view->thread ) {
5042 $content_actions['delete']['href'] =
51 - $this->thread->title()->getFullURL( 'action=delete' );
 43+ $view->thread->title()->getFullURL( 'action=delete' );
5244 }
5345
5446 if ( array_key_exists( 'history', $content_actions ) ) {
55 - $content_actions['history']['href'] = self::permalinkUrl( $this->thread, 'thread_history' );
56 - if ( $this->methodApplies( 'thread_history' ) ) {
 47+ $content_actions['history']['href'] = self::permalinkUrl( $view->thread, 'thread_history' );
 48+ if ( $view->methodApplies( 'thread_history' ) ) {
5749 $content_actions['history']['class'] = 'selected';
5850 }
5951 }
6052
6153 return true;
6254 }
 55+
 56+ static function customizeThreadNavigation( $skin, &$links, $view ) {
 57+ if ( !$view->thread ) {
 58+ return true;
 59+ }
 60+
 61+ // Insert 'article' and 'discussion' namespace-tabs
 62+ $new_nstabs = self::getCustomTabs( $view );
 63+
 64+ $nstabs =& $links['namespaces'];
6365
 66+ $talkKey = $view->thread->title()->getNamespaceKey('').'_talk';
 67+ unset( $nstabs[$talkKey] );
 68+ $nstabs = $new_nstabs + $nstabs;
 69+
 70+ // Remove some views.
 71+ $views =& $links['views'];
 72+ unset( $views['viewsource'] );
 73+ unset( $views['edit'] );
 74+
 75+ // Re-point move, delete and history actions
 76+ $subpage = $view->thread->title()->getPrefixedText();
 77+ $actions =& $links['actions'];
 78+ if ( isset($actions['move']) ) {
 79+ $actions['move']['href'] =
 80+ SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL();
 81+ }
 82+
 83+ if ( isset($actions['delete']) ) {
 84+ $actions['delete']['href'] =
 85+ $view->thread->title()->getFullURL( 'action=delete' );
 86+ }
 87+
 88+ if ( isset($views['history']) ) {
 89+ $views['history']['href'] =
 90+ self::permalinkUrl( $view->thread, 'thread_history' );
 91+ if ( $view->methodApplies( 'thread_history' ) ) {
 92+ $views['history']['class'] = 'selected';
 93+ }
 94+ }
 95+ }
 96+
 97+ // Pre-generates the tabs to be included, for customizeTabs and customizeNavigation
 98+ // to insert in the appropriate place
 99+ static function getCustomTabs( $view ) {
 100+ $tabs = array();
 101+
 102+ $articleTitle = $view->thread->article()->getTitle()->getSubjectPage();
 103+ $talkTitle = $view->thread->article()->getTitle()->getTalkPage();
 104+
 105+ $articleClasses = array();
 106+ if ( !$articleTitle->exists() ) $articleClasses[] = 'new';
 107+ if ( $articleTitle->equals( $view->thread->article()->getTitle() ) )
 108+ $articleClasses[] = 'selected';
 109+
 110+ $talkClasses = array();
 111+ if ( !$talkTitle->exists() ) $talkClasses[] = 'new';
 112+ if ( $talkTitle->equals( $view->thread->article()->getTitle() ) )
 113+ $talkClasses[] = 'selected';
 114+
 115+ $tabs['article'] =
 116+ array(
 117+ 'text' => wfMsg( $articleTitle->getNamespaceKey() ),
 118+ 'href' => $articleTitle->getFullURL(),
 119+ 'class' => implode( ' ', $articleClasses ),
 120+ );
 121+
 122+ $tabs['lqt_talk'] =
 123+ array(
 124+ // talkpage certainly exists since this thread is from it.
 125+ 'text' => wfMsg( 'talk' ),
 126+ 'href' => $talkTitle->getFullURL(),
 127+ 'class' => implode( ' ', $talkClasses ),
 128+ );
 129+
 130+ return $tabs;
 131+ }
 132+
64133 function showThreadHeading( $thread ) {
65134 parent::showThreadHeading( $thread );
66135 }
@@ -108,26 +177,21 @@
109178 }
110179
111180 function __construct( &$output, &$article, &$title, &$user, &$request ) {
112 -
113181 parent::__construct( $output, $article, $title, $user, $request );
114182
115183 $t = Threads::withRoot( $this->article );
116184
117185 $this->thread = $t;
118186 if ( !$t ) {
119 - return; // error reporting is handled in show(). this kinda sucks.
 187+ return;
120188 }
121189
122190 // $this->article gets saved to thread_article, so we want it to point to the
123191 // subject page associated with the talkpage, always, not the permalink url.
124192 $this->article = $t->article(); # for creating reply threads.
125 -
126193 }
127194
128195 function show() {
129 - global $wgHooks;
130 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
131 -
132196 if ( !$this->thread ) {
133197 $this->showMissingThreadPage();
134198 return false;
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/ThreadHistoryListingView.php
@@ -4,9 +4,6 @@
55
66 class ThreadHistoryListingView extends ThreadPermalinkView {
77 function show() {
8 - global $wgHooks;
9 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
10 -
118 if ( ! $this->thread ) {
129 $this->showMissingThreadPage();
1310 return false;
@@ -33,5 +30,16 @@
3431
3532 return false;
3633 }
 34+
 35+ function customizeTabs( $skin, &$links ) {
 36+ parent::customizeTabs( $skin, $links );
 37+ $links['history']['class'] = 'selected';
 38+ }
 39+
 40+ function customizeNavigation( $skin, &$links ) {
 41+ parent::customizeNavigation( $skin, $links );
 42+ $links['views']['history']['class'] = 'selected';
 43+ $links['views']['view']['class'] = '';
 44+ }
3745 }
3846
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/pages/TalkpageView.php
@@ -4,7 +4,7 @@
55
66 class TalkpageView extends LqtView {
77 /* Added to SkinTemplateTabs hook in TalkpageView::show(). */
8 - function customizeTabs( $skintemplate, &$content_actions ) {
 8+ static function customizeTalkpageTabs( $skintemplate, &$content_actions, $view ) {
99 // The arguments are passed in by reference.
1010 unset( $content_actions['edit'] );
1111 unset( $content_actions['viewsource'] );
@@ -12,13 +12,34 @@
1313
1414 # Protection against non-SkinTemplate skins
1515 if ( isset( $content_actions['history'] ) ) {
16 - $thisTitle = $this->article->getTitle();
 16+ $thisTitle = $view->article->getTitle();
1717 $history_url = $thisTitle->getFullURL( 'lqt_method=talkpage_history' );
1818 $content_actions['history']['href'] = $history_url;
1919 }
20 -
21 - return true;
2220 }
 21+
 22+ static function customizeTalkpageNavigation( $skin, &$links, $view ) {
 23+ $remove = array( 'views/edit', 'views/viewsource', 'actions/delete' );
 24+
 25+ foreach( $remove as $rem ) {
 26+ list($section, $item) = explode( '/', $rem, 2 );
 27+ unset( $links[$section][$item] );
 28+ }
 29+
 30+ if ( isset( $links['views']['history'] ) ) {
 31+ $title = $view->article->getTitle();
 32+ $history_url = $title->getFullURL( 'lqt_method=talkpage_history' );
 33+ $links['views']['history']['href'] = $history_url;
 34+ }
 35+ }
 36+
 37+ function customizeTabs( $skintemplate, &$links ) {
 38+ self::customizeTalkpageTabs( $skintemplate, $links, $this );
 39+ }
 40+
 41+ function customizeNavigation( $skintemplate, &$links ) {
 42+ self::customizeTalkpageNavigation( $skintemplate, $links, $this );
 43+ }
2344
2445 function showHeader() {
2546 /* Show the contents of the actual talkpage article if it exists. */
@@ -178,10 +199,7 @@
179200 }
180201
181202 function show() {
182 - global $wgHooks;
183203 wfLoadExtensionMessages( 'LiquidThreads' );
184 - // FIXME Why is a hook added here?
185 - $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs' );
186204
187205 $this->output->setPageTitle( $this->title->getPrefixedText() );
188206 self::addJSandCSS();
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/api/ApiThreadAction.php
@@ -30,6 +30,11 @@
3131 'text' => 'The text of the post to create',
3232 'render' => 'If set, on post/reply methods, the top-level thread '.
3333 'after the change will be rendered and returned in the result.',
 34+ 'bump' => 'If set, overrides default behaviour as to whether or not to ',
 35+ "increase the thread's sort key. If true, sets it to current ".
 36+ "timestamp. If false, does not set it. Default depends on ".
 37+ "the action being taken. Presently only works for newthread ".
 38+ "and reply actions.",
3439 );
3540 }
3641
@@ -54,6 +59,7 @@
5560 'newparent' => null,
5661 'text' => null,
5762 'render' => null,
 63+ 'bump' => null,
5864 );
5965 }
6066
@@ -294,6 +300,8 @@
295301 return;
296302 }
297303
 304+ $bump = isset($params['bump']) ? $params['bump'] : null;
 305+
298306 $subject = $params['subject'];
299307 $title = null;
300308 $subjectOk = Thread::validateSubject( $subject, $title, null, $talkpage );
@@ -357,7 +365,7 @@
358366 $title->resetArticleID( $articleId );
359367
360368 $thread = LqtView::postEditUpdates( 'new', null, $article, $talkpage,
361 - $subject, $summary, null, $text );
 369+ $subject, $summary, null, $text, $bump );
362370
363371 $maxLag = wfGetLB()->getMaxLag();
364372 $maxLag = $maxLag[1];
@@ -414,6 +422,8 @@
415423
416424 $text = $params['text'];
417425
 426+ $bump = isset($params['bump']) ? $params['bump'] : null;
 427+
418428 // Generate/pull summary
419429 $summary = wfMsgForContent( 'lqt-reply-summary', $replyTo->subject(),
420430 $replyTo->title()->getPrefixedText() );
@@ -468,7 +478,7 @@
469479 $title->resetArticleID( $articleId );
470480
471481 $thread = LqtView::postEditUpdates( 'reply', $replyTo, $article, $talkpage,
472 - $subject, $summary, null, $text );
 482+ $subject, $summary, null, $text, $bump );
473483
474484 $maxLag = wfGetLB()->getMaxLag();
475485 $maxLag = $maxLag[1];
Index: branches/wmf-deployment/extensions/LiquidThreads_alpha/lqt.js
@@ -97,7 +97,7 @@
9898 var cancelButton = $j(container).find('#mw-editform-cancel');
9999 cancelButton.click( liquidThreads.cancelEdit );
100100
101 - $j(container).find('#wpTextbox1')[0].rows = 10;
 101+ $j(container).find('#wpTextbox1').attr( 'rows', 12 );
102102
103103 // Add toolbar
104104 mwSetupToolbar();
@@ -466,6 +466,7 @@
467467 var threadId = thread.data('thread-id');
468468 var replies = thread.parent().find('.lqt-thread-replies');
469469 var loader = $j('<div class="mw-ajax-loader"/>');
 470+ var sep = $j('<div class="lqt-post-sep">&nbsp;</div>');
470471
471472 replies.empty();
472473 replies.hide();
@@ -493,6 +494,8 @@
494495 liquidThreads.setupThread( $j(this) );
495496 } );
496497
 498+ replies.before(sep);
 499+
497500 // Show
498501 loader.remove();
499502 replies.fadeIn('slow');
@@ -641,8 +644,15 @@
642645
643646 var text = editform.find('#wpTextbox1').val();
644647 var summary = editform.find('#wpSummary').val();
 648+
 649+ // Check if summary is undefined
 650+ if (summary === undefined) {
 651+ summary = '';
 652+ }
 653+
645654 var subject = editform.find( '#lqt_subject_field' ).val();
646655 var replyThread = editform.find('input[name=lqt_operand]').val();
 656+ var bump = editform.find('#wpBumpThread').is(':checked') ? 1 : 0;
647657
648658 var spinner = $j('<div class="mw-ajax-loader"/>');
649659 editform.prepend(spinner);
@@ -747,18 +757,19 @@
748758 };
749759
750760 if ( type == 'reply' ) {
751 - liquidThreads.doReply( replyThread, text, summary, doneCallback);
 761+ liquidThreads.doReply( replyThread, text, summary,
 762+ doneCallback, bump );
752763
753764 e.preventDefault();
754765 } else if ( type == 'talkpage_new_thread' ) {
755766 liquidThreads.doNewThread( wgPageName, subject, text, summary,
756 - doneCallback );
 767+ doneCallback, bump );
757768
758769 e.preventDefault();
759770 }
760771 },
761772
762 - 'doNewThread' : function( talkpage, subject, text, summary, callback ) {
 773+ 'doNewThread' : function( talkpage, subject, text, summary, callback, bump ) {
763774 liquidThreads.getToken(
764775 function(token) {
765776 var newTopicParams =
@@ -771,7 +782,8 @@
772783 'token' : token,
773784 'format' : 'json',
774785 'render' : '1',
775 - 'reason' : summary
 786+ 'reason' : summary,
 787+ 'bump' : bump
776788 };
777789
778790 $j.post( wgScriptPath+'/api'+wgScriptExtension, newTopicParams,
@@ -783,7 +795,7 @@
784796 } );
785797 },
786798
787 - 'doReply' : function( thread, text, summary, callback ) {
 799+ 'doReply' : function( thread, text, summary, callback, bump ) {
788800 liquidThreads.getToken(
789801 function(token) {
790802 var replyParams =
@@ -795,7 +807,8 @@
796808 'token' : token,
797809 'format' : 'json',
798810 'render' : '1',
799 - 'reason' : summary
 811+ 'reason' : summary,
 812+ 'bump' : bump
800813 };
801814
802815 $j.post( wgScriptPath+'/api'+wgScriptExtension, replyParams,
Property changes on: branches/wmf-deployment/extensions/LiquidThreads_alpha
___________________________________________________________________
Modified: svn:mergeinfo
803816 Merged /trunk/extensions/LiquidThreads:r59354-59416,59418-59419,59421-59422,59424-59427

Status & tagging log