logo       

[MediaWiki-CVS] SVN: [54091] trunk: msg#01469

mediawiki-cvs

Subject: [MediaWiki-CVS] SVN: [54091] trunk

http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54091

Revision: 54091
Author: werdna
Date: 2009-07-31 10:59:11 +0000 (Fri, 31 Jul 2009)

Log Message:
-----------
LiquidThreads code quality, bug fixes and cleanup:
* Remove large swathes of dead code, hooks that have never existed, and dormant
methods.
* Remove the TalkpageArchiveView, which has been inaccessible from the UI for
ages.
* Break most miscellaneous hooks out into their own file, classes/Hooks.php
* Float the reply link on the RHS.
* Organise the hooks section of LiquidThreads.php somewhat.
* Remove deprecated =& syntax in some places.
* Move scratchTitle and related methods into Threads class instead of View
class.
* Kill home-grown revision insertion code from leaveTrace, and rewrite it to
use Article::doEdit
* Internal documentation, variable naming as appropriate.
* Remove special-case handling for links, unnecessary now.
* Fix customizeOldChangesList, it looks like it was never properly tested. Even
if it had worked, it would have put (not by the author) on every edit to a post.
* Fail fast when trying to move a non-toplevel thread.
* Add rollback, extra links to the end of new-thread recentchanges entries.

Modified Paths:
--------------
trunk/extensions/LiquidThreads/LiquidThreads.php
trunk/extensions/LiquidThreads/LqtFunctions.php
trunk/extensions/LiquidThreads/classes/Dispatch.php
trunk/extensions/LiquidThreads/classes/NewMessagesController.php
trunk/extensions/LiquidThreads/classes/Thread.php
trunk/extensions/LiquidThreads/classes/Threads.php
trunk/extensions/LiquidThreads/classes/View.php
trunk/extensions/LiquidThreads/lqt.css
trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
trunk/phase3/includes/ChangesList.php

Removed Paths:
-------------
trunk/extensions/LiquidThreads/pages/TalkpageArchiveView.php

Modified: trunk/extensions/LiquidThreads/LiquidThreads.php
===================================================================
--- trunk/extensions/LiquidThreads/LiquidThreads.php 2009-07-31 10:58:58 UTC
(rev 54090)
+++ trunk/extensions/LiquidThreads/LiquidThreads.php 2009-07-31 10:59:11 UTC
(rev 54091)
@@ -48,19 +48,28 @@
}

// Hooks
-$wgHooks['SpecialWatchlistQuery'][] = 'efLqtBeforeWatchlistHook';
+// Main dispatch hook
$wgHooks['MediaWikiPerformAction'][] = 'LqtDispatch::tryPage';
-$wgHooks['SpecialMovepageAfterMove'][] = 'LqtDispatch::onPageMove';
-$wgHooks['LinkerMakeLinkObj'][] = 'LqtDispatch::makeLinkObj';
-$wgHooks['SkinTemplateTabAction'][] = 'LqtDispatch::tabAction';
-$wgHooks['OldChangesListRecentChangesLine'][] =
'LqtDispatch::customizeOldChangesList';
-$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'LqtDispatch::setNewtalkHTML';
-$wgHooks['TitleGetRestrictions'][] = 'Thread::getRestrictionsForTitle';
-$wgHooks['GetPreferences'][] = 'lqtGetPreferences';
-$wgHooks['ArticleEditUpdateNewTalk'][] = 'lqtUpdateNewtalkOnEdit';
+
+// Miscellaneous
+$wgHooks['SpecialMovepageAfterMove'][] = 'LqtHooks::onPageMove'; // Move
threads to new loc
+// Customisation of recentchanges
+$wgHooks['OldChangesListRecentChangesLine'][] =
'LqtHooks::customizeOldChangesList';
+
+// Notification (watchlist, newtalk)
+$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'LqtHooks::setNewtalkHTML';
+$wgHooks['SpecialWatchlistQuery'][] = 'LqtHooks::beforeWatchlist';
+$wgHooks['ArticleEditUpdateNewTalk'][] = 'LqtHooks::updateNewtalkOnEdit';
+
+// Preferences
+$wgHooks['GetPreferences'][] = 'LqtHooks::getPreferences';
+
+// Export-related
+$wgHooks['XmlDumpWriterOpenPage'][] = 'LqtHooks::dumpThreadData';
+$wgHooks['ModifyExportQuery'][] = 'LqtHooks::modifyExportQuery';
+
+// Magic words
$wgHooks['LanguageGetMagic'][] = 'LiquidThreadsMagicWords::getMagicWords';
-$wgHooks['XmlDumpWriterOpenPage'][] = 'lqtDumpThreadData';
-$wgHooks['ModifyExportQuery'][] = 'lqtModifyExportQuery';

// Deletion
$wgHooks['ArticleDeleteComplete'][] =
'LqtDeletionController::onArticleDeleteComplete';
@@ -69,7 +78,6 @@
$wgHooks['ArticleDelete'][] = 'LqtDeletionController::onArticleDelete';

