r56562 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56561‎ | r56562 | r56563 >
Date:19:54, 17 September 2009
Author:siebrand
Status:deferred (Comments)
Tags:
Comment:
* code formatting updates
* stylize.php, removed trailing whitespace

No functional changes
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtFunctions.php (modified) (history)
  • /trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/api/ApiQueryLQTThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/DeletionController.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Dispatch.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/HistoricalThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Hooks.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/NewMessagesController.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/ThreadRevision.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Threads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/LiquidThreads/compat/HTMLForm.php (modified) (history)
  • /trunk/extensions/LiquidThreads/compat/Lqt-compat.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/compat/LqtCompatArticle.php (modified) (history)
  • /trunk/extensions/LiquidThreads/compat/generateCompatibilityLocalisation.php (modified) (history)
  • /trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/import/import-parsed-discussions.php (modified) (history)
  • /trunk/extensions/LiquidThreads/migrateDatabase.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/IndividualThreadHistoryView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SpecialMergeThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SpecialNewMessages.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/SummaryPageView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageHeaderView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadActionPage.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadHistoryListingView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -101,7 +101,7 @@
102102 $wgAutoloadClasses['LqtParserFunctions'] = $dir . 'classes/ParserFunctions.php';
103103 $wgAutoloadClasses['LqtDeletionController'] = $dir . 'classes/DeletionController.php';
104104 $wgAutoloadClasses['LqtHooks'] = $dir . 'classes/Hooks.php';
105 -$wgAutoloadClasses['ThreadRevision'] = $dir."/classes/ThreadRevision.php";
 105+$wgAutoloadClasses['ThreadRevision'] = $dir . "/classes/ThreadRevision.php";
106106
107107 // View classes
108108 $wgAutoloadClasses['TalkpageView'] = $dir . 'pages/TalkpageView.php';
Index: trunk/extensions/LiquidThreads/classes/Dispatch.php
@@ -13,41 +13,42 @@
1414 'ThreadProtectionFormView' => 'ThreadProtectionFormView',
1515 'ThreadWatchView' => 'ThreadWatchView',
1616 'SummaryPageView' => 'SummaryPageView'
17 - );
18 -
 17+ );
 18+
1919 /** static cache of per-page LiquidThreads activation setting */
2020 static $userLQTActivated;
2121
2222 static function talkpageMain( &$output, &$article, &$title, &$user, &$request ) {
2323 // We are given a talkpage article and title. Fire up a TalkpageView
24 -
 24+
2525 if ( $title->getNamespace() == NS_LQT_THREAD + 1 /* talk page */ ) {
2626 // Threads don't have talk pages; redirect to the thread page.
2727 $output->redirect( $title->getSubjectPage()->getFullUrl() );
2828 return false;
2929 }
30 -
 30+
3131 // If we came here from a red-link, redirect to the thread page.
3232 $redlink = $request->getCheck( 'redlink' ) &&
3333 $request->getText( 'action' ) == 'edit';
34 - if( $redlink ) {
 34+ if ( $redlink ) {
3535 $output->redirect( $title->getFullURL() );
3636 return false;
3737 }
3838
3939 /* Certain actions apply to the "header", which is stored in the actual talkpage
40 - in the database. Drop everything and behave like a normal page if those
41 - actions come up, to avoid hacking the various history, editing, etc. code. */
 40+ * in the database. Drop everything and behave like a normal page if those
 41+ * actions come up, to avoid hacking the various history, editing, etc. code.
 42+ */
4243 $action = $request->getVal( 'action' );
4344 $header_actions = array( 'history', 'edit', 'submit', 'delete' );
4445 global $wgRequest;
45 - if ($action == 'edit' && $request->getVal('section') == 'new') {
 46+ if ( $action == 'edit' && $request->getVal( 'section' ) == 'new' ) {
4647 // Hijack section=new for "new thread".
4748 $request->setVal( 'lqt_method', 'talkpage_new_thread' );
4849 $request->setVal( 'section', '' );
49 -
 50+
5051 $viewname = self::$views['TalkpageView'];
51 -
 52+
5253 } elseif ( $request->getVal( 'lqt_method', null ) === null &&
5354 ( in_array( $action, $header_actions ) ||
5455 $request->getVal( 'diff', null ) !== null ) ) {
@@ -64,7 +65,6 @@
6566 }
6667
6768 static function threadPermalinkMain( &$output, &$article, &$title, &$user, &$request ) {
68 -
6969 $action = $request->getVal( 'action' );
7070 $lqt_method = $request->getVal( 'lqt_method' );
7171
@@ -88,7 +88,7 @@
8989 } else {
9090 $viewname = self::$views['ThreadPermalinkView'];
9191 }
92 -
 92+
9393 $view = new $viewname( $output, $article, $title, $user, $request );
9494 return $view->show();
9595 }
@@ -98,29 +98,28 @@
9999 $view = new $viewname( $output, $article, $title, $user, $request );
100100 return $view->show();
101101 }
102 -
 102+
103103 static function isLqtPage( $title ) {
104104 global $wgLqtPages, $wgLqtTalkPages;
105 - $isTalkPage = ($title->isTalkPage() && $wgLqtTalkPages) ||
 105+ $isTalkPage = ( $title->isTalkPage() && $wgLqtTalkPages ) ||
106106 in_array( $title->getPrefixedText(), $wgLqtPages ) ||
107107 self::hasUserEnabledLQT( $title->getArticleId() );
108 -
 108+
109109 return $isTalkPage;
110110 }
111 -
 111+
112112 static function hasUserEnabledLQT( $article ) {
113 -
114 - if (is_object($article)) {
 113+ if ( is_object( $article ) ) {
115114 $article = $article->getId();
116115 }
117 -
 116+
118117 // Instance cache
119118 if ( isset( self::$userLQTActivated[$article] ) ) {
120119 $cacheVal = self::$userLQTActivated[$article];
121120
122121 return $cacheVal;
123122 }
124 -
 123+
125124 // Memcached: It isn't clear that this is needed yet, but since I already wrote the
126125 // code, I might as well leave it commented out instead of deleting it.
127126 // Main reason I've left this commented out is because it isn't obvious how to
@@ -135,15 +134,21 @@
136135 // return $wgLqtThreadArchiveStartDays;
137136 // }
138137 // }
139 -
 138+
140139 // Load from the database.
141140 $dbr = wfGetDB( DB_SLAVE );
142 -
143 - $dbVal = $dbr->selectField( 'page_props', 'pp_value',
144 - array( 'pp_propname' => 'use-liquid-threads',
145 - 'pp_page' => $article ), __METHOD__ );
146 -
147 - if ($dbVal) {
 141+
 142+ $dbVal = $dbr->selectField(
 143+ 'page_props',
 144+ 'pp_value',
 145+ array(
 146+ 'pp_propname' => 'use-liquid-threads',
 147+ 'pp_page' => $article
 148+ ),
 149+ __METHOD__
 150+ );
 151+
 152+ if ( $dbVal ) {
148153 self::$userLQTActivated[$article] = true;
149154 # $wgMemc->set( $key, $dbVal, 1800 );
150155 return true;
Index: trunk/extensions/LiquidThreads/classes/Hooks.php
@@ -5,10 +5,12 @@
66 // Shortcut for non-LQT pages.
77 if ( !LqtDispatch::isLqtPage( $ot ) )
88 return true;
9 -
 9+
1010 // Move the threads on that page to the new page.
11 - $threads = Threads::where( array( Threads::articleClause( new Article( $ot ) ),
12 - Threads::topLevelClause() ) );
 11+ $threads = Threads::where( array(
 12+ Threads::articleClause( new Article( $ot ) ),
 13+ Threads::topLevelClause() )
 14+ );
1315
1416 foreach ( $threads as $t ) {
1517 $t->moveToPage( $nt, false );
@@ -20,7 +22,7 @@
2123 static function customizeOldChangesList( &$changeslist, &$s, $rc ) {
2224 if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD )
2325 return true;
24 -
 26+
2527 $thread = Threads::withRoot( new Article( $rc->getTitle() ) );
2628 if ( !$thread ) return true;
2729
@@ -29,7 +31,7 @@
3032
3133 if ( $rc->mAttribs['rc_new'] ) {
3234 global $wgOut;
33 -
 35+
3436 $sig = "";
3537 $changeslist->insertUserRelatedLinks( $sig, $rc );
3638
@@ -43,7 +45,7 @@
4446 $link = $sk->link( $thread->title(), wfMsg( 'lqt_rc_ellipsis' ),
4547 array( 'class' => 'lqt_rc_ellipsis' ), array(), array( 'known' ) );
4648 }
47 -
 49+
4850 $quote = $wgOut->parseInline( $quote ) . $link;
4951
5052 if ( $thread->isTopmostThread() ) {
@@ -51,10 +53,10 @@
5254 } else {
5355 $message_name = 'lqt_rc_new_reply';
5456 }
55 -
 57+
5658 $tmp_title = $thread->article()->getTitle();
5759 $tmp_title->setFragment( '#' . LqtView::anchorName( $thread ) );
58 -
 60+
5961 // Make sure it points to the right page. The Pager seems to use the DB
6062 // representation of a timestamp for its offset field, odd.
6163 $dbr = wfGetDB( DB_SLAVE );
@@ -62,7 +64,7 @@
6365 $offset = $dbr->timestamp( $offset );
6466
6567 $thread_link = $changeslist->skin->link( $tmp_title,
66 - htmlspecialchars($thread->subjectWithoutIncrement()),
 68+ htmlspecialchars( $thread->subjectWithoutIncrement() ),
6769 array(), array( 'offset' => $offset ), array( 'known' ) );
6870
6971 $talkpage_link = $changeslist->skin->link(
@@ -72,19 +74,19 @@
7375
7476 $s = wfMsg( $message_name, $thread_link, $talkpage_link, $sig )
7577 . Xml::tags( 'blockquote', array( 'class' => 'lqt_rc_blockquote' ), $quote );
76 -
 78+
7779 $classes = array();
7880 $changeslist->insertTags( $s, $rc, $classes );
7981 $changeslist->insertExtra( $s, $rc, $classes );
8082 } else {
8183 // Add whether it was original author.
8284 if ( $thread->author()->getName() != $rc->mAttribs['rc_user_text'] ) {
83 - $appendix = Xml::tags( 'span',
84 - array( 'class' => 'lqt_rc_author_notice ' .
85 - 'lqt_rc_author_notice_others' ),
86 - wfMsgExt( 'lqt_rc_author_others', 'parseinline' )
87 - );
88 -
 85+ $appendix = Xml::tags(
 86+ 'span',
 87+ array( 'class' => 'lqt_rc_author_notice ' . 'lqt_rc_author_notice_others' ),
 88+ wfMsgExt( 'lqt_rc_author_others', 'parseinline' )
 89+ );
 90+
8991 $s .= ' ' . $appendix;
9092 }
9193 }
@@ -102,8 +104,10 @@
103105 && ! $watchlist_t->equals( $wgTitle )
104106 && ! $usertalk_t->equals( $wgTitle )
105107 ) {
106 - $s = wfMsgExt( 'lqt_youhavenewmessages', array( 'parseinline' ),
107 - $newmsg_t->getFullURL() );
 108+ $s = wfMsgExt(
 109+ 'lqt_youhavenewmessages', array( 'parseinline' ),
 110+ $newmsg_t->getFullURL()
 111+ );
108112 $tpl->set( "newtalk", $s );
109113 $wgOut->setSquidMaxage( 0 );
110114 } else {
@@ -112,62 +116,64 @@
113117
114118 return true;
115119 }
116 -
 120+
117121 static function beforeWatchlist( &$conds, &$tables, &$join_conds, &$fields ) {
118122 global $wgOut, $wgUser;
119 -
 123+
120124 $db = wfGetDB( DB_SLAVE );
121 -
 125+
122126 if ( !in_array( 'page', $tables ) ) {
123127 $tables[] = 'page';
124128 // Yes, this is the correct field to join to. Weird naming.
125129 $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
126130 }
127 - $conds[] = "page_namespace != " . $db->addQuotes(NS_LQT_THREAD);
128 -
 131+ $conds[] = "page_namespace != " . $db->addQuotes( NS_LQT_THREAD );
 132+
129133 $talkpage_messages = NewMessages::newUserMessages( $wgUser );
130134 $tn = count( $talkpage_messages );
131 -
 135+
132136 $watch_messages = NewMessages::watchedThreadsForUser( $wgUser );
133137 $wn = count( $watch_messages );
134 -
 138+
135139 if ( $tn == 0 && $wn == 0 )
136140 return true;
137 -
 141+
138142 LqtView::addJSandCSS();
139143 wfLoadExtensionMessages( 'LiquidThreads' );
140144 $messages_title = SpecialPage::getTitleFor( 'NewMessages' );
141145 $new_messages = wfMsgExt( 'lqt-new-messages', 'parseinline' );
142 -
 146+
143147 $sk = $wgUser->getSkin();
144 - $link = $sk->link( $messages_title, $new_messages,
145 - array( 'class' => 'lqt_watchlist_messages_notice' ) );
 148+ $link = $sk->link(
 149+ $messages_title,
 150+ $new_messages,
 151+ array( 'class' => 'lqt_watchlist_messages_notice' )
 152+ );
146153 $wgOut->addHTML( $link );
147 -
 154+
148155 return true;
149156 }
150 -
 157+
151158 static function getPreferences( $user, &$preferences ) {
152159 global $wgEnableEmail;
153160 wfLoadExtensionMessages( 'LiquidThreads' );
154 -
155 - if ($wgEnableEmail) {
156 - $preferences['lqtnotifytalk'] =
157 - array(
158 - 'type' => 'toggle',
159 - 'label-message' => 'lqt-preference-notify-talk',
160 - 'section' => 'personal/email'
161 - );
 161+
 162+ if ( $wgEnableEmail ) {
 163+ $preferences['lqtnotifytalk'] = array(
 164+ 'type' => 'toggle',
 165+ 'label-message' => 'lqt-preference-notify-talk',
 166+ 'section' => 'personal/email'
 167+ );
162168 }
163 -
164 -
 169+
 170+
165171 $preferences['lqt-watch-threads'] =
166172 array(
167173 'type' => 'toggle',
168174 'label-message' => 'lqt-preference-watch-threads',
169175 'section' => 'watchlist/advancedwatchlist',
170176 );
171 -
 177+
172178 // Display depth and count
173179 $preferences['lqtdisplaydepth'] =
174180 array(
@@ -175,7 +181,7 @@
176182 'label-message' => 'lqt-preference-display-depth',
177183 'section' => 'lqt',
178184 );
179 -
 185+
180186 // Display depth and count
181187 $preferences['lqtdisplaycount'] =
182188 array(
@@ -183,36 +189,40 @@
184190 'label-message' => 'lqt-preference-display-count',
185191 'section' => 'lqt',
186192 );
187 -
 193+
188194 return true;
189195 }
190 -
 196+
191197 static function updateNewtalkOnEdit( $article ) {
192198 $title = $article->getTitle();
193 -
 199+
194200 if ( LqtDispatch::isLqtPage( $title ) ) {
195201 // They're only editing the header, don't update newtalk.
196202 return false;
197203 }
198 -
 204+
199205 return true;
200206 }
201 -
 207+
202208 static function dumpThreadData( $writer, &$out, $row, $title ) {
203 - $editedStati = array( Threads::EDITED_NEVER => 'never',
204 - Threads::EDITED_HAS_REPLY => 'has-reply',
205 - Threads::EDITED_BY_AUTHOR => 'by-author',
206 - Threads::EDITED_BY_OTHERS => 'by-others' );
207 - $threadTypes = array( Threads::TYPE_NORMAL => 'normal',
208 - Threads::TYPE_MOVED => 'moved',
209 - Threads::TYPE_DELETED => 'deleted' );
 209+ $editedStati = array(
 210+ Threads::EDITED_NEVER => 'never',
 211+ Threads::EDITED_HAS_REPLY => 'has-reply',
 212+ Threads::EDITED_BY_AUTHOR => 'by-author',
 213+ Threads::EDITED_BY_OTHERS => 'by-others'
 214+ );
 215+ $threadTypes = array(
 216+ Threads::TYPE_NORMAL => 'normal',
 217+ Threads::TYPE_MOVED => 'moved',
 218+ Threads::TYPE_DELETED => 'deleted'
 219+ );
210220 // Is it a thread
211221 if ( $row->thread_id ) {
212222 $thread = new Thread( $row );
213223 $threadInfo = "\n";
214224 $attribs = array();
215225 $attribs['ThreadSubject'] = $thread->subject();
216 - if ($thread->hasSuperThread()) {
 226+ if ( $thread->hasSuperThread() ) {
217227 $attribs['ThreadParent'] = $thread->superThread()->id();
218228 }
219229 $attribs['ThreadAncestor'] = $thread->topmostThread()->id();
@@ -224,39 +234,39 @@
225235 $attribs['ThreadAuthor'] = $thread->author()->getName();
226236 $attribs['ThreadEditStatus'] = $editedStati[$thread->editedness()];
227237 $attribs['ThreadType'] = $threadTypes[$thread->type()];
228 -
229 - foreach( $attribs as $key => $value ) {
230 - $threadInfo .= "\t".Xml::element( $key, null, $value ) . "\n";
 238+
 239+ foreach ( $attribs as $key => $value ) {
 240+ $threadInfo .= "\t" . Xml::element( $key, null, $value ) . "\n";
231241 }
232 -
 242+
233243 $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) . "\n";
234244 }
235 -
 245+
236246 return true;
237247 }
238 -
 248+
239249 static function modifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) {
240250 $tables[] = 'thread';
241 -
 251+
242252 $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) );
243 -
 253+
244254 return true;
245255 }
246 -
 256+
247257 static function customiseSearchResultTitle( &$title, &$text, $result, $terms, $page ) {
248258 if ( $title->getNamespace() != NS_LQT_THREAD ) {
249259 return true;
250260 }
251 -
252 - $thread = Threads::withRoot( new Article($title) );
 261+
 262+ $thread = Threads::withRoot( new Article( $title ) );
253263 $text = $thread->subject();
254 -
 264+
255265 $title = clone $thread->topmostThread()->title();
256 - $title->setFragment( '#'.$thread->getAnchorName() );
257 -
 266+ $title->setFragment( '#' . $thread->getAnchorName() );
 267+
258268 return true;
259269 }
260 -
 270+
261271 static function onUserRename( $renameUserSQL ) {
262272 // Always use the job queue, talk page edits will take forever
263273 $renameUserSQL->tablesJob['thread'] =
@@ -265,57 +275,55 @@
266276 array( 'th_user_text', 'th_user', 'th_timestamp' );
267277 return true;
268278 }
269 -
 279+
270280 static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) {
271281 $article = $editPage->getArticle();
272282 $title = $article->getTitle();
273 -
 283+
274284 if ( !$article->exists() && $title->getNamespace() == NS_LQT_THREAD ) {
275285 unset( $checkboxes['minor'] );
276286 }
277 -
 287+
278288 return true;
279289 }
280 -
 290+
281291 static function customiseSearchProfiles( &$profiles ) {
282292 wfLoadExtensionMessages( 'LiquidThreads' );
283 -
 293+
284294 $namespaces = array( NS_LQT_THREAD, NS_LQT_SUMMARY );
285 -
 295+
286296 // Add odd namespaces
287 - foreach( SearchEngine::searchableNamespaces() as $ns => $nsName ) {
288 - if ($ns % 2 == 1) {
 297+ foreach ( SearchEngine::searchableNamespaces() as $ns => $nsName ) {
 298+ if ( $ns % 2 == 1 ) {
289299 $namespaces[] = $ns;
290300 }
291301 }
292 -
 302+
293303 $insert = array(
294 - 'threads' =>
295 - array(
296 - 'message' => 'searchprofile-threads',
297 - 'tooltip' => 'searchprofile-threads-tooltip',
298 - 'namespaces' => $namespaces,
299 - 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ),
300 - ),
 304+ 'threads' => array(
 305+ 'message' => 'searchprofile-threads',
 306+ 'tooltip' => 'searchprofile-threads-tooltip',
 307+ 'namespaces' => $namespaces,
 308+ 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ),
 309+ ),
301310 );
302 -
 311+
303312 $profiles = wfArrayInsertAfter( $profiles, $insert, 'help' );
304 -
 313+
305314 return true;
306315 }
307 -
 316+
308317 public static function onLoadExtensionSchemaUpdates() {
309318 global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields,
310319 $wgExtPGAlteredFields, $wgExtNewIndexes, $wgDBtype;
311320
312321 $dir = realpath( dirname( __FILE__ ) . '/..' );
313 -
 322+
314323 // DB updates
315324 $wgExtNewTables[] = array( 'thread', "$dir/lqt.sql" );
316325 $wgExtNewTables[] = array( 'user_message_state', "$dir/lqt.sql" );
317326 $wgExtNewTables[] = array( 'thread_history', "$dir/schema-changes/thread_history_table.sql" );
318 -
319 -
 327+
320328 $wgExtNewFields[] = array( "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql" );
321329 $wgExtNewFields[] = array( "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql" );
322330 $wgExtNewFields[] = array( "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql" );
@@ -326,9 +334,9 @@
327335 $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" );
328336 $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" );
329337 $wgExtNewFields[] = array( "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql" );
330 -
 338+
331339 $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' );
332 -
 340+
333341 return true;
334342 }
335343 }
Index: trunk/extensions/LiquidThreads/classes/NewMessagesController.php
@@ -2,7 +2,6 @@
33 if ( !defined( 'MEDIAWIKI' ) ) die;
44
55 class NewMessages {
6 -
76 static function markThreadAsUnreadByUser( $thread, $user ) {
87 self::writeUserMessageState( $thread, $user, null );
98 }
@@ -29,10 +28,17 @@
3029 }
3130
3231 $dbw = wfGetDB( DB_MASTER );
33 -
34 - $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ),
35 - array( 'ums_user' => $user_id, 'ums_thread' => $thread_id,
36 - 'ums_read_timestamp' => $timestamp ), __METHOD__ );
 32+
 33+ $dbw->replace(
 34+ 'user_message_state',
 35+ array( array( 'ums_user', 'ums_thread' ) ),
 36+ array(
 37+ 'ums_user' => $user_id,
 38+ 'ums_thread' => $thread_id,
 39+ 'ums_read_timestamp' => $timestamp
 40+ ),
 41+ __METHOD__
 42+ );
3743 }
3844
3945 /**
@@ -41,7 +47,7 @@
4248 */
4349 static function writeMessageStateForUpdatedThread( $t, $type, $changeUser ) {
4450 global $wgUser;
45 -
 51+
4652 wfDebugLog( 'LiquidThreads', 'Doing notifications' );
4753
4854 $dbw =& wfGetDB( DB_MASTER );
@@ -50,40 +56,50 @@
5157 $root_t = $t->topmostThread()->root()->getTitle();
5258
5359 // Select any applicable watchlist entries for the thread.
54 - $talkpageWhere = array( 'wl_namespace' => $tpTitle->getNamespace(),
55 - 'wl_title' => $tpTitle->getDBkey() );
56 - $rootWhere = array( 'wl_namespace' => $root_t->getNamespace(),
57 - 'wl_title' => $root_t->getDBkey() );
58 -
 60+ $talkpageWhere = array(
 61+ 'wl_namespace' => $tpTitle->getNamespace(),
 62+ 'wl_title' => $tpTitle->getDBkey()
 63+ );
 64+ $rootWhere = array(
 65+ 'wl_namespace' => $root_t->getNamespace(),
 66+ 'wl_title' => $root_t->getDBkey()
 67+ );
 68+
5969 $talkpageWhere = $dbw->makeList( $talkpageWhere, LIST_AND );
6070 $rootWhere = $dbw->makeList( $rootWhere, LIST_AND );
61 -
 71+
6272 $where_clause = $dbw->makeList( array( $talkpageWhere, $rootWhere ), LIST_OR );
63 -
 73+
6474 // <= 1.15 compatibility, it kinda sucks having to do all this up here.
6575 $tables = array( 'watchlist', 'user_message_state' );
66 - $joins = array( 'user_message_state' =>
67 - array( 'left join',
68 - array( 'ums_user=wl_user', 'ums_thread' => $t->id() ) ) );
 76+ $joins = array(
 77+ 'user_message_state' => array(
 78+ 'left join',
 79+ array(
 80+ 'ums_user=wl_user',
 81+ 'ums_thread' => $t->id()
 82+ )
 83+ )
 84+ );
6985 $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp' );
70 -
 86+
7187 $oldPrefCompat = false;
7288 global $wgVersion;
7389 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
7490 $oldPrefCompat = true;
75 -
 91+
7692 $tables[] = 'user';
7793 $joins['user'] = array( 'left join', 'user_id=wl_user' );
7894 $fields[] = 'user_options';
7995 } else {
8096 $tables[] = 'user_properties';
81 - $joins['user_properties'] =
 97+ $joins['user_properties'] = array(
 98+ 'left join',
8299 array(
83 - 'left join',
84 - array( 'up_user=wl_user',
85 - 'up_property' => 'lqtnotifytalk',
86 - )
87 - );
 100+ 'up_user=wl_user',
 101+ 'up_property' => 'lqtnotifytalk'
 102+ )
 103+ );
88104 $fields[] = 'up_value';
89105 }
90106
@@ -91,78 +107,83 @@
92108 // user_message_state row exists for them, and whether or not to send an email
93109 // notification.
94110 $dbr = wfGetDB( DB_SLAVE );
95 - $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins);
96 -
 111+ $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins );
 112+
97113 $insert_rows = array();
98114 $update_tuples = array();
99115 $notify_users = array();
100 - while( $row = $dbr->fetchObject( $res ) ) {
 116+ while ( $row = $dbr->fetchObject( $res ) ) {
101117 // Don't notify yourself
102118 if ( $changeUser->getId() == $row->wl_user )
103119 continue;
104 -
 120+
105121 if ( $row->ums_user && !$row->ums_read_timestamp ) {
106122 // It's already positive.
107123 } else {
108 - $insert_rows[] =
109 - array(
110 - 'ums_user' => $row->wl_user,
111 - 'ums_thread' => $t->id(),
112 - 'ums_read_timestamp' => null,
113 - );
114 -
 124+ $insert_rows[] = array(
 125+ 'ums_user' => $row->wl_user,
 126+ 'ums_thread' => $t->id(),
 127+ 'ums_read_timestamp' => null,
 128+ );
 129+
115130 // Set newtalk
116131 $u = User::newFromId( $row->wl_user );
117132 $u->setNewtalk( true );
118133 }
119 -
 134+
120135 $wantsTalkNotification = false;
121 -
 136+
122137 if ( $oldPrefCompat ) {
123138 $decodedOptions = self::decodeUserOptions( $row->user_options );
124 -
125 - $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) &&
 139+
 140+ $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) &&
126141 User::getDefaultOption( 'lqtnotifytalk' ) ) || $row->up_value;
127142 } else {
128143 $wantsTalkNotification =
129 - (is_null($row->up_value) && User::getDefaultOption( 'lqtnotifytalk' ) )
 144+ ( is_null( $row->up_value ) && User::getDefaultOption( 'lqtnotifytalk' ) )
130145 || $row->up_value;
131146 }
132 -
 147+
133148 if ( $wantsTalkNotification ) {
134149 $notify_users[] = $row->wl_user;
135150 }
136151 }
137 -
 152+
138153 // Add user talk notification
139154 if ( $t->article()->getTitle()->getNamespace() == NS_USER_TALK ) {
140155 $name = $t->article()->getTitle()->getText();
141 -
 156+
142157 $user = User::newFromName( $name );
143158 if ( $user ) {
144159 $user->setNewtalk( true );
145 -
146 - $insert_rows[] = array( 'ums_user' => $user->getId(),
147 - 'ums_thread' => $t->id(),
148 - 'ums_read_timestamp' => null );
149 -
 160+
 161+ $insert_rows[] = array(
 162+ 'ums_user' => $user->getId(),
 163+ 'ums_thread' => $t->id(),
 164+ 'ums_read_timestamp' => null
 165+ );
 166+
150167 if ( $user->getOption( 'enotifusertalkpages' ) ) {
151168 $notify_users[] = $user->getId();
152169 }
153170 }
154171 }
155 -
 172+
156173 // Do the actual updates
157 - if ( count($insert_rows) ) {
158 - $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ),
159 - $insert_rows, __METHOD__ );
 174+ if ( count( $insert_rows ) ) {
 175+ $dbw->replace(
 176+ 'user_message_state',
 177+ array( array( 'ums_user', 'ums_thread' ) ),
 178+ $insert_rows,
 179+ __METHOD__
 180+ );
160181 }
161 -
162 - if ( count($notify_users) ) {
 182+
 183+ if ( count( $notify_users ) ) {
163184 self::notifyUsersByMail( $t, $notify_users, wfTimestampNow(), $type );
164185 }
165186 }
166 -
 187+
167188 // Would refactor User::decodeOptions, but the whole point is that this is
168189 // compatible with old code :)
169190 static function decodeUserOptions( $str ) {
@@ -174,10 +195,10 @@
175196 $opts[$m[1]] = $m[2];
176197 }
177198 }
178 -
 199+
179200 return $opts;
180201 }
181 -
 202+
