
werdna at svn
Nov 24, 2009, 4:47 AM
Post #1 of 1
(75 views)
Permalink
|
|
SVN: [59379] trunk/extensions/LiquidThreads
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59379 Revision: 59379 Author: werdna Date: 2009-11-24 12:47:35 +0000 (Tue, 24 Nov 2009) Log Message: ----------- LiquidThreads: Make bumping a thread optional. Resolves bug 21055. * Also includes a fix for bug 21452, which I came across while refactoring some code. Modified Paths: -------------- trunk/extensions/LiquidThreads/api/ApiThreadAction.php trunk/extensions/LiquidThreads/classes/Hooks.php trunk/extensions/LiquidThreads/classes/Thread.php trunk/extensions/LiquidThreads/classes/Threads.php trunk/extensions/LiquidThreads/classes/View.php trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php trunk/extensions/LiquidThreads/lqt.js Modified: trunk/extensions/LiquidThreads/api/ApiThreadAction.php =================================================================== --- trunk/extensions/LiquidThreads/api/ApiThreadAction.php 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/api/ApiThreadAction.php 2009-11-24 12:47:35 UTC (rev 59379) @@ -30,6 +30,11 @@ 'text' => 'The text of the post to create', 'render' => 'If set, on post/reply methods, the top-level thread '. 'after the change will be rendered and returned in the result.', + 'bump' => 'If set, overrides default behaviour as to whether or not to ', + "increase the thread's sort key. If true, sets it to current ". + "timestamp. If false, does not set it. Default depends on ". + "the action being taken. Presently only works for newthread ". + "and reply actions.", ); } @@ -54,6 +59,7 @@ 'newparent' => null, 'text' => null, 'render' => null, + 'bump' => null, ); } @@ -294,6 +300,8 @@ return; } + $bump = isset($params['bump']) ? $params['bump'] : null; + $subject = $params['subject']; $title = null; $subjectOk = Thread::validateSubject( $subject, $title, null, $talkpage ); @@ -357,7 +365,7 @@ $title->resetArticleID( $articleId ); $thread = LqtView::postEditUpdates( 'new', null, $article, $talkpage, - $subject, $summary, null, $text ); + $subject, $summary, null, $text, $bump ); $maxLag = wfGetLB()->getMaxLag(); $maxLag = $maxLag[1]; @@ -414,6 +422,8 @@ $text = $params['text']; + $bump = isset($params['bump']) ? $params['bump'] : null; + // Generate/pull summary $summary = wfMsgForContent( 'lqt-reply-summary', $replyTo->subject(), $replyTo->title()->getPrefixedText() ); @@ -468,7 +478,7 @@ $title->resetArticleID( $articleId ); $thread = LqtView::postEditUpdates( 'reply', $replyTo, $article, $talkpage, - $subject, $summary, null, $text ); + $subject, $summary, null, $text, $bump ); $maxLag = wfGetLB()->getMaxLag(); $maxLag = $maxLag[1]; Modified: trunk/extensions/LiquidThreads/classes/Hooks.php =================================================================== --- trunk/extensions/LiquidThreads/classes/Hooks.php 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/classes/Hooks.php 2009-11-24 12:47:35 UTC (rev 59379) @@ -283,6 +283,7 @@ } static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) { + global $wgRequest; $article = $editPage->getArticle(); $title = $article->getTitle(); @@ -290,6 +291,25 @@ unset( $checkboxes['minor'] ); } + if ( $title->getNamespace() == NS_LQT_THREAD && self::$editType != 'new' ) { + wfLoadExtensionMessages( 'LiquidThreads' ); + $label = wfMsgExt( 'lqt-edit-bump', 'parseinline' ); + $tooltip = wfMsgExt( 'lqt-edit-bump-tooltip', 'parsemag' ); + + $checked = ! $wgRequest->wasPosted() || + $wgRequest->getBool( 'wpBumpThread' ); + + $html = + Xml::check( 'wpBumpThread', $checked, array( + 'title' => $tooltip, 'id' => 'wpBumpThread' + ) ); + + $html .= Xml::tags( 'label', array( 'for' => 'wpBumpThread', + 'title' => $tooltip ), $label ); + + $checkboxes['bump'] = $html; + } + return true; } Modified: trunk/extensions/LiquidThreads/classes/Thread.php =================================================================== --- trunk/extensions/LiquidThreads/classes/Thread.php 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/classes/Thread.php 2009-11-24 12:47:35 UTC (rev 59379) @@ -55,7 +55,8 @@ } static function create( $root, $article, $superthread = null, - $type = Threads::TYPE_NORMAL, $subject = '' ) { + $type = Threads::TYPE_NORMAL, $subject = '', + $summary = '', $bump = null ) { $dbw = wfGetDB( DB_MASTER ); @@ -91,7 +92,7 @@ if ( $superthread ) { $superthread->addReply( $thread ); - $superthread->commitRevision( $change_type, $thread ); + $superthread->commitRevision( $change_type, $thread, $summary, $bump ); } else { $hthread = ThreadRevision::create( $thread, $change_type ); } Modified: trunk/extensions/LiquidThreads/classes/Threads.php =================================================================== --- trunk/extensions/LiquidThreads/classes/Threads.php 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/classes/Threads.php 2009-11-24 12:47:35 UTC (rev 59379) @@ -51,11 +51,6 @@ static $cache_by_id = array(); static $occupied_titles = array(); - static function newThread( $root, $article, $superthread = null, - $type = self::TYPE_NORMAL, $subject = '' ) { - return Thread::create( $root, $article, $superthread, $type, $subject ); - } - /** * Create the talkpage if it doesn't exist so that links to it * will show up blue instead of red. For use upon new thread creation. Modified: trunk/extensions/LiquidThreads/classes/View.php =================================================================== --- trunk/extensions/LiquidThreads/classes/View.php 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/classes/View.php 2009-11-24 12:47:35 UTC (rev 59379) @@ -510,10 +510,12 @@ // $this->renameThread( $thread, $subject, $e->summary ); } + $bump = $this->request->getBool( 'wpBumpThread' ); + $thread = self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article, $subject, $e->summary, $thread, - $e->textbox1 + $e->textbox1, $bump ); if ( $submitted_nonce && $nonce_key ) { @@ -537,22 +539,25 @@ } static function postEditUpdates( $edit_type, $edit_applies_to, $edit_page, $article, - $subject, $edit_summary, $thread, $new_text ) { + $subject, $edit_summary, $thread, $new_text, + $bump = null ) { // Update metadata - create and update thread and thread revision objects as // appropriate. if ( $edit_type == 'reply' ) { $subject = $edit_applies_to->subject(); - $thread = Threads::newThread( $edit_page, $article, $edit_applies_to, - Threads::TYPE_NORMAL, $subject ); + $thread = Thread::create( $edit_page, $article, $edit_applies_to, + Threads::TYPE_NORMAL, $subject, + $edit_summary, $bump ); global $wgUser; NewMessages::markThreadAsReadByUser( $edit_applies_to, $wgUser ); } elseif ( $edit_type == 'summarize' ) { $edit_applies_to->setSummary( $edit_page ); $edit_applies_to->commitRevision( Threads::CHANGE_EDITED_SUMMARY, - $edit_applies_to, $edit_summary ); + $edit_applies_to, $edit_summary, + $bump); } elseif ( $edit_type == 'editExisting' ) { // Use a separate type if the content is blanked. $type = strlen( trim( $new_text ) ) @@ -560,10 +565,11 @@ : Threads::CHANGE_ROOT_BLANKED; // Add the history entry. - $thread->commitRevision( $type, $thread, $edit_summary ); + $thread->commitRevision( $type, $thread, $edit_summary, $bump ); } else { - $thread = Threads::newThread( $edit_page, $article, null, - Threads::TYPE_NORMAL, $subject ); + $thread = Thread::create( $edit_page, $article, null, + Threads::TYPE_NORMAL, $subject, + $edit_summary ); } return $thread; Modified: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php =================================================================== --- trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php 2009-11-24 12:47:35 UTC (rev 59379) @@ -277,6 +277,9 @@ 'lqt-protected-reply-thread' => 'You cannot post in this thread because it has been protected from new posts.', 'lqt-protected-reply-talkpage' => 'You cannot post in this thread because this discussion page has been protected from replies to its threads.', 'lqt-protected-newthread' => 'You cannot post new threads to this discussion page because it has been protected from new threads.', + + 'lqt-edit-bump' => 'Bump this thread', + 'lqt-edit-bump-tooltip' => 'Move this thread to the top of its discussion page', ); /** Message documentation (Message documentation) Modified: trunk/extensions/LiquidThreads/lqt.js =================================================================== --- trunk/extensions/LiquidThreads/lqt.js 2009-11-24 11:31:54 UTC (rev 59378) +++ trunk/extensions/LiquidThreads/lqt.js 2009-11-24 12:47:35 UTC (rev 59379) @@ -643,6 +643,7 @@ var summary = editform.find('#wpSummary').val(); var subject = editform.find( '#lqt_subject_field' ).val(); var replyThread = editform.find('input[name=lqt_operand]').val(); + var bump = editform.find('#wpBumpThread').is(':checked') ? 1 : 0; var spinner = $j('<div class="mw-ajax-loader"/>'); editform.prepend(spinner); @@ -747,18 +748,19 @@ }; if ( type == 'reply' ) { - liquidThreads.doReply( replyThread, text, summary, doneCallback); + liquidThreads.doReply( replyThread, text, summary, + doneCallback, bump ); e.preventDefault(); } else if ( type == 'talkpage_new_thread' ) { liquidThreads.doNewThread( wgPageName, subject, text, summary, - doneCallback ); + doneCallback, bump ); e.preventDefault(); } }, - 'doNewThread' : function( talkpage, subject, text, summary, callback ) { + 'doNewThread' : function( talkpage, subject, text, summary, callback, bump ) { liquidThreads.getToken( function(token) { var newTopicParams = @@ -771,7 +773,8 @@ 'token' : token, 'format' : 'json', 'render' : '1', - 'reason' : summary + 'reason' : summary, + 'bump' : bump }; $j.post( wgScriptPath+'/api'+wgScriptExtension, newTopicParams, @@ -783,7 +786,7 @@ } ); }, - 'doReply' : function( thread, text, summary, callback ) { + 'doReply' : function( thread, text, summary, callback, bump ) { liquidThreads.getToken( function(token) { var replyParams = @@ -795,7 +798,8 @@ 'token' : token, 'format' : 'json', 'render' : '1', - 'reason' : summary + 'reason' : summary, + 'bump' : bump }; $j.post( wgScriptPath+'/api'+wgScriptExtension, replyParams, _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|