// Special pages
-#$wgSpecialPages['UndeleteThread'] = 'SpecialUndeleteThread';
$wgSpecialPages['MoveThread'] = 'SpecialMoveThread';
$wgSpecialPages['NewMessages'] = 'SpecialNewMessages';
$wgSpecialPages['SplitThread'] = 'SpecialSplitThread';
@@ -85,10 +93,10 @@
$wgAutoloadClasses['LiquidThreadsMagicWords'] = $dir .
'i18n/LiquidThreads.magic.php';
$wgAutoloadClasses['LqtParserFunctions'] = $dir .
'classes/ParserFunctions.php';
$wgAutoloadClasses['LqtDeletionController'] =
"$dir/classes/DeletionController.php";
+$wgAutoloadClasses['LqtHooks'] = "$dir/classes/Hooks.php";

-// Page classes
+// View classes
$wgAutoloadClasses['TalkpageView'] = $dir . 'pages/TalkpageView.php';
-$wgAutoloadClasses['TalkpageArchiveView'] = $dir .
'pages/TalkpageArchiveView.php';
$wgAutoloadClasses['ThreadPermalinkView'] = $dir .
'pages/ThreadPermalinkView.php';
$wgAutoloadClasses['TalkpageHeaderView'] = $dir .
'pages/TalkpageHeaderView.php';
$wgAutoloadClasses['IndividualThreadHistoryView'] = $dir .
'pages/IndividualThreadHistoryView.php';
@@ -100,8 +108,8 @@
$wgAutoloadClasses['SummaryPageView'] = $dir . 'pages/SummaryPageView.php';
$wgAutoloadClasses['NewUserMessagesView'] = $dir .
'pages/NewUserMessagesView.php';

+// Special pages
$wgAutoloadClasses['ThreadActionPage'] = "$dir/pages/ThreadActionPage.php";
-
$wgAutoloadClasses['SpecialMoveThread'] = $dir . 'pages/SpecialMoveThread.php';
$wgAutoloadClasses['SpecialNewMessages'] = $dir .
'pages/SpecialNewMessages.php';
$wgAutoloadClasses['SpecialSplitThread'] = "$dir/pages/SpecialSplitThread.php";

Modified: trunk/extensions/LiquidThreads/LqtFunctions.php
===================================================================
--- trunk/extensions/LiquidThreads/LqtFunctions.php 2009-07-31 10:58:58 UTC
(rev 54090)
+++ trunk/extensions/LiquidThreads/LqtFunctions.php 2009-07-31 10:59:11 UTC
(rev 54091)
@@ -37,99 +37,11 @@
$original_array = $new_assoc;
}

-function efVarDump( $value ) {
- wfVarDump( $value );
-}
-
-function efThreadTable( $ts ) {
- global $wgOut;
- $html = '';
- foreach ( $ts as $t ) {
- $html .= efThreadTableHelper( $t, 0 );
- }
- $html = "<table><tbody>\n$html\n</tbody></table>";
- $wgOut->addHTML( $html );
-}
-
-function efThreadTableHelper( $thread, $indent ) {
- $html = '';
-
- $html .= Xml::tags( '<td>', null, $indent );
- $html .= Xml::tags( '<td>', null, $thread->id() );
- $html .= Xml::tags( '<td>', null, $thread->title()->getPrefixedText() );
-
- $html = Xml::tags( 'tr', null, $html );
-
- foreach ( $t->subthreads() as $subthread ) {
- $html .= efThreadTableHelper( $subthread, $indent + 1 );
- }
-
- return $html;
-}
-
-function efLqtBeforeWatchlistHook( &$conds, &$tables, &$join_conds, &$fields )
{
- global $wgOut, $wgUser;
-
- if ( !in_array( 'page', $tables ) ) {
- $tables[] = 'page';
- $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
- }
- $conds[] = "page_namespace != " . NS_LQT_THREAD;
-
- $talkpage_messages = NewMessages::newUserMessages( $wgUser );
- $tn = count( $talkpage_messages );
-
- $watch_messages = NewMessages::watchedThreadsForUser( $wgUser );
- $wn = count( $watch_messages );
-
- if ( $tn == 0 && $wn == 0 )
- return true;
-
- LqtView::addJSandCSS();
- wfLoadExtensionMessages( 'LiquidThreads' );
- $messages_title = SpecialPage::getPage( 'NewMessages' )->getTitle();
- $new_messages = wfMsg ( 'lqt-new-messages' );
-
- $sk = $wgUser->getSkin();
- $link = $sk->link( $messages_title, $new_messages,
- array( 'class' =>
'lqt_watchlist_messages_notice' ) );
- $wgOut->addHTML( $link );
-
- return true;
-}
-
function lqtFormatMoveLogEntry( $type, $action, $title, $sk, $parameters ) {
return wfMsgExt( 'lqt-log-action-move', 'parseinline',
array( $title->getPrefixedText(),
$parameters[0], $parameters[1] ) );
}

-function lqtGetPreferences( $user, &$preferences ) {
- global $wgEnableEmail;
-
- if ($wgEnableEmail) {
- wfLoadExtensionMessages( 'LiquidThreads' );
- $preferences['lqtnotifytalk'] =
- array(
- 'type' => 'toggle',
- 'label-message' => 'lqt-preference-notify-talk',
- 'section' => 'personal/email'
- );
- }
-
- return true;
-}
-
-function lqtUpdateNewtalkOnEdit( $article ) {
- $title = $article->getTitle();
-
- if ( LqtDispatch::isLqtPage( $title ) ) {
- // They're only editing the header, don't update newtalk.
- return false;
- }
-
- return true;
-}
-
function lqtSetupParserFunctions() {
global $wgParser;

@@ -138,47 +50,3 @@
return true;
}