182203 static function notifyUsersByMail( $t, $watching_users, $timestamp, $type ) {
183204 wfLoadExtensionMessages( 'LiquidThreads' );
184205 $messages = array(
@@ -188,148 +209,169 @@
189210 Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply',
190211 Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread',
191212 );
192 -
193 - if ( !isset($messages[$type]) || !isset($subjects[$type]) ) {
 213+
 214+ if ( !isset( $messages[$type] ) || !isset( $subjects[$type] ) ) {
194215 wfDebugLog( 'LiquidThreads', "Email notification failed: type $type unrecognised" );
195216 return;
196217 } else {
197218 $msgName = $messages[$type];
198219 $subjectMsg = $subjects[$type];
199220 }
200 -
 221+
201222 // Send email notification, fetching all the data in one go
202 -
 223+
203224 global $wgVersion;
204225 $tables = array( 'user' );
205226 $fields = array( 'user.*' );
206227 $join_conds = array();
207228 $oldPreferenceFormat = false;
208 - if (version_compare( $wgVersion, '1.16', '<' )) {
 229+ if ( version_compare( $wgVersion, '1.16', '<' ) ) {
209230 $oldPreferenceFormat = true;
210231 } else {
211232 $tables[] = 'user_properties as tc_prop';
212233 $fields[] = 'tc_prop.up_value as timecorrection';
213 -
 234+
214235 $join_conds['user_properties as tc_prop'] =
215 - array( 'left join',
 236+ array( 'left join',
216237 array(
217238 'up_user=user_id',
218239 'up_property' => 'timecorrection',
219240 )
220241 );
221 -
 242+
222243 $tables[] = 'user_properties as l_prop';
223244 $fields[] = 'l_prop.up_value as language';
224 -
 245+
225246 $join_conds['user_properties as l_prop'] =
226 - array( 'left join',
 247+ array( 'left join',
227248 array(
228249 'up_user=user_id',
229250 'up_property' => 'language',
230251 )
231252 );
232253 }
233 -
 254+
234255 $dbr = wfGetDB( DB_SLAVE );
235 - $res = $dbr->select( $tables, $fields,
236 - array( 'user_id' => $watching_users ), __METHOD__, array(),
237 - $join_conds
238 - );
239 -
 256+ $res = $dbr->select(
 257+ $tables,
 258+ $fields,
 259+ array( 'user_id' => $watching_users ),
 260+ __METHOD__,
 261+ array(),
 262+ $join_conds
 263+ );
 264+
240265 // Set up one-time data.
241266 $link_title = clone $t->article()->getTitle();
242 - $link_title->setFragment( '#'.$t->getAnchorName() );
 267+ $link_title->setFragment( '#' . $t->getAnchorName() );
243268 $permalink = $link_title->getFullURL();
244269 $talkPage = $t->article()->getTitle()->getPrefixedText();
245270 $from = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
246271 $threadSubject = $t->subject();
247 -
 272+
248273 // Parse content and strip HTML of post content
249274 // Doesn't work for some reason (transaction issues?)
250275 // $content = $t->root()->getContent();
251276 // global $wgOut;
252277 // $html = $wgOut->parse( $content );
253278 // $text = StringUtils::delimiterReplace( '<', '>', '', $html );
254 -
255 - while( $row = $dbr->fetchObject( $res ) ) {
 279+
 280+ while ( $row = $dbr->fetchObject( $res ) ) {
256281 $u = User::newFromRow( $row );
257 -
258 - if ($oldPreferenceFormat) {
 282+
 283+ if ( $oldPreferenceFormat ) {
259284 $langCode = $u->getOption( 'language' );
260 - } elseif ($row->language) {
 285+ } elseif ( $row->language ) {
261286 $langCode = $row->language;
262287 } else {
263288 global $wgLanguageCode;
264289 $langCode = $wgLanguageCode;
265290 }
266 -
 291+
267292 $lang = Language::factory( $langCode );
268 -
 293+
269294 // Adjust with time correction
270 - if ($oldPreferenceFormat) {
 295+ if ( $oldPreferenceFormat ) {
271296 $timeCorrection = $u->getOption( 'timecorrection' );
272297 } else {
273298 $timeCorrection = $row->timecorrection;
274299 }
275300 $adjustedTimestamp = $lang->userAdjust( $timestamp, $timeCorrection );
276 -
 301+
277302 $date = $lang->date( $adjustedTimestamp );
278303 $time = $lang->time( $adjustedTimestamp );
279 -
 304+
280305 $params = array( $u->getName(), $t->subjectWithoutIncrement(),
281306 $date, $time, $talkPage, $permalink );
282 -
 307+
283308 // Get message in user's own language, bug 20645
284309 $msg = wfMsgReal( $msgName, $params, true /* use DB */, $langCode,
285310 true /*transform*/ );
286 -
 311+
287312 global $wgPasswordSender;
288 -
 313+
289314 $to = new MailAddress( $u );
290 - $subject = wfMsgReal( $subjectMsg, array($threadSubject), true /* use DB */,
291 - $langCode, true /* transform */);
292 -
 315+ $subject = wfMsgReal( $subjectMsg, array( $threadSubject ), true /* use DB */,
 316+ $langCode, true /* transform */ );
 317+
293318 UserMailer::send( $to, $from, $subject, $msg );
294319 }
295320 }
296321
297322 static function newUserMessages( $user ) {
298323 $talkPage = new Article( $user->getUserPage()->getTalkPage() );
299 -
 324+
300325 $dbr = wfGetDB( DB_SLAVE );
301 -
 326+
302327 $joinConds = array( 'ums_user' => null );
303 - $joinConds[] = $dbr->makeList( array( 'ums_user' => $user->getId(),
304 - 'ums_thread=thread_id' ), LIST_AND );
 328+ $joinConds[] = $dbr->makeList(
 329+ array(
 330+ 'ums_user' => $user->getId(),
 331+ 'ums_thread=thread_id'
 332+ ),
 333+ LIST_AND
 334+ );
305335 $joinClause = $dbr->makeList( $joinConds, LIST_OR );
306 -
307 - $res = $dbr->select( array( 'thread', 'user_message_state' ), '*',
308 - array( 'ums_read_timestamp' => null,
309 - Threads::articleClause( $talkPage ) ),
310 - __METHOD__, array(),
311 - array(
312 - 'user_message_state' =>
313 - array( 'LEFT OUTER JOIN', $joinClause )
314 - ) );
315 -
 336+
 337+ $res = $dbr->select(
 338+ array( 'thread', 'user_message_state' ),
 339+ '*',
 340+ array(
 341+ 'ums_read_timestamp' => null,
 342+ Threads::articleClause( $talkPage )
 343+ ),
 344+ __METHOD__,
 345+ array(),
 346+ array(
 347+ 'user_message_state' =>
 348+ array( 'LEFT OUTER JOIN', $joinClause )
 349+ )
 350+ );
 351+
316352 return Threads::loadFromResult( $res, $dbr );
317353 }
318354
319355 static function watchedThreadsForUser( $user ) {
320356 $talkPage = new Article( $user->getUserPage()->getTalkPage() );
321 -
 357+
322358 $dbr = wfGetDB( DB_SLAVE );
323 -
324 - $res = $dbr->select( array( 'thread', 'user_message_state' ), '*',
325 - array( 'ums_read_timestamp' => null,
326 - 'ums_user' => $user->getId(),
327 - 'not (' . Threads::articleClause( $talkPage ) . ')',
328 - ),
329 - __METHOD__, array(),
330 - array( 'user_message_state' =>
331 - array( 'INNER JOIN', 'ums_thread=thread_id' ),
332 - ) );
333 -
 359+
 360+ $res = $dbr->select(
 361+ array( 'thread', 'user_message_state' ),
 362+ '*',
 363+ array(
 364+ 'ums_read_timestamp' => null,
 365+ 'ums_user' => $user->getId(),
 366+ 'not (' . Threads::articleClause( $talkPage ) . ')',
 367+ ),
 368+ __METHOD__,
 369+ array(),
 370+ array(
 371+ 'user_message_state' =>
 372+ array( 'INNER JOIN', 'ums_thread=thread_id' ),
 373+ )
 374+ );
 375+
334376 return Threads::loadFromResult( $res, $dbr );
335377 }
336378 }
Index: trunk/extensions/LiquidThreads/classes/ThreadRevision.php
@@ -6,157 +6,157 @@
77 array(
88 'th_id' => 'mId',
99 'th_thread' => 'mThreadId',
10 -
 10+
1111 'th_timestamp' => 'mTimestamp',
12 -
 12+
1313 'th_user' => 'mUserId',
1414 'th_user_text' => 'mUserText',
15 -
 15+
1616 'th_change_type' => 'mChangeType',
1717 'th_change_object' => 'mChangeObjectId',
1818 'th_change_comment' => 'mChangeComment',
1919 'th_content' => 'mObjSer',
2020 );
21 -
 21+
2222 protected $mId, $mThreadId, $mTimestamp, $mUserId, $mUserText, $mChangeType,
2323 $mChangeObjectId, $mChangeObject, $mChangeComment, $mObjSer, $mThreadObj;
24 -
 24+
2525 static function loadFromId( $id ) {
2626 $dbr = wfGetDB( DB_SLAVE );
2727 $row = $dbr->selectRow( 'thread_history', '*', array( 'th_id' => $id ), __METHOD__ );
28 -
 28+
2929 return self::loadFromRow( $row );
3030 }
31 -
 31+
3232 static function loadFromRow( $row ) {
3333 $rev = new ThreadRevision;
34 -
35 - foreach( self::$load as $col => $field ) {
 34+
 35+ foreach ( self::$load as $col => $field ) {
3636 $rev->$field = $row->$col;
3737 }
38 -
 38+
3939 $rev->mUser = User::newFromName( $rev->mUserText, /* Don't validate */ false );
4040 $rev->mThreadObj = unserialize( $rev->mObjSer );
41 -
 41+
4242 return $rev;
4343 }
44 -
 44+
4545 static function create( $thread, $change_type, $change_object = null, $comment = '',
4646 $user = null, $timestamp = null ) {
47 - if ( is_null($user) ) {
 47+ if ( is_null( $user ) ) {
4848 global $wgUser;
4949 $user = $wgUser;
5050 }
51 -
52 - if ( is_null($timestamp) ) {
 51+
 52+ if ( is_null( $timestamp ) ) {
5353 $timestamp = wfTimestampNow();
5454 }
55 -
 55+
5656 $rev = new ThreadRevision;
57 -
 57+
5858 $rev->mThreadId = $thread->topmostThread()->id();
5959 $rev->mTimestamp = $timestamp;
60 -
 60+
6161 $rev->mUser = $user;
6262 $rev->mUserId = $user->getId();
6363 $rev->mUserText = $user->getName();
64 -
 64+
6565 $rev->mChangeType = $change_type;
66 -
 66+
6767 if ( $change_object instanceof Thread ) {
6868 $rev->mChangeObjectId = $change_object->id();
6969 $rev->mChangeObject = $change_object;
70 - } elseif ( is_null($change_object) ) {
 70+ } elseif ( is_null( $change_object ) ) {
7171 $rev->mChangeObjectId = $thread->id();
7272 $rev->mChangeObject = $thread;
7373 } else {
7474 $rev->mChangeObjectId = $change_object;
7575 }
76 -
 76+
7777 $rev->mChangeComment = $comment;
78 -
 78+
7979 $rev->mThreadObj = $thread->topmostThread();
8080 $rev->mObjSer = serialize( $rev->mThreadObj );
81 -
 81+
8282 $rev->insert();
83 -
 83+
8484 return $rev;
8585 }
86 -
 86+
8787 function insert() {
8888 $dbw = wfGetDB( DB_MASTER );
89 -
 89+
9090 $row = $this->getRow();
9191 $row['th_id'] = $dbw->nextSequenceValue( 'thread_history_th_id' );
92 -
 92+
9393 $dbw->insert( 'thread_history', $row, __METHOD__ );
94 -
 94+
9595 $this->mId = $dbw->insertId();
9696 }
97 -
 97+
9898 function save() {
9999 $row = $this->getRow();
100 -
 100+
101101 $dbw = wfGetDB( DB_MASTER );
102 -
 102+
103103 $dbw->replace( 'thread_history', array( 'th_thread' ), $row, __METHOD__ );
104104 }
105 -
 105+
106106 function getRow() {
107107 $row = array();
108 -
 108+
109109 // First, prep the data for insertion
110110 $dbw = wfGetDB( DB_MASTER );
111111 $this->mTimestamp = $dbw->timestamp( $this->mTimestamp );
112 -
113 - foreach( self::$load as $col => $field ) {
 112+
 113+ foreach ( self::$load as $col => $field ) {
114114 $row[$col] = $this->$field;
115115 }
116 -
 116+
117117 return $row;
118118 }
119 -
 119+
120120 function getTimestamp() {
121121 return wfTimestamp( TS_MW, $this->mTimestamp );
122122 }
123 -
 123+
124124 function getUser() {
125 - if ($this->mUserId) {
 125+ if ( $this->mUserId ) {
126126 return User::newFromId( $this->mUserId );
127127 }
128 -
 128+
129129 return User::newFromText( $this->mUserText, /* No validation */ false );
130130 }
131 -
 131+
132132 function getChangeType() {
133133 return $this->mChangeType;
134134 }
135 -
 135+
136136 function getChangeObject() {
137137 if ( !$this->mChangeObject && $this->mChangeObjectId ) {
138138 $this->mChangeObject = Threads::withId( $this->mChangeObjectId );
139139 }
140 -
 140+
141141 return $this->mChangeObject;
142142 }
143 -
 143+
144144 function getChangeComment() {
145145 return $this->mChangeComment;
146146 }
147 -
 147+
148148 function getId() {
149149 return $this->mId;
150150 }
151 -
 151+
152152 function getThreadObj() {
153153 if ( !$this->mThreadObj && $this->mObjSer ) {
154154 $this->mThreadObj = unserialize( $this->mObjSer );
155 - } elseif (!$this->mThreadObj) {
 155+ } elseif ( !$this->mThreadObj ) {
156156 throw new MWException( "Missing mObjSer" );
157157 }
158 -
 158+
159159 $this->mThreadObj->threadRevision = $this;
160 -
 160+
161161 return $this->mThreadObj;
162162 }
163163 }
Index: trunk/extensions/LiquidThreads/classes/DeletionController.php
@@ -2,97 +2,97 @@
33
44 class LqtDeletionController {
55 static $pageids_to_revive;
6 -
 6+
77 static function onArticleDeleteComplete( &$article, &$user, $reason, $id ) {
88 $title = $article->getTitle();
9 -
10 - if ($title->getNamespace() != NS_LQT_THREAD) {
 9+
 10+ if ( $title->getNamespace() != NS_LQT_THREAD ) {
1111 return true;
1212 }
13 -
 13+
1414 $threads = Threads::where( array( 'thread_root' => $id ) );
15 -
16 - if (!count($threads)) {
17 - wfDebugLog( __METHOD__.": no threads with root $id, ignoring...\n" );
 15+
 16+ if ( !count( $threads ) ) {
 17+ wfDebugLog( __METHOD__ . ": no threads with root $id, ignoring...\n" );
1818 return true;
1919 }
20 -
21 - $thread = array_pop($threads);
22 -
 20+
 21+ $thread = array_pop( $threads );
 22+
2323 // Mark the thread as deleted
24 - $thread->delete($reason);
25 -
 24+ $thread->delete( $reason );
 25+
2626 // Avoid orphaning subthreads, update their parentage.
2727 wfLoadExtensionMessages( 'LiquidThreads' );
2828 if ( $thread->replies() && $thread->isTopmostThread() ) {
29 - $reason = wfMsg('lqt-delete-parent-deleted', $reason );
30 - foreach( $thread->replies() as $reply ) {
 29+ $reason = wfMsg( 'lqt-delete-parent-deleted', $reason );
 30+ foreach ( $thread->replies() as $reply ) {
3131 $reply->root()->doDeleteArticle( $reason, false, $reply->root()->getId() );
3232 }
3333 global $wgOut;
3434 $wgOut->addWikiMsg( 'lqt-delete-replies-done' );
3535 } elseif ( $thread->replies() ) {
36 - foreach( $thread->replies() as $reply ) {
 36+ foreach ( $thread->replies() as $reply ) {
3737 $reply->setSuperthread( $thread->superthread() );
3838 $reply->save( );
3939 }
4040 }
41 -
 41+
4242 return true;
4343 }
44 -
 44+
4545 static function onArticleRevisionUndeleted( &$title, $revision, $page_id ) {
4646 if ( $title->getNamespace() == NS_LQT_THREAD ) {
4747 self::$pageids_to_revive[$page_id] = $title;
4848 }
49 -
 49+
5050 return true;
5151 }
52 -
 52+
5353 static function onArticleUndelete( &$udTitle, $created, $comment = '' ) {
54 - if ( empty(self::$pageids_to_revive) ) {
 54+ if ( empty( self::$pageids_to_revive ) ) {
5555 return true;
5656 }
57 -
58 - foreach( self::$pageids_to_revive as $pageid => $title ) {
59 - if ($pageid == 0) {
 57+
 58+ foreach ( self::$pageids_to_revive as $pageid => $title ) {
 59+ if ( $pageid == 0 ) {
6060 continue;
6161 }
62 -
 62+
6363 // Try to get comment for old versions where it isn't passed, hacky :(
64 - if (!$comment) {
 64+ if ( !$comment ) {
6565 global $wgRequest;
6666 $comment = $wgRequest->getText( 'wpComment' );
6767 }
68 -
 68+
6969 // TX has not been committed yet, so we must select from the master
7070 $dbw = wfGetDB( DB_MASTER );
7171 $res = $dbw->select( 'thread', '*', array( 'thread_root' => $pageid ), __METHOD__ );
7272 $threads = Threads::loadFromResult( $res, $dbw );
73 -
74 - if ( count($threads) ) {
75 - $thread = array_pop($threads);
 73+
 74+ if ( count( $threads ) ) {
 75+ $thread = array_pop( $threads );
7676 $thread->setRoot( new Article( $title ) );
7777 $thread->undelete( $comment );
7878 } else {
79 - wfDebug( __METHOD__. ":No thread found with root set to $pageid (??)\n" );
 79+ wfDebug( __METHOD__ . ":No thread found with root set to $pageid (??)\n" );
8080 }
8181 }
82 -
 82+
8383 return true;
8484 }
85 -
 85+
8686 static function onArticleConfirmDelete( $article, $out, &$reason ) {
87 - if ($article->getTitle()->getNamespace() != NS_LQT_THREAD) return true;
88 -
 87+ if ( $article->getTitle()->getNamespace() != NS_LQT_THREAD ) return true;
 88+
8989 $thread = Threads::withRoot( $article );
90 -
91 - if ( $thread->isTopmostThread() && count($thread->replies()) ) {
 90+
 91+ if ( $thread->isTopmostThread() && count( $thread->replies() ) ) {
9292 wfLoadExtensionMessages( 'LiquidThreads' );
9393 $out->wrapWikiMsg( '<strong>$1</strong>',
9494 'lqt-delete-parent-warning' );
9595 }
96 -
 96+
9797 return true;
9898 }
9999 }
Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -31,35 +31,35 @@
3232 protected $subject;
3333 protected $authorId;
3434 protected $authorName;
35 -
 35+
3636 protected $allDataLoaded;
37 -
 37+
3838 protected $isHistorical = false;
39 -
 39+
4040 protected $rootRevision;
4141
4242 /* Flag about who has edited or replied to this thread. */
4343 protected $editedness;
4444
4545 protected $replies;
46 -
 46+
4747 static $titleCacheById = array();
4848 static $replyCacheById = array();
4949 static $articleCacheById = array();
50 -
 50+
5151 static $VALID_TYPES = array( Threads::TYPE_NORMAL, Threads::TYPE_MOVED, Threads::TYPE_DELETED );
5252
5353 function isHistorical() {
5454 return $this->isHistorical;
5555 }
56 -
 56+
5757 static function create( $root, $article, $superthread = null,
58 - $type = Threads::TYPE_NORMAL, $subject = '' ) {
 58+ $type = Threads::TYPE_NORMAL, $subject = '' ) {
5959
60 - $dbw = wfGetDB( DB_MASTER );
61 -
62 - $thread = new Thread(null);
 60+ $dbw = wfGetDB( DB_MASTER );
6361
 62+ $thread = new Thread( null );
 63+
6464 if ( !in_array( $type, self::$VALID_TYPES ) ) {
6565 throw new MWException( __METHOD__ . ": invalid change type $type." );
6666 }
@@ -80,50 +80,50 @@
8181 $thread->setArticle( $article );
8282 $thread->setSubject( $subject );
8383 $thread->setType( $type );
84 -
 84+
8585 $thread->insert();
86 -
 86+
8787 if ( $superthread ) {
8888 $superthread->addReply( $thread );
89 -
 89+
9090 $superthread->commitRevision( $change_type, $thread );
9191 } else {
9292 $hthread = ThreadRevision::create( $thread, $change_type );
9393 }
94 -
 94+
9595 // Create talk page
9696 Threads::createTalkpageIfNeeded( $article );
9797
9898 // Notifications
9999 NewMessages::writeMessageStateForUpdatedThread( $thread, $change_type, $wgUser );
100 -
101 - if ($wgUser->getOption( 'lqt-watch-threads', false ) ) {
 100+
 101+ if ( $wgUser->getOption( 'lqt-watch-threads', false ) ) {
102102 $thread->topmostThread()->root()->doWatch();
103103 }
104104
105105 return $thread;
106106 }
107 -
 107+
108108 function insert() {
109109 $this->dieIfHistorical();
110 -
 110+
111111 $dbw = wfGetDB( DB_MASTER );
112 -
 112+
113113 $row = $this->getRow();
114114 $row['thread_id'] = $dbw->nextSequenceValue( 'thread_thread_id' );
115 -
 115+
116116 $dbw->insert( 'thread', $row, __METHOD__ );
117117 $this->id = $dbw->insertId();
118 -
 118+
119119 // Touch the root
120 - if ($this->root()) {
 120+ if ( $this->root() ) {
121121 $this->root()->getTitle()->invalidateCache();
122122 }
123 -
 123+
124124 // Touch the talk page, too.
125125 $this->article()->getTitle()->invalidateCache();
126126 }
127 -
 127+
128128 function setRoot( $article ) {
129129 $this->rootId = $article->getId();
130130 $this->root = $article;
@@ -136,27 +136,27 @@
137137 $this->modified = wfTimestampNow();
138138 $this->updateEditedness( $change_type );
139139 $this->save();
140 -
 140+
141141 $topmost = $this->topmostThread();
142142 $topmost->modified = wfTimestampNow();
143143 $topmost->save();
144 -
 144+
145145 ThreadRevision::create( $this, $change_type, $change_object, $reason );
146146
147147 if ( $change_type == Threads::CHANGE_EDITED_ROOT ) {
148148 NewMessages::writeMessageStateForUpdatedThread( $this, $change_type, $wgUser );
149149 }
150150 }
151 -
 151+
152152 function updateEditedness( $change_type ) {
153153 global $wgUser;
154 -
 154+
155155 if ( $change_type == Threads::CHANGE_REPLY_CREATED
156156 && $this->editedness == Threads::EDITED_NEVER ) {
157157 $this->editedness = Threads::EDITED_HAS_REPLY;
158158 } elseif ( $change_type == Threads::CHANGE_EDITED_ROOT ) {
159159 $originalAuthor = $this->author();
160 -
 160+
161161 if ( ( $wgUser->getId() == 0 && $originalAuthor->getName() != $wgUser->getName() )
162162 || $wgUser->getId() != $originalAuthor->getId() ) {
163163 $this->editedness = Threads::EDITED_BY_OTHERS;
@@ -165,60 +165,60 @@
166166 }
167167 }
168168 }
169 -
 169+
170170 /** Unless you know what you're doing, you want commitRevision */
171 - function save() {
 171+ function save() {
172172 $this->dieIfHistorical();
173173
174174 $dbr = wfGetDB( DB_MASTER );
175 -
 175+
176176 $res = $dbr->update( 'thread',
177177 /* SET */ $this->getRow(),
178178 /* WHERE */ array( 'thread_id' => $this->id, ),
179179 __METHOD__ );
180 -
 180+
181181 // Touch the root
182 - if ($this->root()) {
 182+ if ( $this->root() ) {
183183 $this->root()->getTitle()->invalidateCache();
184184 }
185 -
 185+
186186 // Touch the talk page, too.
187187 $this->article()->getTitle()->invalidateCache();
188188 }
189 -
 189+
190190 function getRow() {
191191 $id = $this->id();
192 -
 192+
193193 $dbw = wfGetDB( DB_MASTER );
194194
195 - if (!$id) {
 195+ if ( !$id ) {
196196 $id = $dbw->nextSequenceValue( 'thread_thread_id' );
197197 }
198 -
 198+
199199 // Reflect schema changes here.
200 -
 200+
201201 return array(
202 - 'thread_id' => $id,
203 - 'thread_root' => $this->rootId,
204 - 'thread_parent' => $this->parentId,
205 - 'thread_article_namespace' => $this->articleNamespace,
206 - 'thread_article_title' => $this->articleTitle,
207 - 'thread_modified' => $dbw->timestamp($this->modified),
208 - 'thread_created' => $dbw->timestamp($this->created),
209 - 'thread_ancestor' => $this->ancestorId,
210 - 'thread_type' => $this->type,
211 - 'thread_subject' => $this->subject,
212 - 'thread_author_id' => $this->authorId,
213 - 'thread_author_name' => $this->authorName,
214 - 'thread_summary_page' => $this->summaryId,
215 - 'thread_editedness' => $this->editedness,
216 - );
 202+ 'thread_id' => $id,
 203+ 'thread_root' => $this->rootId,
 204+ 'thread_parent' => $this->parentId,
 205+ 'thread_article_namespace' => $this->articleNamespace,
 206+ 'thread_article_title' => $this->articleTitle,
 207+ 'thread_modified' => $dbw->timestamp( $this->modified ),
 208+ 'thread_created' => $dbw->timestamp( $this->created ),
 209+ 'thread_ancestor' => $this->ancestorId,
 210+ 'thread_type' => $this->type,
 211+ 'thread_subject' => $this->subject,
 212+ 'thread_author_id' => $this->authorId,
 213+ 'thread_author_name' => $this->authorName,
 214+ 'thread_summary_page' => $this->summaryId,
 215+ 'thread_editedness' => $this->editedness,
 216+ );
217217 }
218 -
 218+
219219 function author() {
220220 $this->doLazyUpdates();
221 -
222 - if ($this->authorId) {
 221+
 222+ if ( $this->authorId ) {
223223 return User::newFromId( $this->authorId );
224224 } else {
225225 // Do NOT validate username. If the user did it, they did it.
@@ -230,49 +230,51 @@
231231 $this->type = Threads::TYPE_DELETED;
232232 $this->commitRevision( Threads::CHANGE_DELETED, $this, $reason );
233233 /* Mark thread as read by all users, or we get blank thingies in New Messages. */
234 -
 234+
235235 $this->dieIfHistorical();
236 -
 236+
237237 $dbw = wfGetDB( DB_MASTER );
238 -
 238+
239239 $dbw->delete( 'user_message_state', array( 'ums_thread' => $this->id() ),
240240 __METHOD__ );
241241 }
242 -
 242+
243243 function undelete( $reason ) {
244244 $this->type = Threads::TYPE_NORMAL;
245245 $this->commitRevision( Threads::CHANGE_UNDELETED, $this, $reason );
246246 }
247247
248248 function moveToPage( $title, $reason, $leave_trace ) {
249 - if (!$this->isTopmostThread() )
 249+ if ( !$this->isTopmostThread() )
250250 throw new MWException( "Attempt to move non-toplevel thread to another page" );
251 -
 251+
252252 $this->dieIfHistorical();
253 -
 253+
254254 $dbr = wfGetDB( DB_MASTER );
255255
256256 $oldTitle = $this->article()->getTitle();
257257 $newTitle = $title;
258 -
 258+
259259 $new_articleNamespace = $title->getNamespace();
260260 $new_articleTitle = $title->getDBkey();
261 -
 261+
262262 // Update on *all* subthreads.
263 - $dbr->update( 'thread',
264 - array(
265 - 'thread_revision=thread_revision+1',
266 - 'thread_article_namespace' => $new_articleNamespace,
267 - 'thread_article_title' => $new_articleTitle,
268 - 'thread_modified' => $dbr->timestamp( wfTimestampNow() ),
269 - ),
270 - array( 'thread_ancestor' => $this->id() ),
271 - __METHOD__ );
 263+ $dbr->update(
 264+ 'thread',
 265+ array(
 266+ 'thread_revision=thread_revision+1',
 267+ 'thread_article_namespace' => $new_articleNamespace,
 268+ 'thread_article_title' => $new_articleTitle,
 269+ 'thread_modified' => $dbr->timestamp( wfTimestampNow() ),
 270+ ),
 271+ array( 'thread_ancestor' => $this->id() ),
 272+ __METHOD__
 273+ );
272274
273275 $this->articleNamespace = $new_articleNamespace;
274276 $this->articleTitle = $new_articleTitle;
275277 $this->commitRevision( Threads::CHANGE_MOVED_TALKPAGE, null, $reason );
276 -
 278+
277279 # Log the move
278280 $log = new LogPage( 'liquidthreads' );
279281 $log->addEntry( 'move', $this->title(), $reason, array( $oldTitle, $newTitle ) );
@@ -286,59 +288,57 @@
287289 // there.
288290 function leaveTrace( $reason, $oldTitle, $newTitle ) {
289291 $this->dieIfHistorical();
290 -
 292+
291293 $dbw = wfGetDB( DB_MASTER );
292294
293295 // Create redirect text
294296 $mwRedir = MagicWord::get( 'redirect' );
295297 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $this->title()->getPrefixedText() . "]]\n";
296 -
 298+
297299 // Make the article edit.
298 - $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat($oldTitle) );
 300+ $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat( $oldTitle ) );
299301 $redirectArticle = new Article_LQT_Compat( $traceTitle );
300302 $redirectArticle->doEdit( $redirectText, $reason, EDIT_NEW );
301303
302304 // Add the trace thread to the tracking table.
303 - $thread = Threads::newThread( $redirectArticle, new Article_LQT_Compat($oldTitle), null,
 305+ $thread = Threads::newThread( $redirectArticle, new Article_LQT_Compat( $oldTitle ), null,
304306 Threads::TYPE_MOVED, $this->subject() );
305307 }
306308
307 -
308 -
309309 function __construct( $line, $unused = null ) {
310310 /* SCHEMA changes must be reflected here. */
311 -
312 - if ( is_null($line) ) { // For Thread::create().
 311+
 312+ if ( is_null( $line ) ) { // For Thread::create().
313313 $this->modified = wfTimestampNow();
314314 $this->created = wfTimestampNow();
315315 $this->editedness = Threads::EDITED_NEVER;
316316 return;
317317 }
318 -
 318+
319319 $dataLoads = array(
320 - 'thread_id' => 'id',
321 - 'thread_root' => 'rootId',
322 - 'thread_article_namespace' => 'articleNamespace',
323 - 'thread_article_title' => 'articleTitle',
324 - 'thread_summary_page' => 'summaryId',
325 - 'thread_ancestor' => 'ancestorId',
326 - 'thread_parent' => 'parentId',
327 - 'thread_modified' => 'modified',
328 - 'thread_created' => 'created',
329 - 'thread_type' => 'type',
330 - 'thread_editedness' => 'editedness',
331 - 'thread_subject' => 'subject',
332 - 'thread_author_id' => 'authorId',
333 - 'thread_author_name' => 'authorName',
334 - );
335 -
336 - foreach( $dataLoads as $db_field => $member_field ) {
337 - if ( isset($line->$db_field) ) {
 320+ 'thread_id' => 'id',
 321+ 'thread_root' => 'rootId',
 322+ 'thread_article_namespace' => 'articleNamespace',
 323+ 'thread_article_title' => 'articleTitle',
 324+ 'thread_summary_page' => 'summaryId',
 325+ 'thread_ancestor' => 'ancestorId',
 326+ 'thread_parent' => 'parentId',
 327+ 'thread_modified' => 'modified',
 328+ 'thread_created' => 'created',
 329+ 'thread_type' => 'type',
 330+ 'thread_editedness' => 'editedness',
 331+ 'thread_subject' => 'subject',
 332+ 'thread_author_id' => 'authorId',
 333+ 'thread_author_name' => 'authorName',
 334+ );
 335+
 336+ foreach ( $dataLoads as $db_field => $member_field ) {
 337+ if ( isset( $line->$db_field ) ) {
338338 $this->$member_field = $line->$db_field;
339339 }
340340 }
341 -
342 - if ( isset($line->page_namespace) && isset($line->page_title) ) {
 341+
 342+ if ( isset( $line->page_namespace ) && isset( $line->page_title ) ) {
343343 $root_title = Title::makeTitle( $line->page_namespace, $line->page_title );
344344 $this->root = new Article_LQT_Compat( $root_title );
345345 $this->root->loadPageData( $line );
@@ -348,220 +348,223 @@
349349 } else {
350350 $root_title = Title::newFromID( $this->rootId );
351351 }
352 -
353 - if ($root_title) {
 352+
 353+ if ( $root_title ) {
354354 $this->root = new Article_LQT_Compat( $root_title );
355355 }
356356 }
357 -
 357+
358358 $this->doLazyUpdates( $line );
359359 }
360 -
 360+
361361 // Load a list of threads in bulk, including all subthreads.
362 - static function bulkLoad( $rows ) {
 362+ static function bulkLoad( $rows ) {
363363 // Preload subthreads
364364 $thread_ids = array();
365365 $all_thread_rows = $rows;
366366 $pageIds = array();
367367 $linkBatch = new LinkBatch();
368 -
369 - if (!is_array(self::$replyCacheById)) {
 368+
 369+ if ( !is_array( self::$replyCacheById ) ) {
370370 self::$replyCacheById = array();
371371 }
372 -
 372+
373373 // Build a list of threads for which to pull replies, and page IDs to pull data for.
374374 // Also, pre-initialise the reply cache.
375 - foreach( $rows as $row ) {
 375+ foreach ( $rows as $row ) {
376376 $thread_ids[] = $row->thread_id;
377 -
 377+
378378 // Grab page data while we're here.
379 - if ($row->thread_root)
 379+ if ( $row->thread_root )
380380 $pageIds[] = $row->thread_root;
381 - if ($row->thread_summary_page)
 381+ if ( $row->thread_summary_page )
382382 $pageIds[] = $row->thread_summary_page;
383 -
 383+
384384 if ( !isset( self::$replyCacheById[$row->thread_id] ) ) {
385385 self::$replyCacheById[$row->thread_id] = array();
386386 }
387387 }
388 -
 388+
389389 // Pull replies to the threads provided, and as above, pull page IDs to pull data for,
390390 // pre-initialise the reply cache, and stash the row object for later use.
391 - if ( count($thread_ids) ) {
 391+ if ( count( $thread_ids ) ) {
392392 $dbr = wfGetDB( DB_SLAVE );
393393 $res = $dbr->select( 'thread', '*', array( 'thread_ancestor' => $thread_ids ),
394394 __METHOD__ );
395 -
396 - while( $row = $dbr->fetchObject($res) ) {
 395+
 396+ while ( $row = $dbr->fetchObject( $res ) ) {
397397 // Grab page data while we're here.
398 - if ($row->thread_root)
 398+ if ( $row->thread_root )
399399 $pageIds[] = $row->thread_root;
400 - if ($row->thread_summary_page)
 400+ if ( $row->thread_summary_page )
401401 $pageIds[] = $row->thread_summary_page;
402 -
 402+
403403 $all_thread_rows[] = $row;
404 -
 404+
405405 if ( !isset( self::$replyCacheById[$row->thread_id] ) ) {
406406 self::$replyCacheById[$row->thread_id] = array();
407407 }
408408 }
409409 }
410 -
411 - // Preload page data (restrictions, and preload Article object with everything from
 410+
 411+ // Preload page data (restrictions, and preload Article object with everything from
412412 // the page table. Also, precache the title and article objects for pulling later.
413413 $articlesById = array();
414 - if ( count($pageIds) ) {
 414+ if ( count( $pageIds ) ) {
415415 // Pull restriction info. Needs to come first because otherwise it's done per
416416 // page by loadPageData.
417417 $restrictionRows = array_fill_keys( $pageIds, array() );
418418 $res = $dbr->select( 'page_restrictions', '*', array( 'pr_page' => $pageIds ),
419419 __METHOD__ );
420 - while( $row = $dbr->fetchObject( $res ) ) {
 420+ while ( $row = $dbr->fetchObject( $res ) ) {
421421 $restrictionRows[$row->pr_page][] = $row;
422422 }
423 -
 423+
424424 $res = $dbr->select( 'page', '*', array( 'page_id' => $pageIds ), __METHOD__ );
425 -
426 - while( $row = $dbr->fetchObject( $res ) ) {
 425+
 426+ while ( $row = $dbr->fetchObject( $res ) ) {
427427 $t = Title::newFromRow( $row );
428 -
 428+
429429 if ( isset( $restrictionRows[$t->getArticleId()] ) ) {
430430 $t->loadRestrictionsFromRows( $restrictionRows[$t->getArticleId()],
431431 $row->page_restrictions );
432432 }
433 -
 433+
434434 $article = new Article_LQT_Compat( $t );
435435 $article->loadPageData( $row );
436 -
 436+
437437 self::$titleCacheById[$t->getArticleId()] = $t;
438438 $articlesById[$article->getId()] = $article;
439 -
440 - if ( count(self::$titleCacheById) > 10000 ) {
 439+
 440+ if ( count( self::$titleCacheById ) > 10000 ) {
441441 self::$titleCacheById = array();
442442 }
443443 }
444444 }
445 -
 445+
446446 // For every thread we have a row object for, load a Thread object, add the user and
447447 // user talk pages to a link batch, cache the relevant user id/name pair, and
448448 // populate the reply cache.
449 - foreach( $all_thread_rows as $row ) {
 449+ foreach ( $all_thread_rows as $row ) {
450450 $thread = new Thread( $row, null );
451 -
452 - if ( isset($articlesById[$thread->rootId]) )
 451+
 452+ if ( isset( $articlesById[$thread->rootId] ) )
453453 $thread->root = $articlesById[$thread->rootId];
454 -
 454+
455455 Threads::$cache_by_id[$row->thread_id] = $thread;
456 -
 456+
457457 // User cache data
458458 $t = Title::makeTitleSafe( NS_USER, $row->thread_author_name );
459459 $linkBatch->addObj( $t );
460460 $t = Title::makeTitleSafe( NS_USER_TALK, $row->thread_author_name );
461461 $linkBatch->addObj( $t );
462 -
 462+
463463 User::$idCacheByName[$row->thread_author_name] = $row->thread_author_id;
464 -
 464+
465465 if ( $row->thread_parent ) {
466466 self::$replyCacheById[$row->thread_parent][$row->thread_id] = $thread;
467467 }
468468 }
469 -
 469+
470470 // Pull link batch data.
471471 $linkBatch->execute();
472 -
 472+
473473 $threads = array();
474 -
 474+
475475 // Fill and return an array with the threads that were actually requested.
476 - foreach( $rows as $row ) {
 476+ foreach ( $rows as $row ) {
477477 $threads[$row->thread_id] = Threads::$cache_by_id[$row->thread_id];
478478 }
479 -
 479+
480480 return $threads;
481481 }
482 -
 482+
483483 /**
484484 * Return the User object representing the author of the first revision
485485 * (or null, if the database is screwed up).
486486 */
487487 function loadOriginalAuthorFromRevision( ) {
488488 $this->dieIfHistorical();
489 -
 489+
490490 $dbr = wfGetDB( DB_SLAVE );
491 -
 491+
492492 $article = $this->root();
493493
494 - $line = $dbr->selectRow( 'revision',
495 - 'rev_user_text',
496 - array( 'rev_page' => $article->getID() ),
497 - __METHOD__,
498 - array(
499 - 'ORDER BY' => 'rev_timestamp',
500 - 'LIMIT' => '1'
501 - ) );
 494+ $line = $dbr->selectRow(
 495+ 'revision',
 496+ 'rev_user_text',
 497+ array( 'rev_page' => $article->getID() ),
 498+ __METHOD__,
 499+ array(
 500+ 'ORDER BY' => 'rev_timestamp',
 501+ 'LIMIT' => '1'
 502+ )
 503+ );
 504+
502505 if ( $line )
503506 return User::newFromName( $line->rev_user_text, false );
504507 else
505508 return null;
506509 }
507 -
 510+
508511 // Lazy updates done whenever a thread is loaded.
509512 // Much easier than running a long-running maintenance script.
510513 function doLazyUpdates( ) {
511514 if ( $this->isHistorical() )
512515 return; // Don't do lazy updates on stored historical threads.
513 -
 516+
514517 // This is an invocation guard to avoid infinite recursion when fixing a
515518 // missing ancestor.
516519 static $doingUpdates = false;
517 - if ($doingUpdates) return;
 520+ if ( $doingUpdates ) return;
518521 $doingUpdates = true;
519 -
 522+
520523 // Fix missing ancestry information.
521524 // (there was a bug where this was not saved properly)
522 - if ($this->parentId &&!$this->ancestorId) {
 525+ if ( $this->parentId && !$this->ancestorId ) {
523526 $this->fixMissingAncestor();
524527 }
525 -
 528+
526529 $ancestor = $this->topmostThread();
527 -
 530+
528531 $set = array();
529 -
 532+
530533 // Fix missing subject information
531534 // (this information only started to be added later)
532535 if ( !$this->subject && $this->root() ) {
533536 $detectedSubject = $this->root()->getTitle()->getText();
534537 $parts = self::splitIncrementFromSubject( $detectedSubject );
535 -
 538+
536539 $this->subject = $detectedSubject = $parts[1];
537 -
 540+
538541 // Update in the DB
539542 $set['thread_subject'] = $detectedSubject;
540543 }
541 -
 544+
542545 // Fix inconsistent subject information
543546 // (in some intermediate versions this was not updated when the subject was changed)
544 - if ($this->subject() != $ancestor->subject()) {
 547+ if ( $this->subject() != $ancestor->subject() ) {
545548 $set['thread_subject'] = $ancestor->subject();
546 -
 549+
547550 $this->subject = $ancestor->subject();
548551 }
549 -
 552+
550553 // Fix missing authorship information
551554 // (this information only started to be added later)
552555 if ( !$this->authorName ) {
553556 $author = $this->loadOriginalAuthorFromRevision();
554 -
 557+
555558 $this->authorId = $author->getId();
556559 $this->authorName = $author->getName();
557 -
 560+
558561 $set['thread_author_name'] = $this->authorName;
559562 $set['thread_author_id'] = $this->authorId;
560563 }
561 -
562 - //Check for article being in subject, not talk namespace.
563 - //If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant
 564+
 565+ // Check for article being in subject, not talk namespace.
 566+ // If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant
564567 // to be on the corresponding talk page, but only if the talk-page is a LQT page.
565 - //(Previous versions stored the subject page, for some totally bizarre reason)
 568+ // (Previous versions stored the subject page, for some totally bizarre reason)
566569 // Old versions also sometimes store the thread page for trace threads as the
567570 // article, not as the root.
568571 // Trying not to exacerbate this by moving it to be the 'Thread talk' page.
@@ -571,99 +574,103 @@
572575 $articleTitle->getNamespace() != NS_LQT_THREAD ) {
573576 $newTitle = $articleTitle->getTalkPage();
574577 $newArticle = new Article_LQT_Compat( $newTitle );
575 -
 578+
576579 $set['thread_article_namespace'] = $newTitle->getNamespace();
577580 $set['thread_article_title'] = $newTitle->getDbKey();
578 -
 581+
579582 $this->articleNamespace = $newTitle->getNamespace();
580583 $this->articleTitle = $newTitle->getDbKey();
581 -
 584+
582585 $this->article = $newArticle;
583586 }
584 -
 587+
585588 // Check for article corruption from incomplete thread moves.
586589 // (thread moves only updated this on immediate replies, not replies to replies etc)
587 - if (! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) {
 590+ if ( ! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) {
588591 $title = $ancestor->article()->getTitle();
589592 $set['thread_article_namespace'] = $title->getNamespace();
590593 $set['thread_article_title'] = $title->getDbKey();
591 -
 594+
592595 $this->articleNamespace = $title->getNamespace();
593596 $this->articleTitle = $title->getDbKey();
594 -
 597+
595598 $this->article = $ancestor->article();
596599 }
597 -
598 - if ( count($set) ) {
 600+
 601+ if ( count( $set ) ) {
599602 $dbw = wfGetDB( DB_MASTER );
600 -
 603+
601604 $dbw->update( 'thread', $set, array( 'thread_id' => $this->id() ), __METHOD__ );
602605 }
603 -
 606+
604607 // Done
605608 $doingUpdates = false;
606609 }
607610
608611 function addReply( $thread ) {
609612 $thread->setSuperThread( $this );
610 -
611 - if ( is_array($this->replies) ) {
 613+
 614+ if ( is_array( $this->replies ) ) {
612615 $this->replies[$thread->id()] = $thread;
613616 } else {
614617 $this->replies();
615618 $this->replies[$thread->id()] = $thread;
616619 }
617620 }
618 -
 621+
619622 function removeReply( $thread ) {
620 - if ( is_object($thread) ) {
 623+ if ( is_object( $thread ) ) {
621624 $thread = $thread->id();
622625 }
623 -
 626+
624627 $this->replies();
625 -
 628+
626629 unset( $thread->replies[$thread] );
627630 }
628 -
 631+
629632 function replies() {
630 - if ( !is_null($this->replies) ) {
 633+ if ( !is_null( $this->replies ) ) {
631634 return $this->replies;
632635 }
633 -
 636+
634637 $this->dieIfHistorical();
635 -
 638+
636639 // Check cache
637640 if ( isset( self::$replyCacheById[$this->id()] ) ) {
638641 return $this->replies = self::$replyCacheById[$this->id()];
639642 }
640 -
 643+
641644 $this->replies = array();
642 -
 645+
643646 $dbr = wfGetDB( DB_SLAVE );
644 -
645 - $res = $dbr->select( 'thread', '*',
646 - array( 'thread_parent' => $this->id() ), __METHOD__ );
647 -
 647+
 648+ $res = $dbr->select(
 649+ 'thread',
 650+ '*',
 651+ array( 'thread_parent' => $this->id() ),
 652+ __METHOD__
 653+ );
 654+
648655 $rows = array();
649 - while ( $row = $dbr->fetchObject($res) ) {
 656+ while ( $row = $dbr->fetchObject( $res ) ) {
650657 $rows[] = $row;
651658 }
652 -
 659+
653660 $this->replies = Thread::bulkLoad( $rows );
654 -
 661+
655662 return $this->replies;
656663 }
657664
658665 function setSuperthread( $thread ) {
659 - if ($thread == null) {
 666+ if ( $thread == null ) {
660667 $this->parentId = null;
661668 $this->ancestorId = 0;
662669 return;
663670 }
664 -
 671+
665672 $this->parentId = $thread->id();
666673 $this->superthread = $thread;
667 -
 674+
668675 if ( $thread->isTopmostThread() ) {
669676 $this->ancestorId = $thread->id();
670677 $this->ancestor = $thread;
@@ -689,23 +696,23 @@
690697 function topmostThread() {
691698 if ( $this->isTopmostThread() ) {
692699 return $this->ancestor = $this;
693 - } elseif ($this->ancestor) {
 700+ } elseif ( $this->ancestor ) {
694701 return $this->ancestor;
695702 } else {
696703 $this->dieIfHistorical();
697 -
 704+
698705 $thread = Threads::withId( $this->ancestorId );
699706
700 - if (!$thread) {
 707+ if ( !$thread ) {
701708 $thread = $this->fixMissingAncestor();
702709 }
703 -
 710+
704711 $this->ancestor = $thread;
705 -
 712+
706713 return $thread;
707714 }
708715 }
709 -
 716+
710717 function setAncestor( $newAncestor ) {
711718 if ( is_object( $newAncestor ) ) {
712719 $this->ancestorId = $newAncestor->id();
@@ -718,19 +725,23 @@
719726 // Fix the corruption by repeatedly grabbing the parent until we hit the topmost thread.
720727 function fixMissingAncestor() {
721728 $thread = $this;
722 -
 729+
723730 $this->dieIfHistorical();
724 -
 731+
725732 while ( !$thread->isTopmostThread() ) {
726733 $thread = $thread->superthread();
727734 }
728 -
 735+
729736 $this->ancestorId = $thread->id();
730 -
 737+
731738 $dbw = wfGetDB( DB_MASTER );
732 - $dbw->update( 'thread', array( 'thread_ancestor' => $thread->id() ),
733 - array( 'thread_id' => $this->id() ), __METHOD__ );
734 -
 739+ $dbw->update(
 740+ 'thread',
 741+ array( 'thread_ancestor' => $thread->id() ),
 742+ array( 'thread_id' => $this->id() ),
 743+ __METHOD__
 744+ );
 745+
735746 return $thread;
736747 }
737748
@@ -745,14 +756,14 @@
746757 $this->articleTitle = $a->getTitle()->getDBkey();
747758 $this->touch();
748759 }
749 -
 760+
750761 function touch() {
751762 // Nothing here yet
752763 }
753764
754765 function article() {
755766 if ( $this->article ) return $this->article;
756 -
 767+
757768 if ( !is_null( $this->articleId ) ) {
758769 $title = Title::newFromID( $this->articleId );
759770 if ( $title ) {
@@ -780,19 +791,19 @@
781792 function root( ) {
782793 if ( !$this->rootId ) return null;
783794 if ( !$this->root ) {
784 - if ( isset(self::$articleCacheById[$this->rootId]) ) {
 795+ if ( isset( self::$articleCacheById[$this->rootId] ) ) {
785796 $this->root = self::$articleCacheById[$this->rootId];
786797 return $this->root;
787798 }
788 -
 799+
789800 if ( isset( self::$titleCacheById[$this->rootId] ) ) {
790801 $title = self::$titleCacheById[$this->rootId];
791802 } else {
792803 $title = Title::newFromID( $this->rootId );
793804 }
794 -
795 - if (!$title) return null;
796 -
 805+
 806+ if ( !$title ) return null;
 807+
797808 $this->root = new Article_LQT_Compat( $title );
798809 }
799810 return $this->root;
@@ -805,20 +816,19 @@
806817 function summary() {
807818 if ( !$this->summaryId )
808819 return null;
809 -
 820+
810821 if ( !$this->summary ) {
811822 $title = Title::newFromID( $this->summaryId );
812 -
813 - if (!$title) {
814 - wfDebug( __METHOD__.": supposed summary doesn't exist" );
 823+
 824+ if ( !$title ) {
 825+ wfDebug( __METHOD__ . ": supposed summary doesn't exist" );
815826 $this->summaryId = null;
816827 return null;
817828 }
818 -
 829+
819830 $this->summary = new Article_LQT_Compat( $title );
 831+ }
820832
821 - }
822 -
823833 return $this->summary;
824834 }
825835
@@ -848,7 +858,7 @@
849859 function subject() {
850860 return $this->subject;
851861 }
852 -
 862+
853863 function setSubject( $subject ) {
854864 $this->subject = $subject;
855865 }
@@ -883,8 +893,8 @@
884894 function type() {
885895 return $this->type;
886896 }
887 -
888 - function setType($t) {
 897+
 898+ function setType( $t ) {
889899 $this->type = $t;
890900 }
891901
@@ -892,7 +902,7 @@
893903 $rev = Revision::newFromId( $this->root()->getLatest() );
894904 $rtitle = Title::newFromRedirect( $rev->getRawText() );
895905 if ( !$rtitle ) return null;
896 -
 906+
897907 $this->dieIfHistorical();
898908 $rthread = Threads::withRoot( new Article_LQT_Compat( $rtitle ) );
899909 return $rthread;
@@ -916,98 +926,102 @@
917927 $result = $parent_restrictions;
918928 return false;
919929 }
 930+ }
920931
921 - }
922 -
923932 function getAnchorName() {
924933 return "lqt_thread_{$this->id()}";
925934 }
926 -
 935+
927936 function updateHistory() {
928937 // $dbr = wfGetDB( DB_SLAVE );
929 -//
930 -// $res = $dbr->select( 'historical_thread', '*',
931 -// array( 'hthread_id' => $this->id() ),
932 -// __METHOD__,
933 -// array( 'ORDER BY' => 'hthread_revision ASC' ) );
934 -//
 938+//
 939+// $res = $dbr->select(
 940+// 'historical_thread',
 941+// '*',
 942+// array( 'hthread_id' => $this->id() ),
 943+// __METHOD__,
 944+// array( 'ORDER BY' => 'hthread_revision ASC' )
 945+// );
 946+//
935947 // foreach( $row as $res ) {
936948 // $historical_thread = HistoricalThread::fromTextRepresentation( $row->hthread_content );
937 -//
938 -// // Insert a revision into the database.
939 -// $rev = ThreadRevision::create( $historical_thread,
940 -// $historical_thread->changeType(),
941 -// $historical_thread->changeObject(),
942 -// $historical_thread->changeComment(),
943 -// $historical_thread->changeUser(),
944 -// $historical_thread->modified() );
 949+//
 950+// // Insert a revision into the database.
 951+// $rev = ThreadRevision::create(
 952+// $historical_thread,
 953+// $historical_thread->changeType(),
 954+// $historical_thread->changeObject(),
 955+// $historical_thread->changeComment(),
 956+// $historical_thread->changeUser(),
 957+// $historical_thread->modified()
 958+// );
945959 // }
946960 }
947 -
 961+
948962 function setAuthor( $user ) {
949963 $this->authorId = $user->getId();
950964 $this->authorName = $user->getName();
951965 }
952 -
 966+
953967 // Load all lazy-loaded data in prep for (e.g.) serialization.
954968 function loadAllData() {
955969 // Make sure superthread and topmost thread are loaded.
956970 $this->superthread();
957971 $this->topmostThread();
958 -
 972+
959973 // Make sure replies, and all the data therein, is loaded.
960 - foreach( $this->replies() as $reply ) {
 974+ foreach ( $this->replies() as $reply ) {
961975 $reply->loadAllData();
962976 }
963977 }
964 -
 978+
965979 // On serialization, load all data because it will be different in the DB when we wake up.
966980 function __sleep() {
967 -
 981+
968982 $this->loadAllData();
969 -
 983+
970984 $fields = array_keys( get_object_vars( $this ) );
971 -
 985+
972986 // Filter out article objects, there be dragons (or unserialization problems)
973987 $fields = array_diff( $fields, array( 'root', 'article', 'summary', 'sleeping' ) );
974 -
 988+
975989 return $fields;
976990 }
977 -
 991+
978992 function __wakeup() {
979993 // Mark as historical.
980994 $this->isHistorical = true;
981995 }
982 -
 996+
983997 // This is a safety valve that makes sure that the DB is NEVER touched by a historical
984998 // thread (even for reading, because the data will be out of date).
985999 function dieIfHistorical() {
986 - if ($this->isHistorical()) {
 1000+ if ( $this->isHistorical() ) {
9871001 throw new MWException( "Attempted write or DB operation on historical thread" );
9881002 }
9891003 }
990 -
 1004+
9911005 function rootRevision() {
992 - if ( !$this->isHistorical() || !isset($this->topmostThread()->threadRevision) ) {
 1006+ if ( !$this->isHistorical() || !isset( $this->topmostThread()->threadRevision ) ) {
9931007 return null;
9941008 }
995 -
 1009+
9961010 $dbr = wfGetDB( DB_SLAVE );
997 -
 1011+
9981012 $revision = $this->topmostThread()->threadRevision;
9991013 $timestamp = $dbr->timestamp( $revision->getTimestamp() );
1000 -
 1014+
10011015 $conds = array(
1002 - 'rev_timestamp<='.$dbr->addQuotes( $timestamp ),
 1016+ 'rev_timestamp<=' . $dbr->addQuotes( $timestamp ),
10031017 'page_namespace' => $this->root()->getTitle()->getNamespace(),
10041018 'page_title' => $this->root()->getTitle()->getDBKey(),
10051019 );
1006 -
 1020+
10071021 $join_conds = array( 'page' => array( 'JOIN', 'rev_page=page_id' ) );
1008 -
 1022+
10091023 $row = $dbr->selectRow( array( 'revision', 'page' ), '*', $conds, __METHOD__,
10101024 array( 'ORDER BY' => 'rev_timestamp DESC' ), $join_conds );
1011 -
 1025+
10121026 return $row->rev_id;
10131027 }
10141028 }
Index: trunk/extensions/LiquidThreads/classes/HistoricalThread.php
@@ -2,7 +2,6 @@
33 if ( !defined( 'MEDIAWIKI' ) ) die;
44
55 class HistoricalThread extends Thread {
6 -
76 /* Information about what changed in this revision. */
87 protected $changeType;
98 protected $changeObject;
@@ -57,12 +56,12 @@
5857 function isHistorical() {
5958 return true;
6059 }
61 -
6260
 61+
6362 function changeType() {
6463 return $this->changeType;
6564 }
66 -
 65+
6766 function changeObject() {
6867 return $this->replyWithId( $this->changeObject );
6968 }
@@ -95,7 +94,7 @@
9695 function changeComment() {
9796 return $this->changeComment;
9897 }
99 -
 98+
10099 function setChangeUser( $user ) {
101100 $this->changeUser = $user->getId();
102101 $this->changeUserText = $user->getName();
Index: trunk/extensions/LiquidThreads/classes/Threads.php
@@ -3,7 +3,6 @@
44
55 /** Module of factory methods. */
66 class Threads {
7 -
87 const TYPE_NORMAL = 0;
98 const TYPE_MOVED = 1;
109 const TYPE_DELETED = 2;
@@ -21,7 +20,7 @@
2221 const CHANGE_MERGED_FROM = 10;
2322 const CHANGE_MERGED_TO = 11;
2423 const CHANGE_SPLIT_FROM = 12;
25 -
 24+
2625 static $VALID_CHANGE_TYPES = array( self::CHANGE_EDITED_SUMMARY, self::CHANGE_EDITED_ROOT,
2726 self::CHANGE_REPLY_CREATED, self::CHANGE_NEW_THREAD, self::CHANGE_DELETED, self::CHANGE_UNDELETED,
2827 self::CHANGE_MOVED_TALKPAGE, self::CHANGE_SPLIT, self::CHANGE_EDITED_SUBJECT,
@@ -58,26 +57,26 @@
5958 }
6059 }
6160 }
62 -
 61+
6362 static function loadFromResult( $res, $db ) {
6463 $rows = array();
65 -
66 - while( $row = $db->fetchObject( $res ) ) {
 64+
 65+ while ( $row = $db->fetchObject( $res ) ) {
6766 $rows[] = $row;
6867 }
69 -
 68+
7069 return Thread::bulkLoad( $rows );
7170 }
7271
7372 static function where( $where, $options = array() ) {
7473 global $wgDBprefix;
7574 $dbr = wfGetDB( DB_SLAVE );
76 -
 75+
7776 $res = $dbr->select( 'thread', '*', $where, __METHOD__, $options );
7877 $threads = Threads::loadFromResult( $res, $dbr );
7978
8079 foreach ( $threads as $thread ) {
81 - if ($thread->root()) {
 80+ if ( $thread->root() ) {
8281 self::$cache_by_root[$thread->root()->getID()] = $thread;
8382 }
8483 self::$cache_by_id[$thread->id()] = $thread;
@@ -93,7 +92,7 @@
9493
9594 private static function assertSingularity( $threads, $attribute, $value ) {
9695 if ( count( $threads ) == 0 ) { return null; }
97 - if ( count( $threads ) == 1 ) { return array_pop($threads); }
 96+ if ( count( $threads ) == 1 ) { return array_pop( $threads ); }
9897 if ( count( $threads ) > 1 ) {
9998 Threads::databaseError( "More than one thread with $attribute = $value." );
10099 return null;
@@ -126,7 +125,7 @@
127126 return self::$cache_by_id[$id];
128127 }
129128 $ts = Threads::where( array( 'thread_id' => $id ) );
130 -
 129+
131130 return self::assertSingularity( $ts, 'thread_id', $id );
132131 }
133132
@@ -136,78 +135,78 @@
137136 }
138137
139138 /**
140 - * Horrible, horrible!
141 - * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth.
142 - * Returned as an array of months in the format yyyymm
143 - */
 139+ * Horrible, horrible!
 140+ * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth.
 141+ * Returned as an array of months in the format yyyymm
 142+ */
144143 static function monthsWhereArticleHasThreads( $article ) {
145144 // FIXME this probably performs absolutely horribly for pages with lots of threads.
146 -
 145+
147146 $threads = Threads::where( Threads::articleClause( $article ) );
148147 $months = array();
149 -
 148+
150149 foreach ( $threads as $t ) {
151150 $month = substr( $t->modified(), 0, 6 );
152 -
 151+
153152 $months[$month] = true;
154153 }
155 -
 154+
156155 // Some code seems to assume that it's sorted by month, make sure it's true.
157156 ksort( $months );
158 -
159 - return array_keys($months);
 157+
 158+ return array_keys( $months );
160159 }
161160
162161 static function articleClause( $article ) {
163162 $dbr = wfGetDB( DB_SLAVE );
164 -
 163+
165164 $arr = array( 'thread_article_title' => $article->getTitle()->getDBKey(),
166165 'thread_article_namespace' => $article->getTitle()->getNamespace() );
167 -
 166+
168167 return $dbr->makeList( $arr, LIST_AND );
169168 }
170169
171170 static function topLevelClause() {
172171 $dbr = wfGetDB( DB_SLAVE );
173 -
 172+
174173 $arr = array( 'thread_ancestor=thread_id', 'thread_parent' => null );
175 -
 174+
176175 return $dbr->makeList( $arr, LIST_OR );
177176 }
178 -
 177+
179178 static function scratchTitle() {
180179 $token = md5( uniqid( rand(), true ) );
181180 return Title::newFromText( "Thread:$token" );
182181 }
183 -
 182+
184183 static function newThreadTitle( $subject, $article ) {
185184 wfLoadExtensionMessages( 'LiquidThreads' );
186185 $subject = $subject ? $subject : wfMsg( 'lqt_nosubject' );
187 -
 186+
188187 $base = $article->getTitle()->getPrefixedText() . "/$subject";
189 -
 188+
190189 return self::incrementedTitle( $base, NS_LQT_THREAD );
191190 }
192 -
 191+
193192 static function newSummaryTitle( $t ) {
194193 return self::incrementedTitle( $t->title()->getText(), NS_LQT_SUMMARY );
195194 }
196 -
197 - static function newReplyTitle( $thread, $user) {
 195+
 196+ static function newReplyTitle( $thread, $user ) {
198197 $topThread = $thread->topmostThread();
199 -
 198+
200199 $base = $topThread->title()->getText() . '/' . $user->getName();
201 -
 200+
202201 return self::incrementedTitle( $base, NS_LQT_THREAD );
203202 }
204 -
 203+
205204 /** Keep trying titles starting with $basename until one is unoccupied. */
206205 public static function incrementedTitle( $basename, $namespace ) {
207206 $i = 2;
208 -
 207+
209208 $replacements = array_fill_keys( array( '[', ']', '{', '}', '|' ), '_' );
210209 $basename = strtr( $basename, $replacements );
211 -
 210+
212211 $t = Title::makeTitleSafe( $namespace, $basename );
213212 while ( !$t || $t->exists() ||
214213 in_array( $t->getPrefixedDBkey(), self::$occupied_titles ) ) {
@@ -215,5 +214,5 @@
216215 $i++;
217216 }
218217 return $t;
219 - }
 218+ }
220219 }
Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1,11 +1,10 @@
22 <?php
3 -
43 /**
5 -* @package MediaWiki
6 -* @subpackage LiquidThreads
7 -* @author David McCabe <davemccabe@gmail.com>
8 -* @licence GPL2
9 -*/
 4+ * @package MediaWiki
 5+ * @subpackage LiquidThreads
 6+ * @author David McCabe <davemccabe@gmail.com>
 7+ * @licence GPL2
 8+ */
109
1110 if ( !defined( 'MEDIAWIKI' ) ) {
1211 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
@@ -25,7 +24,7 @@
2625 public $threadNestingLevel = 0;
2726
2827 protected $sort_order = LQT_NEWEST_CHANGES;
29 -
 28+
3029 static $stylesAndScriptsDone = false;
3130
3231 function __construct( &$output, &$article, &$title, &$user, &$request ) {
@@ -42,10 +41,10 @@
4342 $this->headerLevel = $int;
4443 }
4544
46 - /*************************
47 - * (1) linking to liquidthreads pages and
48 - * (2) figuring out what page you're on and what you need to do.
49 - *************************/
 45+ /**
 46+ * (1) linking to liquidthreads pages and
 47+ * (2) figuring out what page you're on and what you need to do.
 48+ */
5049
5150 function methodAppliesToThread( $method, $thread ) {
5251 return $this->request->getVal( 'lqt_method' ) == $method &&
@@ -57,64 +56,65 @@
5857
5958 static function permalinkUrl( $thread, $method = null, $operand = null,
6059 $uquery = array() ) {
61 - list ($title, $query) = self::permalinkData( $thread, $method, $operand );
62 -
 60+ list ( $title, $query ) = self::permalinkData( $thread, $method, $operand );
 61+
6362 $query = array_merge( $query, $uquery );
64 -
 63+
6564 $queryString = wfArrayToCGI( $query );
66 -
 65+
6766 return $title->getFullUrl( $queryString );
6867 }
69 -
 68+
7069 /** Gets an array of (title, query-parameters) for a permalink **/
7170 static function permalinkData( $thread, $method = null, $operand = null ) {
7271 $query = array();
73 -
74 - if ($method) {
 72+
 73+ if ( $method ) {
7574 $query['lqt_method'] = $method;
7675 }
77 - if ($operand) {
 76+ if ( $operand ) {
7877 $query['lqt_operand'] = $operand;
7978 }
80 -
 79+
8180 return array( $thread->root()->getTitle(), $query );
8281 }
8382
8483 /* This is used for action=history so that the history tab works, which is
85 - why we break the lqt_method paradigm. */
 84+ * why we break the lqt_method paradigm.
 85+ */
8686 static function permalinkUrlWithQuery( $thread, $query ) {
87 - if ( !is_array($query) ) {
 87+ if ( !is_array( $query ) ) {
8888 $query = wfCGIToArray( $query );
8989 }
90 -
 90+
9191 return self::permalinkUrl( $thread, null, null, $query );
9292 }
93 -
 93+
9494 static function permalink( $thread, $text = null, $method = null, $operand = null,
9595 $sk = null, $attribs = array(), $uquery = array() ) {
96 - if ( is_null($sk) ) {
 96+ if ( is_null( $sk ) ) {
9797 global $wgUser;
9898 $sk = $wgUser->getSkin();
9999 }
100 -
 100+
101101 list( $title, $query ) = self::permalinkData( $thread, $method, $operand );
102 -
 102+
103103 $query = array_merge( $query, $uquery );
104 -
 104+
105105 return $sk->link( $title, $text, $attribs, $query );
106106 }
107 -
 107+
108108 static function diffQuery( $thread, $revision ) {
109109 $changed_thread = $revision->getChangeObject();
110110 $curr_rev_id = $revision->getThreadObj()->rootRevision();
111111 $curr_rev = Revision::newFromId( $curr_rev_id );
112112 $prev_rev = $curr_rev->getPrevious();
113113 $oldid = $prev_rev ? $prev_rev->getId() : "";
114 -
 114+
115115 $query = array( 'lqt_method' => 'diff',
116116 'diff' => $curr_rev_id,
117117 'oldid' => $oldid );
118 -
 118+
119119 return $query;
120120 }
121121
@@ -122,49 +122,49 @@
123123 $query = self::diffQuery( $thread );
124124 return self::permalinkUrl( $thread->changeObject(), null, null, $query );
125125 }
126 -
 126+
127127 static function diffPermalink( $thread, $text, $revision ) {
128128 $query = self::diffQuery( $thread, $revision );
129129 return self::permalink( $thread, $text, null, null, null, array(), $query );
130130 }
131 -
132 - static function talkpageLink( $title, $text = null , $method=null, $operand=null,
133 - $includeFragment=true, $attribs = array(),
 131+
 132+ static function talkpageLink( $title, $text = null , $method = null, $operand = null,
 133+ $includeFragment = true, $attribs = array(),
134134 $options = array() ) {
135135 list( $title, $query ) = self::talkpageLinkData( $title, $method, $operand,
136136 $includeFragment );
137 -
 137+
138138 global $wgUser;
139139 $sk = $wgUser->getSkin();
140 -
 140+
141141 return $sk->link( $title, $text, $attribs, $query, $options );
142142 }
143 -
 143+
144144 static function talkpageLinkData( $title, $method = null, $operand = null,
145145 $includeFragment = true ) {
146146 global $wgRequest;
147147 $query = array();
148 -
149 - if ($method) {
 148+
 149+ if ( $method ) {
150150 $query['lqt_method'] = $method;
151151 }
152 -
153 - if ($operand) {
 152+
 153+ if ( $operand ) {
154154 $query['lqt_operand'] = $operand->id();
155155 }
156 -
 156+
157157 $oldid = $wgRequest->getVal( 'oldid', null );
158 -
 158+
159159 if ( $oldid !== null ) {
160160 // this is an immensely ugly hack to make editing old revisions work.
161161 $query['oldid'] = $oldid;
162162 }
163 -
 163+
164164 // Add fragment if appropriate.
165 - if ($operand && $includeFragment) {
166 - $title->mFragment = 'lqt_thread_'.$operand->id();
 165+ if ( $operand && $includeFragment ) {
 166+ $title->mFragment = 'lqt_thread_' . $operand->id();
167167 }
168 -
 168+
169169 return array( $title, $query );
170170 }
171171
@@ -172,40 +172,40 @@
173173 $includeFragment = true ) {
174174 global $wgUser;
175175 $sk = $wgUser->getSkin();
176 -
 176+
177177 list( $title, $query ) =
178178 self::talkpageLinkData( $title, $method, $operand, $includeFragment );
179 -
 179+
180180 return $title->getLinkUrl( $query );
181181 }
182182
183183
184184 /**
185 - * Return a URL for the current page, including Title and query vars,
 185+ * Return a URL for the current page, including Title and query vars,
186186 * with the given replacements made.
187 - * @param $repls array( 'name'=>new_value, ... )
188 - */
 187+ * @param $repls array( 'name'=>new_value, ... )
 188+ */
189189 function queryReplaceLink( $repls ) {
190190 $query = $this->getReplacedQuery( $repls );
191 -
 191+
192192 return $this->title->getFullURL( wfArrayToCGI( $vs ) );
193193 }
194 -
 194+
195195 function getReplacedQuery( $replacements ) {
196196 $values = $this->request->getValues();
197 -
 197+
198198 foreach ( $replacements as $k => $v ) {
199199 $values[$k] = $v;
200200 }
201 -
 201+
202202 return $values;
203203 }
204204
205 - /*************************************************************
206 - * Editing methods (here be dragons) *
207 - * Forget dragons: This section distorts the rest of the code *
208 - * like a star bending spacetime around itself. *
209 - *************************************************************/
 205+ /**
 206+ * Editing methods (here be dragons)
 207+ * Forget dragons: This section distorts the rest of the code
 208+ * like a star bending spacetime around itself.
 209+ */
210210
211211 /**
212212 * Return an HTML form element whose value is gotten from the request.
@@ -246,37 +246,37 @@
247247 $this->output->addWikiMsg( 'lqt-summarize-intro' );
248248 $this->showEditingFormInGeneral( $thread, 'summarize', $thread );
249249 }
250 -
 250+
251251 function doInlineEditForm() {
252252 $method = $this->request->getVal( 'lqt_method' );
253253 $operand = $this->request->getVal( 'lqt_operand' );
254 -
255 - $thread = Threads::withId( intval($operand) );
256 -
257 - if ($method == 'reply') {
 254+
 255+ $thread = Threads::withId( intval( $operand ) );
 256+
 257+ if ( $method == 'reply' ) {
258258 $this->showReplyForm( $thread );
259 - } elseif ($method == 'talkpage_new_thread') {
 259+ } elseif ( $method == 'talkpage_new_thread' ) {
260260 $this->showNewThreadForm();
261261 }
262 -
 262+
263263 $this->output->setArticleBodyOnly( true );
264264 }
265265
266266 private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) {
267267 /*
268 - EditPage needs an Article. If there isn't a real one, as for new posts,
269 - replies, and new summaries, we need to generate a title. Auto-generated
270 - titles are based on the subject line. If the subject line is blank, we
271 - can temporarily use a random scratch title. It's fine if the title changes
272 - throughout the edit cycle, since the article doesn't exist yet anyways.
273 - */
 268+ * EditPage needs an Article. If there isn't a real one, as for new posts,
 269+ * replies, and new summaries, we need to generate a title. Auto-generated
 270+ * titles are based on the subject line. If the subject line is blank, we
 271+ * can temporarily use a random scratch title. It's fine if the title changes
 272+ * throughout the edit cycle, since the article doesn't exist yet anyways.
 273+ */
274274
275 - // Stuff that might break the save
 275+ // Stuff that might break the save
276276 $valid_subject = true;
277277 $failed_rename = false;
278 -
 278+
279279 $subject = $this->request->getVal( 'lqt_subject_field', '' );
280 -
 280+
281281 if ( $edit_type == 'summarize' && $edit_applies_to->summary() ) {
282282 $article = $edit_applies_to->summary();
283283 } elseif ( $edit_type == 'summarize' ) {
@@ -287,7 +287,7 @@
288288 // Dodgy title
289289 $valid_subject = false;
290290 $t = $this->scratchTitle();
291 - } else {
 291+ } else {
292292 if ( $edit_type == 'new' ) {
293293 $t = $this->newScratchTitle( $subject );
294294 } elseif ( $edit_type == 'reply' ) {
@@ -300,16 +300,16 @@
301301 }
302302
303303 $e = new EditPage( $article );
304 -
305 -
 304+
 305+
306306 // Find errors.
307 - if (!$valid_subject && $subject) {
308 - $e->editFormPageTop .=
 307+ if ( !$valid_subject && $subject ) {
 308+ $e->editFormPageTop .=
309309 Xml::tags( 'div', array( 'class' => 'error' ),
310310 wfMsgExt( 'lqt_invalid_subject', 'parse' ) );
311311 }
312 -
313 - if ( (!$valid_subject && $subject) || $failed_rename ) {
 312+
 313+ if ( ( !$valid_subject && $subject ) || $failed_rename ) {
314314 // Dirty hack to prevent saving from going ahead
315315 global $wgRequest;
316316 $wgRequest->setVal( 'wpPreview', true );
@@ -320,20 +320,20 @@
321321 $this->perpetuate( 'lqt_method', 'hidden' ) .
322322 $this->perpetuate( 'lqt_operand', 'hidden' ) .
323323 Xml::hidden( 'lqt_nonce', wfGenerateToken() );
324 -
 324+
325325 // Add a one-time random string to a hidden field. Store the random string
326326 // in memcached on submit and don't allow the edit to go ahead if it's already
327327 // been added.
328328 $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
329 - if ($submitted_nonce) {
 329+ if ( $submitted_nonce ) {
330330 global $wgMemc;
331 -
 331+
332332 $key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() );
333 - if ( $wgMemc->get($key) ) {
 333+ if ( $wgMemc->get( $key ) ) {
334334 $this->output->redirect( $this->article->getTitle()->getFullURL() );
335335 return;
336336 }
337 -
 337+
338338 $wgMemc->set( $key, 1, 3600 );
339339 }
340340
@@ -343,9 +343,9 @@
344344 $db_subject = $thread ? $thread->subjectWithoutIncrement() : '';
345345 $subject = $this->request->getVal( 'lqt_subject_field', $db_subject );
346346 $subject_label = wfMsg( 'lqt_subject' );
347 -
 347+
348348 $attr = array( 'tabindex' => 1 );
349 -
 349+
350350 $e->editFormTextBeforeContent .=
351351 Xml::inputLabel( $subject_label, 'lqt_subject_field', 'lqt_subject_field',
352352 60, $subject, $attr ) . Xml::element( 'br' );
@@ -354,9 +354,8 @@
355355 $e->edit();
356356
357357 // Override what happens in EditPage::showEditForm, called from $e->edit():
 358+ $this->output->setArticleFlag( false );
358359
359 - $this->output->setArticleFlag( false );
360 -
361360 if ( $e->didSave ) {
362361 $thread = self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article,
363362 $subject, $e->summary, $thread );
@@ -367,24 +366,24 @@
368367 // so $thread is null. In that case, just allow editpage to redirect back to the talk page.
369368 if ( $this->output->getRedirect() != '' && $thread ) {
370369 $redirectTitle = clone $thread->article()->getTitle();
371 - $redirectTitle->setFragment( '#'.$this->anchorName( $thread ) );
 370+ $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) );
372371 $this->output->redirect( $this->title->getFullURL() );
373372 } else if ( $this->output->getRedirect() != '' && $edit_applies_to ) {
374373 // For summaries:
375374 $redirectTitle = clone $edit_applies_to->article()->getTitle();
376 - $redirectTitle->setFragment( '#'.$this->anchorName( $edit_applies_to ) );
 375+ $redirectTitle->setFragment( '#' . $this->anchorName( $edit_applies_to ) );
377376 $this->output->redirect( $redirectTitle->getFullURL() );
378377 }
379378 }
380 -
381 - static function postEditUpdates($edit_type, $edit_applies_to, $edit_page, $article,
 379+
 380+ static function postEditUpdates( $edit_type, $edit_applies_to, $edit_page, $article,
382381 $subject, $edit_summary, $thread ) {
383382 // Update metadata - create and update thread and thread revision objects as
384383 // appropriate.
385 -
 384+
386385 if ( $edit_type == 'reply' ) {
387386 $subject = $edit_applies_to->subject();
388 -
 387+
389388 $thread = Threads::newThread( $edit_page, $article, $edit_applies_to,
390389 Threads::TYPE_NORMAL, $subject );
391390 } elseif ( $edit_type == 'summarize' ) {
@@ -395,25 +394,25 @@
396395 // Move the thread and replies if subject changed.
397396 if ( $subject && $subject != $thread->subjectWithoutIncrement() ) {
398397 $thread->setSubject( $subject );
399 -
 398+
400399 // Disabled page-moving for now.
401400 // $this->renameThread( $thread, $subject, $e->summary );
402401 }
403 -
 402+
404403 // Add the history entry.
405404 $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $edit_summary );
406405 } else {
407406 $thread = Threads::newThread( $edit_page, $article, null,
408407 Threads::TYPE_NORMAL, $subject );
409408 }
410 -
 409+
411410 return $thread;
412411 }
413412
414413 function renameThread( $t, $s, $reason ) {
415414 $this->simplePageMove( $t->root()->getTitle(), $s, $reason );
416415 // TODO here create a redirect from old page to new.
417 -
 416+
418417 foreach ( $t->subthreads() as $st ) {
419418 $this->renameThread( $st, $s, $reason );
420419 }
@@ -422,15 +421,15 @@
423422 function scratchTitle() {
424423 return Threads::scratchTitle();
425424 }
426 -
 425+
427426 function newScratchTitle( $subject ) {
428427 return Threads::newThreadTitle( $subject, $this->article );
429428 }
430 -
 429+
431430 function newSummaryTitle( $thread ) {
432431 return Threads::newSummaryTitle( $thread );
433432 }
434 -
 433+
435434 function newReplyTitle( $unused, $thread ) {
436435 return Threads::newReplyTitle( $thread, $this->user );
437436 }
@@ -490,77 +489,77 @@
491490 'enabled' => true );
492491
493492 if ( $this->user->isAllowed( 'delete' ) ) {
494 - $delete_url = $thread->title()->getFullURL( 'action=delete');
 493+ $delete_url = $thread->title()->getFullURL( 'action=delete' );
495494 $deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete';
496 -
 495+
497496 $commands['delete'] = array( 'label' => wfMsgExt( $deleteMsg, 'parseinline' ),
498497 'href' => $delete_url,
499498 'enabled' => true );
500499 }
501 -
 500+
502501 if ( !$thread->isTopmostThread() && $this->user->isAllowed( 'lqt-split' ) ) {
503502 $splitUrl = SpecialPage::getTitleFor( 'SplitThread',
504503 $thread->title()->getPrefixedText() )->getFullURL();
505504 $commands['split'] = array( 'label' => wfMsgExt( 'lqt-thread-split', 'parseinline' ),
506505 'href' => $splitUrl, 'enabled' => true );
507506 }
508 -
 507+
509508 if ( $this->user->isAllowed( 'lqt-merge' ) ) {
510509 $mergeParams = $_GET;
511510 $mergeParams['lqt_merge_from'] = $thread->id();
512 -
513 - unset($mergeParams['title']);
514 -
 511+
 512+ unset( $mergeParams['title'] );
 513+
515514 $mergeUrl = $this->title->getFullURL( wfArrayToCGI( $mergeParams ) );
516515 $label = wfMsgExt( 'lqt-thread-merge', 'parseinline' );
517 -
 516+
518517 $commands['merge'] = array( 'label' => $label,
519518 'href' => $mergeUrl, 'enabled' => true );
520519 }
521520
522521 return $commands;
523522 }
524 -
 523+
525524 // Commands for the bottom.
526525 function threadMajorCommands( $thread ) {
527526 wfLoadExtensionMessages( 'LiquidThreads' );
528 -
529 - if ($thread->isHistorical() ) {
 527+
 528+ if ( $thread->isHistorical() ) {
530529 // No links for historical threads.
531530 return array();
532531 }
533 -
 532+
534533 $commands = array();
535 -
 534+
536535 if ( $this->user->isAllowed( 'lqt-merge' ) &&
537536 $this->request->getCheck( 'lqt_merge_from' ) ) {
538537 $srcThread = Threads::withId( $this->request->getVal( 'lqt_merge_from' ) );
539538 $par = $srcThread->title()->getPrefixedText();
540539 $mergeTitle = SpecialPage::getTitleFor( 'MergeThread', $par );
541 - $mergeUrl = $mergeTitle->getFullURL( 'dest='.$thread->id() );
 540+ $mergeUrl = $mergeTitle->getFullURL( 'dest=' . $thread->id() );
542541 $label = wfMsgExt( 'lqt-thread-merge-to', 'parseinline' );
543 -
 542+
544543 $commands['merge-to'] = array( 'label' => $label, 'href' => $mergeUrl,
545544 'enabled' => true, 'tooltip' => $label );
546545 }
547 -
 546+
548547 $commands['reply'] = array( 'label' => wfMsgExt( 'lqt_reply', 'parseinline' ),
549548 'href' => $this->talkpageUrl( $this->title, 'reply', $thread ),
550549 'enabled' => true, 'icon' => 'reply.png', 'showlabel' => 1,
551550 'tooltip' => wfMsg( 'lqt_reply' ) );
552 -
 551+
553552 $commands['link'] = array( 'label' => wfMsgExt( 'lqt_permalink', 'parseinline' ),
554553 'href' => $thread->title()->getFullURL(),
555554 'enabled' => true, 'icon' => 'link.png',
556555 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' ) );
557 -
 556+
558557 if ( $thread->root()->getTitle()->quickUserCan( 'edit' ) ) {
559558 $commands['edit'] = array( 'label' => wfMsgExt( 'edit', 'parseinline' ),
560559 'href' => $this->talkpageUrl( $this->title, 'edit', $thread ),
561560 'enabled' => true, 'icon' => 'edit.png',
562561 'tooltip' => wfMsgExt( 'edit', 'parseinline' ) );
563562 }
564 -
 563+
565564 return $commands;
566565 }
567566
@@ -568,33 +567,41 @@
569568 wfLoadExtensionMessages( 'LiquidThreads' );
570569 $commands = array();
571570
572 - $commands['history'] = array( 'label' => wfMsg( 'history_short' ),
573 - 'href' => self::permalinkUrl( $thread, 'thread_history' ),
574 - 'enabled' => true );
 571+ $commands['history'] = array(
 572+ 'label' => wfMsg( 'history_short' ),
 573+ 'href' => self::permalinkUrl( $thread, 'thread_history' ),
 574+ 'enabled' => true
 575+ );
575576
576577 if ( in_array( 'move', $this->user->getRights() ) ) {
577578 $move_href = SpecialPage::getTitleFor( 'MoveThread' )->getFullURL()
578579 . '/' . $thread->title()->getPrefixedURL();
579 - $commands['move'] = array( 'label' => wfMsg( 'move' ),
580 - 'href' => $move_href,
581 - 'enabled' => true );
 580+ $commands['move'] = array(
 581+ 'label' => wfMsg( 'move' ),
 582+ 'href' => $move_href,
 583+ 'enabled' => true
 584+ );
582585 }
583586 if ( !$this->user->isAnon() && !$thread->title()->userIsWatching() ) {
584 - $commands['watch'] = array( 'label' => wfMsg( 'watch' ),
585 - 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ),
586 - 'enabled' => true );
 587+ $commands['watch'] = array(
 588+ 'label' => wfMsg( 'watch' ),
 589+ 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ),
 590+ 'enabled' => true
 591+ );
587592 } else if ( !$this->user->isAnon() ) {
588 - $commands['unwatch'] = array( 'label' => wfMsg( 'unwatch' ),
589 - 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ),
590 - 'enabled' => true );
 593+ $commands['unwatch'] = array(
 594+ 'label' => wfMsg( 'unwatch' ),
 595+ 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ),
 596+ 'enabled' => true
 597+ );
591598 }
592 -
 599+
593600 $summarizeUrl = self::permalinkUrl( $thread, 'summarize', $thread->id() );
594601 $commands['summarize'] = array(
595 - 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ),
596 - 'href' => $summarizeUrl,
597 - 'enabled' => true,
598 - );
 602+ 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ),
 603+ 'href' => $summarizeUrl,
 604+ 'enabled' => true,
 605+ );
599606
600607 return $commands;
601608 }
@@ -606,38 +613,38 @@
607614 static function addJSandCSS() {
608615 // Changed this to be static so that we can call it from
609616 // wfLqtBeforeWatchlistHook.
610 -
 617+
611618 if ( self::$stylesAndScriptsDone ) {
612619 return;
613620 }
614 -
 621+
615622 global $wgOut;
616623 global $wgScriptPath, $wgStyleVersion;
617624 global $wgEnableJS2system;
618625
619626 $wgOut->addInlineScript( 'var wgLqtMessages = ' . self::exportJSLocalisation() . ';' );
620 -
621 - if (!$wgEnableJS2system) {
 627+
 628+ if ( !$wgEnableJS2system ) {
622629 $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/js2.combined.js" );
623630 }
624 -
 631+
625632 $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/lqt.js" );
626633 $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/LiquidThreads/lqt.css?{$wgStyleVersion}" );
627 -
 634+
628635 self::$stylesAndScriptsDone = true;
629636 }
630 -
 637+
631638 static function exportJSLocalisation() {
632639 wfLoadExtensionMessages( 'LiquidThreads' );
633 -
 640+
634641 $messages = array( 'lqt-quote-intro', 'lqt-quote', 'lqt-ajax-updated',
635642 'lqt-ajax-update-link' );
636643 $data = array();
637 -
638 - foreach( $messages as $msg ) {
 644+
 645+ foreach ( $messages as $msg ) {
639646 $data[$msg] = wfMsgNoTrans( $msg );
640647 }
641 -
 648+
642649 return json_encode( $data );
643650 }
644651
@@ -647,65 +654,83 @@
648655 * $post->getParserOutput. */
649656 function showPostBody( $post, $oldid = null ) {
650657 global $wgOut;
651 -
 658+
652659 // Load compatibility layer for older versions
653 - if ( !($post instanceof Article_LQT_Compat) ) {
 660+ if ( !( $post instanceof Article_LQT_Compat ) ) {
654661 wfWarn( "No article compatibility layer loaded, inefficiently duplicating information." );
655662 $post = new Article_LQT_Compat( $post->getTitle() );
656663 }
657 -
 664+
658665 $parserOutput = $post->getParserOutput( $oldid );
659666 $wgOut->addParserOutputNoText( $parserOutput );
660 -
 667+
661668 return $parserOutput->getText();
662669 }
663 -
 670+
664671 function showThreadToolbar( $thread ) {
665672 global $wgLang;
666 -
 673+
667674 $sk = $this->user->getSkin();
668675 $html = '';
669676
670677 $headerParts = array();
671 -
672 - foreach( $this->threadMajorCommands( $thread ) as $key => $cmd ) {
 678+
 679+ foreach ( $this->threadMajorCommands( $thread ) as $key => $cmd ) {
673680 $content = $this->contentForCommand( $cmd, false /* No icon divs */ );
674 - $headerParts[] = Xml::tags( 'li',
675 - array( 'class' => "lqt-command lqt-command-$key" ),
676 - $content );
 681+ $headerParts[] = Xml::tags(
 682+ 'li',
 683+ array( 'class' => "lqt-command lqt-command-$key" ),
 684+ $content
 685+ );
677686 }
678 -
 687+
679688 // Drop-down menu
680689 $commands = $this->threadCommands( $thread );
681 - $menuHTML = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-command-list'),
682 - $this->listItemsForCommands( $commands ) );
683 -
684 - $triggerText = Xml::tags( 'span', array('class' => 'lqt-thread-actions-icon'),
685 - '&nbsp;');
686 - $dropDownTrigger = Xml::tags( 'div',
687 - array( 'class' => 'lqt-thread-actions-trigger '.
688 - 'lqt-command-icon', 'style' => 'display: none;'),
689 - $triggerText );
690 - $headerParts[] = Xml::tags( 'li',
691 - array( 'class' => 'lqt-thread-toolbar-menu' ),
692 - $dropDownTrigger );
693 -
 690+ $menuHTML = Xml::tags(
 691+ 'ul',
 692+ array( 'class' => 'lqt-thread-toolbar-command-list' ),
 693+ $this->listItemsForCommands( $commands )
 694+ );
 695+
 696+ $triggerText = Xml::tags(
 697+ 'span',
 698+ array( 'class' => 'lqt-thread-actions-icon' ),
 699+ '&nbsp;'
 700+ );
 701+ $dropDownTrigger = Xml::tags(
 702+ 'div',
 703+ array(
 704+ 'class' => 'lqt-thread-actions-trigger ' .
 705+ 'lqt-command-icon', 'style' => 'display: none;'
 706+ ),
 707+ $triggerText
 708+ );
 709+ $headerParts[] = Xml::tags(
 710+ 'li',
 711+ array( 'class' => 'lqt-thread-toolbar-menu' ),
 712+ $dropDownTrigger
 713+ );
 714+
694715 $html .= implode( ' ', $headerParts );
695 -
 716+
696717 $html = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-commands' ), $html );
697718 $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0;' ), '&nbsp;' );
698 -
 719+
699720 // Box stuff
700 - $boxElements = array( 'lqt-thread-toolbar-box-tl', 'lqt-thread-toolbar-box-tr',
701 - 'lqt-thread-toolbar-box-br', 'lqt-thread-toolbar-box-bl' );
702 - foreach( $boxElements as $class ) {
 721+ $boxElements = array(
 722+ 'lqt-thread-toolbar-box-tl',
 723+ 'lqt-thread-toolbar-box-tr',
 724+ 'lqt-thread-toolbar-box-br',
 725+ 'lqt-thread-toolbar-box-bl'
 726+ );
 727+ foreach ( $boxElements as $class ) {
703728 $html = Xml::openElement( 'div', array( 'class' => $class ) ) . $html .
704729 Xml::closeElement( 'div' );
705730 }
706 -
 731+
707732 $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-toolbar' ), $html ) .
708733 $menuHTML;
709 -
 734+
710735 return $html;
711736 }
712737
@@ -713,55 +738,72 @@
714739 $result = array();
715740 foreach ( $commands as $key => $command ) {
716741 $thisCommand = $this->contentForCommand( $command );
717 -
718 - $thisCommand = Xml::tags( 'li',
719 - array( 'class' => 'lqt-command lqt-command-'.$key ),
720 - $thisCommand );
721 -
 742+
 743+ $thisCommand = Xml::tags(
 744+ 'li',
 745+ array( 'class' => 'lqt-command lqt-command-' . $key ),
 746+ $thisCommand
 747+ );
 748+
722749 $result[] = $thisCommand;
723750 }
724751 return join( ' ', $result );
725752 }
726 -
 753+
727754 function contentForCommand( $command, $icon_divs = true ) {
728755 $label = $command['label'];
729756 $href = $command['href'];
730757 $enabled = $command['enabled'];
731 - $tooltip = isset($command['tooltip']) ? $command['tooltip'] : '';
732 -
 758+ $tooltip = isset( $command['tooltip'] ) ? $command['tooltip'] : '';
 759+
733760 if ( isset( $command['icon'] ) ) {
734761 global $wgScriptPath;
735 - $icon = Xml::tags( 'div', array( 'title' => $label,
736 - 'class' => 'lqt-command-icon' ), '&nbsp;' );
737 - if ($icon_divs) {
738 - if ( !empty($command['showlabel']) ) {
739 - $label = $icon.'&nbsp;'.$label;
 762+ $icon = Xml::tags(
 763+ 'div',
 764+ array(
 765+ 'title' => $label,
 766+ 'class' => 'lqt-command-icon'
 767+ ),
 768+ '&nbsp;'
 769+ );
 770+ if ( $icon_divs ) {
 771+ if ( !empty( $command['showlabel'] ) ) {
 772+ $label = $icon . '&nbsp;' . $label;
740773 } else {
741774 $label = $icon;
742775 }
743776 } else {
744 - if ( empty($command['showlabel']) ) {
 777+ if ( empty( $command['showlabel'] ) ) {
745778 $label = '';
746779 }
747780 }
748781 }
749 -
 782+
750783 $thisCommand = '';
751 -
 784+
752785 if ( $enabled ) {
753 - $thisCommand = Xml::tags( 'a', array( 'href' => $href, 'title' => $tooltip ),
754 - $label );
 786+ $thisCommand = Xml::tags(
 787+ 'a',
 788+ array( 'href' => $href, 'title' => $tooltip ),
 789+ $label
 790+ );
755791 } else {
756 - $thisCommand = Xml::tags( 'span', array( 'class' => 'lqt_command_disabled',
757 - 'title' => $tooltip), $label );
 792+ $thisCommand = Xml::tags(
 793+ 'span',
 794+ array(
 795+ 'class' => 'lqt_command_disabled',
 796+ 'title' => $tooltip
 797+ ),
 798+ $label
 799+ );
758800 }
759 -
 801+
760802 return $thisCommand;
761803 }
762804
763805 /** Shows a normal (i.e. not deleted or moved) thread body */
764806 function showThreadBody( $thread ) {
765 -
 807+
766808 // Remove 'editsection', it won't work.
767809 $popts = $this->output->parserOptions();
768810 $previous_editsection = $popts->getEditSection();
@@ -769,7 +811,7 @@
770812 $this->output->parserOptions( $popts );
771813
772814 $post = $thread->root();
773 -
 815+
774816 $divClass = $this->postDivClass( $thread );
775817 $html = '';
776818
@@ -789,7 +831,7 @@
790832 $html = Xml::openElement( 'div', array( 'class' => $divClass ) );
791833 $this->output->addHTML( $html );
792834 $html = '';
793 -
 835+
794836 // No way am I refactoring EditForm to send its output as HTML.
795837 // so I'm just flushing the HTML and displaying it as-is.
796838 $this->showPostEditingForm( $thread );
@@ -800,8 +842,8 @@
801843 $html .= $this->showPostBody( $post, $oldid );
802844 $html .= Xml::closeElement( 'div' );
803845 $html .= $this->threadSignature( $thread );
804 - }
805 -
 846+ }
 847+
806848 // If we're replying to this thread, show the reply form after it.
807849 if ( $this->methodAppliesToThread( 'reply', $thread ) ) {
808850 // As with above, flush HTML to avoid refactoring EditPage.
@@ -809,60 +851,69 @@
810852 $this->showReplyForm( $thread );
811853 $html = '';
812854 } else {
813 - $html .= Xml::tags( 'div',
814 - array( 'class' => 'lqt-reply-form lqt-edit-form',
815 - 'style' => 'display: none;' ),
816 - '' );
 855+ $html .= Xml::tags(
 856+ 'div',
 857+ array(
 858+ 'class' => 'lqt-reply-form lqt-edit-form',
 859+ 'style' => 'display: none;'
 860+ ),
 861+ ''
 862+ );
817863 }
818 -
 864+
819865 $this->output->addHTML( $html );
820866
821867 $popts->setEditSection( $previous_editsection );
822868 $this->output->parserOptions( $popts );
823869 }
824 -
 870+
825871 function threadSignature( $thread ) {
826872 global $wgUser;
827873 $sk = $wgUser->getSkin();
828 -
 874+
829875 $author = $thread->author();
830876 $signature = $sk->userLink( $author->getId(), $author->getName() );
831 - $signature = '&mdash; '. Xml::tags( 'span', array( 'class' => 'lqt-thread-author' ),
 877+ $signature = '&mdash; ' . Xml::tags( 'span', array( 'class' => 'lqt-thread-author' ),
832878 $signature );
833879 $signature .= $sk->userToolLinks( $author->getId(), $author->getName() );
834 -
 880+
835881 $signature = Xml::tags( 'div', array( 'class' => 'lqt-thread-signature' ),
836882 $signature );
837 -
 883+
838884 return $signature;
839885 }
840 -
 886+
841887 function threadInfoPanel( $thread ) {
842888 global $wgUser, $wgLang;
843 -
 889+
844890 $sk = $wgUser->getSkin();
845 -
 891+
846892 $infoElements = array();
847 -
 893+
848894 $timestamp = $wgLang->timeanddate( $thread->created(), true );
849895 $infoElements[] = Xml::element( 'div', array( 'class' => 'lqt-thread-toolbar-timestamp' ),
850896 $timestamp );
851 -
 897+
852898 // Check for edited flag.
853 - $editedFlag = $thread->editedness();
 899+ $editedFlag = $thread->editedness();
854900 $ebLookup = array( Threads::EDITED_BY_AUTHOR => 'author',
855901 Threads::EDITED_BY_OTHERS => 'others' );
856902 if ( isset( $ebLookup[$editedFlag] ) ) {
857903
858904 $editedBy = $ebLookup[$editedFlag];
859 - $editedNotice = wfMsgExt( 'lqt-thread-edited-'.$editedBy, 'parseinline' );
860 - $infoElements[] = Xml::element( 'div', array( 'class' =>
861 - 'lqt-thread-toolbar-edited-'.$editedBy ),
862 - $editedNotice );
 905+ $editedNotice = wfMsgExt( 'lqt-thread-edited-' . $editedBy, 'parseinline' );
 906+ $infoElements[] = Xml::element(
 907+ 'div',
 908+ array( 'class' => 'lqt-thread-toolbar-edited-' . $editedBy ),
 909+ $editedNotice
 910+ );
863911 }
864 -
865 - return Xml::tags( 'div', array( 'class' => 'lqt-thread-info-panel' ),
866 - implode( "\n", $infoElements ) );
 912+
 913+ return Xml::tags(
 914+ 'div',
 915+ array( 'class' => 'lqt-thread-info-panel' ),
 916+ implode( "\n", $infoElements )
 917+ );
867918 }
868919
869920 /** Shows the headING for a thread (as opposed to the headeER for a post within
@@ -873,53 +924,57 @@
874925 $commands_html = "";
875926 } else {
876927 $lis = $this->listItemsForCommands( $this->topLevelThreadCommands( $thread ) );
877 - $commands_html = Xml::tags( 'ul',
878 - array( 'class' => 'lqt_threadlevel_commands' ),
879 - $lis );
 928+ $commands_html = Xml::tags(
 929+ 'ul',
 930+ array( 'class' => 'lqt_threadlevel_commands' ),
 931+ $lis
 932+ );
880933 }
881 -
882 - $id = 'lqt-header-'.$thread->id();
883934
 935+ $id = 'lqt-header-' . $thread->id();
 936+
884937 $html = $this->output->parseInline( $thread->subjectWithoutIncrement() );
885938 $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html );
886 - $html = Xml::tags( 'h'.$this->headerLevel,
887 - array( 'class' => 'lqt_header', 'id' => $id),
888 - $html ) . $commands_html;
889 -
 939+ $html = Xml::tags(
 940+ 'h' . $this->headerLevel,
 941+ array( 'class' => 'lqt_header', 'id' => $id ),
 942+ $html
 943+ ) . $commands_html;
 944+
890945 return $html;
891946 }
892 -
 947+
893948 return '';
894949 }
895950
896951 function postDivClass( $thread ) {
897 - $levelClass = 'lqt-thread-nest-'.$this->threadNestingLevel;
898 - $alternatingType = ($this->threadNestingLevel % 2) ? 'odd' : 'even';
 952+ $levelClass = 'lqt-thread-nest-' . $this->threadNestingLevel;
 953+ $alternatingType = ( $this->threadNestingLevel % 2 ) ? 'odd' : 'even';
899954 $alternatingClass = "lqt-thread-$alternatingType";
900 -
 955+
901956 return "lqt_post $levelClass $alternatingClass";
902957 }
903958
904959 static function anchorName( $thread ) {
905960 return $thread->getAnchorName();
906961 }
907 -
 962+
908963 // Display a moved thread
909964 function showMovedThread( $thread ) {
910965 global $wgLang;
911 -
 966+
912967 $sk = $this->user->getSkin();
913 -
 968+
914969 // Grab target thread
915970 $article = new Article( $thread->title() );
916971 $target = Title::newFromRedirect( $article->getContent() );
917972 $t_thread = Threads::withRoot( new Article( $target ) );
918 -
 973+
919974 // Grab data about the new post.
920975 $author = $thread->author();
921976 $sig = $sk->userLink( $author->getID(), $author->getName() ) .
922977 $sk->userToolLinks( $author->getID(), $author->getName() );
923 -
 978+
924979 $html =
925980 wfMsgExt( 'lqt_move_placeholder', array( 'parseinline', 'replaceafter' ),
926981 $sk->link( $target ),
@@ -927,10 +982,10 @@
928983 $wgLang->date( $thread->modified() ),
929984 $wgLang->time( $thread->modified() )
930985 );
931 -
 986+
932987 $this->output->addHTML( $html );
933988 }
934 -
 989+
935990 /** Shows a deleted thread. Returns true to show the thread body */
936991 function showDeletedThread( $thread ) {
937992 $sk = $this->user->getSkin();
@@ -946,216 +1001,233 @@
9471002 return false;
9481003 }
9491004 }
950 -
 1005+
9511006 // Shows a single thread, rather than a thread tree.
9521007 function showSingleThread( $thread ) {
9531008 wfLoadExtensionMessages( 'LiquidThreads' );
954 -
 1009+
9551010 $html = '';
956 -
 1011+
9571012 // If it's a 'moved' thread, show the placeholder
9581013 if ( $thread->type() == Threads::TYPE_MOVED ) {
9591014 $this->showMovedThread( $thread );
9601015 return;
9611016 } elseif ( $thread->type() == Threads::TYPE_DELETED ) {
9621017 $res = $this->showDeletedThread( $thread );
963 -
964 - if (!$res) return;
 1018+
 1019+ if ( !$res ) return;
9651020 }
966 -
 1021+
9671022 $this->output->addHTML( $this->threadInfoPanel( $thread ) );
968 -
 1023+
9691024 if ( $thread->summary() ) {
9701025 $html .= $this->getSummary( $thread );
9711026 }
972 -
 1027+
9731028 // Unfortunately, I can't rewrite showRootPost() to pass back HTML
9741029 // as it would involve rewriting EditPage, which I do NOT intend to do.
9751030
9761031 $this->output->addHTML( $html );
977 -
 1032+
9781033 $this->showThreadBody( $thread );
979 -
 1034+
9801035 }
9811036
9821037 function showThread( $thread, $levelNum = 1, $totalInLevel = 1, $options = array() ) {
9831038 global $wgLang;
984 -
 1039+
9851040 // Safeguard
9861041 if ( $thread->type() == Threads::TYPE_DELETED
987 - && ! ($this->request->getBool( 'lqt_show_deleted_threads' )
 1042+ && ! ( $this->request->getBool( 'lqt_show_deleted_threads' )
9881043 && $this->user->isAllowed( 'deletedhistory' ) ) ) {
9891044 return;
9901045 }
991 -
 1046+
9921047 $this->threadNestingLevel++;
993 -
 1048+
9941049 // Figure out which threads *need* to be shown because they're involved in an
9951050 // operation
9961051 static $mustShowThreads = null; // Array of thread IDs
997 - if ( is_null($mustShowThreads) ) {
 1052+ if ( is_null( $mustShowThreads ) ) {
9981053 $mustShowThreads = array();
9991054 if ( $this->request->getVal( 'lqt_operand' ) ) {
10001055 $walk_thread = Threads::withId( $this->request->getVal( 'lqt_operand' ) );
1001 -
 1056+
10021057 do {
10031058 $mustShowThreads[$walk_thread->id()] = $walk_thread;
10041059 $walk_thread = $walk_thread->superthread();
10051060 } while ( $walk_thread );
10061061 }
10071062 }
1008 -
 1063+
10091064 $sk = $this->user->getSkin();
1010 -
 1065+
10111066 $html = '';
10121067
1013 - $html .= Xml::element( 'a', array( 'name' => $this->anchorName($thread) ), ' ' );
 1068+ $html .= Xml::element( 'a', array( 'name' => $this->anchorName( $thread ) ), ' ' );
10141069
10151070 $html .= $this->showThreadHeading( $thread );
1016 -
 1071+
10171072 $class = $this->threadDivClass( $thread );
1018 - if ($levelNum == 1) {
 1073+ if ( $levelNum == 1 ) {
10191074 $class .= ' lqt-thread-first';
1020 - } elseif ($levelNum == $totalInLevel) {
 1075+ } elseif ( $levelNum == $totalInLevel ) {
10211076 $class .= ' lqt-thread-last';
10221077 }
1023 -
1024 - $html .= Xml::openElement( 'div', array( 'class' => $class,
1025 - 'id' => 'lqt_thread_id_'. $thread->id() ) );
10261078
 1079+ $html .= Xml::openElement(
 1080+ 'div',
 1081+ array(
 1082+ 'class' => $class,
 1083+ 'id' => 'lqt_thread_id_' . $thread->id()
 1084+ )
 1085+ );
 1086+
10271087 // Modified time for topmost threads...
10281088 if ( $thread->isTopmostThread() ) {
1029 - $html .= Xml::hidden( 'lqt-thread-modified-'.$thread->id(),
1030 - wfTimestamp( TS_MW, $thread->modified() ),
1031 - array( 'id' => 'lqt-thread-modified-'.$thread->id(),
1032 - 'class' => 'lqt-thread-modified' ) );
1033 - }
 1089+ $html .= Xml::hidden('lqt-thre
 1090+ ad-modified-' . $thread->id(),
 1091+ wfTimestamp( TS_MW, $thread->modified() ),
 1092+ array(
 1093+ 'id' => 'lqt-thread-modified-' . $thread->id(),
 1094+ 'class' => 'lqt-thread-modified'
 1095+ )
 1096+ );
 1097+ }
10341098
10351099 // Flush output to display thread
10361100 $this->output->addHTML( $html );
1037 - $this->output->addHTML( Xml::openElement( 'div',
1038 - array( 'class' => 'lqt-post-wrapper' ) ) );
 1101+ $this->output->addHTML( Xml::openElement(
 1102+ 'div',
 1103+ array( 'class' => 'lqt-post-wrapper' )
 1104+ ) );
10391105 $this->showSingleThread( $thread );
10401106 $this->output->addHTML( Xml::closeElement( 'div' ) );
10411107
10421108 // Check depth and count
1043 - if ( isset($options['maxDepth']) ) {
 1109+ if ( isset( $options['maxDepth'] ) ) {
10441110 $maxDepth = $options['maxDepth'];
10451111 } else {
10461112 $maxDepth = $this->user->getOption( 'lqtdisplaydepth' );
10471113 }
1048 -
1049 - if ( isset($options['maxCount']) ) {
 1114+
 1115+ if ( isset( $options['maxCount'] ) ) {
10501116 $maxCount = $options['maxCount'];
10511117 } else {
10521118 $maxCount = $this->user->getOption( 'lqtdisplaycount' );
10531119 }
1054 -
 1120+
10551121 if ( isset( $options['startAt'] ) ) {
10561122 $startAt = $options['startAt'];
10571123 } else {
10581124 $startAt = 0;
10591125 }
1060 -
 1126+
10611127 $cascadeOptions = $options;
1062 - unset($cascadeOptions['startAt']);
1063 -
1064 - $showThreads = ($maxDepth == -1) || ( $this->threadNestingLevel <= $maxDepth );
1065 -
 1128+ unset( $cascadeOptions['startAt'] );
 1129+
 1130+ $showThreads = ( $maxDepth == - 1 ) || ( $this->threadNestingLevel <= $maxDepth );
 1131+
10661132 // Show subthreads if one of the subthreads is on the must-show list
10671133 $showThreads = $showThreads ||
1068 - count( array_intersect( array_keys($mustShowThreads), array_keys( $thread->replies() ) ) );
 1134+ count( array_intersect( array_keys( $mustShowThreads ), array_keys( $thread->replies() ) ) );
10691135 if ( $thread->hasSubthreads() && $showThreads ) {
1070 - $repliesClass = 'lqt-thread-replies lqt-thread-replies-'.$this->threadNestingLevel;
 1136+ $repliesClass = 'lqt-thread-replies lqt-thread-replies-' . $this->threadNestingLevel;
10711137 $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) );
10721138 $this->output->addHTML( $div );
1073 -
 1139+
10741140 $subthreadCount = count( $thread->subthreads() );
10751141 $i = 0;
10761142 $showCount = 0;
10771143 $showThreads = true;
1078 -
 1144+
10791145 foreach ( $thread->subthreads() as $st ) {
10801146 ++$i;
1081 -
 1147+
10821148 // Only show undeleted threads that are above our 'startAt' index.
10831149 $shown = false;
1084 - if ($st->type() != Threads::TYPE_DELETED && $i >= $startAt && $showThreads) {
1085 - if ($showCount > $maxCount && $maxCount > 0) {
 1150+ if ( $st->type() != Threads::TYPE_DELETED && $i >= $startAt && $showThreads ) {
 1151+ if ( $showCount > $maxCount && $maxCount > 0 ) {
10861152 // We've shown too many threads.
10871153 $linkText = wfMsgExt( 'lqt-thread-show-more', 'parseinline' );
10881154 $linkTitle = clone $thread->topmostThread()->title();
1089 - $linkTitle->setFragment( '#'.$st->getAnchorName() );
1090 -
1091 - $link = $sk->link( $linkTitle, $linkText,
1092 - array( 'class' => 'lqt-show-more-posts' ) );
1093 - $link .= Xml::hidden( 'lqt-thread-start-at', $i,
1094 - array( 'class' => 'lqt-thread-start-at' ) );
1095 -
 1155+ $linkTitle->setFragment( '#' . $st->getAnchorName() );
 1156+
 1157+ $link = $sk->link(
 1158+ $linkTitle,
 1159+ $linkText,
 1160+ array( 'class' => 'lqt-show-more-posts' )
 1161+ );
 1162+ $link .= Xml::hidden(
 1163+ 'lqt-thread-start-at',
 1164+ $i,
 1165+ array( 'class' => 'lqt-thread-start-at' )
 1166+ );
 1167+
10961168 $this->output->addHTML( $link );
10971169 $showThreads = false;
10981170 continue;
10991171 }
1100 -
 1172+
11011173 ++$showCount;
1102 - if ($showCount == 1 ) {
 1174+ if ( $showCount == 1 ) {
11031175 $this->output->addHTML(
11041176 Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&nbsp;' ) );
11051177 }
1106 -
 1178+
11071179 $this->showThread( $st, $i, $subthreadCount, $cascadeOptions );
11081180 $shown = true;
11091181 }
1110 -
1111 - if ($st->type() != Threads::TYPE_DELETED && !$shown &&
 1182+
 1183+ if ( $st->type() != Threads::TYPE_DELETED && !$shown &&
11121184 array_key_exists( $st->id(), $mustShowThreads ) ) {
1113 -
 1185+
11141186 $this->showThread( $st, $i, $subthreadCount, $cascadeOptions );
11151187 }
11161188 }
1117 -
 1189+
11181190 $finishDiv = Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ),
11191191 Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), '&nbsp;' ) );
1120 -
 1192+
11211193 $this->output->addHTML( $finishDiv . Xml::CloseElement( 'div' ) );
11221194 } elseif ( $thread->hasSubthreads() && !$showThreads ) {
11231195 // Add a "show subthreads" link.
1124 - $replies = count($thread->replies());
1125 - $linkText = wfMsgExt( 'lqt-thread-show-replies', 'parseinline', $wgLang->formatNum($replies) );
 1196+ $replies = count( $thread->replies() );
 1197+ $linkText = wfMsgExt( 'lqt-thread-show-replies', 'parseinline', $wgLang->formatNum( $replies ) );
11261198 $linkTitle = clone $thread->topmostThread()->title();
1127 - $linkTitle->setFragment( '#'.$thread->getAnchorName() );
1128 -
 1199+ $linkTitle->setFragment( '#' . $thread->getAnchorName() );
 1200+
11291201 $link = $sk->link( $linkTitle, $linkText, array( 'class' => 'lqt-show-replies' ) );
1130 -
 1202+
11311203 $this->output->addHTML( Xml::tags( 'div', array( 'class' => 'lqt-thread-replies' ), $link ) );
1132 -
1133 - if ($levelNum < $totalInLevel) {
 1204+
 1205+ if ( $levelNum < $totalInLevel ) {
11341206 $this->output->addHTML(
11351207 Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&nbsp;' ) );
11361208 }
1137 - } elseif ($levelNum < $totalInLevel) {
 1209+ } elseif ( $levelNum < $totalInLevel ) {
11381210 $this->output->addHTML(
11391211 Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&nbsp;' ) );
11401212 }
11411213
1142 - if ($this->threadNestingLevel == 1) {
 1214+ if ( $this->threadNestingLevel == 1 ) {
11431215 $finishDiv = Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ),
11441216 Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), '&nbsp;' ) );
1145 -
 1217+
11461218 $this->output->addHTML( $finishDiv );
11471219 }
11481220
11491221 $this->output->addHTML( Xml::closeElement( 'div' ) );
1150 -
 1222+
11511223 $this->threadNestingLevel--;
11521224 }
1153 -
 1225+
11541226 function threadDivClass( $thread ) {
1155 - $levelClass = 'lqt-thread-nest-'.$this->threadNestingLevel;
1156 - $alternatingType = ($this->threadNestingLevel % 2) ? 'odd' : 'even';
 1227+ $levelClass = 'lqt-thread-nest-' . $this->threadNestingLevel;
 1228+ $alternatingType = ( $this->threadNestingLevel % 2 ) ? 'odd' : 'even';
11571229 $alternatingClass = "lqt-thread-$alternatingType";
11581230 $topmostClass = $thread->isTopmostThread() ? ' lqt-thread-topmost' : '';
1159 -
 1231+
11601232 return "lqt_thread $levelClass $alternatingClass$topmostClass";
11611233 }
11621234
@@ -1165,32 +1237,42 @@
11661238 wfLoadExtensionMessages( 'LiquidThreads' );
11671239 global $wgUser;
11681240 $sk = $wgUser->getSkin();
1169 -
 1241+
11701242 $label = wfMsgExt( 'lqt_summary_label', 'parseinline' );
11711243 $edit_text = wfMsgExt( 'edit', 'parseinline' );
11721244 $link_text = wfMsg( 'lqt_permalink', 'parseinline' );
1173 -
 1245+
11741246 $html = '';
1175 -
 1247+
11761248 $html .= Xml::tags( 'span',
11771249 array( 'class' => 'lqt_thread_permalink_summary_title' ),
11781250 $label );
1179 -
 1251+
11801252 $link = $sk->link( $t->summary()->getTitle(), $link_text );
11811253 $edit_link = self::permalink( $t, $edit_text, 'summarize', $t->id() );
11821254 $links = "[$link]\n[$edit_link]";
1183 - $html .= Xml::tags( 'span', array( 'class' => 'lqt_thread_permalink_summary_edit' ),
1184 - $links );
1185 -
 1255+ $html .= Xml::tags(
 1256+ 'span',
 1257+ array( 'class' => 'lqt_thread_permalink_summary_edit' ),
 1258+ $links
 1259+ );
 1260+
11861261 $summary_body = $this->showPostBody( $t->summary() );
1187 - $html .= Xml::tags( 'div', array( 'class' => 'lqt_thread_permalink_summary_body' ),
1188 - $summary_body );
1189 -
1190 - $html = Xml::tags( 'div', array( 'class' => 'lqt_thread_permalink_summary' ), $html );
1191 -
 1262+ $html .= Xml::tags(
 1263+ 'div',
 1264+ array( 'class' => 'lqt_thread_permalink_summary_body' ),
 1265+ $summary_body
 1266+ );
 1267+
 1268+ $html = Xml::tags(
 1269+ 'div',
 1270+ array( 'class' => 'lqt_thread_permalink_summary' ),
 1271+ $html
 1272+ );
 1273+
11921274 return $html;
11931275 }
1194 -
 1276+
11951277 function showSummary( $t ) {
11961278 $this->output->addHTML( $this->getSummary( $t ) );
11971279 }
Index: trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php
@@ -5,23 +5,20 @@
66
77 function getFormFields() {
88 $splitForm = array(
9 - 'src' =>
10 - array(
11 - 'type' => 'info',
12 - 'label-message' => 'lqt-thread-split-thread',
13 - 'default' => LqtView::permalink( $this->mThread ),
14 - 'raw' => 1,
15 - ),
16 - 'subject' =>
17 - array(
18 - 'type' => 'text',
19 - 'label-message' => 'lqt-thread-split-subject',
20 - ),
21 - 'reason' =>
22 - array(
23 - 'label-message' => 'movereason',
24 - 'type' => 'text',
25 - ),
 9+ 'src' => array(
 10+ 'type' => 'info',
 11+ 'label-message' => 'lqt-thread-split-thread',
 12+ 'default' => LqtView::permalink( $this->mThread ),
 13+ 'raw' => 1,
 14+ ),
 15+ 'subject' => array(
 16+ 'type' => 'text',
 17+ 'label-message' => 'lqt-thread-split-subject',
 18+ ),
 19+ 'reason' => array(
 20+ 'label-message' => 'movereason',
 21+ 'type' => 'text',
 22+ )
2623 );
2724
2825 return $splitForm;
@@ -53,13 +50,16 @@
5451 $this->mThread->commitRevision( Threads::CHANGE_SPLIT, null, $reason );
5552
5653 $title = clone $this->mThread->article()->getTitle();
57 - $title->setFragment( '#'.$this->mThread->getAnchorName() );
 54+ $title->setFragment( '#' . $this->mThread->getAnchorName() );
5855
5956 $link = $this->user->getSkin()->link( $title, $this->mThread->subject() );
6057
6158 global $wgOut;
62 - $wgOut->addHTML( wfMsgExt( 'lqt-split-success', array( 'parseinline', 'replaceafter' ),
63 - $link ) );
 59+ $wgOut->addHTML( wfMsgExt(
 60+ 'lqt-split-success',
 61+ array( 'parseinline', 'replaceafter' ),
 62+ $link )
 63+ );
6464
6565 return true;
6666 }
@@ -68,19 +68,19 @@
6969 $thread->setSubject( $subject );
7070 $thread->setAncestor( $ancestor->id() );
7171
72 - if ($first) {
 72+ if ( $first ) {
7373 $thread->setSuperThread( null );
7474 }
7575
7676 $thread->save( );
7777
78 - foreach( $thread->replies() as $subThread ) {
 78+ foreach ( $thread->replies() as $subThread ) {
7979 $this->recursiveSet( $subThread, $subject, $ancestor );
8080 }
8181 }
8282
8383 function validateSubject( $target ) {
84 - if (!$target) {
 84+ if ( !$target ) {
8585 return wfMsgExt( 'lqt_split_nosubject', 'parseinline' );
8686 }
8787
Index: trunk/extensions/LiquidThreads/pages/SummaryPageView.php
@@ -8,12 +8,14 @@
99 $thread = Threads::withSummary( $this->article );
1010 if ( $thread ) {
1111 global $wgUser;
12 -
 12+
1313 $t = $thread->root()->getTitle();
1414 $link = $wgUser->getSkin()->link( $t );
15 - $this->output->setSubtitle(
16 - wfMsgExt( 'lqt_summary_subtitle', array( 'parseinline', 'replaceafter' ),
17 - $link ) );
 15+ $this->output->setSubtitle( wfMsgExt(
 16+ 'lqt_summary_subtitle',
 17+ array( 'parseinline', 'replaceafter' ),
 18+ $link )
 19+ );
1820 }
1921 return true;
2022 }
Index: trunk/extensions/LiquidThreads/pages/SpecialMergeThread.php
@@ -5,70 +5,66 @@
66
77 function getFormFields() {
88 $splitForm = array(
9 - 'src' =>
10 - array(
11 - 'type' => 'info',
12 - 'label-message' => 'lqt-thread-merge-source',
13 - 'default' => $this->formatThreadField( 'src', $this->mThread->id() ),
14 - 'raw' => 1,
15 - ),
16 - 'dest' =>
17 - array(
18 - 'type' => 'info',
19 - 'label-message' => 'lqt-thread-merge-dest',
20 - 'default' =>
21 - $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ),
22 - 'raw' => 1,
23 - ),
24 - 'reason' =>
25 - array(
26 - 'label-message' => 'movereason',
27 - 'type' => 'text',
28 - ),
 9+ 'src' => array(
 10+ 'type' => 'info',
 11+ 'label-message' => 'lqt-thread-merge-source',
 12+ 'default' => $this->formatThreadField( 'src', $this->mThread->id() ),
 13+ 'raw' => 1,
 14+ ),
 15+ 'dest' => array(
 16+ 'type' => 'info',
 17+ 'label-message' => 'lqt-thread-merge-dest',
 18+ 'default' => $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ),
 19+ 'raw' => 1,
 20+ ),
 21+ 'reason' => array(
 22+ 'label-message' => 'movereason',
 23+ 'type' => 'text',
 24+ )
2925 );
30 -
 26+
3127 return $splitForm;
3228 }
33 -
 29+
3430 protected function getRightRequirement() { return 'lqt-merge'; }
35 -
 31+
3632 public function checkParameters( $par ) {
3733 global $wgOut;
38 - if ( !parent::checkParameters($par) ) {
 34+ if ( !parent::checkParameters( $par ) ) {
3935 return false;
4036 }
41 -
 37+
4238 $dest = $this->request->getVal( 'dest' );
43 -
44 - if (!$dest) {
 39+
 40+ if ( !$dest ) {
4541 $wgOut->addWikiMsg( 'lqt_threadrequired' );
4642 return false;
4743 }
48 -
 44+
4945 $thread = Threads::withId( $dest );
50 -
51 - if (!$thread) {
 46+
 47+ if ( !$thread ) {
5248 $wgOut->addWikiMsg( 'lqt_nosuchthread' );
5349 return false;
5450 }
55 -
 51+
5652 $this->mDestThread = $thread;
57 -
 53+
5854 return true;
5955 }
6056
6157 function formatThreadField( $field, $threadid ) {
62 -
63 - if ( !is_object($threadid) ) {
 58+
 59+ if ( !is_object( $threadid ) ) {
6460 $t = Threads::withId( $threadid );
6561 } else {
6662 $t = $threadid;
6763 $threadid = $t->id();
6864 }
69 -
 65+
7066 $out = Xml::hidden( $field, $threadid );
7167 $out .= LqtView::permalink( $t );
72 -
 68+
7369 return $out;
7470 }
7571
@@ -79,63 +75,63 @@
8076 wfLoadExtensionMessages( 'LiquidThreads' );
8177 return wfMsg( 'lqt_merge_thread' );
8278 }
83 -
 79+
8480 function trySubmit( $data ) {
8581 // Load data
8682 $srcThread = $this->mThread;
8783 $dstThread = $this->mDestThread;
8884 $newSubject = $dstThread->subject();
8985 $reason = $data['reason'];
90 -
 86+
9187 $oldTopThread = $srcThread->topmostThread();
9288 $oldParent = $srcThread->superthread();
93 -
 89+
9490 $this->recursiveSet( $srcThread, $newSubject, $dstThread, $dstThread );
9591
9692 $dstThread->addReply( $srcThread );
97 -
98 - if ($oldParent) {
 93+
 94+ if ( $oldParent ) {
9995 $oldParent->removeReply( $srcThread );
10096 }
101 -
 97+
10298 $oldTopThread->commitRevision( Threads::CHANGE_MERGED_FROM, $srcThread, $reason );
10399 $dstThread->commitRevision( Threads::CHANGE_MERGED_TO, $srcThread, $reason );
104 -
 100+
105101 $srcTitle = clone $srcThread->article()->getTitle();
106 - $srcTitle->setFragment( '#'.$srcThread->getAnchorName() );
107 -
 102+ $srcTitle->setFragment( '#' . $srcThread->getAnchorName() );
 103+
108104 $dstTitle = clone $dstThread->article()->getTitle();
109 - $dstTitle->setFragment( '#'.$dstThread->getAnchorName() );
110 -
 105+ $dstTitle->setFragment( '#' . $dstThread->getAnchorName() );
 106+
111107 $srcLink = $this->user->getSkin()->link( $srcTitle, $srcThread->subject() );
112108 $dstLink = $this->user->getSkin()->link( $dstTitle, $dstThread->subject() );
113 -
 109+
114110 global $wgOut;
115111 $wgOut->addHTML( wfMsgExt( 'lqt-merge-success', array( 'parseinline', 'replaceafter' ),
116112 $srcLink, $dstLink ) );
117 -
 113+
118114 return true;
119115 }
120 -
 116+
121117 function recursiveSet( $thread, $subject, $ancestor, $superthread = false ) {
122118 $thread->setSubject( $subject );
123119 $thread->setAncestor( $ancestor->id() );
124 -
125 - if ($superthread) {
 120+
 121+ if ( $superthread ) {
126122 $thread->setSuperThread( $superthread );
127123 }
128 -
 124+
129125 $thread->save();
130 -
131 - foreach( $thread->replies() as $subThread ) {
 126+
 127+ foreach ( $thread->replies() as $subThread ) {
132128 $this->recursiveSet( $subThread, $subject, $ancestor );
133129 }
134130 }
135 -
 131+
136132 function getPageName() {
137133 return 'MergeThread';
138134 }
139 -
 135+
140136 function getSubmitText() {
141137 wfLoadExtensionMessages( 'LiquidThreads' );
142138 return wfMsg( 'lqt-merge-submit' );
Index: trunk/extensions/LiquidThreads/pages/TalkpageHeaderView.php
@@ -26,30 +26,44 @@
2727
2828 if ( $wgRequest->getVal( 'action' ) === 'edit' ) {
2929 wfLoadExtensionMessages( 'LiquidThreads' );
30 -
 30+
3131 $html = '';
32 -
33 - $warn_bold = Xml::tags( 'strong', null,
34 - wfMsgExt( 'lqt_header_warning_bold', 'parseinline' ) );
35 -
36 - $warn_link =
37 - $this->talkpageLink( $wgTitle, wfMsgExt( 'lqt_header_warning_new_discussion',
38 - 'parseinline' ), 'talkpage_new_thread' );
39 -
40 - $html .= wfMsgExt( 'lqt_header_warning_before_big',
41 - array('parseinline', 'replaceafter' ),
42 - array( $warn_bold, $warn_link ) );
43 - $html .= Xml::tags( 'big', null,
44 - wfMsgExt( 'lqt_header_warning_big',
45 - array( 'parseinline', 'replaceafter' ),
46 - array( $warn_bold, $warn_link ) ) );
 32+
 33+ $warn_bold = Xml::tags(
 34+ 'strong',
 35+ null,
 36+ wfMsgExt( 'lqt_header_warning_bold', 'parseinline' )
 37+ );
 38+
 39+ $warn_link = $this->talkpageLink(
 40+ $wgTitle,
 41+ wfMsgExt( 'lqt_header_warning_new_discussion', 'parseinline' ),
 42+ 'talkpage_new_thread'
 43+ );
 44+
 45+ $html .= wfMsgExt(
 46+ 'lqt_header_warning_before_big',
 47+ array( 'parseinline', 'replaceafter' ),
 48+ array( $warn_bold, $warn_link )
 49+ );
 50+ $html .= Xml::tags(
 51+ 'big',
 52+ null,
 53+ wfMsgExt(
 54+ 'lqt_header_warning_big',
 55+ array( 'parseinline', 'replaceafter' ),
 56+ array( $warn_bold, $warn_link )
 57+ )
 58+ );
4759 $html .= wfMsg( 'word-separator' );
48 - $html .= wfMsgExt( 'lqt_header_warning_after_big',
49 - array( 'parseinline', 'replaceafter' ),
50 - array( $warn_bold, $warn_link ) );
51 -
 60+ $html .= wfMsgExt(
 61+ 'lqt_header_warning_after_big',
 62+ array( 'parseinline', 'replaceafter' ),
 63+ array( $warn_bold, $warn_link )
 64+ );
 65+
5266 $html = Xml::tags( 'p', array( 'class' => 'lqt_header_warning' ), $html );
53 -
 67+
5468 $wgOut->addHTML( $html );
5569 }
5670
Index: trunk/extensions/LiquidThreads/pages/IndividualThreadHistoryView.php
@@ -16,12 +16,16 @@
1717 function customizeSubtitle() {
1818 wfLoadExtensionMessages( 'LiquidThreads' );
1919 $msg = wfMsgExt( 'lqt_hist_view_whole_thread', 'parseinline' );
20 - $threadhist = $this->permalink( $this->thread->topmostThread(),
21 - $msg,
22 - 'thread_history' );
23 - $this->output->setSubtitle( parent::getSubtitle() . '<br />' .
24 - $this->output->getSubtitle() .
25 - "<br />$threadhist" );
 20+ $threadhist = $this->permalink(
 21+ $this->thread->topmostThread(),
 22+ $msg,
 23+ 'thread_history'
 24+ );
 25+ $this->output->setSubtitle(
 26+ parent::getSubtitle() . '<br />' .
 27+ $this->output->getSubtitle() .
 28+ "<br />$threadhist"
 29+ );
2630 return true;
2731 }
2832
Index: trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php
@@ -11,119 +11,125 @@
1212 wfLoadExtensionMessages( 'LiquidThreads' );
1313 return wfMsg( 'lqt_movethread' );
1414 }
15 -
 15+
1616 function getFormFields() {
17 - return
18 - array(
19 - 'dest-title' =>
20 - array(
21 - 'label-message' => 'lqt_move_destinationtitle',
22 - 'type' => 'text',
23 - 'validation-callback' => array( $this, 'validateTarget' ),
24 - ),
25 - 'reason' =>
26 - array(
27 - 'label-message' => 'movereason',
28 - 'type' => 'text',
29 - ),
30 - );
 17+ return array(
 18+ 'dest-title' => array(
 19+ 'label-message' => 'lqt_move_destinationtitle',
 20+ 'type' => 'text',
 21+ 'validation-callback' => array( $this, 'validateTarget' ),
 22+ ),
 23+ 'reason' => array(
 24+ 'label-message' => 'movereason',
 25+ 'type' => 'text',
 26+ ),
 27+ );
3128 }
32 -
 29+
3330 function getPageName() { return 'MoveThread'; }
34 -
 31+
3532 function getSubmitText() {
3633 wfLoadExtensionMessages( 'LiquidThreads' );
3734 return wfMsg( 'lqt_move_move' );
3835 }
39 -
 36+
4037 function buildForm() {
4138 $form = parent::buildForm();
42 -
 39+
4340 // Generate introduction
4441 $intro = '';
45 -
 42+
4643 global $wgUser;
4744 $sk = $wgUser->getSkin();
4845 $page = $article_name = $this->mThread->article()->getTitle()->getPrefixedText();
49 -
 46+
5047 $edit_text = wfMsgExt( 'lqt_move_torename_edit', 'parseinline' );
51 - $edit_link = $sk->link( $this->mThread->title(), $edit_text, array(),
52 - array( 'lqt_method' => 'edit', 'lqt_operand' => $this->mThread->id() ) );
53 -
54 - $intro .= wfMsgExt( 'lqt_move_movingthread', 'parse',
55 - array('[['.$this->mTarget.']]', '[['.$page.']]') );
56 - $intro .= wfMsgExt( 'lqt_move_torename', array( 'parse', 'replaceafter' ),
57 - array( $edit_link ) );
58 -
 48+ $edit_link = $sk->link(
 49+ $this->mThread->title(),
 50+ $edit_text,
 51+ array(),
 52+ array( 'lqt_method' => 'edit', 'lqt_operand' => $this->mThread->id() )
 53+ );
 54+
 55+ $intro .= wfMsgExt(
 56+ 'lqt_move_movingthread',
 57+ 'parse',
 58+ array( '[[' . $this->mTarget . ']]', '[[' . $page . ']]' )
 59+ );
 60+ $intro .= wfMsgExt(
 61+ 'lqt_move_torename',
 62+ array( 'parse', 'replaceafter' ),
 63+ array( $edit_link )
 64+ );
 65+
5966 $form->setIntro( $intro );
60 -
 67+
6168 return $form;
6269 }
63 -
 70+
6471 function checkUserRights( $oldTitle, $newTitle ) {
6572 global $wgUser, $wgOut;
66 -
 73+
6774 $oldErrors = $oldTitle->getUserPermissionsErrors( 'move', $wgUser );
6875 $newErrors = $newTitle->getUserPermissionsErrors( 'move', $wgUser );
69 -
 76+
7077 // Custom merge/unique function because we don't have the second parameter to
7178 // array_unique on Wikimedia.
7279 $mergedErrors = array();
73 - foreach( array_merge( $oldErrors, $newErrors ) as $key => $value ) {
74 - if ( !is_numeric($key) ) {
 80+ foreach ( array_merge( $oldErrors, $newErrors ) as $key => $value ) {
 81+ if ( !is_numeric( $key ) ) {
7582 $mergedErrors[$key] = $value;
7683 } elseif ( !in_array( $value, $mergedErrors ) ) {
7784 $mergedErrors[] = $value;
7885 }
7986 }
80 -
81 - if ( count($mergedErrors) > 0 ) {
82 - return $wgOut->parse(
83 - $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' )
84 - );
 87+
 88+ if ( count( $mergedErrors ) > 0 ) {
 89+ return $wgOut->parse(
 90+ $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' )
 91+ );
8592 }
8693
8794 return true;
8895 }
89 -
 96+
9097 function trySubmit( $data ) {
9198 // Load data
9299 $tmp = $data['dest-title'];
93100 $newtitle = Title::newFromText( $tmp );
94101 $reason = $data['reason'];
95 -
 102+
96103 $rightsResult = $this->checkUserRights( $this->mThread->title(), $newtitle );
97 -
98 - if ($rightsResult !== true)
 104+
 105+ if ( $rightsResult !== true )
99106 return $rightsResult;
100107
101108 // TODO no status code from this method.
102109 $this->mThread->moveToPage( $newtitle, $reason, true );
103 -
 110+
104111 global $wgOut, $wgUser;
105112 $sk = $wgUser->getSkin();
106113 $wgOut->addHTML( wfMsgExt( 'lqt_move_success', array( 'parse', 'replaceafter' ),
107114 array( $sk->link( $newtitle ) ) ) );
108 -
 115+
109116 return true;
110117 }
111 -
 118+
112119 function validateTarget( $target ) {
113 - if (!$target) {
 120+ if ( !$target ) {
114121 return wfMsgExt( 'lqt_move_nodestination', 'parseinline' );
115122 }
116 -
 123+
117124 $title = Title::newFromText( $target );
118 -
 125+
119126 if ( !$title || !LqtDispatch::isLqtPage( $title ) ) {
120127 return wfMsgExt( 'lqt_move_thread_bad_destination', 'parseinline' );
121128 }
122 -
 129+
123130 if ( $title->equals( $this->mThread->article()->getTitle() ) ) {
124131 return wfMsgExt( 'lqt_move_samedestination', 'parseinline' );
125132 }
126 -
 133+
127134 return true;
128135 }
129 -
130136 }
Index: trunk/extensions/LiquidThreads/pages/ThreadActionPage.php
@@ -6,40 +6,40 @@
77 function __construct() {
88 parent::__construct( $this->getPageName(), $this->getRightRequirement() );
99 $this->includable( false );
10 -
 10+
1111 global $wgOut, $wgUser, $wgRequest;
1212 $this->output = $wgOut;
1313 $this->user = $wgUser;
1414 $this->request = $wgRequest;
1515 }
16 -
 16+
1717 abstract function getPageName();
18 -
 18+
1919 abstract function getFormFields();
20 -
 20+
2121 protected function getRightRequirement() { return ''; }
2222
2323 function execute( $par ) {
2424 wfLoadExtensionMessages( 'LiquidThreads' );
25 -
 25+
2626 global $wgOut, $wgUser;
27 -
 27+
2828 if ( !$this->userCanExecute( $wgUser ) ) {
2929 $this->displayRestrictionError();
3030 return;
3131 }
32 -
 32+
3333 // Page title
3434 $wgOut->setPageTitle( $this->getDescription() );
35 -
36 - if ( !$this->checkParameters($par) ) {
 35+
 36+ if ( !$this->checkParameters( $par ) ) {
3737 return;
3838 }
39 -
 39+
4040 $form = $this->buildForm();
4141 $form->show();
4242 }
43 -
 43+
4444 // Loads stuff like the thread and so on
4545 function checkParameters( $par ) {
4646 // Handle parameter
@@ -49,32 +49,31 @@
5050 $this->output->addHTML( wfMsg( 'lqt_threadrequired' ) );
5151 return false;
5252 }
53 -
 53+
5454 $thread = Threads::withRoot( new Article( Title::newFromURL( $par ) ) );
5555 if ( !$thread ) {
5656 $this->output->addHTML( wfMsg( 'lqt_nosuchthread' ) );
5757 return false;
5858 }
59 -
 59+
6060 $this->mThread = $thread;
61 -
 61+
6262 return true;
6363 }
64 -
 64+
6565 abstract function getSubmitText();
66 -
 66+
6767 function buildForm() {
68 - $form = new HTMLForm( $this->getFormFields(), 'lqt-'.$this->getPageName() );
69 -
 68+ $form = new HTMLForm( $this->getFormFields(), 'lqt-' . $this->getPageName() );
 69+
7070 $par = $this->mThread->title()->getPrefixedText();
71 -
 71+
7272 $form->setSubmitText( $this->getSubmitText() );
7373 $form->setTitle( SpecialPage::getTitleFor( $this->getPageName(), $par ) );
7474 $form->setSubmitCallback( array( $this, 'trySubmit' ) );
75 -
 75+
7676 return $form;
7777 }
78 -
79 - abstract function trySubmit( $data );
8078
 79+ abstract function trySubmit( $data );
8180 }
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php
@@ -3,7 +3,6 @@
44 if ( !defined( 'MEDIAWIKI' ) ) die;
55
66 class ThreadHistoricalRevisionView extends ThreadPermalinkView {
7 -
87 public $mDisplayRevision = null;
98
109 /* TOOD: customize tabs so that History is highlighted. */
@@ -12,16 +11,16 @@
1312 $changedObject = $this->mDisplayRevision->getChangeObject();
1413 $is_changed_thread = $changedObject &&
1514 ( $changedObject->id() == $thread->id() );
16 -
 15+
1716 $class = parent::postDivClass( $thread );
18 -
 17+
1918 if ( $is_changed_thread ) {
2019 return "$class lqt_post_changed_by_history";
2120 } else {
2221 return $class;
2322 }
2423 }
25 -
 24+
2625 function getMessageForChangeType( $ct ) {
2726 static $messages = array(
2827 Threads::CHANGE_NEW_THREAD => 'lqt_change_new_thread',
@@ -36,11 +35,11 @@
3736 Threads::CHANGE_SPLIT_FROM => 'lqt_change_split_from',
3837 Threads::CHANGE_EDITED_SUMMARY => 'lqt_change_edited_summary',
3938 );
40 -
41 - if ( isset($messages[$ct]) ) {
 39+
 40+ if ( isset( $messages[$ct] ) ) {
4241 return $messages[$ct];
4342 }
44 -
 43+
4544 return '';
4645 }
4746
@@ -49,33 +48,38 @@
5049 wfLoadExtensionMessages( 'LiquidThreads' );
5150
5251 $html = '';
53 - $html .= wfMsgExt( 'lqt_revision_as_of', 'parseinline',
54 - array(
55 - $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ),
56 - $wgLang->date( $this->mDisplayRevision->getTimestamp() ),
57 - $wgLang->time( $this->mDisplayRevision->getTimestamp() )
58 - )
59 - );
60 -
 52+ $html .= wfMsgExt(
 53+ 'lqt_revision_as_of', 'parseinline',
 54+ array(
 55+ $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ),
 56+ $wgLang->date( $this->mDisplayRevision->getTimestamp() ),
 57+ $wgLang->time( $this->mDisplayRevision->getTimestamp() )
 58+ )
 59+ );
 60+
6161 $html .= '<br/>';
6262
6363 $ct = $this->mDisplayRevision->getChangeType();
64 -
 64+
6565 $msg = '';
6666 if ( $ct == Threads::CHANGE_EDITED_ROOT ) {
67 - $diff_link = $this->diffPermalink( $this->thread,
68 - wfMsgExt( 'diff', 'parseinline' ),
69 - $this->mDisplayRevision );
70 - $msg = wfMsgExt( 'lqt_change_edited_root', 'parseinline' ) .
71 - " [$diff_link]";
 67+ $diff_link = $this->diffPermalink(
 68+ $this->thread,
 69+ wfMsgExt( 'diff', 'parseinline' ),
 70+ $this->mDisplayRevision
 71+ );
 72+ $msg = wfMsgExt(
 73+ 'lqt_change_edited_root',
 74+ 'parseinline'
 75+ ) . " [$diff_link]";
7276 } else {
73 - $msg = wfMsgExt( $this->getMessageForChangeType($ct), 'parseinline' );
 77+ $msg = wfMsgExt( $this->getMessageForChangeType( $ct ), 'parseinline' );
7478 }
75 -
 79+
7680 $html .= $msg;
77 -
 81+
7882 $html = Xml::tags( 'div', array( 'class' => 'lqt_history_info' ), $html );
79 -
 83+
8084 $this->output->addHTML( $html );
8185 }
8286
@@ -84,12 +88,12 @@
8589 $this->showMissingThreadPage();
8690 return false;
8791 }
88 -
 92+
8993 $oldid = $this->request->getInt( 'lqt_oldid' );
9094 $this->mDisplayRevision = ThreadRevision::loadFromId( $oldid );
9195
9296 $this->thread = $this->mDisplayRevision->getThreadObj();
93 -
 97+
9498 $this->showHistoryInfo();
9599 parent::show();
96100 return false;
Index: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
@@ -10,13 +10,13 @@
1111 // Insert fake 'article' and 'discussion' tabs before the thread tab.
1212 // If you call the key 'talk', the url gets re-set later. TODO:
1313 // the access key for the talk tab doesn't work.
14 - if ($this->thread) {
 14+ if ( $this->thread ) {
1515 $article_t = $this->thread->article()->getTitle();
1616 $talk_t = $this->thread->article()->getTitle();
1717 } else {
1818 return true;
1919 }
20 -
 20+
2121 $articleTab =
2222 array(
2323 'text' => wfMsg( $article_t->getNamespaceKey() ),
@@ -24,27 +24,27 @@
2525 'class' => $article_t->exists() ? '' : 'new'
2626 );
2727 efInsertIntoAssoc( 'article', $articleTab, 'nstab-thread', $content_actions );
28 -
 28+
2929 $talkTab =
3030 array(
3131 // talkpage certainly exists since this thread is from it.
3232 'text' => wfMsg( 'talk' ),
3333 'href' => $talk_t->getFullURL()
3434 );
35 -
 35+
3636 efInsertIntoAssoc( 'not_talk', $talkTab, 'nstab-thread', $content_actions );
3737
3838 unset( $content_actions['edit'] );
3939 unset( $content_actions['viewsource'] );
4040 unset( $content_actions['talk'] );
41 -
 41+
4242 $subpage = $this->thread->title()->getPrefixedText();
43 -
 43+
4444 if ( array_key_exists( 'move', $content_actions ) && $this->thread ) {
4545 $content_actions['move']['href'] =
4646 SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL();
4747 }
48 -
 48+
4949 if ( array_key_exists( 'delete', $content_actions ) && $this->thread ) {
5050 $content_actions['delete']['href'] =
5151 $this->thread->title()->getFullURL( 'action=delete' );
@@ -77,33 +77,39 @@
7878
7979 function getSubtitle() {
8080 wfLoadExtensionMessages( 'LiquidThreads' );
81 -
 81+
8282 $sk = $this->user->getSkin();
83 - $fragment = '#'.$this->anchorName( $this->thread );
84 -
 83+ $fragment = '#' . $this->anchorName( $this->thread );
 84+
8585 if ( $this->thread->isHistorical() ) {
8686 // TODO: Point to the relevant part of the archive.
8787 $query = '';
8888 } else {
8989 $query = '';
9090 }
91 -
 91+
9292 $talkpage = $this->thread->article()->getTitle();
9393 $talkpage->setFragment( $fragment );
9494 $talkpage_link = $sk->link( $talkpage );
95 -
 95+
9696 if ( $this->thread->hasSuperthread() ) {
9797 $topmostTitle = $this->thread->topmostThread()->title();
9898 $topmostTitle->setFragment( $fragment );
99 -
 99+
100100 $linkText = wfMsgExt( 'lqt_discussion_link', 'parseinline' );
101101 $permalink = $sk->link( $topmostTitle, $linkText );
102 -
103 - return wfMsgExt( 'lqt_fragment', array('parseinline', 'replaceafter'),
104 - array( $permalink, $talkpage_link ) );
 102+
 103+ return wfMsgExt(
 104+ 'lqt_fragment',
 105+ array( 'parseinline', 'replaceafter' ),
 106+ array( $permalink, $talkpage_link )
 107+ );
105108 } else {
106 - return wfMsgExt( 'lqt_from_talk', array('parseinline', 'replaceafter'),
107 - array($talkpage_link) );
 109+ return wfMsgExt(
 110+ 'lqt_from_talk',
 111+ array( 'parseinline', 'replaceafter' ),
 112+ array( $talkpage_link )
 113+ );
108114 }
109115 }
110116
@@ -112,7 +118,7 @@
113119 parent::__construct( $output, $article, $title, $user, $request );
114120
115121 $t = Threads::withRoot( $this->article );
116 -
 122+
117123 $this->thread = $t;
118124 if ( !$t ) {
119125 return; // error reporting is handled in show(). this kinda sucks.
@@ -132,7 +138,7 @@
133139 $this->showMissingThreadPage();
134140 return false;
135141 }
136 -
 142+
137143 if ( $this->request->getBool( 'lqt_inline' ) ) {
138144 $this->doInlineEditForm();
139145 return false;
@@ -146,8 +152,8 @@
147153 elseif ( $this->methodApplies( 'split' ) )
148154 $this->showSplitForm( $this->thread );
149155
150 - $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => -1, 'maxCount' => -1 ) );
151 -
 156+ $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => - 1, 'maxCount' => - 1 ) );
 157+
152158 $this->output->setPageTitle( $this->thread->subject() );
153159 return false;
154160 }
Index: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php
@@ -13,10 +13,15 @@
1414 $html = '';
1515 $html .= Xml::hidden( 'lqt_method', 'mark_as_read' );
1616 $html .= Xml::hidden( 'lqt_operand', $ids_s );
17 - $html .= Xml::submitButton( $label, array( 'name' => 'lqt_read_button',
18 - 'title' => $title ) );
 17+ $html .= Xml::submitButton(
 18+ $label,
 19+ array(
 20+ 'name' => 'lqt_read_button',
 21+ 'title' => $title
 22+ )
 23+ );
1924 $html = Xml::tags( 'form', array( 'method' => 'post', 'class' => $class ), $html );
20 -
 25+
2126 return $html;
2227 }
2328
@@ -24,49 +29,56 @@
2530 wfLoadExtensionMessages( 'LiquidThreads' );
2631 $ids = array_map( create_function( '$t', 'return $t->id();' ), $threads ); // ew
2732 return $this->htmlForReadButton(
28 - wfMsg( 'lqt-read-all' ),
29 - wfMsg( 'lqt-read-all-tooltip' ),
30 - "lqt_newmessages_read_all_button",
31 - $ids
32 - );
 33+ wfMsg( 'lqt-read-all' ),
 34+ wfMsg( 'lqt-read-all-tooltip' ),
 35+ "lqt_newmessages_read_all_button",
 36+ $ids
 37+ );
3338 }
3439
3540 function getUndoButton( $ids ) {
3641 wfLoadExtensionMessages( 'LiquidThreads' );
37 -
 42+
3843 if ( count( $ids ) == 1 ) {
3944 $t = Threads::withId( $ids[0] );
4045 if ( !$t )
4146 return; // empty or just bogus operand.
42 - $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array($t->subject()) );
 47+ $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array( $t->subject() ) );
4348 } else {
4449 $count = count( $ids );
45 - $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array($count) );
 50+ $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) );
4651 }
4752 $operand = implode( ',', $ids );
48 -
 53+
4954 $html = '';
5055 $html .= $msg;
5156 $html .= Xml::hidden( 'lqt_method', 'mark_as_unread' );
5257 $html .= Xml::hidden( 'lqt_operand', $operand );
53 - $html .= Xml::submitButton( wfMsg('lqt-email-undo'), array( 'name' => 'lqt_read_button',
54 - 'title' => wfMsg( 'lqt-email-info-undo' ) ) );
55 -
56 - $html = Xml::tags( 'form',
57 - array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ),
58 - $html );
59 -
 58+ $html .= Xml::submitButton(
 59+ wfMsg( 'lqt-email-undo' ),
 60+ array(
 61+ 'name' => 'lqt_read_button',
 62+ 'title' => wfMsg( 'lqt-email-info-undo' )
 63+ )
 64+ );
 65+
 66+ $html = Xml::tags(
 67+ 'form',
 68+ array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ),
 69+ $html
 70+ );
 71+
6072 return $html;
6173 }
6274
6375 function postDivClass( $thread ) {
6476 $origClass = parent::postDivClass( $thread );
65 -
 77+
6678 $topid = $thread->topmostThread()->id();
67 -
 79+
6880 if ( in_array( $thread->id(), $this->targets[$topid] ) )
6981 return "$origClass lqt_post_new_message";
70 -
 82+
7183 return $origClass;
7284 }
7385
@@ -82,11 +94,13 @@
8395
8496 if ( $this->request->wasPosted() && $this->methodApplies( 'mark_as_unread' ) ) {
8597 $ids = explode( ',', $this->request->getVal( 'lqt_operand', '' ) );
86 -
 98+
8799 if ( $ids !== false ) {
88100 foreach ( $ids as $id ) {
89 - $tmp_thread = Threads::withId( $id ); if ( $tmp_thread )
 101+ $tmp_thread = Threads::withId( $id );
 102+ if ( $tmp_thread ) {
90103 NewMessages::markThreadAsUnReadByUser( $tmp_thread, $this->user );
 104+ }
91105 }
92106 $this->output->redirect( $this->title->getFullURL() );
93107 }
@@ -95,8 +109,9 @@
96110 if ( $ids !== false ) {
97111 foreach ( $ids as $id ) {
98112 $tmp_thread = Threads::withId( $id );
99 - if ( $tmp_thread )
 113+ if ( $tmp_thread ) {
100114 NewMessages::markThreadAsReadByUser( $tmp_thread, $this->user );
 115+ }
101116 }
102117 $query = 'lqt_method=undo_mark_as_read&lqt_operand=' . implode( ',', $ids );
103118 $this->output->redirect( $this->title->getFullURL( $query ) );
@@ -111,7 +126,7 @@
112127 if ( ! is_array( $this->threads ) ) {
113128 throw new MWException( 'You must use NewUserMessagesView::setThreads() before calling NewUserMessagesView::show().' );
114129 }
115 -
 130+
116131 if ( $this->request->getBool( 'lqt_inline' ) ) {
117132 $this->doInlineEditForm();
118133 return false;
@@ -124,10 +139,10 @@
125140 $this->tops = array();
126141 foreach ( $this->threads as $t ) {
127142 $top = $t->topmostThread();
128 -
 143+
129144 // It seems that in some cases $top is zero.
130 - if (!$top)
131 - throw new MWException("{$t->id()} seems to have no topmost thread");
 145+ if ( !$top )
 146+ throw new MWException( "{$t->id()} seems to have no topmost thread" );
132147
133148 if ( !array_key_exists( $top->id(), $this->tops ) )
134149 $this->tops[$top->id()] = $top;
@@ -135,7 +150,7 @@
136151 $this->targets[$top->id()] = array();
137152 $this->targets[$top->id()][] = $t->id();
138153 }
139 -
 154+
140155 $this->output->addHTML( '<table><tbody>' );
141156
142157 foreach ( $this->tops as $t ) {
@@ -145,34 +160,39 @@
146161
147162 $this->showWrappedThread( $t );
148163 }
149 -
 164+
150165 $this->output->addHTML( '</tbody></table>' );
151 -
 166+
152167 return false;
153168 }
154 -
 169+
155170 function showWrappedThread( $t ) {
156171 wfLoadExtensionMessages( 'LiquidThreads' );
157 -
 172+
158173 $read_button = $this->htmlForReadButton(
159174 wfMsg( 'lqt-read-message' ),
160175 wfMsg( 'lqt-read-message-tooltip' ),
161176 'lqt_newmessages_read_button',
162177 $this->targets[$t->id()] );
163 -
 178+
164179 // Left-hand column � read button and context link to the full thread.
165180 $topmostThread = $t->topmostThread();
166 - $contextLink = self::permalink( $topmostThread,
167 - wfMsgExt( 'lqt-newmessages-context', 'parseinline' ) );
 181+ $contextLink = self::permalink(
 182+ $topmostThread,
 183+ wfMsgExt( 'lqt-newmessages-context', 'parseinline' )
 184+ );
168185 $leftColumn = Xml::tags( 'p', null, $read_button ) .
169186 Xml::tags( 'p', null, $contextLink );
170 - $leftColumn = Xml::tags( 'td', array( 'class' => 'mw-lqt-newmessages-left' ),
171 - $leftColumn );
 187+ $leftColumn = Xml::tags(
 188+ 'td',
 189+ array( 'class' => 'mw-lqt-newmessages-left' ),
 190+ $leftColumn
 191+ );
172192 $html = "<tr>$leftColumn<td>";
173193 $this->output->addHTML( $html );
174194
175195 $this->showThread( $t );
176 -
 196+
177197 $this->output->addHTML( "</td></tr>" );
178198 }
179199
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoryListingView.php
@@ -13,92 +13,90 @@
1414 }
1515 self::addJSandCSS();
1616 wfLoadExtensionMessages( 'LiquidThreads' );
17 -
 17+
1818 $this->thread->updateHistory();
1919
2020 $this->output->setPageTitle( wfMsg( 'lqt-history-title' ) );
2121 $this->output->setSubtitle( $this->getSubtitle() . '<br />' .
2222 wfMsg( 'lqt_hist_listing_subtitle' ) );
2323 $this->showThreadHeading( $this->thread );
24 -
 24+
2525 $pager = new ThreadHistoryPager( $this, $this->thread );
26 -
 26+
2727 $html = $pager->getNavigationBar() .
2828 $pager->getBody() .
2929 $pager->getNavigationBar();
30 -
 30+
3131 $this->output->addHTML( $html );
32 -
 32+
3333 $this->showThread( $this->thread );
34 -
 34+
3535 return false;
3636 }
3737 }
3838
3939 class ThreadHistoryPager extends TablePager {
4040 static $change_names;
41 -
4241
 42+
4343 function __construct( $view, $thread ) {
4444 parent::__construct();
45 -
 45+
4646 $this->thread = $thread;
4747 $this->view = $view;
48 -
49 - self::$change_names =
50 - array(
51 - Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ),
52 - Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans( 'lqt_hist_summary_changed' ),
53 - Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans( 'lqt_hist_reply_created' ),
54 - Threads::CHANGE_NEW_THREAD => wfMsgNoTrans( 'lqt_hist_thread_created' ),
55 - Threads::CHANGE_DELETED => wfMsgNoTrans( 'lqt_hist_deleted' ),
56 - Threads::CHANGE_UNDELETED => wfMsgNoTrans( 'lqt_hist_undeleted' ),
57 - Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans( 'lqt_hist_moved_talkpage' ),
58 - Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans( 'lqt_hist_edited_subject' ),
59 - Threads::CHANGE_SPLIT => wfMsgNoTrans( 'lqt_hist_split' ),
60 - Threads::CHANGE_MERGED_FROM => wfMsgNoTrans( 'lqt_hist_merged_from' ),
61 - Threads::CHANGE_MERGED_TO => wfMsgNoTrans( 'lqt_hist_merged_to' ),
62 - Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans( 'lqt_hist_split_from' ),
63 - );
 48+
 49+ self::$change_names = array(
 50+ Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ),
 51+ Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans( 'lqt_hist_summary_changed' ),
 52+ Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans( 'lqt_hist_reply_created' ),
 53+ Threads::CHANGE_NEW_THREAD => wfMsgNoTrans( 'lqt_hist_thread_created' ),
 54+ Threads::CHANGE_DELETED => wfMsgNoTrans( 'lqt_hist_deleted' ),
 55+ Threads::CHANGE_UNDELETED => wfMsgNoTrans( 'lqt_hist_undeleted' ),
 56+ Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans( 'lqt_hist_moved_talkpage' ),
 57+ Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans( 'lqt_hist_edited_subject' ),
 58+ Threads::CHANGE_SPLIT => wfMsgNoTrans( 'lqt_hist_split' ),
 59+ Threads::CHANGE_MERGED_FROM => wfMsgNoTrans( 'lqt_hist_merged_from' ),
 60+ Threads::CHANGE_MERGED_TO => wfMsgNoTrans( 'lqt_hist_merged_to' ),
 61+ Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans( 'lqt_hist_split_from' ),
 62+ );
6463 }
65 -
 64+
6665 function getQueryInfo() {
67 - $queryInfo =
68 - array(
69 - 'tables' => array( 'thread_history' ),
70 - 'fields' => '*',
71 - 'conds' => array( 'th_thread' => $this->thread->id() ),
72 - 'options' => array( 'order by' => 'th_timestamp desc' ),
73 - );
74 -
 66+ $queryInfo = array(
 67+ 'tables' => array( 'thread_history' ),
 68+ 'fields' => '*',
 69+ 'conds' => array( 'th_thread' => $this->thread->id() ),
 70+ 'options' => array( 'order by' => 'th_timestamp desc' ),
 71+ );
 72+
7573 return $queryInfo;
7674 }
77 -
 75+
7876 function getFieldNames() {
7977 static $headers = null;
8078
81 - if (!empty($headers)) {
 79+ if ( !empty( $headers ) ) {
8280 return $headers;
8381 }
8482
85 - $headers = array(
86 - 'th_timestamp' => 'lqt-history-time',
87 - 'th_user_text' => 'lqt-history-user',
 83+ $headers = array(
 84+ 'th_timestamp' => 'lqt-history-time',
 85+ 'th_user_text' => 'lqt-history-user',
8886 'th_change_type' => 'lqt-history-action',
89 - 'th_change_comment' => 'lqt-history-comment',
90 - );
 87+ 'th_change_comment' => 'lqt-history-comment',
 88+ );
9189
9290 $headers = array_map( 'wfMsg', $headers );
9391
9492 return $headers;
9593 }
96 -
 94+
9795 function formatValue( $name, $value ) {
98 - global $wgOut,$wgLang, $wgTitle;
 96+ global $wgOut, $wgLang, $wgTitle;
9997
100 - static $sk=null;
 98+ static $sk = null;
10199
102 - if (empty($sk)) {
 100+ if ( empty( $sk ) ) {
103101 global $wgUser;
104102 $sk = $wgUser->getSkin();
105103 }
@@ -107,7 +105,7 @@
108106
109107 $formatted = '';
110108
111 - switch($name) {
 109+ switch( $name ) {
112110 case 'th_timestamp':
113111 $formatted = $wgLang->timeanddate( $value );
114112 return $sk->link( $wgTitle, $formatted, array(),
@@ -124,20 +122,19 @@
125123 break;
126124 }
127125 }
128 -
 126+
129127 function getIndexField() {
130128 return 'th_timestamp';
131129 }
132 -
 130+
133131 function getDefaultSort() {
134132 return 'th_timestamp';
135133 }
136134
137 - function isFieldSortable($name) {
 135+ function isFieldSortable( $name ) {
138136 $sortable_fields = array( 'th_timestamp', 'th_user_text', 'th_change_type' );
139137 return in_array( $name, $sortable_fields );
140138 }
141 -
 139+
142140 function getDefaultDirections() { return true; /* descending */ }
143141 }
144 -
Index: trunk/extensions/LiquidThreads/pages/SpecialNewMessages.php
@@ -26,7 +26,7 @@
2727 $this->request = $wgRequest;
2828
2929 $this->setHeaders();
30 -
 30+
3131 $article = new Article( $this->getTitle() );
3232 $title = $this->getTitle();
3333
@@ -42,21 +42,27 @@
4343 $wgOut->addWikitext( wfMsg( 'lqt-no-new-messages' ) );
4444 return;
4545 }
46 -
 46+
4747 $html = '';
48 -
 48+
4949 $html .= $view->getReadAllButton( $both_sets );
5050
5151 $view->setHeaderLevel( 3 );
5252
53 - $html .= Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ),
54 - wfMsgExt( 'lqt-messages-sent', 'parseinline' ) );
 53+ $html .= Xml::tags(
 54+ 'h2',
 55+ array( 'class' => 'lqt_newmessages_section' ),
 56+ wfMsgExt( 'lqt-messages-sent', 'parseinline' )
 57+ );
5558 $wgOut->addHTML( $html );
5659 $view->setThreads( $first_set );
5760 $view->show();
5861
59 - $wgOut->addHTML( Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ),
60 - wfMsgExt( 'lqt-other-messages', 'parseinline' ) ) );
 62+ $wgOut->addHTML( Xml::tags(
 63+ 'h2',
 64+ array( 'class' => 'lqt_newmessages_section' ),
 65+ wfMsgExt( 'lqt-other-messages', 'parseinline' )
 66+ ) );
6167 $view->setThreads( $second_set );
6268 $view->show();
6369 }
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php
@@ -19,7 +19,7 @@
2020
2121 function showHeader() {
2222 /* Show the contents of the actual talkpage article if it exists. */
23 -
 23+
2424 global $wgUser;
2525 $sk = $wgUser->getSkin();
2626
@@ -32,107 +32,124 @@
3333 // when the first thread was posted to make the links blue.
3434 if ( $article->exists() && $article->getContent() ) {
3535 $html = '';
36 -
 36+
3737 $article->view();
38 -
 38+
3939 $actionLinks = array();
40 - $actionLinks[] = $sk->link( $this->title,
41 - wfMsgExt( 'edit', 'parseinline' ) . "&uarr;",
42 - array(), array( 'action' => 'edit' ) );
43 - $actionLinks[] = $sk->link( $this->title,
44 - wfMsgExt( 'history_short', 'parseinline' ) . "&uarr;",
45 - array(), array( 'action' => 'history' ) );
46 -
 40+ $actionLinks[] = $sk->link(
 41+ $this->title,
 42+ wfMsgExt( 'edit', 'parseinline' ) . "&uarr;",
 43+ array(),
 44+ array( 'action' => 'edit' )
 45+ );
 46+ $actionLinks[] = $sk->link(
 47+ $this->title,
 48+ wfMsgExt( 'history_short', 'parseinline' ) . "&uarr;",
 49+ array(),
 50+ array( 'action' => 'history' )
 51+ );
 52+
4753 if ( $wgUser->isAllowed( 'delete' ) ) {
48 - $actionLinks[] = $sk->link( $this->title,
49 - wfMsgExt( 'delete', 'parseinline' ) . '&uarr;',
50 - array(), array( 'action' => 'delete' ) );
 54+ $actionLinks[] = $sk->link(
 55+ $this->title,
 56+ wfMsgExt( 'delete', 'parseinline' ) . '&uarr;',
 57+ array(),
 58+ array( 'action' => 'delete' )
 59+ );
5160 }
52 -
 61+
5362 $actions = '';
54 - foreach( $actionLinks as $link ) {
 63+ foreach ( $actionLinks as $link ) {
5564 $actions .= Xml::tags( 'li', null, "[$link]" ) . "\n";
5665 }
5766 $actions = Xml::tags( 'ul', array( 'class' => 'lqt_header_commands' ), $actions );
5867 $html .= $actions;
5968
6069 $html = Xml::tags( 'div', array( 'class' => 'lqt_header_content' ), $html );
61 -
 70+
6271 $this->output->addHTML( $html );
6372 } else {
64 -
65 - $editLink = $sk->link( $this->title, wfMsgExt( 'lqt_add_header', 'parseinline' ),
66 - array(), array( 'action' => 'edit' ) );
67 -
 73+
 74+ $editLink = $sk->link(
 75+ $this->title,
 76+ wfMsgExt( 'lqt_add_header', 'parseinline' ),
 77+ array(),
 78+ array( 'action' => 'edit' )
 79+ );
 80+
6881 $html = Xml::tags( 'p', array( 'class' => 'lqt_header_notice' ), "[$editLink]" );
69 -
 82+
7083 $this->output->addHTML( $html );
7184 }
7285 }
73 -
 86+
7487 function getTOC( $threads ) {
7588 global $wgLang;
76 -
 89+
7790 wfLoadExtensionMessages( 'LiquidThreads' );
7891
7992 $sk = $this->user->getSkin();
80 -
 93+
8194 $html = '';
82 -
 95+
8396 $h2_header = Xml::tags( 'h2', null, wfMsgExt( 'lqt_contents_title', 'parseinline' ) );
84 -
 97+
8598 // Header row
8699 $headerRow = '';
87 - $headers = array( 'lqt_toc_thread_title', 'lqt_toc_thread_author',
88 - 'lqt_toc_thread_replycount', 'lqt_toc_thread_modified' );
89 - foreach( $headers as $msg ) {
 100+ $headers = array(
 101+ 'lqt_toc_thread_title',
 102+ 'lqt_toc_thread_author',
 103+ 'lqt_toc_thread_replycount',
 104+ 'lqt_toc_thread_modified'
 105+ );
 106+ foreach ( $headers as $msg ) {
90107 $headerRow .= Xml::tags( 'th', null, wfMsgExt( $msg, 'parseinline' ) );
91108 }
92109 $headerRow = Xml::tags( 'tr', null, $headerRow );
93110 $headerRow = Xml::tags( 'thead', null, $headerRow );
94 -
 111+
95112 // Table body
96113 $rows = array();
97 - foreach( $threads as $thread ) {
 114+ foreach ( $threads as $thread ) {
98115 $row = '';
99 - $anchor = '#'.$this->anchorName( $thread );
 116+ $anchor = '#' . $this->anchorName( $thread );
100117 $subject = $this->output->parseInline( $thread->subjectWithoutIncrement() );
101118 $subject = Xml::tags( 'a', array( 'href' => $anchor ), $subject );
102119 $row .= Xml::tags( 'td', null, $subject );
103 -
 120+
104121 $author = $thread->author();
105122 $authorLink = $sk->userLink( $author->getId(), $author->getName() );
106123 $row .= Xml::tags( 'td', null, $authorLink );
107 -
 124+
108125 $row .= Xml::element( 'td', null, count( $thread->replies() ) );
109 -
 126+
110127 $timestamp = $wgLang->timeanddate( $thread->modified(), true );
111128 $row .= Xml::element( 'td', null, $timestamp );
112 -
 129+
113130 $row = Xml::tags( 'tr', null, $row );
114131 $rows[] = $row;
115132 }
116 -
 133+
117134 $html .= $headerRow . "\n" . Xml::tags( 'tbody', null, implode( "\n", $rows ) );
118135 $html = $h2_header . Xml::tags( 'table', array( 'class' => 'lqt_toc' ), $html );
119 -
 136+
120137 return $html;
121138 }
122 -
 139+
123140 function getList( $kind, $class, $id, $contents ) {
124141 $html = '';
125142 foreach ( $contents as $li ) {
126143 $html .= Xml::tags( 'li', null, $li );
127144 }
128145 $html = Xml::tags( $kind, array( 'class' => $class, 'id' => $id ), $html );
129 -
 146+
130147 return $html;
131148 }
132149
133150 function getArchiveWidget( ) {
134151 wfLoadExtensionMessages( 'LiquidThreads' );
135152 $url = $this->talkpageUrl( $this->title, 'talkpage_archive' );
136 -
 153+
137154 $html = '';
138155 $html = Xml::tags( 'div', array( 'class' => 'lqt_archive_teaser' ), $html );
139156 return $html;
@@ -144,32 +161,44 @@
145162 if ( $article->exists() ) {
146163 $form_action_url = $this->talkpageUrl( $this->title, 'talkpage_sort_order' );
147164 $go = wfMsg( 'go' );
148 -
 165+
149166 $html = '';
150 -
 167+
151168 $html .= Xml::label( wfMsg( 'lqt_sorting_order' ), 'lqt_sort_select' ) . ' ';
152169
153170 $sortOrderSelect =
154171 new XmlSelect( 'lqt_order', 'lqt_sort_select', $this->getSortType() );
155 -
 172+
156173 $sortOrderSelect->setAttribute( 'class', 'lqt_sort_select' );
157 - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_changes' ),
158 - LQT_NEWEST_CHANGES );
159 - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_threads' ),
160 - LQT_NEWEST_THREADS );
161 - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_oldest_threads' ),
162 - LQT_OLDEST_THREADS );
 174+ $sortOrderSelect->addOption(
 175+ wfMsg( 'lqt_sort_newest_changes' ),
 176+ LQT_NEWEST_CHANGES
 177+ );
 178+ $sortOrderSelect->addOption(
 179+ wfMsg( 'lqt_sort_newest_threads' ),
 180+ LQT_NEWEST_THREADS
 181+ );
 182+ $sortOrderSelect->addOption(
 183+ wfMsg( 'lqt_sort_oldest_threads' ),
 184+ LQT_OLDEST_THREADS
 185+ );
163186 $html .= $sortOrderSelect->getHTML();
164 -
 187+
165188 $html .= Xml::submitButton( wfMsg( 'go' ), array( 'class' => 'lqt_go_sort' ) );
166189 $html .= Xml::hidden( 'title', $this->title->getPrefixedText() );
167 -
168 -
169 - $html = Xml::tags( 'form', array( 'action' => $form_action_url,
170 - 'method' => 'get',
171 - 'name' => 'lqt_sort' ), $html );
 190+
 191+
 192+ $html = Xml::tags(
 193+ 'form',
 194+ array(
 195+ 'action' => $form_action_url,
 196+ 'method' => 'get',
 197+ 'name' => 'lqt_sort'
 198+ ),
 199+ $html
 200+ );
172201 $html = Xml::tags( 'div', array( 'class' => 'lqt_view_options' ), $html );
173 -
 202+
174203 return $html;
175204 }
176205 }
@@ -182,54 +211,62 @@
183212
184213 $this->output->setPageTitle( $this->title->getPrefixedText() );
185214 self::addJSandCSS();
186 -
 215+
187216 $sk = $this->user->getSkin();
188 -
 217+
189218 $article = new Article( $this->title );
190 -
 219+
191220 if ( $this->request->getBool( 'lqt_inline' ) ) {
192221 $this->doInlineEditForm();
193222 return false;
194223 }
195 -
 224+
196225 // Search!
197226 if ( $this->request->getCheck( 'lqt_search' ) ) {
198227 $q = $this->request->getText( 'lqt_search' );
199 - $q .= ' ondiscussionpage:'.$article->getTitle()->getPrefixedText();
200 -
201 - $params = array( 'search' => $q,
202 - 'fulltext' => 1,
203 - 'ns'.NS_LQT_THREAD => 1,
204 - );
205 -
 228+ $q .= ' ondiscussionpage:' . $article->getTitle()->getPrefixedText();
 229+
 230+ $params = array(
 231+ 'search' => $q,
 232+ 'fulltext' => 1,
 233+ 'ns' . NS_LQT_THREAD => 1,
 234+ );
 235+
206236 $t = SpecialPage::getTitleFor( 'Search' );
207237 $url = $t->getLocalURL( wfArrayToCGI( $params ) );
208 -
 238+
209239 $this->output->redirect( $url );
210 -
211240 }
212241
213242 $this->showHeader();
214 -
 243+
215244 $html = '';
216 -
 245+
217246 // Set up a per-page header for new threads, search box, and sorting stuff.
218 -
 247+
219248 $talkpageHeader = '';
220 -
 249+
221250 $newThreadText = wfMsgExt( 'lqt_new_thread', 'parseinline' );
222 - $newThreadLink = $sk->link( $this->title, $newThreadText,
223 - array( ),
224 - array( 'lqt_method' => 'talkpage_new_thread' ),
225 - array( 'known' ) );
226 -
227 - $talkpageHeader .= Xml::tags( 'strong', array( 'class' => 'lqt_start_discussion' ),
228 - $newThreadLink );
 251+ $newThreadLink = $sk->link(
 252+ $this->title, $newThreadText,
 253+ array(),
 254+ array( 'lqt_method' => 'talkpage_new_thread' ),
 255+ array( 'known' )
 256+ );
 257+
 258+ $talkpageHeader .= Xml::tags(
 259+ 'strong',
 260+ array( 'class' => 'lqt_start_discussion' ),
 261+ $newThreadLink
 262+ );
229263 $talkpageHeader .= $this->getSearchBox();
230264 $talkpageHeader .= $this->showTalkpageViewOptions( $article );
231 - $talkpageHeader = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-header' ),
232 - $talkpageHeader );
233 -
 265+ $talkpageHeader = Xml::tags(
 266+ 'div',
 267+ array( 'class' => 'lqt-talkpage-header' ),
 268+ $talkpageHeader
 269+ );
 270+
234271 $this->output->addHTML( $talkpageHeader );
235272
236273 global $wgRequest;
@@ -242,63 +279,71 @@
243280 $this->output->addHTML( Xml::tags( 'div',
244281 array( 'class' => 'lqt-new-thread lqt-edit-form' ), '' ) );
245282 }
246 -
 283+
247284 $pager = $this->getPager();
248 -
 285+
249286 $threads = $this->getPageThreads( $pager );
250287
251 - if ( count($threads) > 0 ) {
 288+ if ( count( $threads ) > 0 ) {
252289 $html .= Xml::element( 'br', array( 'style' => 'clear: both;' ) );
253290 $html .= $this->getTOC( $threads );
254291 } else {
255292 $html .= wfMsgExt( 'lqt-no-threads', 'parseinline' );
256293 }
257 -
 294+
258295 $html .= $pager->getNavigationBar();
259 -
 296+
260297 $this->output->addHTML( $html );
261298
262299 foreach ( $threads as $t ) {
263300 $this->showThread( $t );
264301 }
265 -
 302+
266303 $this->output->addHTML( $pager->getNavigationBar() );
267 -
 304+
268305 return false;
269306 }
270 -
 307+
271308 function getSearchBox() {
272309 $html = '';
273 - $html .= Xml::inputLabel( wfMsg('lqt-search-label'), 'lqt_search', 'lqt-search-box',
274 - 45 );
275 -
 310+ $html .= Xml::inputLabel(
 311+ wfMsg( 'lqt-search-label' ),
 312+ 'lqt_search',
 313+ 'lqt-search-box',
 314+ 45
 315+ );
 316+
276317 $html .= ' ' . Xml::submitButton( wfMsg( 'lqt-search-button' ) );
277318 $html .= Xml::hidden( 'title', $this->title->getPrefixedText() );
278 - $html = Xml::tags( 'form',
279 - array( 'action' => $this->title->getLocalURL(),
280 - 'method' => 'get' ),
281 - $html );
282 -
 319+ $html = Xml::tags(
 320+ 'form',
 321+ array(
 322+ 'action' => $this->title->getLocalURL(),
 323+ 'method' => 'get'
 324+ ),
 325+ $html
 326+ );
 327+
283328 # $html = Xml::fieldset( wfMsg('lqt-search-legend' ), $html,
284329 # array( 'class' => 'lqt-talkpage-search' ) );
285330
286331 $html = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-search' ), $html );
287 -
 332+
288333 return $html;
289334 }
290 -
 335+
291336 function getPager() {
292 -
 337+
293338 $sortType = $this->getSortType();
294339 return new LqtDiscussionPager( $this->article, $sortType );
295340 }
296 -
 341+
297342 function getPageThreads( $pager ) {
298343 $rows = $pager->getRows();
299 -
 344+
300345 return Thread::bulkLoad( $rows );
301346 }
302 -
 347+
303348 function getSortType() {
304349 // Determine sort order
305350 if ( $this->request->getCheck( 'lqt_order' ) ) {
@@ -313,7 +358,7 @@
314359 return LQT_OLDEST_THREADS;
315360 }
316361 }
317 -
 362+
318363 // Default
319364 return LQT_NEWEST_CHANGES;
320365 }
@@ -324,39 +369,37 @@
325370 function __construct( $article, $orderType ) {
326371 $this->article = $article;
327372 $this->orderType = $orderType;
328 -
 373+
329374 parent::__construct();
330 -
 375+
331376 $this->mLimit = 20;
332377 }
333 -
 378+
334379 function getQueryInfo() {
335 - $queryInfo =
336 - array(
337 - 'tables' => array( 'thread' ),
338 - 'fields' => '*',
339 - 'conds' =>
340 - array(
341 - Threads::articleClause( $this->article ),
342 - Threads::topLevelClause(),
343 - 'thread_type != '. $this->mDb->addQuotes( Threads::TYPE_DELETED ),
344 - ),
345 - );
346 -
 380+ $queryInfo = array(
 381+ 'tables' => array( 'thread' ),
 382+ 'fields' => '*',
 383+ 'conds' => array(
 384+ Threads::articleClause( $this->article ),
 385+ Threads::topLevelClause(),
 386+ 'thread_type != ' . $this->mDb->addQuotes( Threads::TYPE_DELETED ),
 387+ ),
 388+ );
 389+
347390 return $queryInfo;
348391 }
349 -
 392+
350393 // Adapted from getBody().
351394 function getRows() {
352395 if ( !$this->mQueryDone ) {
353396 $this->doQuery();
354397 }
355 -
 398+
356399 # Don't use any extra rows returned by the query
357400 $numRows = min( $this->mResult->numRows(), $this->mLimit );
358401
359402 $rows = array();
360 -
 403+
361404 if ( $numRows ) {
362405 if ( $this->mIsBackwards ) {
363406 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
@@ -372,14 +415,14 @@
373416 }
374417 }
375418 }
376 -
 419+
377420 return $rows;
378421 }
379 -
 422+
380423 function formatRow( $row ) {
381424 // No-op, we get the list of rows from getRows()
382425 }
383 -
 426+
384427 function getIndexField() {
385428 switch( $this->orderType ) {
386429 case LQT_NEWEST_CHANGES:
@@ -388,10 +431,10 @@
389432 case LQT_NEWEST_THREADS:
390433 return 'thread_created';
391434 default:
392 - throw new MWException( "Unknown sort order ".$this->orderType );
 435+ throw new MWException( "Unknown sort order " . $this->orderType );
393436 }
394437 }
395 -
 438+
396439 function getDefaultDirections() {
397440 switch( $this->orderType ) {
398441 case LQT_NEWEST_CHANGES:
@@ -400,10 +443,10 @@
401444 case LQT_OLDEST_THREADS:
402445 return false; // Ascending
403446 default:
404 - throw new MWException( "Unknown sort order ".$this->orderType );
 447+ throw new MWException( "Unknown sort order " . $this->orderType );
405448 }
406449 }
407 -
 450+
408451 /**
409452 * A navigation bar with images
410453 * Stolen from TablePager because it's pretty.
@@ -453,7 +496,7 @@
454497 $s .= "</tr></table>\n";
455498 return $s;
456499 }
457 -
 500+
458501 function getNavClass() {
459502 return 'TalkpagePager_nav';
460503 }
Index: trunk/extensions/LiquidThreads/migrateDatabase.php
@@ -3,71 +3,73 @@
44 // Utility script to update your LiquidThreads installation by batch-running lazy updates
55 // normally done on-demand when a thread is loaded. Also runs any necessary database updates.
66
7 -require_once ( getenv('MW_INSTALL_PATH') !== false
8 - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc"
 7+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
 8+ ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
99 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
10 -
 10+
1111 $db = wfGetDB( DB_MASTER );
1212
1313 // Do database updates
14 -$threadFieldUpdates = array('thread_article_namespace' => 'split-thread_article.sql',
15 - 'thread_article_title' => 'split-thread_article.sql',
16 - 'thread_ancestor' => 'normalise-ancestry.sql',
17 - 'thread_parent' => 'normalise-ancestry.sql',
18 - 'thread_modified' => 'split-timestamps.sql',
19 - 'thread_created' => 'split-timestamps.sql',
20 - 'thread_editedness' => 'store-editedness.sql',
21 - 'thread_subject' => 'store_subject-author.sql',
22 - 'thread_author_id' => 'store_subject-author.sql',
23 - 'thread_author_name' => 'store_subject-author.sql',
24 - );
25 -$threadIndexUpdates = array('thread_summary_page' => 'index-summary_page.sql');
 14+$threadFieldUpdates = array(
 15+ 'thread_article_namespace' => 'split-thread_article.sql',
 16+ 'thread_article_title' => 'split-thread_article.sql',
 17+ 'thread_ancestor' => 'normalise-ancestry.sql',
 18+ 'thread_parent' => 'normalise-ancestry.sql',
 19+ 'thread_modified' => 'split-timestamps.sql',
 20+ 'thread_created' => 'split-timestamps.sql',
 21+ 'thread_editedness' => 'store-editedness.sql',
 22+ 'thread_subject' => 'store_subject-author.sql',
 23+ 'thread_author_id' => 'store_subject-author.sql',
 24+ 'thread_author_name' => 'store_subject-author.sql',
 25+);
 26+$threadIndexUpdates = array( 'thread_summary_page' => 'index-summary_page.sql' );
2627
2728 $newTableUpdates = array( 'thread_history' => 'thread_history_table.sql' );
2829
29 -foreach( $threadFieldUpdates as $field => $patch ) {
30 - if (!$db->fieldExists( 'thread', $field, 'lqt-update-script' ) ) {
31 - dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch );
 30+foreach ( $threadFieldUpdates as $field => $patch ) {
 31+ if ( !$db->fieldExists( 'thread', $field, 'lqt-update-script' ) ) {
 32+ dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch );
3233 }
3334 }
3435
35 -foreach( $threadIndexUpdates as $index => $patch ) {
36 - if (!$db->indexExists( 'thread', $index, 'lqt-update-script' ) ) {
37 - dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch );
 36+foreach ( $threadIndexUpdates as $index => $patch ) {
 37+ if ( !$db->indexExists( 'thread', $index, 'lqt-update-script' ) ) {
 38+ dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch );
3839 }
3940 }
4041
41 -foreach( $newTableUpdates as $table => $patch ) {
42 - if (!$db->tableExists( $table, 'lqt-update-script' ) ) {
43 - dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch );
 42+foreach ( $newTableUpdates as $table => $patch ) {
 43+ if ( !$db->tableExists( $table, 'lqt-update-script' ) ) {
 44+ dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch );
4445 }
4546 }
4647
47 -
4848 // Batch lazy updates
4949 $upTo = $lastUpTo = 0;
5050
5151 do {
5252 $lastUpTo = $upTo;
53 -
 53+
5454 $db->begin();
55 -
 55+
5656 // Read 500 rows
57 - $res = $db->select( 'thread', '*', array( 'thread_id>'.$db->addQuotes($upTo ) ),
58 - 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE',
59 - 'ORDER BY' => 'thread_id asc' ) );
60 -
 57+ $res = $db->select(
 58+ 'thread', '*', array( 'thread_id>' . $db->addQuotes( $upTo ) ),
 59+ 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE',
 60+ 'ORDER BY' => 'thread_id asc' )
 61+ );
 62+
6163 $threads = Threads::loadFromResult( $res, $db );
62 -
63 - foreach( $threads as $thread ) {
 64+
 65+ foreach ( $threads as $thread ) {
6466 $thread->doLazyUpdates();
6567 $thread->updateHistory();
66 -
 68+
6769 if ( $thread->id() > $upTo ) {
6870 $upTo = $thread->id();
6971 }
7072 }
71 -
 73+
7274 $db->commit();
73 -
 75+
7476 } while ( $lastUpTo != $upTo );
Index: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php
@@ -17,9 +17,9 @@
1818 * http://www.gnu.org/copyleft/gpl.html
1919 */
2020
21 -if (!defined('MEDIAWIKI')) {
 21+if ( !defined( 'MEDIAWIKI' ) ) {
2222 // Eclipse helper - will be ignored in production
23 - require_once ("ApiBase.php");
 23+ require_once ( "ApiBase.php" );
2424 }
2525
2626 /**
@@ -29,15 +29,15 @@
3030 */
3131 class ApiFeedLQTThreads extends ApiBase {
3232
33 - public function __construct($main, $action) {
34 - parent :: __construct($main, $action);
 33+ public function __construct( $main, $action ) {
 34+ parent :: __construct( $main, $action );
3535 }
3636
3737 /**
3838 * This module uses a custom feed wrapper printer.
3939 */
4040 public function getCustomPrinter() {
41 - return new ApiFormatFeedWrapper($this->getMain());
 41+ return new ApiFormatFeedWrapper( $this->getMain() );
4242 }
4343
4444 /**
@@ -46,98 +46,102 @@
4747 */
4848 public function execute() {
4949 global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgContLanguageCode;
50 -
 50+
5151 $params = $this->extractRequestParams();
52 -
 52+
5353 $db = wfGetDB( DB_SLAVE );
54 -
 54+
5555 $feedTitle = self::createFeedTitle( $params );
5656 $feedClass = $wgFeedClasses[$params['feedformat']];
5757 // TODO need a better URL :)
5858 $feedUrl = 'http://www.mediawiki.org/wiki/Extension:LiquidThreads';
5959 $feedItems = array();
60 -
 60+
6161 $tables = array( 'thread' );
6262 $fields = array( 'thread.*' );
6363 $conds = $this->getConditions( $params, $db );
6464 $options = array( 'LIMIT' => 200, 'ORDER BY' => 'thread_created DESC' );
65 -
 65+
6666 $res = $db->select( $tables, $fields, $conds, __METHOD__, $options );
67 -
68 - foreach( $res as $row ) {
 67+
 68+ foreach ( $res as $row ) {
6969 $feedItems[] = $this->createFeedItem( $row );
7070 }
71 -
72 - $feed = new $feedClass($feedTitle, '', $feedUrl);
7371
74 - ApiFormatFeedWrapper :: setResult($this->getResult(), $feed, $feedItems);
 72+ $feed = new $feedClass( $feedTitle, '', $feedUrl );
 73+
 74+ ApiFormatFeedWrapper :: setResult( $this->getResult(), $feed, $feedItems );
7575 }
76 -
77 - private function createFeedItem($row) {
 76+
 77+ private function createFeedItem( $row ) {
7878 global $wgOut;
7979 $thread = new Thread( $row );
8080 $linker = new Linker;
81 -
 81+
8282 $titleStr = $thread->subject();
8383 $completeText = $thread->root()->getContent();
8484 $completeText = $wgOut->parse( $completeText );
8585 $threadTitle = clone $thread->topmostThread()->title();
86 - $threadTitle->setFragment( '#'.$thread->getAnchorName() );
 86+ $threadTitle->setFragment( '#' . $thread->getAnchorName() );
8787 $titleUrl = $threadTitle->getFullURL();
8888 $timestamp = $thread->created();
8989 $user = $thread->author()->getName();
90 -
 90+
9191 // Grab the title for the superthread, if one exists.
9292 $stTitle = null;
9393 if ( $thread->hasSuperThread() ) {
9494 $stTitle = clone $thread->topmostThread()->title();
95 - $stTitle->setFragment( '#'.$thread->superthread()->getAnchorName() );
 95+ $stTitle->setFragment( '#' . $thread->superthread()->getAnchorName() );
9696 }
97 -
 97+
9898 // Prefix content with a quick description
9999 $userLink = $linker->userLink( $thread->author()->getId(), $user );
100100 $talkpageLink = $linker->link( $thread->article()->getTitle() );
101101 $superthreadLink = $linker->link( $stTitle );
102 -
 102+
103103 $description = '';
104104 if ( $thread->hasSuperThread() ) {
105 - $description = wfMsgExt( 'lqt-feed-reply-intro',
106 - array( 'parse', 'replaceafter' ),
107 - array( $talkpageLink, $userLink, $superthreadLink ) );
 105+ $description = wfMsgExt(
 106+ 'lqt-feed-reply-intro',
 107+ array( 'parse', 'replaceafter' ),
 108+ array( $talkpageLink, $userLink, $superthreadLink )
 109+ );
108110 } else {
109 - $description = wfMsgExt( 'lqt-feed-new-thread-intro',
110 - array( 'parse', 'replaceafter' ),
111 - array( $talkpageLink, $userLink ) );
 111+ $description = wfMsgExt(
 112+ 'lqt-feed-new-thread-intro',
 113+ array( 'parse', 'replaceafter' ),
 114+ array( $talkpageLink, $userLink )
 115+ );
112116 }
113 -
 117+
114118 $completeText = $description . $completeText;
115119
116 - return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 120+ return new FeedItem( $titleStr, $completeText, $titleUrl, $timestamp, $user );
117121 }
118 -
 122+
119123 public static function createFeedTitle( $params ) {
120124 wfLoadExtensionMessages( 'LiquidThreads' );
121125 $fromPlaces = array();
122 -
123 - foreach( (array)$params['thread'] as $thread ) {
 126+
 127+ foreach ( (array)$params['thread'] as $thread ) {
124128 $t = Title::newFromText( $thread );
125129 $fromPlaces[] = $t->getPrefixedText();
126130 }
127 -
128 - foreach( (array)$params['talkpage'] as $talkpage ) {
 131+
 132+ foreach ( (array)$params['talkpage'] as $talkpage ) {
129133 $t = Title::newFromText( $talkpage );
130134 $fromPlaces[] = $t->getPrefixedText();
131135 }
132 -
 136+
133137 global $wgLang;
134 - $fromCount = count($fromPlaces);
 138+ $fromCount = count( $fromPlaces );
135139 $fromPlaces = $wgLang->commaList( $fromPlaces );
136 -
 140+
137141 // What's included?
138142 $types = (array)$params['type'];
139 -
 143+
140144 $msg = '';
141 -
 145+
142146 if ( !count( array_diff( array( 'replies', 'newthreads' ), $types ) ) ) {
143147 $msg = 'lqt-feed-title-all';
144148 } elseif ( in_array( 'replies', $types ) ) {
@@ -145,67 +149,71 @@
146150 } elseif ( in_array( 'newthreads', $types ) ) {
147151 $msg = 'lqt-feed-title-new-threads';
148152 } else {
149 - throw new MWException( "Unable to determine appropriate display type");
 153+ throw new MWException( "Unable to determine appropriate display type" );
150154 }
151 -
 155+
152156 if ( $fromCount ) {
153157 $msg .= '-from';
154158 }
155 -
 159+
156160 return wfMsg( $msg, $fromPlaces, $fromCount );
157161 }
158 -
 162+
159163 function getConditions( $params, $db ) {
160164 $conds = array();
161 -
 165+
162166 // Types
163167 $conds['thread_type'] = Threads::TYPE_NORMAL;
164 -
 168+
165169 // Limit
166 - $cutoff = time() - intval($params['days'] * 24 * 3600);
 170+ $cutoff = time() - intval( $params['days'] * 24 * 3600 );
167171 $cutoff = $db->timestamp( $cutoff );
168172 $conds[] = 'thread_created > ' . $db->addQuotes( $cutoff );
169 -
 173+
170174 // Talkpage conditions
171175 $pageConds = array();
172 -
 176+
173177 $talkpages = (array)$params['talkpage'];
174 - foreach( $talkpages as $page ) {
 178+ foreach ( $talkpages as $page ) {
175179 $title = Title::newFromText( $page );
176 - $pageCond = array( 'thread_article_namespace' => $title->getNamespace(),
177 - 'thread_article_title' => $title->getDBkey() );
 180+ $pageCond = array(
 181+ 'thread_article_namespace' => $title->getNamespace(),
 182+ 'thread_article_title' => $title->getDBkey()
 183+ );
178184 $pageConds[] = $db->makeList( $pageCond, LIST_AND );
179185 }
180 -
 186+
181187 // Thread conditions
182188 $threadConds = array();
183189 $threads = (array)$params['thread'];
184 - foreach( $threads as $thread ) {
 190+ foreach ( $threads as $thread ) {
185191 $root = new Article( Title::newFromText( $thread ) );
186192 $thread = Threads::withRoot( $root );
187 -
188 - $threadCond = array( 'thread_ancestor' => $thread->id(),
189 - 'thread_id' => $thread->id() );
 193+
 194+ $threadCond = array(
 195+ 'thread_ancestor' => $thread->id(),
 196+ 'thread_id' => $thread->id()
 197+ );
190198 $pageConds[] = $db->makeList( $threadCond, LIST_OR );
191199 }
192 - if ( count($pageConds) ) {
 200+ if ( count( $pageConds ) ) {
193201 $conds[] = $db->makeList( $pageConds, LIST_OR );
194202 }
195 -
 203+
196204 // New thread v. Reply
197205 $types = (array)$params['type'];
198206 if ( !in_array( 'replies', $types ) ) {
199207 $conds[] = Threads::topLevelClause();
200208 } elseif ( !in_array( 'newthreads', $types ) ) {
201 - $conds[] = '!'.Threads::topLevelClause();
 209+ $conds[] = '!' . Threads::topLevelClause();
202210 }
203 -
 211+
204212 return $conds;
205213 }
206214
207215 public function getAllowedParams() {
208216 global $wgFeedClasses;
209 - $feedFormatNames = array_keys($wgFeedClasses);
 217+ $feedFormatNames = array_keys( $wgFeedClasses );
210218 return array (
211219 'feedformat' => array (
212220 ApiBase :: PARAM_DFLT => 'rss',
Property changes on: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php
___________________________________________________________________
Added: svn:eol-style
213221 + native
Index: trunk/extensions/LiquidThreads/api/ApiQueryLQTThreads.php
@@ -15,20 +15,25 @@
1616 * - "root" page ID
1717 * - type
1818 */
 19+
1920 class ApiQueryLQTThreads extends ApiQueryBase {
2021
2122 // Property definitions
2223 static $propRelations = array(
2324 'id' => 'thread_id',
2425 'subject' => 'thread_subject',
25 - 'page' => array( 'namespace' => 'thread_article_namespace',
26 - 'title' => 'thread_article_title' ),
 26+ 'page' => array(
 27+ 'namespace' => 'thread_article_namespace',
 28+ 'title' => 'thread_article_title'
 29+ ),
2730 'parent' => 'thread_parent',
2831 'ancestor' => 'thread_ancestor',
2932 'created' => 'thread_created',
3033 'modified' => 'thread_modified',
31 - 'author' => array( 'id' => 'thread_author_id',
32 - 'name' => 'thread_author_name'),
 34+ 'author' => array(
 35+ 'id' => 'thread_author_id',
 36+ 'name' => 'thread_author_name'
 37+ ),
3338 'summaryid' => 'thread_summary_page',
3439 'rootid' => 'thread_root',
3540 'type' => 'thread_type',
@@ -40,20 +45,20 @@
4146
4247 public function execute() {
4348 global $wgUser;
44 -
 49+
4550 $params = $this->extractRequestParams();
4651 $prop = array_flip( $params['prop'] );
4752 $result = $this->getResult();
4853 $this->addTables( 'thread' );
4954 $this->addFields( 'thread_id' );
50 -
 55+
5156 foreach ( self::$propRelations as $name => $fields ) {
5257 // Pass a straight array rather than one with string
5358 // keys, to be sure that merging it into other added
5459 // arrays doesn't mess stuff up
5560 $this->addFieldsIf( array_values( (array)$fields ), isset( $prop[$name] ) );
5661 }
57 -
 62+
5863 // Check for conditions
5964 $conditionFields = array( 'page', 'root', 'summary', 'author', 'id' );
6065 foreach ( $conditionFields as $field ) {
@@ -65,23 +70,25 @@
6671 $this->addOption( 'LIMIT', $params['limit'] + 1 );
6772 $this->addWhereRange( 'thread_id', $params['dir'],
6873 $params['startid'], $params['endid'] );
69 -
 74+
7075 if ( !$params['showdeleted'] ) {
71 - $delType = $this->getDB()->addQuotes( Threads::TYPE_DELETED );
 76+ $delType = $this->getDB()->addQuotes( Threads::TYPE_DELETED );
7277 $this->addWhere( "thread_type != $delType" );
7378 }
74 -
 79+
7580 if ( $params['render'] ) {
7681 // All fields
77 - $allFields = array( 'thread_id', 'thread_root', 'thread_article_namespace',
 82+ $allFields = array(
 83+ 'thread_id', 'thread_root', 'thread_article_namespace',
7884 'thread_article_title', 'thread_summary_page', 'thread_ancestor',
7985 'thread_parent', 'thread_modified', 'thread_created', 'thread_type',
80 - 'thread_editedness', 'thread_subject', 'thread_author_id',
81 - 'thread_author_name' );
82 -
 86+ 'thread_editedness', 'thread_subject', 'thread_author_id',
 87+ 'thread_author_name'
 88+ );
 89+
8390 $this->addFields( $allFields );
8491 }
85 -
 92+
8693 $res = $this->select( __METHOD__ );
8794 $count = 0;
8895 foreach ( $res as $row )
@@ -91,22 +98,22 @@
9299 $this->setContinueEnumParameter( 'startid', $row->thread_id );
93100 break;
94101 }
95 -
 102+
96103 $entry = array();
97104 foreach ( $prop as $name => $nothing ) {
98105 $fields = self::$propRelations[$name];
99106 self::formatProperty( $name, $fields, $row, $entry );
100107 }
101 -
 108+
102109 // Render if requested
103110 if ( $params['render'] ) {
104111 self::renderThread( $row, $params, $entry );
105112 }
106 -
 113+
107114 if ( $entry ) {
108115 $fit = $result->addValue( array( 'query',
109116 $this->getModuleName() ),
110 - null, $entry);
 117+ null, $entry );
111118 if ( !$fit ) {
112119 $this->setContinueEnumParameter( 'startid', $row->thread_id );
113120 break;
@@ -115,42 +122,42 @@
116123 }
117124 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'thread' );
118125 }
119 -
 126+
120127 static function renderThread( $row, $params, &$entry ) {
121128 // Set up OutputPage
122129 global $wgOut, $wgUser, $wgRequest;
123130 $oldOutputText = $wgOut->getHTML();
124131 $wgOut->clearHTML();
125 -
 132+
126133 // Setup
127134 $thread = new Thread( $row );
128135 $article = $thread->root();
129136 $title = $article->getTitle();
130137 $view = new LqtView( $wgOut, $article, $title, $wgUser, $wgRequest );
131 -
 138+
132139 // Parameters
133140 $view->threadNestingLevel = $params['renderlevel'];
134 -
 141+
135142 $renderpos = $params['renderthreadpos'];
136143 $rendercount = $params['renderthreadcount'];
137 -
 144+
138145 $options = array();
139 - if ( isset($params['rendermaxthreadcount']) )
 146+ if ( isset( $params['rendermaxthreadcount'] ) )
140147 $options['maxCount'] = $params['rendermaxthreadcount'];
141 - if ( isset($params['rendermaxdepth']) )
 148+ if ( isset( $params['rendermaxdepth'] ) )
142149 $options['maxDepth'] = $params['rendermaxdepth'];
143 - if ( isset($params['renderstartrepliesat']) )
 150+ if ( isset( $params['renderstartrepliesat'] ) )
144151 $options['startAt' ] = $params['renderstartrepliesat'];
145 -
 152+
146153 $view->showThread( $thread, $renderpos, $rendercount, $options );
147 -
 154+
148155 $result = $wgOut->getHTML();
149156 $wgOut->clearHTML();
150157 $wgOut->addHTML( $oldOutputText );
151 -
 158+
152159 $entry['content'] = $result;
153160 }
154 -
 161+
155162 static function formatProperty( $name, $fields, $row, &$entry ) {
156163 if ( !is_array( $fields ) ) {
157164 // Common case.
@@ -170,7 +177,7 @@
171178 }
172179 }
173180 }
174 -
 181+
175182 function addPageCond( $prop, $value ) {
176183 if ( count( $value ) === 1 ) {
177184 $cond = $this->getPageCond( $prop, $value[0] );
@@ -181,12 +188,12 @@
182189 $cond = $this->getPageCond( $prop, $page );
183190 $conds[] = $this->getDB()->makeList( $cond, LIST_AND );
184191 }
185 -
 192+
186193 $cond = $this->getDB()->makeList( $conds, LIST_OR );
187194 $this->addWhere( $cond );
188195 }
189196 }
190 -
 197+
191198 function getPageCond( $prop, $value ) {
192199 $fieldMappings = array(
193200 'page' => array(
@@ -196,7 +203,7 @@
197204 'root' => array( 'id' => 'thread_root' ),
198205 'summary' => array( 'id' => 'thread_summary_id' ),
199206 );
200 -
 207+
201208 // Split.
202209 $t = Title::newFromText( $value );
203210 $cond = array();
@@ -217,11 +224,11 @@
218225 }
219226 return $cond;
220227 }
221 -
 228+
222229 function handleCondition( $prop, $value ) {
223230 $titleParams = array( 'page', 'root', 'summary' );
224231 $fields = self::$propRelations[$prop];
225 -
 232+
226233 if ( in_array( $prop, $titleParams ) ) {
227234 // Special cases
228235 $this->addPageCond( $prop, $value );
@@ -261,7 +268,7 @@
262269 ApiBase :: PARAM_TYPE => array_keys( self::$propRelations ),
263270 ApiBase :: PARAM_ISMULTI => true
264271 ),
265 -
 272+
266273 'page' => array(
267274 ApiBase :: PARAM_ISMULTI => true
268275 ),
@@ -297,8 +304,8 @@
298305 ApiBase :: PARAM_DFLT => null,
299306 ),
300307 );
301 - }
302 -
 308+ }
 309+
303310 public function getParamDescription() {
304311 return array (
305312 'startid' => 'The thread id to start enumerating from',
Index: trunk/extensions/LiquidThreads/import/import-parsed-discussions.php
@@ -1,12 +1,12 @@
22 <?php
33
4 -require_once ( getenv('MW_INSTALL_PATH') !== false
5 - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc"
 4+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
 5+ ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
66 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
77
8 -## Imports JSON-encoded discussions from parse-wikitext-discussions.pl
 8+# # Imports JSON-encoded discussions from parse-wikitext-discussions.pl
99
10 -$structure = json_decode(file_get_contents( $argv[1] ), true);
 10+$structure = json_decode( file_get_contents( $argv[1] ), true );
1111
1212 $article = new Article( Title::newFromText( $argv[2] ) );
1313
@@ -17,35 +17,35 @@
1818
1919 function recursiveParseArray( $array ) {
2020 static $recurseLevel = 0;
21 -
 21+
2222 $recurseLevel++;
23 -
24 - if ($recurseLevel > 90) {
 23+
 24+ if ( $recurseLevel > 90 ) {
2525 print var_dump( $array );
2626 die( wfBacktrace() );
2727 }
28 -
 28+
2929 global $subject, $rootPost;
30 - if ( is_array( $array ) && isset($array['title']) ) {
 30+ if ( is_array( $array ) && isset( $array['title'] ) ) {
3131 $subject = $array['title'];
3232 recursiveParseArray( $array['content'] );
33 -
 33+
3434 $rootPost = null;
35 - } elseif ( is_array( $array ) && isset($array['user']) ) {
 35+ } elseif ( is_array( $array ) && isset( $array['user'] ) ) {
3636 // We have a post.
3737 $t = createPost( $array, $subject, $rootPost );
38 -
39 - if (!$rootPost) {
 38+
 39+ if ( !$rootPost ) {
4040 $rootPost = $t;
4141 }
42 - } elseif (is_array($array)) {
43 - foreach( $array as $info ) {
 42+ } elseif ( is_array( $array ) ) {
 43+ foreach ( $array as $info ) {
4444 recursiveParseArray( $info );
4545 }
46 -
 46+
4747 $rootPost = null;
4848 }
49 -
 49+
5050 $recurseLevel--;
5151 }
5252
@@ -53,33 +53,33 @@
5454 $userName = $info['user'];
5555 if ( strpos( $userName, '#' ) !== false ) {
5656 $pos = strpos( $userName, '#' );
57 -
 57+
5858 $userName = substr( $userName, 0, $pos );
5959 }
60 -
 60+
6161 $user = User::newFromName( $userName, /* no validation */ false );
62 -
63 - if (!$user) {
64 - throw new MWException( "Username ".$info['user']." is invalid." );
 62+
 63+ if ( !$user ) {
 64+ throw new MWException( "Username " . $info['user'] . " is invalid." );
6565 }
66 -
 66+
6767 global $article;
68 -
69 - if ($super) {
 68+
 69+ if ( $super ) {
7070 $title = Threads::newReplyTitle( $super, $user );
7171 } else {
7272 $title = Threads::newThreadTitle( $subject, $article );
7373 }
74 -
75 - print "Creating thread $title as a subthread of ".($super ? $super->title() : 'none')."\n";
76 -
 74+
 75+ print "Creating thread $title as a subthread of " . ( $super ? $super->title() : 'none' ) . "\n";
 76+
7777 $root = new Article( $title );
7878 $root->doEdit( $info['content'], 'Imported from JSON', EDIT_NEW, false, $user );
79 -
80 - $t = LqtView::postEditUpdates($super ? 'reply' : 'new', $super, $root, $article,
 79+
 80+ $t = LqtView::postEditUpdates( $super ? 'reply' : 'new', $super, $root, $article,
8181 $subject, 'Imported from JSON', null );
82 -
 82+
8383 $t = Threads::withId( $t->id() ); // Some weirdness.
84 -
 84+
8585 return $t;
8686 }
Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -19,7 +19,7 @@
2020 * Recreate the original associative array so that a new pair with the given key
2121 * and value is inserted before the given existing key. $original_array gets
2222 * modified in-place.
23 -*/
 23+ */
2424 function efInsertIntoAssoc( $new_key, $new_value, $before, &$original_array ) {
2525 $ordered = array();
2626 $i = 0;
@@ -44,7 +44,7 @@
4545
4646 function lqtSetupParserFunctions() {
4747 global $wgParser;
48 -
 48+
4949 $wgParser->setFunctionHook( 'useliquidthreads',
5050 array( 'LqtParserFunctions', 'useLiquidThreads' ) );
5151 return true;
Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php
@@ -183,7 +183,7 @@
184184 'lqt-thread-split' => 'Split to new thread',
185185 'lqt-split-success' => 'You have successfully split off the thread $1.',
186186 'lqt_split_thread' => 'Split a thread',
187 - 'lqt-thread-split-subject'=> 'New thread subject:',
 187+ 'lqt-thread-split-subject' => 'New thread subject:',
188188 'lqt-thread-split-thread' => 'Thread:',
189189 'lqt-split-submit' => 'Split',
190190 'lqt_split_badsubject' => 'The subject you entered is invalid.',
@@ -249,7 +249,7 @@
250250 'lqt-ajax-update-link' => 'Update',
251251 'lqt-thread-show-replies' => 'Show $1 replies',
252252 'lqt-thread-show-more' => 'Show more replies',
253 -
 253+
254254 // Feeds
255255 'lqt-feed-title-all' => '{{SITENAME}} — New posts',
256256 'lqt-feed-title-all-from' => '{{SITENAME}} — New posts from $1',
@@ -999,12 +999,12 @@
10001000 'lqt-enotif-subject-reply' => 'Абмеркаваньне {{GRAMMAR:родны|{{SITENAME}}}} — Адказ: $1',
10011001 'lqt-enotif-subject-newthread' => 'Абмеркаваньне {{GRAMMAR:родны|{{SITENAME}}}} — Новая галіна: $1',
10021002 'lqt-enotif-newthread' => "Вітаем $1,
1003 -Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новую галіну $5, '$2',
 1003+Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новую галіну $5, '$2',
10041004 створаную $3 $4.
10051005
10061006 Вы можаце паглядзець яе на <$6>",
10071007 'lqt-enotif-reply' => "Вітаем $1,
1008 -Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новы адказ $5, '$2',
 1008+Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новы адказ $5, '$2',
10091009 створаны $3 $4.
10101010
10111011 Вы можаце паглядзець яго на <$6>",
@@ -1338,7 +1338,7 @@
13391339 'lqt_invalid_subject' => 'El tema que heu introduït no és vàlid.
13401340 Pot:
13411341 * contenir caràcters no vàlids, com []{}&lt;&gt;,
1342 -* ser massa llarg, o
 1342+* ser massa llarg, o
13431343 * entrar en conflicte amb prefixos interwiki o altres espai de noms.',
13441344 'lqt_subject_change_forbidden' => "No podeu canviar el tema d'aquest fil perquè no teniu el permís de moure les pàgines.",
13451345 'lqt_in_response_to' => 'En resposta a $1 per $2, amunt:',
Index: trunk/extensions/LiquidThreads/compat/Lqt-compat.i18n.php
@@ -1,7 +1,7 @@
22 <?php
33 // This file is generated automatically by generateCompatibilityLocalisation.php
44 $messages = array (
5 - 'ar' =>
 5+ 'ar' =>
66 array (
77 'htmlform-reset' => 'الرجوع عن التغييرات',
88 'htmlform-submit' => 'تنفيذ',
@@ -12,13 +12,13 @@
1313 'htmlform-selectorother-other' => 'أخرى',
1414 'htmlform-invalid-input' => 'توجد مشكلات ضمن بعض من مدخلاتك',
1515 ),
16 - 'arc' =>
 16+ 'arc' =>
1717 array (
1818 'htmlform-reset' => 'ܠܐ ܥܒܘܕ ܫܘܚܠܦ̈ܐ',
1919 'htmlform-submit' => 'ܫܕܪ',
2020 'htmlform-selectorother-other' => 'ܐܚܪܢܐ',
2121 ),
22 - 'arz' =>
 22+ 'arz' =>
2323 array (
2424 'htmlform-reset' => 'الرجوع فى التغييرات',
2525 'htmlform-submit' => 'تقديم',
@@ -29,7 +29,7 @@
3030 'htmlform-selectorother-other' => 'تانيين',
3131 'htmlform-invalid-input' => 'فى مشاكل فى المدخلات بتاعتك',
3232 ),
33 - 'bcc' =>
 33+ 'bcc' =>
3434 array (
3535 'htmlform-reset' => 'ترینگ تغییرات',
3636 'htmlform-submit' => 'دیم دی',
@@ -40,7 +40,7 @@
4141 'htmlform-selectorother-other' => 'دگه',
4242 'htmlform-invalid-input' => 'لهتی چه ورودی شما مشکل هست',
4343 ),
44 - 'be-tarask' =>
 44+ 'be-tarask' =>
4545 array (
4646 'htmlform-reset' => 'Адмяніць зьмены',
4747 'htmlform-submit' => 'Захаваць',
@@ -51,13 +51,13 @@
5252 'htmlform-selectorother-other' => 'Іншае',
5353 'htmlform-invalid-input' => 'Узьніклі праблемы з некаторымі з Вашых уваходных зьвестак',
5454 ),
55 - 'bg' =>
 55+ 'bg' =>
5656 array (
5757 'htmlform-reset' => 'Отказване на промените',
5858 'htmlform-submit' => 'Изпращане',
5959 'htmlform-selectorother-other' => 'Друга',
6060 ),
61 - 'br' =>
 61+ 'br' =>
6262 array (
6363 'htmlform-reset' => 'Dizober ar c\'hemmoù',
6464 'htmlform-submit' => 'Kas',
@@ -68,7 +68,7 @@
6969 'htmlform-selectorother-other' => 'Unan all',
7070 'htmlform-invalid-input' => 'Kudennoù zo gant talvoudennoù zo merket ganeoc\'h.',
7171 ),
72 - 'bs' =>
 72+ 'bs' =>
7373 array (
7474 'htmlform-reset' => 'Vrati izmjene',
7575 'htmlform-submit' => 'Pošalji',
@@ -79,7 +79,7 @@
8080 'htmlform-selectorother-other' => 'Ostalo',
8181 'htmlform-invalid-input' => 'Postoje određeni problemi s Vašim unosom',
8282 ),
83 - 'ca' =>
 83+ 'ca' =>
8484 array (
8585 'htmlform-reset' => 'Desfés els canvis',
8686 'htmlform-submit' => 'Tramet',
@@ -90,11 +90,11 @@
9191 'htmlform-selectorother-other' => 'Altres',
9292 'htmlform-invalid-input' => 'Hi ha problemes amb alguna de les seves entrades',
9393 ),
94 - 'ckb-arab' =>
 94+ 'ckb-arab' =>
9595 array (
9696 'htmlform-reset' => 'گەڕانەوەی گۆڕانکاری',
9797 ),
98 - 'cs' =>
 98+ 'cs' =>
9999 array (
100100 'htmlform-reset' => 'Vrátit změny',
101101 'htmlform-submit' => 'Odeslat',
@@ -105,12 +105,12 @@
106106 'htmlform-selectorother-other' => 'Jiná hodnota',
107107 'htmlform-invalid-input' => 'Některé vámi zadané údaje jsou chybné',
108108 ),
109 - 'cy' =>
 109+ 'cy' =>
110110 array (
111111 'htmlform-reset' => 'Datod y newidiadau',
112112 'htmlform-selectorother-other' => 'Arall',
113113 ),
114 - 'da' =>
 114+ 'da' =>
115115 array (
116116 'htmlform-reset' => 'Annuller ændringer',
117117 'htmlform-submit' => 'Gem',
@@ -121,7 +121,7 @@
122122 'htmlform-selectorother-other' => 'Anden',
123123 'htmlform-invalid-input' => 'Det er problemer med dine angivelser',
124124 ),
125 - 'de' =>
 125+ 'de' =>
126126 array (
127127 'htmlform-reset' => 'Änderungen rückgängig machen',
128128 'htmlform-submit' => 'Übertragen',
@@ -132,7 +132,7 @@
133133 'htmlform-selectorother-other' => 'Andere',
134134 'htmlform-invalid-input' => 'Mit einigen Eingaben gibt es Probleme',
135135 ),
136 - 'dsb' =>
 136+ 'dsb' =>
137137 array (
138138 'htmlform-reset' => 'Změny anulěrowaś',
139139 'htmlform-submit' => 'Wótpósłaś',
@@ -143,7 +143,7 @@
144144 'htmlform-selectorother-other' => 'Druge',
145145 'htmlform-invalid-input' => 'Su někotare problemy z twójim zapodaśim',
146146 ),
147 - 'el' =>
 147+ 'el' =>
148148 array (
149149 'htmlform-reset' => 'Αναστροφή αλλαγών',
150150 'htmlform-submit' => 'Υποβολή',
@@ -154,7 +154,7 @@
155155 'htmlform-selectorother-other' => 'Άλλο',
156156 'htmlform-invalid-input' => 'Υπάρχουν κάποια προβλήματα με μερικές από τις εισροές σας',
157157 ),
158 - 'en' =>
 158+ 'en' =>
159159 array (
160160 'htmlform-reset' => 'Undo changes',
161161 'htmlform-submit' => 'Submit',
@@ -165,7 +165,7 @@
166166 'htmlform-selectorother-other' => 'Other',
167167 'htmlform-invalid-input' => 'There are problems with some of your input',
168168 ),
169 - 'eo' =>
 169+ 'eo' =>
170170 array (
171171 'htmlform-reset' => 'Malfari ŝanĝojn',
172172 'htmlform-submit' => 'Ek!',
@@ -176,7 +176,7 @@
177177 'htmlform-selectorother-other' => 'Alia',
178178 'htmlform-invalid-input' => 'Estas problemoj kun iom da via enigo',
179179 ),
180 - 'es' =>
 180+ 'es' =>
181181 array (
182182 'htmlform-reset' => 'Deshacer cambios',
183183 'htmlform-submit' => 'Enviar',
@@ -187,13 +187,13 @@
188188 'htmlform-selectorother-other' => 'Otro',
189189 'htmlform-invalid-input' => 'Hay problemas con alguno de tus ingresos',
190190 ),
191 - 'eu' =>
 191+ 'eu' =>
192192 array (
193193 'htmlform-reset' => 'Aldaketak desegin',
194194 'htmlform-submit' => 'Bidali',
195195 'htmlform-selectorother-other' => 'Beste bat',
196196 ),
197 - 'fa' =>
 197+ 'fa' =>
198198 array (
199199 'htmlform-reset' => 'خنثی کردن تغییرات',
200200 'htmlform-submit' => 'ارسال',
@@ -204,7 +204,7 @@
205205 'htmlform-selectorother-other' => 'دیگر',
206206 'htmlform-invalid-input' => 'بخشی از ورودی شما مشکل دارد',
207207 ),
208 - 'fi' =>
 208+ 'fi' =>
209209 array (
210210 'htmlform-reset' => 'Kumoa muutokset',
211211 'htmlform-submit' => 'Lähetä',
@@ -215,7 +215,7 @@
216216 'htmlform-selectorother-other' => 'Muu',
217217 'htmlform-invalid-input' => 'Antamassasi syötteessä on ongelmia',
218218 ),
219 - 'fr' =>
 219+ 'fr' =>
220220 array (
221221 'htmlform-reset' => 'Défaire les modifications',
222222 'htmlform-submit' => 'Soumettre',
@@ -226,7 +226,7 @@
227227 'htmlform-selectorother-other' => 'Autre',
228228 'htmlform-invalid-input' => 'Des problèmes sont survenus avec certaines valeurs',
229229 ),
230 - 'frp' =>
 230+ 'frp' =>
231231 array (
232232 'htmlform-reset' => 'Dèfâre los changements',
233233 'htmlform-submit' => 'Sometre',
@@ -237,7 +237,7 @@
238238 'htmlform-selectorother-other' => 'Ôtro',
239239 'htmlform-invalid-input' => 'Des problèmos sont arrevâs avouéc quârques valors',
240240 ),
241 - 'gl' =>
 241+ 'gl' =>
242242 array (
243243 'htmlform-reset' => 'Desfacer os cambios',
244244 'htmlform-submit' => 'Enviar',
@@ -248,7 +248,7 @@
249249 'htmlform-selectorother-other' => 'Outra',
250250 'htmlform-invalid-input' => 'Hai algún problema con partes do texto que inseriu',
251251 ),
252 - 'grc' =>
 252+ 'grc' =>
253253 array (
254254 'htmlform-reset' => 'Ἀναστρέφειν μεταβολάς',
255255 'htmlform-submit' => 'Ὑποβάλλειν',
@@ -259,7 +259,7 @@
260260 'htmlform-selectorother-other' => 'Ἄλλον',
261261 'htmlform-invalid-input' => 'Μέρος τῶν εἰσαγομένων δεδομένων σου προβληματικὸν ἐστίν',
262262 ),
263 - 'gsw' =>
 263+ 'gsw' =>
264264 array (
265265 'htmlform-reset' => 'Änderige ruckgängig mache',
266266 'htmlform-submit' => 'Ibertrage',
@@ -270,7 +270,7 @@
271271 'htmlform-selectorother-other' => 'Anderi',
272272 'htmlform-invalid-input' => 'Mit e Teil Yygabe git s Probläm',
273273 ),
274 - 'he' =>
 274+ 'he' =>
275275 array (
276276 'htmlform-reset' => 'ביטול השינויים',
277277 'htmlform-submit' => 'שליחה',
@@ -281,7 +281,7 @@
282282 'htmlform-selectorother-other' => 'אחר',
283283 'htmlform-invalid-input' => 'יש בעיות עם חלק מהקלט שהכנסתם',
284284 ),
285 - 'hr' =>
 285+ 'hr' =>
286286 array (
287287 'htmlform-reset' => 'Poništi izmjene',
288288 'htmlform-submit' => 'Pošalji',
@@ -292,7 +292,7 @@
293293 'htmlform-selectorother-other' => 'Drugi',
294294 'htmlform-invalid-input' => 'Postoje problemi s nekim od vaših unosa',
295295 ),
296 - 'hsb' =>
 296+ 'hsb' =>
297297 array (
298298 'htmlform-reset' => 'Změny cofnyć',
299299 'htmlform-submit' => 'Wotpósłać',
@@ -303,7 +303,7 @@
304304 'htmlform-selectorother-other' => 'Druhe',
305305 'htmlform-invalid-input' => 'Su problemy z twojim zapodaćom',
306306 ),
307 - 'hu' =>
 307+ 'hu' =>
308308 array (
309309 'htmlform-reset' => 'Változtatások visszavonása',
310310 'htmlform-submit' => 'Elküldés',
@@ -314,7 +314,7 @@
315315 'htmlform-selectorother-other' => 'egyéb',
316316 'htmlform-invalid-input' => 'Probléma van az általad megadott értékkel',
317317 ),
318 - 'ia' =>
 318+ 'ia' =>
319319 array (
320320 'htmlform-reset' => 'Disfacer modificationes',
321321 'htmlform-submit' => 'Submitter',
@@ -325,7 +325,7 @@
326326 'htmlform-selectorother-other' => 'Altere',
327327 'htmlform-invalid-input' => 'Il ha problemas con alique que tu entrava',
328328 ),
329 - 'id' =>
 329+ 'id' =>
330330 array (
331331 'htmlform-reset' => 'Batalkan perubahan',
332332 'htmlform-submit' => 'Kirim',
@@ -336,7 +336,7 @@
337337 'htmlform-selectorother-other' => 'Lain-lain',
338338 'htmlform-invalid-input' => 'Ada kesalahan dalam beberapa input Anda',
339339 ),
340 - 'it' =>
 340+ 'it' =>
341341 array (
342342 'htmlform-reset' => 'Annulla modifiche',
343343 'htmlform-submit' => 'Invia',
@@ -347,7 +347,7 @@
348348 'htmlform-selectorother-other' => 'Altro',
349349 'htmlform-invalid-input' => 'Ci sono problemi con l\'input inserito',
350350 ),
351 - 'ja' =>
 351+ 'ja' =>
352352 array (
353353 'htmlform-reset' => '変更を取り消す',
354354 'htmlform-submit' => '送信',
@@ -358,7 +358,7 @@
359359 'htmlform-selectorother-other' => 'その他',
360360 'htmlform-invalid-input' => '入力になんらかの問題があります',
361361 ),
362 - 'jv' =>
 362+ 'jv' =>
363363 array (
364364 'htmlform-reset' => 'Batalna pangowahan',
365365 'htmlform-int-invalid' => 'Aji sing panjenengan lebokaké dudu angka wutuh (integer).',
@@ -368,7 +368,7 @@
369369 'htmlform-selectorother-other' => 'Liya',
370370 'htmlform-invalid-input' => 'Ana masalah jroning sawetara input panjenengan',
371371 ),
372 - 'ka' =>
 372+ 'ka' =>
373373 array (
374374 'htmlform-reset' => 'ცვლილებების გაუქმება',
375375 'htmlform-submit' => 'შენახვა',
@@ -379,7 +379,7 @@
380380 'htmlform-selectorother-other' => 'სხვა',
381381 'htmlform-invalid-input' => 'თქვენს მიერ შეყვანილი ინფორმაციის ნაწილმა გამოიწვია პრობლემები',
382382 ),
383 - 'ko' =>
 383+ 'ko' =>
384384 array (
385385 'htmlform-reset' => '변경한 것을 되돌리기',
386386 'htmlform-submit' => '저장',
@@ -390,7 +390,7 @@
391391 'htmlform-selectorother-other' => '기타',
392392 'htmlform-invalid-input' => '당신이 입력한 값에 문제가 있습니다.',
393393 ),
394 - 'ksh' =>
 394+ 'ksh' =>
395395 array (
396396 'htmlform-reset' => 'Änderunge retuur nämme',
397397 'htmlform-submit' => 'Loß Jonn!',
@@ -401,11 +401,11 @@
402402 'htmlform-selectorother-other' => 'Annder',
403403 'htmlform-invalid-input' => 'Mer han e Problem met jet wat De enjejovve häß',
404404 ),
405 - 'la' =>
 405+ 'la' =>
406406 array (
407407 'htmlform-selectorother-other' => 'Aliud',
408408 ),
409 - 'lb' =>
 409+ 'lb' =>
410410 array (
411411 'htmlform-reset' => 'Ännerungen zrécksetzen',
412412 'htmlform-submit' => 'Späicheren',
@@ -416,7 +416,7 @@
417417 'htmlform-selectorother-other' => 'Anerer',
418418 'htmlform-invalid-input' => 'Et gëtt Problemer mat de Werter déi dir aginn hutt.',
419419 ),
420 - 'lt' =>
 420+ 'lt' =>
421421 array (
422422 'htmlform-reset' => 'Atšaukti pakeitimus',
423423 'htmlform-submit' => 'Siųsti',
@@ -427,7 +427,7 @@
428428 'htmlform-selectorother-other' => 'Kita',
429429 'htmlform-invalid-input' => 'Yra problemų su jūsų įvestimi',
430430 ),
431 - 'lzh' =>
 431+ 'lzh' =>
432432 array (
433433 'htmlform-reset' => '復',
434434 'htmlform-submit' => '呈',
@@ -438,7 +438,7 @@
439439 'htmlform-selectorother-other' => '他',
440440 'htmlform-invalid-input' => '爾之輸問也',
441441 ),
442 - 'mk' =>
 442+ 'mk' =>
443443 array (
444444 'htmlform-reset' => 'Откажи промени',
445445 'htmlform-submit' => 'Зачувај',
@@ -449,11 +449,11 @@
450450 'htmlform-selectorother-other' => 'Друго',
451451 'htmlform-invalid-input' => 'Има проблеми со дел од вашиот внес',
452452 ),
453 - 'ml' =>
 453+ 'ml' =>
454454 array (
455455 'htmlform-reset' => 'മാറ്റങ്ങള്‍ വേണ്ട',
456456 ),
457 - 'ms' =>
 457+ 'ms' =>
458458 array (
459459 'htmlform-reset' => 'Undur perubahan',
460460 'htmlform-submit' => 'Hantar',
@@ -462,7 +462,7 @@
463463 'htmlform-selectorother-other' => 'Lain-lain',
464464 'htmlform-invalid-input' => 'Terdapat beberapa masalah dengan input anda',
465465 ),
466 - 'mt' =>
 466+ 'mt' =>
467467 array (
468468 'htmlform-reset' => 'Annulla l-modifiki',
469469 'htmlform-submit' => 'Ibgħat',
@@ -473,7 +473,7 @@
474474 'htmlform-selectorother-other' => 'Oħrajn',
475475 'htmlform-invalid-input' => 'Hemm xi problemi f\'dak li daħħalt',
476476 ),
477 - 'nds' =>
 477+ 'nds' =>
478478 array (
479479 'htmlform-reset' => 'Ännern trüchsetten',
480480 'htmlform-submit' => 'Afspiekern',
@@ -484,7 +484,7 @@
485485 'htmlform-selectorother-other' => 'Annere',
486486 'htmlform-invalid-input' => 'Mit welk vun de angeven Weerten gifft dat Problemen',
487487 ),
488 - 'nds-nl' =>
 488+ 'nds-nl' =>
489489 array (
490490 'htmlform-reset' => 'Wiezigingen ongedaonmaken',
491491 'htmlform-submit' => 'Opslaon',
@@ -495,7 +495,7 @@
496496 'htmlform-selectorother-other' => 'Aanders',
497497 'htmlform-invalid-input' => 'Der bin preblemen mit een paor in-egeven weerden',
498498 ),
499 - 'nl' =>
 499+ 'nl' =>
500500 array (
501501 'htmlform-reset' => 'Wijzigingen ongedaan maken',
502502 'htmlform-submit' => 'Opslaan',
@@ -506,7 +506,7 @@
507507 'htmlform-selectorother-other' => 'Anders',
508508 'htmlform-invalid-input' => 'Er zijn problemen met enkele ingegeven waarden',
509509 ),
510 - 'nn' =>
 510+ 'nn' =>
511511 array (
512512 'htmlform-reset' => 'Gjer om endringar',
513513 'htmlform-submit' => 'Lagre',
@@ -517,7 +517,7 @@
518518 'htmlform-selectorother-other' => 'Andre',
519519 'htmlform-invalid-input' => 'Det finst problem med innskrivinga di',
520520 ),
521 - 'no' =>
 521+ 'no' =>
522522 array (
523523 'htmlform-reset' => 'Omgjør endringer',
524524 'htmlform-submit' => 'Lagre',
@@ -528,7 +528,7 @@
529529 'htmlform-selectorother-other' => 'Andre',
530530 'htmlform-invalid-input' => 'Det er problemer med noen av inndatene dine',
531531 ),
532 - 'oc' =>
 532+ 'oc' =>
533533 array (
534534 'htmlform-reset' => 'Desfar las modificacions',
535535 'htmlform-submit' => 'Sometre',
@@ -539,11 +539,11 @@
540540 'htmlform-selectorother-other' => 'Autre',
541541 'htmlform-invalid-input' => 'De problèmas son arribats amb d\'unas valors',
542542 ),
543 - 'pdc' =>
 543+ 'pdc' =>
544544 array (
545545 'htmlform-selectorother-other' => 'Annere',
546546 ),
547 - 'pl' =>
 547+ 'pl' =>
548548 array (
549549 'htmlform-reset' => 'Cofnij zmiany',
550550 'htmlform-submit' => 'Zapisz',
@@ -554,11 +554,11 @@
555555 'htmlform-selectorother-other' => 'Inne',
556556 'htmlform-invalid-input' => 'Wystąpił problem z wprowadzonymi danymi',
557557 ),
558 - 'pnt' =>
 558+ 'pnt' =>
559559 array (
560560 'htmlform-selectorother-other' => 'Άλλον',
561561 ),
562 - 'pt' =>
 562+ 'pt' =>
563563 array (
564564 'htmlform-reset' => 'Desfazer alterações',
565565 'htmlform-submit' => 'Enviar',
@@ -569,7 +569,7 @@
570570 'htmlform-selectorother-other' => 'Outros',
571571 'htmlform-invalid-input' => 'Existem problemas com alguns dos dados introduzidos',
572572 ),
573 - 'qu' =>
 573+ 'qu' =>
574574 array (
575575 'htmlform-reset' => 'Hukchasqakunata kutichiy',
576576 'htmlform-submit' => 'Kachay',
@@ -580,7 +580,7 @@
581581 'htmlform-selectorother-other' => 'Wakin',
582582 'htmlform-invalid-input' => 'Yaykuchisqaykiwanqa sasachakuykunam kachkan',
583583 ),
584 - 'ro' =>
 584+ 'ro' =>
585585 array (
586586 'htmlform-reset' => 'Anulează modificările',
587587 'htmlform-submit' => 'Trimite',
@@ -591,7 +591,7 @@
592592 'htmlform-selectorother-other' => 'Altul',
593593 'htmlform-invalid-input' => 'Există probleme la valorile introduse',
594594 ),
595 - 'roa-tara' =>
 595+ 'roa-tara' =>
596596 array (
597597 'htmlform-reset' => 'Annulle le cangiaminde',
598598 'htmlform-submit' => 'Conferme',
@@ -602,7 +602,7 @@
603603 'htmlform-selectorother-other' => 'Otre',
604604 'htmlform-invalid-input' => 'Stonne probbleme cu certe input ca tu è mise',
605605 ),
606 - 'ru' =>
 606+ 'ru' =>
607607 array (
608608 'htmlform-reset' => 'Отменить изменения',
609609 'htmlform-submit' => 'Отправить',
@@ -613,7 +613,7 @@
614614 'htmlform-selectorother-other' => 'Иное',
615615 'htmlform-invalid-input' => 'Часть введённых вами данных вызвала проблемы',
616616 ),
617 - 'sah' =>
 617+ 'sah' =>
618618 array (
619619 'htmlform-reset' => 'Уларытыыны төннөр',
620620 'htmlform-submit' => 'Ыыт',
@@ -624,11 +624,11 @@
625625 'htmlform-selectorother-other' => 'Атын',
626626 'htmlform-invalid-input' => 'Киллэрбит сибидиэнньэҥ сорҕото алҕаһы таһаарда',
627627 ),
628 - 'sc' =>
 628+ 'sc' =>
629629 array (
630630 'htmlform-selectorother-other' => 'Àteru',
631631 ),
632 - 'sh' =>
 632+ 'sh' =>
633633 array (
634634 'htmlform-reset' => 'Vrati izmjene',
635635 'htmlform-submit' => 'Unesi',
@@ -639,7 +639,7 @@
640640 'htmlform-selectorother-other' => 'Ostalo',
641641 'htmlform-invalid-input' => 'Postoje određeni problemi sa Vašim unosom',
642642 ),
643 - 'si' =>
 643+ 'si' =>
644644 array (
645645 'htmlform-reset' => 'වෙනස්කිරීම් අහෝසිකරන්න',
646646 'htmlform-submit' => 'යොමුකරන්න',
@@ -650,7 +650,7 @@
651651 'htmlform-selectorother-other' => 'වෙනත්',
652652 'htmlform-invalid-input' => 'ඔබගේ සමහරක් ප්‍රදානයන් විෂයයෙහි ගැ‍ටළු ඇත',
653653 ),
654 - 'sk' =>
 654+ 'sk' =>
655655 array (
656656 'htmlform-reset' => 'Vrátiť zmeny',
657657 'htmlform-submit' => 'Odoslať',
@@ -661,7 +661,7 @@
662662 'htmlform-selectorother-other' => 'Iné',
663663 'htmlform-invalid-input' => 'Niekotrý z údajov, ktoré ste zadali je problematický',
664664 ),
665 - 'sr-ec' =>
 665+ 'sr-ec' =>
666666 array (
667667 'htmlform-reset' => 'Врати измене',
668668 'htmlform-submit' => 'Пошаљи',
@@ -672,7 +672,7 @@
673673 'htmlform-selectorother-other' => 'Друго',
674674 'htmlform-invalid-input' => 'Има проблема са делом Вашег уноса',
675675 ),
676 - 'sv' =>
 676+ 'sv' =>
677677 array (
678678 'htmlform-reset' => 'Ogör ändringar',
679679 'htmlform-submit' => 'Spara',
@@ -683,15 +683,15 @@
684684 'htmlform-selectorother-other' => 'Andra',
685685 'htmlform-invalid-input' => 'Det finns problem med din inmatning',
686686 ),
687 - 'sw' =>
 687+ 'sw' =>
688688 array (
689689 'htmlform-selectorother-other' => 'Nyingine',
690690 ),
691 - 'te' =>
 691+ 'te' =>
692692 array (
693693 'htmlform-selectorother-other' => 'ఇతర',
694694 ),
695 - 'tr' =>
 695+ 'tr' =>
696696 array (
697697 'htmlform-reset' => 'Değişiklikleri geri al',
698698 'htmlform-submit' => 'Gönder',
@@ -702,7 +702,7 @@
703703 'htmlform-selectorother-other' => 'Diğer',
704704 'htmlform-invalid-input' => 'Girdinizin bir kısmıyla ilgili sorunlar var',
705705 ),
706 - 'uk' =>
 706+ 'uk' =>
707707 array (
708708 'htmlform-reset' => 'Відкотити зміни',
709709 'htmlform-submit' => 'Відправити',
@@ -713,7 +713,7 @@
714714 'htmlform-selectorother-other' => 'Інше',
715715 'htmlform-invalid-input' => 'Частина введених вами даних викликала проблеми',
716716 ),
717 - 'vec' =>
 717+ 'vec' =>
718718 array (
719719 'htmlform-reset' => 'Scancèla modifiche',
720720 'htmlform-submit' => 'Manda',
@@ -723,7 +723,7 @@
724724 'htmlform-select-badoption' => 'El valor che te ghè indicà no\'l xe mia valido.',
725725 'htmlform-invalid-input' => 'Ghe xe problemi con l\'input che te ghè inserìo',
726726 ),
727 - 'vi' =>
 727+ 'vi' =>
728728 array (
729729 'htmlform-reset' => 'Hủy các thay đổi',
730730 'htmlform-submit' => 'Đăng',
@@ -734,15 +734,15 @@
735735 'htmlform-selectorother-other' => 'Khác',
736736 'htmlform-invalid-input' => 'Có vấn đề trong dữ liệu bạn vừa đưa vào',
737737 ),
738 - 'vo' =>
 738+ 'vo' =>
739739 array (
740740 'htmlform-selectorother-other' => 'Votik',
741741 ),
742 - 'xal' =>
 742+ 'xal' =>
743743 array (
744744 'htmlform-reset' => 'Сольлһдудиг уга кех',
745745 ),
746 - 'yue' =>
 746+ 'yue' =>
747747 array (
748748 'htmlform-reset' => '復原更改',
749749 'htmlform-submit' => '遞交',
@@ -753,7 +753,7 @@
754754 'htmlform-selectorother-other' => '其它',
755755 'htmlform-invalid-input' => '響你嘅輸入度有一啲問題',
756756 ),
757 - 'zh-hans' =>
 757+ 'zh-hans' =>
758758 array (
759759 'htmlform-reset' => '撤销更改',
760760 'htmlform-submit' => '提交',
@@ -764,7 +764,7 @@
765765 'htmlform-selectorother-other' => '其他',
766766 'htmlform-invalid-input' => '您输入的内容存在问题',
767767 ),
768 - 'zh-hant' =>
 768+ 'zh-hant' =>
769769 array (
770770 'htmlform-reset' => '復原更改',
771771 'htmlform-submit' => '遞交',
Index: trunk/extensions/LiquidThreads/compat/generateCompatibilityLocalisation.php
@@ -2,27 +2,27 @@
33
44 // Utility script to generate an extension messages file for backwards-compatibility.
55
6 -require_once ( getenv('MW_INSTALL_PATH') !== false
7 - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc"
 6+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
 7+ ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
88 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
99
10 -$messages = array(
11 - 'htmlform-reset',
12 - 'htmlform-submit',
13 - 'htmlform-int-invalid',
14 - 'htmlform-int-toolow',
15 - 'htmlform-int-toohigh',
16 - 'htmlform-select-badoption',
17 - 'htmlform-selectorother-other',
18 - 'htmlform-invalid-input',
19 - );
 10+$messages = array(
 11+ 'htmlform-reset',
 12+ 'htmlform-submit',
 13+ 'htmlform-int-invalid',
 14+ 'htmlform-int-toolow',
 15+ 'htmlform-int-toohigh',
 16+ 'htmlform-select-badoption',
 17+ 'htmlform-selectorother-other',
 18+ 'htmlform-invalid-input',
 19+);
2020
21 -$languages = array_keys(Language::getLanguageNames( false ));
 21+$languages = array_keys( Language::getLanguageNames( false ) );
2222 $data = array_fill_keys( $languages, array() );
2323
24 -foreach( $messages as $msg ) {
 24+foreach ( $messages as $msg ) {
2525 print "\nGetting localisation for $msg...";
26 - foreach( $languages as $lang ) {
 26+ foreach ( $languages as $lang ) {
2727 $data[$lang][$msg] = $wgMessageCache->get( $msg, false, $lang );
2828 print " $lang ";
2929 }
@@ -33,24 +33,24 @@
3434
3535 print "Eliminating redundant data... ";
3636
37 -foreach( $languages as $lang ) {
 37+foreach ( $languages as $lang ) {
3838 $fallback = Language::getFallbackFor( $lang );
39 -
 39+
4040 print " [$lang from $fallback] ";
4141 $lastFallback = $lang;
42 -
43 - while ($fallback && !isset($originalData[$fallback]) && $fallback != $lastFallback) {
 42+
 43+ while ( $fallback && !isset( $originalData[$fallback] ) && $fallback != $lastFallback ) {
4444 $lastFallback = $fallback;
4545 $fallback = Language::getFallbackFor( $lang );
4646 }
47 -
48 - if ( $fallback && isset($originalData[$fallback]) ) {
 47+
 48+ if ( $fallback && isset( $originalData[$fallback] ) ) {
4949 $fallbackData = $originalData[$fallback];
50 -
 50+
5151 $data[$lang] = array_diff_assoc( $originalData[$lang], $fallbackData );
52 -
53 - if (!count($data[$lang]))
54 - unset($data[$lang]);
 52+
 53+ if ( !count( $data[$lang] ) )
 54+ unset( $data[$lang] );
5555 }
5656 }
5757
@@ -58,7 +58,7 @@
5959
6060 $export = "<?php\n" .
6161 "// This file is generated automatically by generateCompatibilityLocalisation.php\n" .
62 - '$messages = '.var_export($data, true).";\n";
 62+ '$messages = ' . var_export( $data, true ) . ";\n";
6363
6464 file_put_contents( 'Lqt-compat.i18n.php', $export );
6565
Index: trunk/extensions/LiquidThreads/compat/HTMLForm.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class HTMLForm {
5 -
65 static $jsAdded = false;
76
87 /* The descriptor is an array of arrays.
@@ -26,14 +25,14 @@
2726
2827 function __construct( $descriptor, $messagePrefix ) {
2928 wfLoadExtensionMessages( 'Lqt-Compat' );
30 -
 29+
3130 $this->mMessagePrefix = $messagePrefix;
3231
3332 // Expand out into a tree.
3433 $loadedDescriptor = array();
3534 $this->mFlatFields = array();
3635
37 - foreach( $descriptor as $fieldname => $info ) {
 36+ foreach ( $descriptor as $fieldname => $info ) {
3837 $section = '';
3938 if ( isset( $info['section'] ) )
4039 $section = $info['section'];
@@ -44,10 +43,10 @@
4544 $field->mParent = $this;
4645
4746 $setSection =& $loadedDescriptor;
48 - if( $section ) {
 47+ if ( $section ) {
4948 $sectionParts = explode( '/', $section );
5049
51 - while( count( $sectionParts ) ) {
 50+ while ( count( $sectionParts ) ) {
5251 $newName = array_shift( $sectionParts );
5352
5453 if ( !isset( $setSection[$newName] ) ) {
@@ -79,7 +78,7 @@
8079 $descriptor['class'] = $class;
8180 }
8281
83 - if( !$class ) {
 82+ if ( !$class ) {
8483 throw new MWException( "Descriptor with no class: " . print_r( $descriptor, true ) );
8584 }
8685
@@ -104,7 +103,7 @@
105104 if ( $wgUser->matchEditToken( $editToken ) )
106105 $result = $this->trySubmit();
107106
108 - if( $result === true )
 107+ if ( $result === true )
109108 return $result;
110109
111110 // Display form.
@@ -118,7 +117,7 @@
119118 */
120119 function trySubmit() {
121120 // Check for validation
122 - foreach( $this->mFlatFields as $fieldname => $field ) {
 121+ foreach ( $this->mFlatFields as $fieldname => $field ) {
123122 if ( !empty( $field->mParams['nodata'] ) ) continue;
124123 if ( $field->validate( $this->mFieldData[$fieldname],
125124 $this->mFieldData ) !== true ) {
@@ -205,7 +204,7 @@
206205
207206 $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
208207
209 - if( $this->mShowReset ) {
 208+ if ( $this->mShowReset ) {
210209 $html .= Xml::element(
211210 'input',
212211 array(
@@ -214,7 +213,7 @@
215214 )
216215 ) . "\n";
217216 }
218 -
 217+
219218 return $html;
220219 }
221220
@@ -228,7 +227,7 @@
229228 } else {
230229 $errorstr = $errors;
231230 }
232 -
 231+
233232 $errorstr = Xml::tags( 'div', array( 'class' => 'error' ), $errorstr );
234233
235234 global $wgOut;
@@ -238,7 +237,7 @@
239238 static function formatErrors( $errors ) {
240239 $errorstr = '';
241240 foreach ( $errors as $error ) {
242 - if( is_array( $error ) ) {
 241+ if ( is_array( $error ) ) {
243242 $msg = array_shift( $error );
244243 } else {
245244 $msg = $error;
@@ -285,14 +284,14 @@
286285 $subsectionHtml = '';
287286 $hasLeftColumn = false;
288287
289 - foreach( $fields as $key => $value ) {
 288+ foreach ( $fields as $key => $value ) {
290289 if ( is_object( $value ) ) {
291290 $v = empty( $value->mParams['nodata'] )
292291 ? $this->mFieldData[$key]
293292 : $value->getDefault();
294293 $tableHtml .= $value->getTableRow( $v );
295294
296 - if( $value->getLabel() != '&nbsp;' )
 295+ if ( $value->getLabel() != '&nbsp;' )
297296 $hasLeftColumn = true;
298297 } elseif ( is_array( $value ) ) {
299298 $section = $this->displaySection( $value );
@@ -302,7 +301,7 @@
303302 }
304303
305304 $classes = array();
306 - if( !$hasLeftColumn ) // Avoid strange spacing when no labels exist
 305+ if ( !$hasLeftColumn ) // Avoid strange spacing when no labels exist
307306 $classes[] = 'mw-htmlform-nolabel';
308307 $classes = implode( ' ', $classes );
309308
@@ -316,7 +315,7 @@
317316
318317 $fieldData = array();
319318
320 - foreach( $this->mFlatFields as $fieldname => $field ) {
 319+ foreach ( $this->mFlatFields as $fieldname => $field ) {
321320 if ( !empty( $field->mParams['nodata'] ) ) continue;
322321 if ( !empty( $field->mParams['disabled'] ) ) {
323322 $fieldData[$fieldname] = $field->getDefault();
@@ -326,7 +325,7 @@
327326 }
328327
329328 // Filter data.
330 - foreach( $fieldData as $name => &$value ) {
 329+ foreach ( $fieldData as $name => &$value ) {
331330 $field = $this->mFlatFields[$name];
332331 $value = $field->filter( $value, $this->mFlatFields );
333332 }
@@ -336,12 +335,12 @@
337336
338337 function importData( $fieldData ) {
339338 // Filter data.
340 - foreach( $fieldData as $name => &$value ) {
 339+ foreach ( $fieldData as $name => &$value ) {
341340 $field = $this->mFlatFields[$name];
342341 $value = $field->filter( $value, $this->mFlatFields );
343342 }
344343
345 - foreach( $this->mFlatFields as $fieldname => $field ) {
 344+ foreach ( $this->mFlatFields as $fieldname => $field ) {
346345 if ( !isset( $fieldData[$fieldname] ) )
347346 $fieldData[$fieldname] = $field->getDefault();
348347 }
@@ -370,7 +369,7 @@
371370 }
372371
373372 function filter( $value, $alldata ) {
374 - if( isset( $this->mFilterCallback ) ) {
 373+ if ( isset( $this->mFilterCallback ) ) {
375374 $value = call_user_func( $this->mFilterCallback, $value, $alldata );
376375 }
377376
@@ -378,7 +377,7 @@
379378 }
380379
381380 function loadDataFromRequest( $request ) {
382 - if( $request->getCheck( $this->mName ) ) {
 381+ if ( $request->getCheck( $this->mName ) ) {
383382 return $request->getText( $this->mName );
384383 } else {
385384 return $this->getDefault();
@@ -388,7 +387,7 @@
389388 function __construct( $params ) {
390389 $this->mParams = $params;
391390
392 - if( isset( $params['label-message'] ) ) {
 391+ if ( isset( $params['label-message'] ) ) {
393392 $msgInfo = $params['label-message'];
394393
395394 if ( is_array( $msgInfo ) ) {
@@ -404,8 +403,8 @@
405404 }
406405
407406 if ( isset( $params['name'] ) ) {
408 - $this->mName = 'wp'.$params['name'];
409 - $this->mID = 'mw-input-'.$params['name'];
 407+ $this->mName = 'wp' . $params['name'];
 408+ $this->mID = 'mw-input-' . $params['name'];
410409 }
411410
412411 if ( isset( $params['default'] ) ) {
@@ -442,7 +441,7 @@
443442 Xml::tags( 'label', array( 'for' => $this->mID ), $this->getLabel() )
444443 );
445444 $html .= Xml::tags( 'td', array( 'class' => 'mw-input' ),
446 - $this->getInputHTML( $value ) ."\n$errors" );
 445+ $this->getInputHTML( $value ) . "\n$errors" );
447446
448447 $fieldType = get_class( $this );
449448
@@ -455,7 +454,7 @@
456455
457456 $text = wfMsgExt( $msg, 'parseinline' );
458457
459 - if( !wfEmptyMsg( $msg, $text ) ) {
 458+ if ( !wfEmptyMsg( $msg, $text ) ) {
460459 $row = Xml::tags( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ),
461460 $text );
462461
@@ -483,7 +482,7 @@
484483 static function flattenOptions( $options ) {
485484 $flatOpts = array();
486485
487 - foreach( $options as $key => $value ) {
 486+ foreach ( $options as $key => $value ) {
488487 if ( is_array( $value ) ) {
489488 $flatOpts = array_merge( $flatOpts, self::flattenOptions( $value ) );
490489 } else {
@@ -507,8 +506,8 @@
508507 if ( isset( $this->mParams['maxlength'] ) ) {
509508 $attribs['maxlength'] = $this->mParams['maxlength'];
510509 }
511 -
512 - if( !empty( $this->mParams['disabled'] ) ) {
 510+
 511+ if ( !empty( $this->mParams['disabled'] ) ) {
513512 $attribs['disabled'] = 'disabled';
514513 }
515514
@@ -530,7 +529,7 @@
531530 function validate( $value, $alldata ) {
532531 $p = parent::validate( $value, $alldata );
533532
534 - if( $p !== true ) return $p;
 533+ if ( $p !== true ) return $p;
535534
536535 if ( intval( $value ) != $value ) {
537536 return wfMsgExt( 'htmlform-int-invalid', 'parse' );
@@ -546,7 +545,7 @@
547546
548547 if ( isset( $this->mParams['max'] ) ) {
549548 $max = $this->mParams['max'];
550 - if( $max < $value )
 549+ if ( $max < $value )
551550 return wfMsgExt( 'htmlform-int-toohigh', 'parse', array( $max ) );
552551 }
553552
@@ -560,7 +559,7 @@
561560 $value = !$value;
562561
563562 $attr = array( 'id' => $this->mID );
564 - if( !empty( $this->mParams['disabled'] ) ) {
 563+ if ( !empty( $this->mParams['disabled'] ) ) {
565564 $attr['disabled'] = 'disabled';
566565 }
567566
@@ -579,7 +578,7 @@
580579 }
581580
582581 // GetCheck won't work like we want for checks.
583 - if( $request->getCheck( 'wpEditToken' ) ) {
 582+ if ( $request->getCheck( 'wpEditToken' ) ) {
584583 // XOR has the following truth table, which is what we want
585584 // INVERT VALUE | OUTPUT
586585 // true true | false
@@ -597,7 +596,7 @@
598597
599598 function validate( $value, $alldata ) {
600599 $p = parent::validate( $value, $alldata );
601 - if( $p !== true ) return $p;
 600+ if ( $p !== true ) return $p;
602601
603602 $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
604603 if ( in_array( $value, $validOptions ) )
@@ -614,7 +613,7 @@
615614 // Working around this by forcing all of them to strings.
616615 $options = array_map( 'strval', $this->mParams['options'] );
617616
618 - if( !empty( $this->mParams['disabled'] ) ) {
 617+ if ( !empty( $this->mParams['disabled'] ) ) {
619618 $select->setAttribute( 'disabled', 'disabled' );
620619 }
621620
@@ -628,7 +627,7 @@
629628 static $jsAdded = false;
630629
631630 function __construct( $params ) {
632 - if( !in_array( 'other', $params['options'] ) ) {
 631+ if ( !in_array( 'other', $params['options'] ) ) {
633632 $params['options'][wfMsg( 'htmlform-selectorother-other' )] = 'other';
634633 }
635634
@@ -638,9 +637,12 @@
639638 function getInputHTML( $value ) {
640639 $valInSelect = false;
641640
642 - if( $value !== false )
643 - $valInSelect = in_array( $value,
644 - HTMLFormField::flattenOptions( $this->mParams['options'] ) );
 641+ if ( $value !== false ) {
 642+ $valInSelect = in_array(
 643+ $value,
 644+ HTMLFormField::flattenOptions( $this->mParams['options'] )
 645+ );
 646+ }
645647
646648 $selected = $valInSelect ? $value : 'other';
647649
@@ -650,7 +652,7 @@
651653 $select->setAttribute( 'class', 'mw-htmlform-select-or-other' );
652654
653655 $tbAttribs = array( 'id' => $this->mID . '-other' );
654 - if( !empty( $this->mParams['disabled'] ) ) {
 656+ if ( !empty( $this->mParams['disabled'] ) ) {
655657 $select->setAttribute( 'disabled', 'disabled' );
656658 $tbAttribs['disabled'] = 'disabled';
657659 }
@@ -661,19 +663,21 @@
662664 $tbAttribs['maxlength'] = $this->mParams['maxlength'];
663665 }
664666
665 - $textbox = Xml::input( $this->mName . '-other',
666 - $this->getSize(),
667 - $valInSelect ? '' : $value,
668 - $tbAttribs );
 667+ $textbox = Xml::input(
 668+ $this->mName . '-other',
 669+ $this->getSize(),
 670+ $valInSelect ? '' : $value,
 671+ $tbAttribs
 672+ );
669673
670674 return "$select<br/>\n$textbox";
671675 }
672676
673677 function loadDataFromRequest( $request ) {
674 - if( $request->getCheck( $this->mName ) ) {
 678+ if ( $request->getCheck( $this->mName ) ) {
675679 $val = $request->getText( $this->mName );
676680
677 - if( $val == 'other' ) {
 681+ if ( $val == 'other' ) {
678682 $val = $request->getText( $this->mName . '-other' );
679683 }
680684
@@ -687,9 +691,9 @@
688692 class HTMLMultiSelectField extends HTMLFormField {
689693 function validate( $value, $alldata ) {
690694 $p = parent::validate( $value, $alldata );
691 - if( $p !== true ) return $p;
 695+ if ( $p !== true ) return $p;
692696
693 - if( !is_array( $value ) ) return false;
 697+ if ( !is_array( $value ) ) return false;
694698
695699 // If all options are valid, array_intersect of the valid options and the provided
696700 // options will return the provided options.
@@ -716,17 +720,24 @@
717721 $attribs['disabled'] = 'disabled';
718722 }
719723
720 - foreach( $options as $label => $info ) {
721 - if( is_array( $info ) ) {
 724+ foreach ( $options as $label => $info ) {
 725+ if ( is_array( $info ) ) {
722726 $html .= Xml::tags( 'h1', null, $label ) . "\n";
723727 $html .= $this->formatOptions( $info, $value );
724728 } else {
725729 $thisAttribs = array( 'id' => $this->mID . "-$info", 'value' => $info );
726 -
727 - $checkbox = Xml::check( $this->mName . '[]', in_array( $info, $value ),
728 - $attribs + $thisAttribs );
729 - $checkbox .= '&nbsp;' . Xml::tags( 'label', array( 'for' => $this->mID . "-$info" ), $label );
730730
 731+ $checkbox = Xml::check(
 732+ $this->mName . '[]',
 733+ in_array( $info, $value ),
 734+ $attribs + $thisAttribs
 735+ );
 736+ $checkbox .= '&nbsp;' . Xml::tags(
 737+ 'label',
 738+ array( 'for' => $this->mID . "-$info" ),
 739+ $label
 740+ );
 741+
731742 $html .= $checkbox . '<br />';
732743 }
733744 }
@@ -736,10 +747,10 @@
737748
738749 function loadDataFromRequest( $request ) {
739750 // won't work with getCheck
740 - if( $request->getCheck( 'wpEditToken' ) ) {
 751+ if ( $request->getCheck( 'wpEditToken' ) ) {
741752 $arr = $request->getArray( $this->mName );
742753
743 - if( !$arr )
 754+ if ( !$arr )
744755 $arr = array();
745756
746757 return $arr;
@@ -760,9 +771,9 @@
761772 class HTMLRadioField extends HTMLFormField {
762773 function validate( $value, $alldata ) {
763774 $p = parent::validate( $value, $alldata );
764 - if( $p !== true ) return $p;
 775+ if ( $p !== true ) return $p;
765776
766 - if( !is_string( $value ) && !is_int( $value ) )
 777+ if ( !is_string( $value ) && !is_int( $value ) )
767778 return false;
768779
769780 $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
@@ -778,7 +789,7 @@
779790
780791 return $html;
781792 }
782 -
 793+
783794 function formatOptions( $options, $value ) {
784795 $html = '';
785796
@@ -787,8 +798,8 @@
788799 $attribs['disabled'] = 'disabled';
789800 }
790801
791 - foreach( $options as $label => $info ) {
792 - if( is_array( $info ) ) {
 802+ foreach ( $options as $label => $info ) {
 803+ if ( is_array( $info ) ) {
793804 $html .= Xml::tags( 'h1', null, $label ) . "\n";
794805 $html .= $this->formatOptions( $info, $value );
795806 } else {
Index: trunk/extensions/LiquidThreads/compat/LqtCompatArticle.php
@@ -3,68 +3,67 @@
44
55 global $wgVersion;
66 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
7 -
87 // LiquidThreads compatibility wrapper around the Article object.
98 class Article_LQT_Compat extends Article {
10 -
 9+
1110 public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) {
1211 global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache;
13 -
 12+
1413 if ( !$parserOptions ) {
1514 $parserOptions = $wgOut->parserOptions();
1615 }
17 -
18 - $time = -wfTime();
 16+
 17+ $time = - wfTime();
1918 $parserOutput = $wgParser->parse( $text, $this->mTitle,
2019 $parserOptions, true, true, $this->getRevIdFetched() );
2120 $time += wfTime();
22 -
 21+
2322 # Timing hack
24 - if( $time > 3 ) {
 23+ if ( $time > 3 ) {
2524 wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time,
26 - $this->mTitle->getPrefixedDBkey()));
 25+ $this->mTitle->getPrefixedDBkey() ) );
2726 }
28 -
29 - if( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) {
 27+
 28+ if ( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != - 1 ) {
3029 $parserCache = ParserCache::singleton();
3130 $parserCache->save( $parserOutput, $this, $parserOptions );
3231 }
3332 // Make sure file cache is not used on uncacheable content.
3433 // Output that has magic words in it can still use the parser cache
3534 // (if enabled), though it will generally expire sooner.
36 - if( $parserOutput->getCacheTime() == -1 || $parserOutput->containsOldMagic() ) {
 35+ if ( $parserOutput->getCacheTime() == - 1 || $parserOutput->containsOldMagic() ) {
3736 $wgUseFileCache = false;
3837 }
3938 return $parserOutput;
4039 }
41 -
 40+
4241 /** Stolen from 1.16-alpha, for compatibility with 1.15 */
4342 /** Lightweight method to get the parser output for a page, checking the parser cache
4443 * and so on. Doesn't consider most of the stuff that Article::view is forced to
4544 * consider, so it's not appropriate to use there. */
4645 function getParserOutput( $oldid = null ) {
4746 global $wgEnableParserCache, $wgUser, $wgOut;
48 -
 47+
4948 // Should the parser cache be used?
5049 $useParserCache = $wgEnableParserCache &&
5150 intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
5251 $this->exists() &&
5352 $oldid === null;
54 -
55 - wfDebug( __METHOD__.': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
 53+
 54+ wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
5655 if ( $wgUser->getOption( 'stubthreshold' ) ) {
5756 wfIncrStats( 'pcache_miss_stub' );
5857 }
59 -
 58+
6059 $parserOutput = false;
6160 if ( $useParserCache ) {
6261 $parserOutput = ParserCache::singleton()->get( $this, $wgOut->parserOptions() );
6362 }
64 -
 63+
6564 if ( $parserOutput === false ) {
6665 // Cache miss; parse and output it.
6766 $rev = Revision::newFromTitle( $this->getTitle(), $oldid );
68 -
 67+
6968 return $this->getOutputFromWikitext( $rev->getText(), $useParserCache );
7069 } else {
7170 return $parserOutput;
@@ -72,5 +71,5 @@
7372 }
7473 }
7574 } else {
76 - class Article_LQT_Compat extends Article {}
 75+ class Article_LQT_Compat extends Article { }
7776 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r56705Revert r56562, large whitespace changes committed with no warning, resulting ...werdna14:44, 21 September 2009

Comments

#Comment by Werdna (talk | contribs)   14:55, 21 September 2009

Reverted in r56705. Please at least warn me before making huge sweeping whitespace changes that will probably conflict with saved patches, my working copy, and what-not.

Status & tagging log