-function lqtDumpThreadData( $writer, &$out, $row, $title ) {
- $editedStati = array( Threads::EDITED_NEVER => 'never',
-
Threads::EDITED_HAS_REPLY => 'has-reply',
-
Threads::EDITED_BY_AUTHOR => 'by-author',
-
Threads::EDITED_BY_OTHERS => 'by-others' );
- $threadTypes = array( Threads::TYPE_NORMAL => 'normal',
- Threads::TYPE_MOVED =>
'moved',
- Threads::TYPE_DELETED
=> 'deleted' );
- // Is it a thread
- if ( $row->thread_id ) {
- $thread = new Thread( $row );
- $threadInfo = "\n";
- $attribs = array();
- $attribs['ThreadSubject'] = $thread->subject();
- if ($thread->hasSuperThread()) {
- $attribs['ThreadParent'] = $thread->superThread()->id();
- }
- $attribs['ThreadAncestor'] = $thread->topmostThread()->id();
- $attribs['ThreadPage'] =
$thread->article()->getTitle()->getPrefixedText();
- $attribs['ThreadID'] = $thread->id();
- if ( $thread->hasSummary() && $thread->summary() ) {
- $attribs['ThreadSummaryPage'] =
$thread->summary()->getId();
- }
- $attribs['ThreadAuthor'] = $thread->author()->getName();
- $attribs['ThreadEditStatus'] =
$editedStati[$thread->editedness()];
- $attribs['ThreadType'] = $threadTypes[$thread->type()];
-
- foreach( $attribs as $key => $value ) {
- $threadInfo .= "\t".Xml::element( $key, null, $value )
. "\n";
- }
-
- $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) .
"\n";
- }
-
- return true;
-}
-
-function lqtModifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) {
- $tables[] = 'thread';
-
- $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) );
-
- return true;
-}

Modified: trunk/extensions/LiquidThreads/classes/Dispatch.php
===================================================================
--- trunk/extensions/LiquidThreads/classes/Dispatch.php 2009-07-31 10:58:58 UTC
(rev 54090)
+++ trunk/extensions/LiquidThreads/classes/Dispatch.php 2009-07-31 10:59:11 UTC
(rev 54091)
@@ -18,11 +18,9 @@
/** static cache of per-page LiquidThreads activation setting */
static $userLQTActivated;

- static function talkpageMain( &$output, &$talk_article, &$title,
&$user, &$request ) {
- // We are given a talkpage article and title. Find the
associated
- // non-talk article and pass that to the view.
- $article = new Article( $title );
-
+ static function talkpageMain( &$output, &$article, &$title, &$user,
&$request ) {
+ // We are given a talkpage article and title. Fire up a
TalkpageView
+
if ( $title->getNamespace() == NS_LQT_THREAD + 1 /* talk page
*/ ) {
// Threads don't have talk pages; redirect to the
thread page.
$output->redirect(
$title->getSubjectPage()->getFullUrl() );
@@ -30,7 +28,8 @@
}

// If we came here from a red-link, redirect to the thread page.
- $redlink = $request->getCheck( 'redlink' );
+ $redlink = $request->getCheck( 'redlink' ) &&
+ $request->getText( 'action' ) == 'edit';
if( $redlink ) {
$output->redirect( $title->getFullURL() );
return false;
@@ -50,8 +49,6 @@
} else if ( $action == 'protect' || $action == 'unprotect' ) {
// Pass through wrapper
$viewname = self::$views['ThreadProtectionFormView'];
- } else if ( $request->getVal( 'lqt_method' ) ==
'talkpage_archive' ) {
- $viewname = self::$views['TalkpageArchiveView'];
} else {
$viewname = self::$views['TalkpageView'];
}
@@ -66,7 +63,8 @@

if ( $lqt_method == 'thread_history' ) {
$viewname = self::$views['ThreadHistoryListingView'];
- } else if ( $lqt_method == 'diff' ) { // this clause and the
next must be in this order.
+ } else if ( $lqt_method == 'diff' ) {
+ // this clause and the next must be in this order.
$viewname = self::$views['ThreadDiffView'];
} else if ( $action == 'history'
|| $request->getVal( 'diff', null ) !== null
@@ -151,171 +149,20 @@
}

/**
- * If the page we recieve is a Liquid Threads page of any kind, process
it
+ * If the page we recieve is a LiquidThreads page of any kind, process it
* as needed and return True. If it's a normal, non-liquid page, return
false.
*/
static function tryPage( $output, $article, $title, $user, $request ) {
if ( LqtDispatch::isLqtPage( $title ) ) {
- return self::talkpageMain ( $output, $article, $title,
$user, $request );
+ // LiquidThreads pages, Talk:X etc
+ return self::talkpageMain( $output, $article, $title,
$user, $request );
} else if ( $title->getNamespace() == NS_LQT_THREAD ) {
+ // Thread permalink pages, Thread:X
return self::threadPermalinkMain( $output, $article,
$title, $user, $request );
} else if ( $title->getNamespace() == NS_LQT_SUMMARY ) {
+ // Summary pages, Summary:X
return self::threadSummaryMain( $output, $article,
$title, $user, $request );
}
return true;
}
-
- static function onPageMove( $movepage, $ot, $nt ) {
- // We are being invoked on the subject page, not the talk page.
-
- $threads = Threads::where( array( Threads::articleClause( new
Article( $ot ) ),
- Threads::topLevelClause() ) );
-
- foreach ( $threads as $t ) {
- $t->moveToPage( $nt, false );
- }
-
- return true;
- }
-
- static function makeLinkObj( &$returnValue, &$linker, $nt, $text,
$query, $trail, $prefix ) {
- if ( ! $nt->isTalkPage() )
- return true;
-
- // Talkpages with headers.
- if ( $nt->getArticleID() != 0 )
- return true;
-
- // Talkpages without headers -- check existance of threads.
- $article = new Article( $nt );
- $threads = Threads::where( Threads::articleClause( $article ),
"LIMIT 1" );
- if ( count( $threads ) == 0 ) {
- // We want it to look like a broken link, but not have
action=edit, since that
- // will edit the header, so we can't use
makeBrokenLinkObj. This code is copied
- // from the body of that method.
- $url = $nt->escapeLocalURL( $query );
- if ( '' == $text )
- $text = htmlspecialchars(
$nt->getPrefixedText() );
- $style = $linker->getInternalLinkAttributesObj( $nt,
$text, "yes" );
- list( $inside, $trail ) = Linker::splitTrail( $trail );
- $returnValue = "<a
href=\"{$url}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
- }
- else {
- $returnValue = $linker->makeKnownLinkObj( $nt, $text,
$query, $trail, $prefix );
- }
- return false;
- }
-
- // One major place that doesn't use makeLinkObj is the tabs. So
override known/unknown there too.
- static function tabAction( &$skintemplate, $title, $message, $selected,
$checkEdit,
- &$classes, &$query, &$text, &$result ) {
- if ( ! $title->isTalkPage() )
- return true;
- if ( $title->getArticleID() != 0 ) {
- $query = "";
- return true;
- }
- // It's a talkpage without a header. Get rid of action=edit
always,
- // color as apropriate.
- $query = "";
- $article = new Article( $title );
- $threads = Threads::where( Threads::articleClause( $article ),
"LIMIT 1" );
- if ( count( $threads ) != 0 ) {
- $i = array_search( 'new', $classes ); if ( $i !== false
) {
- array_splice( $classes, $i, 1 );
- }
- }
- return true;
- }
-
- static function customizeOldChangesList( &$changeslist, &$s, $rc ) {
- if ( $rc->getTitle()->getNamespace() == NS_LQT_THREAD ) {
- $thread = Threads::withRoot( new Article(
$rc->getTitle() ) );
- if ( !$thread ) return true;
-
- LqtView::addJSandCSS();
- wfLoadExtensionMessages( 'LiquidThreads' );
-
- if ( $rc->mAttribs['rc_type'] != RC_NEW ) {
- // Add whether it was original author.
- // TODO: this only asks whether ANY edit has
been by another, not this edit.
- // But maybe that's what we want.
- if ( $thread->editedness() ==
Threads::EDITED_BY_OTHERS ) {
- $appendix = Xml::tags( 'span',
-
array( 'class' => 'lqt_rc_author_notice ' .
-
'lqt_rc_author_notice_others' ),
-
wfMsgExt( 'lqt_rc_author_others', 'parseinline' )
-
);
- } else {
- $appendix = Xml::tags( 'span',
-
array( 'class' => 'lqt_rc_author_notice ' .
-
'lqt_rc_author_notice_original' ),
-
wfMsgExt( 'lqt_rc_author_others', 'parseinline' )
-
);
- }
- $s = preg_replace( '/\<\/li\>$/', $appendix .
'</li>', $s ); // TODO ew
- }
- else {
- global $wgOut;
-
- $sig = "";
- $changeslist->insertUserRelatedLinks( $sig, $rc
);
-
- // This should be stored in RC.
- $quote = Revision::newFromId(
$rc->mAttribs['rc_this_oldid'] )->getText();
- if ( strlen( $quote ) > 230 ) {
- $sk = $changeslist->skin;
- $quote = substr( $quote, 0, 200 ) .
- $sk->link( $thread->title(),
wfMsg( 'lqt_rc_ellipsis' ),
- array( 'class' =>
'lqt_rc_ellipsis' ), array(), array( 'known' ) );
- }
-
- $quote = $wgOut->parseInline( $quote );
-
- if ( $thread->isTopmostThread() ) {
- $message_name = 'lqt_rc_new_discussion';
- $tmp_title = $thread->title();
- } else {
- $message_name = 'lqt_rc_new_reply';
- $tmp_title =
$thread->topmostThread()->title();
- $tmp_title->setFragment( '#' .
LqtView::anchorName( $thread ) );
- }
-
- $thread_link = $changeslist->skin->link(
- $tmp_title,
-
htmlspecialchars($thread->subjectWithoutIncrement()),
- array(), array(), array( 'known' ) );
-
- $talkpage_link = $changeslist->skin->link(
- $thread->article()->getTitle(),
- null,
- array(), array(), array( 'known' ) );
-
- $s = wfMsg( $message_name, $thread_link,
$talkpage_link, $sig )
- . Xml::tags( 'blockquote', array(
'class' => 'lqt_rc_blockquote' ), $quote );
- }
- }
- return true;
- }
-
- static function setNewtalkHTML( $skintemplate, $tpl ) {
- global $wgUser, $wgTitle, $wgOut;
- wfLoadExtensionMessages( 'LiquidThreads' );
- $newmsg_t = SpecialPage::getTitleFor( 'NewMessages' );
- $watchlist_t = SpecialPage::getTitleFor( 'Watchlist' );
- $usertalk_t = $wgUser->getTalkPage();
- if ( $wgUser->getNewtalk()
- && ! $newmsg_t->equals( $wgTitle )
- && ! $watchlist_t->equals( $wgTitle )
- && ! $usertalk_t->equals( $wgTitle )
- ) {
- $s = wfMsgExt( 'lqt_youhavenewmessages', array(
'parseinline' ), $newmsg_t->getFullURL() );
- $tpl->set( "newtalk", $s );
- $wgOut->setSquidMaxage( 0 );
- } else {
- $tpl->set( "newtalk", '' );
- }
-
- return true;
- }
}

Modified: trunk/extensions/LiquidThreads/classes/NewMessagesController.php
===================================================================
--- trunk/extensions/LiquidThreads/classes/NewMessagesController.php
2009-07-31 10:58:58 UTC (rev 54090)
+++ trunk/extensions/LiquidThreads/classes/NewMessagesController.php
2009-07-31 10:59:11 UTC (rev 54091)
@@ -28,7 +28,6 @@
throw new MWException( "writeUserMessageState expected
User or integer but got $user" );
}

- // use query() directly to pass in 'true' for
don't-die-on-errors.
$dbw = wfGetDB( DB_MASTER );

$dbw->replace( 'user_message_state', array( array( 'ums_user',
'ums_thread' ) ),

Modified: trunk/extensions/LiquidThreads/classes/Thread.php
===================================================================
--- trunk/extensions/LiquidThreads/classes/Thread.php 2009-07-31 10:58:58 UTC
(rev 54090)
+++ trunk/extensions/LiquidThreads/classes/Thread.php 2009-07-31 10:59:11 UTC
(rev 54091)
@@ -71,14 +71,13 @@

function historicalRevisions() {
$dbr =& wfGetDB( DB_SLAVE );
- $res = $dbr->select(
- 'historical_thread',
- 'hthread_contents',
- array( 'hthread_id' => $this->id() ),
- __METHOD__ );
+ $res = $dbr->select( 'historical_thread',
+ 'hthread_contents',
+ array( 'hthread_id' =>
$this->id() ),
+ __METHOD__ );
$results = array();
- while ( $l = $dbr->fetchObject( $res ) ) {
- $results[] = HistoricalThread::fromTextRepresentation(
$l->hthread_contents );
+ while ( $row = $dbr->fetchObject( $res ) ) {
+ $results[] = HistoricalThread::fromTextRepresentation(
$row->hthread_contents );
}
return $results;
}
@@ -204,7 +203,7 @@
return User::newFromId( $this->authorId );
} else {
// Do NOT validate username. If the user did it, they
did it.
- return User::newFromName( $this->authorName, false );
+ return User::newFromName( $this->authorName, false /*
no validation */ );
}
}

@@ -227,7 +226,10 @@
}

function moveToPage( $title, $reason, $leave_trace ) {
- $dbr =& wfGetDB( DB_MASTER );
+ if (!$this->isTopmostThread() )
+ throw new MWException( "Attempt to move non-toplevel
thread to another page" );
+
+ $dbr = wfGetDB( DB_MASTER );

$oldTitle = $this->article()->getTitle();
$newTitle = $title;
@@ -253,46 +255,30 @@

# Log the move
$log = new LogPage( 'liquidthreads' );
- $log->addEntry( 'move', $this->double->title(), $reason, array(
$oldTitle, $newTitle ) );
+ $log->addEntry( 'move', $this->title(), $reason, array(
$oldTitle, $newTitle ) );

if ( $leave_trace ) {
- $this->leaveTrace( $reason );
+ $this->leaveTrace( $reason, $oldTitle, $newTitle );
}
}

- function leaveTrace( $reason ) {
- /* Adapted from Title::moveToNewTitle. But now the new title
exists on the old talkpage. */
- $dbw =& wfGetDB( DB_MASTER );
+ // Drop a note at the source location of a move, noting that a thread
was moved from
+ // there.
+ function leaveTrace( $reason, $oldTitle, $newTitle ) {
+ $dbw = wfGetDB( DB_MASTER );

+ // Create redirect text
$mwRedir = MagicWord::get( 'redirect' );
$redirectText = $mwRedir->getSynonym( 0 ) . ' [[' .
$this->title()->getPrefixedText() . "]]\n";
- $redirectArticle = new Article( LqtView::incrementedTitle(
$this->subjectWithoutIncrement(),
- NS_LQT_THREAD ) ); # # TODO move to model.
- $newid = $redirectArticle->insertOn( $dbw );
- $redirectRevision = new Revision( array(
- 'page' => $newid,
- 'comment' => $reason,
- 'text' => $redirectText ) );
- $redirectRevision->insertOn( $dbw );
- $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0
);
+
+ // Make the article edit.
+ $traceTitle = Threads::newThreadTitle( $this->subject(), new
Article($oldTitle) );
+ $redirectArticle = new Article( $traceTitle );
+ $redirectArticle->doEdit( $redirectText, $reason, EDIT_NEW );

- # Purge caches as per article creation
- Article::onArticleCreate( $redirectArticle->getTitle() );
-
- # Record the just-created redirect's linking to the page
- $dbw->insert( 'pagelinks',
- array(
- 'pl_from' => $newid,
- 'pl_namespace' =>
$redirectArticle->getTitle()->getNamespace(),
- 'pl_title' =>
$redirectArticle->getTitle()->getDBkey() ),
- __METHOD__ );
-
- $thread = Threads::newThread( $redirectArticle,
$this->double->article(), null,
+ // Add the trace thread to the tracking table.
+ $thread = Threads::newThread( $redirectArticle, new
Article($oldTitle), null,
Threads::TYPE_MOVED, $this->subject() );
-
- # Purge old title from squid
- # The new title, and links to the new title, are purged in
Article::onArticleCreate()
- # $this-->purgeSquid();
}


@@ -569,24 +555,6 @@
// $this->replies[] = $thread;
}

- function removeReplyWithId( $id ) {
- // Force load
- $this->replies();
-
- $target = null;
- foreach ( $this->replies as $k => $r ) {
- if ( $r->id() == $id ) {
- $target = $k; break;
- }
- }
- if ( $target ) {
- unset( $this->replies[$target] );
- return true;
- } else {
- return false;
- }
- }
-
function replies() {
if ( !is_null($this->replies) ) {
return $this->replies;
@@ -761,6 +729,7 @@

if (!$title) {
wfDebug( __METHOD__.": supposed summary doesn't
exist" );
+ $this->summaryId = null;
return null;
}

@@ -794,10 +763,6 @@
return $matches;
}

- function wikilink() {
- return $this->root()->getTitle()->getPrefixedText();
- }
-
function subject() {
return $this->subject;
}
@@ -811,10 +776,6 @@
}
}

- function wikilinkWithoutIncrement() {
- return $this->wikilink();
- }
-
function subjectWithoutIncrement() {
return $this->subject();
}
@@ -858,6 +819,7 @@
}
return null;
}
+
function changeObject() {
return $this->replyWithId( $this->changeObject );
}
@@ -881,7 +843,7 @@

function changeUser() {
if ( $this->changeUser == 0 ) {
- return User::newFromName( $this->changeUserText, false
);
+ return User::newFromName( $this->changeUserText, false
/* No validation */ );
} else {
return User::newFromId( $this->changeUser );
}
@@ -899,15 +861,6 @@
return $rthread;
}

- // Called from hook in Title::isProtected.
- static function getRestrictionsForTitle( $title, $action, &$result ) {
- $thread = Threads::withRoot( new Article( $title ) );
- if ( $thread )
- return $thread->getRestrictions( $action, $result );
- else
- return true; // not a thread; do normal protection
check.
- }
-
// This only makes sense when called from the hook, because it uses the
hook's
// default behavior to check whether this thread itself is protected,
so you'll
// get false negatives if you use it from some other context.
@@ -928,10 +881,6 @@
}

}
-
- function getArchiveStartDays() {
- return Threads::getArticleArchiveStartDays( $this->article() );
- }

function getAnchorName() {
return "lqt_thread_{$this->id()}";

Modified: trunk/extensions/LiquidThreads/classes/Threads.php
===================================================================
--- trunk/extensions/LiquidThreads/classes/Threads.php 2009-07-31 10:58:58 UTC
(rev 54090)
+++ trunk/extensions/LiquidThreads/classes/Threads.php 2009-07-31 10:59:11 UTC
(rev 54091)
@@ -33,13 +33,14 @@

static $cache_by_root = array();
static $cache_by_id = array();
+ static protected $occupied_titles = array();

static function newThread( $root, $article, $superthread = null,
$type =
self::TYPE_NORMAL, $subject = '' ) {
// SCHEMA changes must be reflected here.
// TODO: It's dumb that the commitRevision code isn't used here.

- $dbw =& wfGetDB( DB_MASTER );
+ $dbw = wfGetDB( DB_MASTER );

if ( !in_array( $type, self::$VALID_TYPES ) ) {
throw new MWException( __METHOD__ . ": invalid type
$type." );
@@ -253,4 +254,43 @@

return $dbr->makeList( $arr, LIST_OR );
}
+
+ static function scratchTitle() {
+ $token = md5( uniqid( rand(), true ) );
+ return Title::newFromText( "Thread:$token" );
+ }
+
+ static function newThreadTitle( $subject, $article ) {
+ wfLoadExtensionMessages( 'LiquidThreads' );
+ $subject = $subject ? $subject : wfMsg( 'lqt_nosubject' );
+
+ $base = $article->getTitle()->getPrefixedText() . "/$subject";
+
+ return self::incrementedTitle( $base, NS_LQT_THREAD );
+ }
+
+ static function newSummaryTitle( $t ) {
+ return self::incrementedTitle( $t->title()->getText(),
NS_LQT_SUMMARY );
+ }
+
+ static function newReplyTitle( $thread, $user) {
+ $topThread = $thread->topMostThread();
+
+ $base = $thread->title()->getText() . '/' . $user->getName();
+
+ return self::incrementedTitle( $base, NS_LQT_THREAD );
+ }
+
+ /** Keep trying titles starting with $basename until one is unoccupied.
*/
+ public static function incrementedTitle( $basename, $namespace ) {
+ $i = 2;
+
+ $t = Title::makeTitleSafe( $namespace, $basename );
+ while ( $t->exists() ||
+ in_array( $t->getPrefixedDBkey(),
self::$occupied_titles ) ) {
+ $t = Title::makeTitleSafe( $namespace, $basename . ' ('
. $i . ')' );
+ $i++;
+ }
+ return $t;
+ }
}

Modified: trunk/extensions/LiquidThreads/classes/View.php
===================================================================
--- trunk/extensions/LiquidThreads/classes/View.php 2009-07-31 10:58:58 UTC
(rev 54090)
+++ trunk/extensions/LiquidThreads/classes/View.php 2009-07-31 10:59:11 UTC
(rev 54091)
@@ -43,8 +43,6 @@
$this->headerLevel = $int;
}

- static protected $occupied_titles = array();
-
/*************************
* (1) linking to liquidthreads pages and
* (2) figuring out what page you're on and what you need to do.
@@ -444,43 +442,20 @@
}

function scratchTitle() {
- $token = md5( uniqid( rand(), true ) );
- return Title::newFromText( "Thread:$token" );
+ return Threads::scratchTitle();
}

function newScratchTitle( $subject ) {
- wfLoadExtensionMessages( 'LiquidThreads' );
- $subject = $subject ? $subject : wfMsg( 'lqt_nosubject' );
-
- $base = $this->article->getTitle()->getPrefixedText() .
"/$subject";
-
- return $this->incrementedTitle( $base, NS_LQT_THREAD );
+ return Threads::newThreadTitle( $subject, $this->article );
}

- function newSummaryTitle( $t ) {
- return $this->incrementedTitle( $t->title()->getText(),
NS_LQT_SUMMARY );
+ function newSummaryTitle( $thread ) {
+ return Threads::newSummaryTitle( $thread );
}

- function newReplyTitle( $s, $t ) {
- $topThread = $t->topMostThread();
-
- $base = $t->title()->getText() . '/' . $this->user->getName();
-
- return $this->incrementedTitle( $base, NS_LQT_THREAD );
+ function newReplyTitle( $unused, $thread ) {
+ return Threads::newReplyTitle( $thread, $this->user );
}
-
- /** Keep trying titles starting with $basename until one is unoccupied.
*/
- public static function incrementedTitle( $basename, $namespace ) {
- $i = 2;
-
- $t = Title::makeTitleSafe( $namespace, $basename );
- while ( $t->exists() ||
- in_array( $t->getPrefixedDBkey(),
self::$occupied_titles ) ) {
- $t = Title::makeTitleSafe( $namespace, $basename . ' ('
. $i . ')' );
- $i++;
- }
- return $t;
- }

/* Adapted from MovePageForm::doSubmit in SpecialMovepage.php. */
function simplePageMove( $old_title, $new_subject, $reason ) {

Modified: trunk/extensions/LiquidThreads/lqt.css
===================================================================
--- trunk/extensions/LiquidThreads/lqt.css 2009-07-31 10:58:58 UTC (rev
54090)
+++ trunk/extensions/LiquidThreads/lqt.css 2009-07-31 10:59:11 UTC (rev
54091)
@@ -314,6 +314,7 @@
display: table;
width: auto;
margin-left: -0.6em;
+ float: right;
}

.lqt_footer li {

Deleted: trunk/extensions/LiquidThreads/pages/TalkpageArchiveView.php
===================================================================
--- trunk/extensions/LiquidThreads/pages/TalkpageArchiveView.php
2009-07-31 10:58:58 UTC (rev 54090)
+++ trunk/extensions/LiquidThreads/pages/TalkpageArchiveView.php
2009-07-31 10:59:11 UTC (rev 54091)
@@ -1,130 +0,0 @@
-<?php
-
-if ( !defined( 'MEDIAWIKI' ) ) die;
-
-class TalkpageArchiveView extends TalkpageView {
- function __construct( &$output, &$article, &$title, &$user, &$request )
{
- parent::__construct( $output, $article, $title, $user, $request
);
- }
-
- function show() {
- global $wgHooks, $wgOut;
- $wgHooks['SkinTemplateTabs'][] = array( $this, 'customizeTabs'
);
-
- wfLoadExtensionMessages( 'LiquidThreads' );
- $this->output->setPageTitle( $this->title->getPrefixedText() );
- $this->output->setSubtitle( wfMsg( 'lqt-archive-subtitle' ) );
- self::addJSandCSS();
-
- $this->output->addWikiMsg( 'lqt-archive-intro',
-
$this->article->getTitle()->getPrefixedText() );
-
- $pager = new TalkpageArchivePager( $this->article, $this );
-
- $html = $pager->getNavigationBar() .
- $pager->getBody() .
- $pager->getNavigationBar();
-
- $wgOut->addHTML( $html );
-
- return false;
- }
-}
-
-class TalkpageArchivePager extends TablePager {
-
- public function __construct( $article, $view ) {
- parent::__construct();
- $this->article = $article;
- $this->view = $view;
- }
-
- public function isFieldSortable( $field ) {
- $sortable = array( 'page_title', 'thread_created',
'thread_modified' );
-
- return in_array( $field, $sortable );
- }
-
- public function formatValue( $field, $value ) {
- global $wgUser, $wgLang;
-
- $sk = $wgUser->getSkin();
-
- switch( $field ) {
- case 'page_title':
- $title = Title::makeTitle( NS_LQT_THREAD,
$value );
- $split = Thread::splitIncrementFromSubject(
$title->getText() );
- return $sk->link( $title, $split[1] );
- case 'thread_summary_page':
- $summary = '';
-
- if ($value) {
- $page = Article::newFromId( $value );
- $summary = $this->view->showPostBody(
$page );
- } elseif ($this->mCurrentRow->thread_type ==
Threads::TYPE_MOVED) {
- $thread = new Thread(
$this->mCurrentRow, array() );
-
- $rt = $thread->redirectThread();
- if ( $rt->hasSummary() ) {
- $summaryPage = $rt->summary();
- $summary =
$this->view->showPostBody( $summaryPage );
- }
- }
- return $summary;
- case 'thread_created':
- case 'thread_modified':
- return $wgLang->timeanddate( $value, true );
- case 'rev_user_text':
- $uid = $this->mCurrentRow->rev_user;
- return $sk->userLink( $uid, $value ) .
$sk->userToolLinks( $uid, $value );
- default:
- return $value;
- }
- }
-
- public function getDefaultSort() {
- return 'thread_created';
- }
-
- public function getFieldNames() {
- $fieldToMsg =
- array(
- 'thread_created' => 'lqt-thread-created',
- 'page_title' => 'lqt-title',
- 'thread_modified' => 'lqt_toc_thread_modified',
- 'rev_user_text' => 'lqt_toc_thread_author',
- 'thread_summary_page' => 'lqt-summary',
- );
-
- return array_map( 'wfMsg', $fieldToMsg );
- }
-
- public function getQueryInfo() {
- $dbr = wfGetDB( DB_SLAVE );
-
- $hasSummaryClauses = array( 'thread_summary_page is not null',
-
'thread_type' => Threads::TYPE_MOVED );
- $hasSummaryClause = $dbr->makeList( $hasSummaryClauses, LIST_OR
);
-
- $queryInfo =
- array(
- 'tables' => array( 'thread', 'page', 'revision'
),
- 'fields' => '*',
- 'conds' =>
- array(
- Threads::articleClause(
$this->article ),
- Threads::topLevelClause(),
- $hasSummaryClause,
- 'rev_parent_id' => 0,
- ),
- 'join_conds' =>
- array(
- 'page' => array( 'left join',
'thread_root=page_id' ),
- 'revision' => array( 'left
join', 'rev_page=page_id' ),
- ),
- );
-
-
- return $queryInfo;
- }
-}

Modified: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
===================================================================
--- trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
2009-07-31 10:58:58 UTC (rev 54090)
+++ trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
2009-07-31 10:59:11 UTC (rev 54091)
@@ -62,7 +62,7 @@

function showThreadHeading( $thread ) {
if ( $this->headerLevel == 2 ) {
- $this->output->setPageTitle( $thread->wikilink() );
+ $this->output->setPageTitle(
$thread->root()->getTitle()->getPrefixedText() );
} else {
parent::showThreadHeading( $thread );
}

Modified: trunk/phase3/includes/ChangesList.php
===================================================================
--- trunk/phase3/includes/ChangesList.php 2009-07-31 10:58:58 UTC (rev
54090)
+++ trunk/phase3/includes/ChangesList.php 2009-07-31 10:59:11 UTC (rev
54091)
@@ -398,7 +398,7 @@
}

/** Inserts a rollback link */
- protected function insertRollback( &$s, &$rc ) {
+ public function insertRollback( &$s, &$rc ) {
global $wgUser;
if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid']
&& $rc->mAttribs['rc_cur_id'] ) {
$page = $rc->getTitle();
@@ -418,7 +418,7 @@
}
}

- protected function insertTags( &$s, &$rc, &$classes ) {
+ public function insertTags( &$s, &$rc, &$classes ) {
if ( empty($rc->mAttribs['ts_tags']) )
return;

@@ -427,7 +427,7 @@
$s .= ' ' . $tagSummary;
}

- protected function insertExtra( &$s, &$rc, &$classes ) {
+ public function insertExtra( &$s, &$rc, &$classes ) {
## Empty, used for subclassers to add anything special.
}
}



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@xxxxxxxxxxxxxxxxxxx
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise