r62230 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62229‎ | r62230 | r62231 >
Date:10:10, 10 February 2010
Author:siebrand
Status:deferred
Tags:
Comment:
styilize.php, formatting updates, whitespace 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/api/ApiThreadAction.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/HotTopics.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LogFormatter.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/NewMessagesController.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/ParserFunctions.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/SynchroniseThreadArticleDataJob.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/ThreadHistoryPager.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/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/SpecialHotTopics.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/TalkpageHistoryView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadActionPage.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadDiffView.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)
  • /trunk/extensions/LiquidThreads/pages/ThreadProtectionFormView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/ThreadWatchView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/migrateDatabase.php
@@ -6,26 +6,28 @@
77 require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
88 ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
99 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
10 -
 10+
1111 $db = wfGetDB( DB_MASTER );
1212
1313 $wgTitle = Title::makeTitleSafe( NS_SPECIAL, 'LiquidThreads' );
1414
1515 // Do database updates
16 -$threadFieldUpdates = array( 'thread_article_namespace' => 'split-thread_article.sql',
17 - 'thread_article_title' => 'split-thread_article.sql',
18 - 'thread_ancestor' => 'normalise-ancestry.sql',
19 - 'thread_parent' => 'normalise-ancestry.sql',
20 - 'thread_modified' => 'split-timestamps.sql',
21 - 'thread_created' => 'split-timestamps.sql',
22 - 'thread_editedness' => 'store-editedness.sql',
23 - 'thread_subject' => 'store_subject-author.sql',
24 - 'thread_author_id' => 'store_subject-author.sql',
25 - 'thread_author_name' => 'store_subject-author.sql',
26 - 'thread_sortkey' => 'new-sortkey.sql',
27 - 'thread_replies' => 'store_reply_count.sql',
28 - 'thread_article_id' => 'store_article_id.sql',
29 - );
 16+$threadFieldUpdates = array(
 17+ 'thread_article_namespace' => 'split-thread_article.sql',
 18+ 'thread_article_title' => 'split-thread_article.sql',
 19+ 'thread_ancestor' => 'normalise-ancestry.sql',
 20+ 'thread_parent' => 'normalise-ancestry.sql',
 21+ 'thread_modified' => 'split-timestamps.sql',
 22+ 'thread_created' => 'split-timestamps.sql',
 23+ 'thread_editedness' => 'store-editedness.sql',
 24+ 'thread_subject' => 'store_subject-author.sql',
 25+ 'thread_author_id' => 'store_subject-author.sql',
 26+ 'thread_author_name' => 'store_subject-author.sql',
 27+ 'thread_sortkey' => 'new-sortkey.sql',
 28+ 'thread_replies' => 'store_reply_count.sql',
 29+ 'thread_article_id' => 'store_article_id.sql',
 30+);
 31+
3032 $threadIndexUpdates = array( 'thread_summary_page' => 'index-summary_page.sql' );
3133
3234 $newTableUpdates = array( 'thread_history' => 'thread_history_table.sql' );
@@ -48,31 +50,32 @@
4951 }
5052 }
5153
52 -
5354 // Batch lazy updates
5455 $upTo = $lastUpTo = 0;
5556
5657 do {
5758 $lastUpTo = $upTo;
58 -
 59+
5960 $db->begin();
60 -
 61+
6162 // Read 500 rows
62 - $res = $db->select( 'thread', '*', array( 'thread_id>' . $db->addQuotes( $upTo ) ),
63 - 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE',
64 - 'ORDER BY' => 'thread_id asc' ) );
65 -
 63+ $res = $db->select(
 64+ 'thread', '*', array( 'thread_id>' . $db->addQuotes( $upTo ) ),
 65+ 'lqt-update-script',
 66+ array( 'LIMIT' => 500, 'FOR UPDATE', 'ORDER BY' => 'thread_id asc' )
 67+ );
 68+
6669 $threads = Threads::loadFromResult( $res, $db );
67 -
 70+
6871 foreach ( $threads as $thread ) {
6972 $thread->doLazyUpdates();
7073 $thread->updateHistory();
71 -
 74+
7275 if ( $thread->id() > $upTo ) {
7376 $upTo = $thread->id();
7477 }
7578 }
76 -
 79+
7780 $db->commit();
78 -
 81+
7982 } while ( $lastUpTo != $upTo );
Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -1,11 +1,10 @@
22 <?php
33
44 class ApiThreadAction extends ApiBase {
5 -
65 public function getDescription() {
76 return 'Allows actions to be taken on threads and posts in threaded discussions.';
87 }
9 -
 8+
109 public function getActions() {
1110 return array(
1211 'markread' => 'actionMarkRead',
@@ -18,7 +17,7 @@
1918 'setsortkey' => 'actionSetSortkey',
2019 );
2120 }
22 -
 21+
2322 protected function getParamDescription() {
2423 return array(
2524 'thread' => 'A list (pipe-separated) of thread IDs or titles to act on',
@@ -29,36 +28,35 @@
3029 'reason' => 'If applicable, the reason/summary for the action',
3130 'newparent' => 'If merging a thread, the ID or title for its new parent',
3231 'text' => 'The text of the post to create',
33 - 'render' => 'If set, on post/reply methods, the top-level thread '.
 32+ 'render' => 'If set, on post/reply methods, the top-level thread ' .
3433 'after the change will be rendered and returned in the result.',
3534 'bump' => 'If set, overrides default behaviour as to whether or not to ',
36 - "increase the thread's sort key. If true, sets it to current ".
37 - "timestamp. If false, does not set it. Default depends on ".
38 - "the action being taken. Presently only works for newthread ".
 35+ "increase the thread's sort key. If true, sets it to current " .
 36+ "timestamp. If false, does not set it. Default depends on " .
 37+ "the action being taken. Presently only works for newthread " .
3938 "and reply actions.",
40 - 'sortkey' => "Specifies the timestamp to which to set a thread's ".
41 - "sort key. Must be in the form YYYYMMddhhmmss, ".
 39+ 'sortkey' => "Specifies the timestamp to which to set a thread's " .
 40+ "sort key. Must be in the form YYYYMMddhhmmss, " .
4241 "a unix timestamp or 'now'.",
43 - 'signature' => 'Specifies the signature to use for that post. Can be '.
 42+ 'signature' => 'Specifies the signature to use for that post. Can be ' .
4443 'NULL to specify the default signature',
4544 );
4645 }
47 -
 46+
4847 public function getExamples() {
4948 return array(
50 -
5149 );
5250 }
53 -
 51+
5452 public function getAllowedParams() {
5553 return array(
5654 'thread' => array(
57 - ApiBase::PARAM_ISMULTI => true,
58 - ),
 55+ ApiBase::PARAM_ISMULTI => true,
 56+ ),
5957 'talkpage' => null,
6058 'threadaction' => array(
61 - ApiBase::PARAM_TYPE => array_keys( $this->getActions() ),
62 - ),
 59+ ApiBase::PARAM_TYPE => array_keys( $this->getActions() ),
 60+ ),
6361 'token' => null,
6462 'subject' => null,
6563 'reason' => null,
@@ -70,67 +68,67 @@
7169 'signature' => null,
7270 );
7371 }
74 -
 72+
7573 public function mustBePosted() { return true; }
7674
7775 public function isWriteMode() {
7876 return true;
7977 }
80 -
 78+
8179 public function execute() {
8280 $params = $this->extractRequestParams();
83 -
 81+
8482 global $wgUser;
85 -
 83+
8684 if ( empty( $params['token'] ) ||
8785 !$wgUser->matchEditToken( $params['token'] ) ) {
8886 $this->dieUsage( 'sessionfailure' );
8987 return;
9088 }
91 -
 89+
9290 if ( empty( $params['threadaction'] ) ) {
9391 $this->dieUsage( 'missing-param', 'action' );
9492 return;
9593 }
96 -
 94+
9795 $allowedAllActions = array( 'markread' );
9896 $action = $params['threadaction'];
99 -
 97+
10098 // Pull the threads from the parameters
10199 $threads = array();
102100 if ( !empty( $params['thread'] ) ) {
103 - foreach( $params['thread'] as $thread ) {
 101+ foreach ( $params['thread'] as $thread ) {
104102 $threadObj = null;
105103 if ( is_numeric( $thread ) ) {
106104 $threadObj = Threads::withId( $thread );
107105 } elseif ( $thread == 'all' &&
108106 in_array( $action, $allowedAllActions ) ) {
109 - $threads = array('all');
 107+ $threads = array( 'all' );
110108 } else {
111109 $title = Title::newFromText( $thread );
112110 $article = new Article( $title );
113111 $threadObj = Threads::withRoot( $article );
114112 }
115 -
 113+
116114 if ( $threadObj instanceof Thread ) {
117115 $threads[] = $threadObj;
118116 }
119117 }
120118 }
121 -
 119+
122120 // Find the appropriate module
123121 $actions = $this->getActions();
124 -
 122+
125123 $method = $actions[$action];
126 -
 124+
127125 call_user_func_array( array( $this, $method ), array( $threads, $params ) );
128126 }
129 -
 127+
130128 public function actionMarkRead( $threads, $params ) {
131129 global $wgUser;
132 -
 130+
133131 $result = array();
134 -
 132+
135133 if ( in_array( 'all', $threads ) ) {
136134 NewMessages::markAllReadByUser( $wgUser );
137135 $result[] = array(
@@ -139,122 +137,119 @@
140138 'threads' => 'all',
141139 );
142140 } else {
143 - foreach( $threads as $t ) {
 141+ foreach ( $threads as $t ) {
144142 NewMessages::markThreadAsReadByUser( $t, $wgUser );
145 - $result[] =
146 - array(
147 - 'result' => 'Success',
148 - 'action' => 'markread',
149 - 'id' => $t->id(),
150 - 'title' => $t->title()->getPrefixedText()
151 - );
 143+ $result[] = array(
 144+ 'result' => 'Success',
 145+ 'action' => 'markread',
 146+ 'id' => $t->id(),
 147+ 'title' => $t->title()->getPrefixedText()
 148+ );
152149 }
153150 }
154 -
 151+
155152 $this->getResult()->setIndexedTagName( $result, 'thread' );
156153 $this->getResult()->addValue( null, 'threadactions', $result );
157154 }
158 -
 155+
159156 public function actionMarkUnread( $threads, $params ) {
160157 global $wgUser;
161 -
 158+
162159 $result = array();
163 -
164 - foreach( $threads as $t ) {
 160+
 161+ foreach ( $threads as $t ) {
165162 NewMessages::markThreadAsUnreadByUser( $t, $wgUser );
166 -
167 - $result[] =
168 - array(
169 - 'result' => 'Success',
170 - 'action' => 'markunread',
171 - 'id' => $t->id(),
172 - 'title' => $t->title()->getPrefixedText()
173 - );
 163+
 164+ $result[] = array(
 165+ 'result' => 'Success',
 166+ 'action' => 'markunread',
 167+ 'id' => $t->id(),
 168+ 'title' => $t->title()->getPrefixedText()
 169+ );
174170 }
175 -
176 -
 171+
 172+
177173 $this->getResult()->setIndexedTagName( $result, 'thread' );
178174 $this->getResult()->addValue( null, 'threadaction', $result );
179175 }
180 -
 176+
181177 public function actionSplit( $threads, $params ) {
182178 global $wgUser;
183 -
184 - if ( count($threads) > 1 ) {
 179+
 180+ if ( count( $threads ) > 1 ) {
185181 $this->dieUsage( 'You may only split one thread at a time',
186182 'too-many-threads' );
187183 return;
188 - } elseif ( count($threads) < 1 ) {
 184+ } elseif ( count( $threads ) < 1 ) {
189185 $this->dieUsage( 'You must specify a thread to split',
190186 'no-specified-threads' );
191187 return;
192188 }
193 -
 189+
194190 $thread = array_pop( $threads );
195 -
 191+
196192 if ( $thread->isTopmostThread() ) {
197193 $this->dieUsage( 'This thread is already a top-level thread.',
198194 'already-top-level' );
199195 }
200 -
 196+
201197 $title = null;
202198 $article = $thread->article();
203 - if ( empty($params['subject'] ) ||
 199+ if ( empty( $params['subject'] ) ||
204200 ! Thread::validateSubject( $params['subject'], $title, null, $article ) ) {
205 -
 201+
206202 $this->dieUsage( 'No subject, or an invalid subject, was specified',
207203 'no-valid-subject' );
208204 }
209 -
 205+
210206 $subject = $params['subject'];
211 -
 207+
212208 // Pull a reason, if applicable.
213209 $reason = '';
214 - if ( !empty($params['reason']) ) {
 210+ if ( !empty( $params['reason'] ) ) {
215211 $reason = $params['reason'];
216212 }
217 -
 213+
218214 // Check if they specified a sortkey
219215 $sortkey = null;
220 - if ( !empty($params['sortkey']) ) {
 216+ if ( !empty( $params['sortkey'] ) ) {
221217 $ts = $params['sortkey'];
222218 $ts = wfTimestamp( TS_MW, $ts );
223 -
 219+
224220 $sortkey = $ts;
225221 }
226 -
 222+
227223 // Do the split
228224 $thread->split( $subject, $reason, $sortkey );
229 -
 225+
230226 $result = array();
231 - $result[] =
232 - array(
233 - 'result' => 'Success',
234 - 'action' => 'split',
235 - 'id' => $thread->id(),
236 - 'title' => $thread->title()->getPrefixedText(),
237 - 'newsubject' => $subject,
238 - );
239 -
 227+ $result[] = array(
 228+ 'result' => 'Success',
 229+ 'action' => 'split',
 230+ 'id' => $thread->id(),
 231+ 'title' => $thread->title()->getPrefixedText(),
 232+ 'newsubject' => $subject,
 233+ );
 234+
240235 $this->getResult()->setIndexedTagName( $result, 'thread' );
241236 $this->getResult()->addValue( null, 'threadaction', $result );
242237 }
243 -
 238+
244239 public function actionMerge( $threads, $params ) {
245240 global $wgUser;
246 -
 241+
247242 if ( count( $threads ) < 1 ) {
248243 $this->dieUsage( 'You must specify a thread to merge',
249244 'no-specified-threads' );
250245 return;
251246 }
252 -
 247+
253248 if ( empty( $params['newparent'] ) ) {
254249 $this->dieUsage( 'You must specify a new parent thread to merge beneath',
255 - 'no-parent-thread' );
 250+ 'no-parent-thread' );
256251 return;
257252 }
258 -
 253+
259254 $newParent = $params['newparent'];
260255 if ( is_numeric( $newParent ) ) {
261256 $newParent = Threads::withId( $newParent );
@@ -263,115 +258,114 @@
264259 $article = new Article( $title );
265260 $newParent = Threads::withRoot( $article );
266261 }
267 -
 262+
268263 if ( !$newParent ) {
269 - $this->dieUsage( 'The parent thread you specified was neither the title '.
 264+ $this->dieUsage( 'The parent thread you specified was neither the title ' .
270265 'of a thread, nor a thread ID.', 'invalid-parent-thread' );
271266 return;
272267 }
273 -
 268+
274269 // Pull a reason, if applicable.
275270 $reason = '';
276 - if ( !empty($params['reason']) ) {
 271+ if ( !empty( $params['reason'] ) ) {
277272 $reason = $params['reason'];
278273 }
279 -
 274+
280275 $result = array();
281 -
282 - foreach( $threads as $thread ) {
 276+
 277+ foreach ( $threads as $thread ) {
283278 $thread->moveToParent( $newParent, $reason );
284 - $result[] =
285 - array(
286 - 'result' => 'Success',
287 - 'action' => 'merge',
288 - 'id' => $thread->id(),
289 - 'title' => $thread->title()->getPrefixedText(),
290 - 'new-parent-id' => $newParent->id(),
291 - 'new-parent-title' => $newParent->title()->getPrefixedText(),
292 - 'new-ancestor-id' => $newParent->topmostThread()->id(),
293 - 'new-ancestor-title' => $newParent->topmostThread()->title()->getPrefixedText(),
294 - );
 279+ $result[] = array(
 280+ 'result' => 'Success',
 281+ 'action' => 'merge',
 282+ 'id' => $thread->id(),
 283+ 'title' => $thread->title()->getPrefixedText(),
 284+ 'new-parent-id' => $newParent->id(),
 285+ 'new-parent-title' => $newParent->title()->getPrefixedText(),
 286+ 'new-ancestor-id' => $newParent->topmostThread()->id(),
 287+ 'new-ancestor-title' => $newParent->topmostThread()->title()->getPrefixedText(),
 288+ );
295289 }
296 -
 290+
297291 $this->getResult()->setIndexedTagName( $result, 'thread' );
298292 $this->getResult()->addValue( null, 'threadaction', $result );
299293 }
300 -
 294+
301295 public function actionNewThread( $threads, $params ) {
302296 global $wgUser;
303 -
 297+
304298 // Validate talkpage parameters
305299 if ( empty( $params['talkpage'] ) ) {
306300 $this->dieUsage( 'You must specify a talk-page to post the thread to',
307301 'missing-param' );
308 -
 302+
309303 return;
310304 }
311 -
 305+
312306 $talkpageTitle = Title::newFromText( $params['talkpage'] );
313 -
314 - if (!$talkpageTitle || !LqtDispatch::isLqtPage( $talkpageTitle ) ) {
315 - $this->dieUsage( 'The talkpage you specified is invalid, or does not '.
 307+
 308+ if ( !$talkpageTitle || !LqtDispatch::isLqtPage( $talkpageTitle ) ) {
 309+ $this->dieUsage( 'The talkpage you specified is invalid, or does not ' .
316310 'have discussion threading enabled.', 'invalid-talkpage' );
317311 return;
318312 }
319313 $talkpage = new Article( $talkpageTitle );
320 -
 314+
321315 // Check if we can post.
322316 if ( Thread::canUserPost( $wgUser, $talkpage ) !== true ) {
323 - $this->dieUsage( 'You cannot post to the specified talkpage, '.
 317+ $this->dieUsage( 'You cannot post to the specified talkpage, ' .
324318 'because it is protected from new posts', 'talkpage-protected' );
325319 return;
326320 }
327 -
 321+
328322 // Validate subject, generate a title
329323 if ( empty( $params['subject'] ) ) {
330324 $this->dieUsage( 'You must specify a thread subject',
331325 'missing-param' );
332326 return;
333327 }
334 -
335 - $bump = isset($params['bump']) ? $params['bump'] : null;
336 -
 328+
 329+ $bump = isset( $params['bump'] ) ? $params['bump'] : null;
 330+
337331 $subject = $params['subject'];
338332 $title = null;
339333 $subjectOk = Thread::validateSubject( $subject, $title, null, $talkpage );
340 -
 334+
341335 if ( !$subjectOk ) {
342336 $this->dieUsage( 'The subject you specified is not valid',
343337 'invalid-subject' );
344 -
 338+
345339 return;
346340 }
347341 $article = new Article( $title );
348 -
 342+
349343 // Check for text
350344 if ( empty( $params['text'] ) ) {
351345 $this->dieUsage( 'You must include text in your post', 'no-text' );
352346 return;
353347 }
354348 $text = $params['text'];
355 -
 349+
356350 // Generate or pull summary
357351 $summary = wfMsgForContent( 'lqt-newpost-summary', $subject );
358352 if ( !empty( $params['reason'] ) ) {
359353 $summary = $params['reason'];
360354 }
361 -
 355+
362356 $signature = null;
363357 if ( isset( $params['signature'] ) ) {
364358 $signature = $params['signature'];
365359 }
366 -
 360+
367361 // Inform hooks what we're doing
368362 LqtHooks::$editTalkpage = $talkpage;
369363 LqtHooks::$editArticle = $article;
370364 LqtHooks::$editThread = null;
371365 LqtHooks::$editType = 'new';
372366 LqtHooks::$editAppliesTo = null;
373 -
 367+
374368 $token = $params['token'];
375 -
 369+
376370 // All seems in order. Construct an API edit request
377371 $requestData = array(
378372 'action' => 'edit',
@@ -382,31 +376,31 @@
383377 'basetimestamp' => wfTimestampNow(),
384378 'format' => 'json',
385379 );
386 -
 380+
387381 $editReq = new FauxRequest( $requestData, true );
388382 $internalApi = new ApiMain( $editReq, true );
389383 $internalApi->execute();
390 -
 384+
391385 $editResult = $internalApi->getResultData();
392 -
 386+
393387 if ( $editResult['edit']['result'] != 'Success' ) {
394388 $result = array( 'result' => 'EditFailure', 'details' => $editResult );
395389 $this->getResult()->addValue( null, $this->getModuleName(), $result );
396390 return;
397391 }
398 -
 392+
399393 $articleId = $editResult['edit']['pageid'];
400 -
 394+
401395 $article->getTitle()->resetArticleID( $articleId );
402396 $title->resetArticleID( $articleId );
403 -
 397+
404398 $thread = LqtView::postEditUpdates( 'new', null, $article, $talkpage,
405399 $subject, $summary, null, $text, $bump, $signature );
406400
407401 $maxLag = wfGetLB()->getMaxLag();
408402 $maxLag = $maxLag[1];
409 -
410 - if ($maxLag == -1) {
 403+
 404+ if ( $maxLag == - 1 ) {
411405 $maxLag = 0;
412406 }
413407
@@ -416,81 +410,81 @@
417411 'thread-title' => $title->getPrefixedText(),
418412 'max-lag' => $maxLag,
419413 );
420 -
 414+
421415 if ( !empty( $params['render'] ) ) {
422416 $result['html'] = self::renderThreadPostAction( $thread );
423417 }
424 -
 418+
425419 $result = array( 'thread' => $result );
426 -
 420+
427421 $this->getResult()->addValue( null, $this->getModuleName(), $result );
428422 }
429 -
 423+
430424 public function actionReply( $threads, $params ) {
431425 global $wgUser;
432 -
 426+
433427 // Validate thread parameter
434 - if ( count($threads) > 1 ) {
 428+ if ( count( $threads ) > 1 ) {
435429 $this->dieUsage( 'You may only reply to one thread at a time',
436430 'too-many-threads' );
437431 return;
438 - } elseif ( count($threads) < 1 ) {
 432+ } elseif ( count( $threads ) < 1 ) {
439433 $this->dieUsage( 'You must specify a thread to reply to',
440434 'no-specified-threads' );
441435 return;
442436 }
443437 $replyTo = array_pop( $threads );
444 -
 438+
445439 // Check if we can reply to that thread.
446440 $perm_result = $replyTo->canUserReply( $wgUser );
447441 if ( $perm_result !== true ) {
448 - $this->dieUsage( "You cannot reply to this thread, because the ".
449 - $perm_result." is protected from replies.",
450 - $perm_result.'-protected' );
 442+ $this->dieUsage( "You cannot reply to this thread, because the " .
 443+ $perm_result . " is protected from replies.",
 444+ $perm_result . '-protected' );
451445 return;
452446 }
453 -
 447+
454448 // Validate text parameter
455449 if ( empty( $params['text'] ) ) {
456450 $this->dieUsage( 'You must include text in your post', 'no-text' );
457451 return;
458452 }
459 -
 453+
460454 $text = $params['text'];
461 -
462 - $bump = isset($params['bump']) ? $params['bump'] : null;
463 -
 455+
 456+ $bump = isset( $params['bump'] ) ? $params['bump'] : null;
 457+
464458 // Generate/pull summary
465459 $summary = wfMsgForContent( 'lqt-reply-summary', $replyTo->subject(),
466460 $replyTo->title()->getPrefixedText() );
467 -
 461+
468462 if ( !empty( $params['reason'] ) ) {
469463 $summary = $params['reason'];
470464 }
471 -
 465+
472466 $signature = null;
473467 if ( isset( $params['signature'] ) ) {
474468 $signature = $params['signature'];
475469 }
476 -
 470+
477471 // Grab data from parent
478472 $talkpage = $replyTo->article();
479473 $subject = $replyTo->subject();
480 -
 474+
481475 // Generate a reply title.
482476 $title = Threads::newReplyTitle( $replyTo, $wgUser );
483477 $article = new Article( $title );
484 -
 478+
485479 // Inform hooks what we're doing
486480 LqtHooks::$editTalkpage = $talkpage;
487481 LqtHooks::$editArticle = $article;
488482 LqtHooks::$editThread = null;
489483 LqtHooks::$editType = 'reply';
490484 LqtHooks::$editAppliesTo = $replyTo;
491 -
 485+
492486 // Pull token in
493487 $token = $params['token'];
494 -
 488+
495489 // All seems in order. Construct an API edit request
496490 $requestData = array(
497491 'action' => 'edit',
@@ -501,33 +495,33 @@
502496 'basetimestamp' => wfTimestampNow(),
503497 'format' => 'json',
504498 );
505 -
 499+
506500 $editReq = new FauxRequest( $requestData, true );
507501 $internalApi = new ApiMain( $editReq, true );
508502 $internalApi->execute();
509 -
 503+
510504 $editResult = $internalApi->getResultData();
511 -
 505+
512506 if ( $editResult['edit']['result'] != 'Success' ) {
513507 $result = array( 'result' => 'EditFailure', 'details' => $editResult );
514508 $this->getResult()->addValue( null, $this->getModuleName(), $result );
515509 return;
516510 }
517 -
 511+
518512 $articleId = $editResult['edit']['pageid'];
519513 $article->getTitle()->resetArticleID( $articleId );
520514 $title->resetArticleID( $articleId );
521 -
 515+
522516 $thread = LqtView::postEditUpdates( 'reply', $replyTo, $article, $talkpage,
523517 $subject, $summary, null, $text, $bump, $signature );
524 -
 518+
525519 $maxLag = wfGetLB()->getMaxLag();
526520 $maxLag = $maxLag[1];
527 -
528 - if ($maxLag == -1) {
 521+
 522+ if ( $maxLag == - 1 ) {
529523 $maxLag = 0;
530524 }
531 -
 525+
532526 $result = array(
533527 'action' => 'reply',
534528 'result' => 'Success',
@@ -539,19 +533,19 @@
540534 'ancestor-title' => $replyTo->topmostThread()->title()->getPrefixedText(),
541535 'max-lag' => $maxLag,
542536 );
543 -
 537+
544538 if ( !empty( $params['render'] ) ) {
545539 $result['html'] = self::renderThreadPostAction( $thread );
546540 }
547 -
 541+
548542 $result = array( 'thread' => $result );
549 -
 543+
550544 $this->getResult()->addValue( null, $this->getModuleName(), $result );
551545 }
552 -
 546+
553547 static function renderThreadPostAction( $thread ) {
554548 $thread = $thread->topmostThread();
555 -
 549+
556550 // Set up OutputPage
557551 global $wgOut, $wgUser, $wgRequest;
558552 $oldOutputText = $wgOut->getHTML();
@@ -561,58 +555,58 @@
562556 $article = $thread->root();
563557 $title = $article->getTitle();
564558 $view = new LqtView( $wgOut, $article, $title, $wgUser, $wgRequest );
565 -
 559+
566560 $view->showThread( $thread );
567561
568562 $result = $wgOut->getHTML();
569563 $wgOut->clearHTML();
570564 $wgOut->addHTML( $oldOutputText );
571 -
 565+
572566 return $result;
573567 }
574 -
 568+
575569 public function actionSetSubject( $threads, $params ) {
576570 // Validate thread parameter
577 - if ( count($threads) > 1 ) {
 571+ if ( count( $threads ) > 1 ) {
578572 $this->dieUsage( 'You may only change the subject of one thread at a time',
579573 'too-many-threads' );
580574 return;
581 - } elseif ( count($threads) < 1 ) {
 575+ } elseif ( count( $threads ) < 1 ) {
582576 $this->dieUsage( 'You must specify a thread to change the subject of',
583577 'no-specified-threads' );
584578 return;
585579 }
586580 $thread = array_pop( $threads );
587 -
 581+
588582 // Validate subject
589583 if ( empty( $params['subject'] ) ) {
590584 $this->dieUsage( 'You must specify a thread subject',
591585 'missing-param' );
592586 return;
593587 }
594 -
 588+
595589 $talkpage = $thread->article();
596 -
 590+
597591 $subject = $params['subject'];
598592 $title = null;
599593 $subjectOk = Thread::validateSubject( $subject, $title, null, $talkpage );
600 -
 594+
601595 if ( !$subjectOk ) {
602596 $this->dieUsage( 'The subject you specified is not valid',
603597 'invalid-subject' );
604 -
 598+
605599 return;
606600 }
607 -
 601+
608602 $reason = null;
609 -
 603+
610604 if ( isset( $params['reason'] ) ) {
611605 $reason = $params['reason'];
612606 }
613 -
 607+
614608 $thread->setSubject( $subject );
615609 $thread->commitRevision( Threads::CHANGE_EDITED_SUBJECT, $thread, $reason );
616 -
 610+
617611 $result = array(
618612 'action' => 'setsubject',
619613 'result' => 'success',
@@ -620,51 +614,51 @@
621615 'thread-title' => $thread->title()->getPrefixedText(),
622616 'new-subject' => $subject,
623617 );
624 -
 618+
625619 $result = array( 'thread' => $result );
626 -
 620+
627621 $this->getResult()->addValue( null, $this->getModuleName(), $result );
628622 }
629 -
 623+
630624 public function actionSetSortkey( $threads, $params ) {
631625 // First check for threads
632 - if ( !count($threads) ) {
 626+ if ( !count( $threads ) ) {
633627 $this->dieUsage( 'You must specify a thread to set the sortkey of',
634628 'no-specified-threads' );
635629 return;
636630 }
637 -
 631+
638632 // Validate timestamp
639633 if ( empty( $params['sortkey'] ) ) {
640 - $this->dieUsage( 'You must specify a valid timestamp for the sortkey'.
641 - 'parameter. It should be in the form YYYYMMddhhmmss, a '.
 634+ $this->dieUsage( 'You must specify a valid timestamp for the sortkey' .
 635+ 'parameter. It should be in the form YYYYMMddhhmmss, a ' .
642636 'unix timestamp or "now".', 'invalid-sortkey' );
643637 return;
644638 }
645 -
 639+
646640 $ts = $params['sortkey'];
647 -
648 - if ($ts == 'now') $ts = wfTimestampNow();
649 -
 641+
 642+ if ( $ts == 'now' ) $ts = wfTimestampNow();
 643+
650644 $ts = wfTimestamp( TS_MW, $ts );
651 -
 645+
652646 if ( !$ts ) {
653 - $this->dieUsage( 'You must specify a valid timestamp for the sortkey'.
654 - 'parameter. It should be in the form YYYYMMddhhmmss, a '.
 647+ $this->dieUsage( 'You must specify a valid timestamp for the sortkey' .
 648+ 'parameter. It should be in the form YYYYMMddhhmmss, a ' .
655649 'unix timestamp or "now".', 'invalid-sortkey' );
656650 return;
657651 }
658 -
 652+
659653 $reason = null;
660 -
 654+
661655 if ( isset( $params['reason'] ) ) {
662656 $reason = $params['reason'];
663657 }
664 -
665 - $thread = array_pop($threads);
 658+
 659+ $thread = array_pop( $threads );
666660 $thread->setSortkey( $ts );
667661 $thread->commitRevision( Threads::CHANGE_ADJUSTED_SORTKEY, null, $reason );
668 -
 662+
669663 $result = array(
670664 'action' => 'setsortkey',
671665 'result' => 'success',
@@ -672,12 +666,12 @@
673667 'thread-title' => $thread->title()->getPrefixedText(),
674668 'new-sortkey' => $ts,
675669 );
676 -
 670+
677671 $result = array( 'thread' => $result );
678 -
 672+
679673 $this->getResult()->addValue( null, $this->getModuleName(), $result );
680674 }
681 -
 675+
682676 public function getVersion() {
683677 return __CLASS__ . ': $Id: $';
684678 }
Index: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /*
54 * This program is free software; you can redistribute it and/or modify
65 * it under the terms of the GNU General Public License as published by
@@ -28,7 +27,6 @@
2928 * @ingroup API
3029 */
3130 class ApiFeedLQTThreads extends ApiBase {
32 -
3331 public function __construct( $main, $action ) {
3432 parent :: __construct( $main, $action );
3533 }
@@ -54,7 +52,7 @@
5553 $feedTitle = self::createFeedTitle( $params );
5654 $feedClass = $wgFeedClasses[$params['feedformat']];
5755 $feedItems = array();
58 -
 56+
5957 $feedUrl = Title::newMainPage()->getFullURL();
6058
6159 $tables = array( 'thread' );
Index: trunk/extensions/LiquidThreads/api/ApiQueryLQTThreads.php
@@ -17,27 +17,26 @@
1818 */
1919
2020 class ApiQueryLQTThreads extends ApiQueryBase {
21 -
2221 // Property definitions
2322 static $propRelations = array(
24 - 'id' => 'thread_id',
25 - 'subject' => 'thread_subject',
26 - 'page' => array(
27 - 'namespace' => 'thread_article_namespace',
28 - 'title' => 'thread_article_title'
29 - ),
30 - 'parent' => 'thread_parent',
31 - 'ancestor' => 'thread_ancestor',
32 - 'created' => 'thread_created',
33 - 'modified' => 'thread_modified',
34 - 'author' => array(
35 - 'id' => 'thread_author_id',
36 - 'name' => 'thread_author_name'
37 - ),
38 - 'summaryid' => 'thread_summary_page',
39 - 'rootid' => 'thread_root',
40 - 'type' => 'thread_type',
41 - );
 23+ 'id' => 'thread_id',
 24+ 'subject' => 'thread_subject',
 25+ 'page' => array(
 26+ 'namespace' => 'thread_article_namespace',
 27+ 'title' => 'thread_article_title'
 28+ ),
 29+ 'parent' => 'thread_parent',
 30+ 'ancestor' => 'thread_ancestor',
 31+ 'created' => 'thread_created',
 32+ 'modified' => 'thread_modified',
 33+ 'author' => array(
 34+ 'id' => 'thread_author_id',
 35+ 'name' => 'thread_author_name'
 36+ ),
 37+ 'summaryid' => 'thread_summary_page',
 38+ 'rootid' => 'thread_root',
 39+ 'type' => 'thread_type',
 40+ );
4241
4342 public function __construct( $query, $moduleName ) {
4443 parent :: __construct( $query, $moduleName, 'th' );
@@ -90,11 +89,11 @@
9190 }
9291
9392 $res = $this->select( __METHOD__ );
94 -
 93+
9594 if ( $params['render'] ) {
9695 $threads = Threads::loadFromResult( $res, $this->getDB() );
9796 }
98 -
 97+
9998 $count = 0;
10099 foreach ( $res as $row )
101100 {
Index: trunk/extensions/LiquidThreads/import/import-parsed-discussions.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
54 ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
65 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -44,7 +44,7 @@
4545 'useliquidthreads',
4646 array( 'LqtParserFunctions', 'useLiquidThreads' )
4747 );
48 -
 48+
4949 $parser->setFunctionHook(
5050 'lqtpagelimit',
5151 array( 'LqtParserFunctions', 'lqtPageLimit' )
Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php
@@ -9,8 +9,6 @@
1010 * @licence GPL2
1111 */
1212
13 -require_once( dirname( __FILE__ ) . '/LiquidThreads.magic.php' );
14 -
1513 $messages = array();
1614
1715 $messages['en'] = array(
@@ -183,7 +181,7 @@
184182 'lqt-newmessages-from' => 'From $1',
185183 'lqt-hot-topics' => 'Hot topics',
186184 'lqt-add-reply' => 'Add a reply',
187 -
 185+
188186 // Recent changes display
189187 'lqt_rc_new_discussion' => "posted a new thread, \"$1\"",
190188 'lqt_rc_new_reply' => "posted a reply to \"$1\"",
@@ -257,12 +255,12 @@
258256 'lqt-marked-as-read-placeholder' => 'The thread $1 was marked as read.',
259257 'lqt-change-subject' => 'Change subject',
260258 'lqt-save-subject' => 'Save',
261 - 'lqt-save-subject-failed' => 'The following error occurred while attempting to '.
 259+ 'lqt-save-subject-failed' => 'The following error occurred while attempting to ' .
262260 'change the subject of this thread: $1',
263 - 'lqt-ajax-invalid-subject' => 'The subject you specified was invalid, probably '.
 261+ 'lqt-ajax-invalid-subject' => 'The subject you specified was invalid, probably ' .
264262 'because it was too long.',
265263 'lqt-ajax-no-subject' => 'You must specify a subject.',
266 - 'lqt-save-subject-error-unknown' => 'An unknown error occurred when attempting '.
 264+ 'lqt-save-subject-error-unknown' => 'An unknown error occurred when attempting ' .
267265 'to set the subject of this thread. Please try to do this by clicking "edit" on the top post.',
268266 'lqt-cancel-subject-edit' => 'Cancel',
269267 'lqt-drag-activate' => 'Drag to new location',
@@ -307,12 +305,12 @@
308306 'lqt-protected-reply-thread' => 'You cannot post in this thread because it has been protected from new posts.',
309307 'lqt-protected-reply-talkpage' => 'You cannot post in this thread because this discussion page has been protected from replies to its threads.',
310308 'lqt-protected-newthread' => 'You cannot post new threads to this discussion page because it has been protected from new threads.',
311 -
 309+
312310 'lqt-edit-bump' => 'Bump this thread',
313311 'lqt-edit-bump-tooltip' => 'Move this thread to the top of its discussion page',
314 -
 312+
315313 'lqt-historicalrevision-error' => 'The revision you have selected is corrupt, and cannot be viewed.',
316 -
 314+
317315 // Reply subpage name
318316 'lqt-reply-subpage' => 'reply',
319317 );
@@ -490,7 +488,7 @@
491489 'lqt-feed-new-thread-intro' => 'Parameters:
492490 * $1 is a link to the talk page with the thread
493491 * $2 is a link to the user posting in the thread
494 -* $3 -not used-
 492+* $3 -not used-
495493 * $4 is the name of the user posting to the thread, optional, can be used for GENDER',
496494 'lqt-feed-reply-intro' => 'Parameters:
497495 * $1 is a link to the talk page with the thread
@@ -1533,12 +1531,12 @@
15341532 'lqt-enotif-subject-reply' => 'Абмеркаваньне {{GRAMMAR:родны|{{SITENAME}}}} — Адказ: $1',
15351533 'lqt-enotif-subject-newthread' => 'Абмеркаваньне {{GRAMMAR:родны|{{SITENAME}}}} — Новая галіна: $1',
15361534 'lqt-enotif-newthread' => "Вітаем $1,
1537 -Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новую галіну $5, '$2',
 1535+Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новую галіну $5, '$2',
15381536 створаную $3 $4.
15391537
15401538 Вы можаце паглядзець яе на <$6>",
15411539 'lqt-enotif-reply' => "Вітаем $1,
1542 -Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новы адказ $5, '$2',
 1540+Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новы адказ $5, '$2',
15431541 створаны $3 $4.
15441542
15451543 Вы можаце паглядзець яго на <$6>",
@@ -1789,7 +1787,7 @@
17901788 'lqt-thread-link-url' => 'URL на препратката:',
17911789 'lqt-thread-link-title' => 'Уикитекст на препратката:',
17921790 'lqt-thread-link-copy' => 'Копиране в системния буфер',
1793 - 'lqt-sign-not-necessary' => 'Не е нужно да подписвате коментара си с четири вълнички.
 1791+ 'lqt-sign-not-necessary' => 'Не е нужно да подписвате коментара си с четири вълнички.
17941792 Подписът ви ще се покаже автоматично.',
17951793 'lqt-marked-as-read-placeholder' => 'Тема $1 беше отбелязана като прочетена.',
17961794 'lqt-change-subject' => 'Смяна на темата',
@@ -2086,7 +2084,7 @@
20872085 'lqt_delete_show_checkbox' => "Diskouez ar c'haozeadennoù diverket",
20882086 'lqt_talkpage_autocreate_summary' => "Pajenn gaozeal krouet ent emgefre p'eo bet kaset an neudennad kaozioù kentañ",
20892087 'lqt_header_warning_big' => "Emaoc'h o kemmañ ur $1",
2090 - 'lqt_header_warning_after_big' => "Evit ar c'hemennoù hag ar rakgerioù eo an talbennoù.
 2088+ 'lqt_header_warning_after_big' => "Evit ar c'hemennoù hag ar rakgerioù eo an talbennoù.
20912089 Marteze e fell deoc'h $2 kentoc'h.",
20922090 'lqt_header_warning_bold' => 'Talbenn ur bajenn gaozeal',
20932091 'lqt_header_warning_new_discussion' => "boulc'hañ gant ur gaoz nevez",
@@ -2526,7 +2524,7 @@
25272525 'lqt_new_thread' => 'Comença una nova discussió',
25282526 'lqt_invalid_subject' => 'El tema que heu introduït no és vàlid.
25292527 Pot:
2530 -* ser massa llarg, o
 2528+* ser massa llarg, o
25312529 * entrar en conflicte amb prefixos interwiki o altres espai de noms.',
25322530 'lqt_empty_subject' => "Heu d'introduir un tema.",
25332531 'lqt_reply' => 'Respon',
@@ -4945,7 +4943,7 @@
49464944 'lqt_nosuchthread' => 'Määrittämääsi viestiketjua ei ole.',
49474945 'lqt_nosuchthread_title' => 'Ketjua ei löydy',
49484946 'lqt_threadrequired' => 'Sinun tulee antaa ketju URL-osoitteessa.',
4949 - 'lqt_move_movingthread' => 'Siirretään $1.
 4947+ 'lqt_move_movingthread' => 'Siirretään $1.
49504948 Tämä ketju on osa sivua $2.',
49514949 'lqt_move_torename' => 'Nimetäksesi uudelleen tämän ketjun – $1 ja muuta Aihe-kenttää.',
49524950 'lqt_move_torename_edit' => 'muokkaa sitä',
@@ -4969,7 +4967,7 @@
49704968 'lqt_delete_show_checkbox' => 'Näytä poistetut ketjut',
49714969 'lqt_talkpage_autocreate_summary' => 'Keskustelusivu luotiin automaattisesti kun ensimmäinen ketju lähettiin.',
49724970 'lqt_header_warning_big' => 'Muokkaat $1.',
4973 - 'lqt_header_warning_after_big' => 'Otsakkeet ovat ilmoituksille.
 4971+ 'lqt_header_warning_after_big' => 'Otsakkeet ovat ilmoituksille.
49744972 Saatat etsiä sivua ”$2” sen sijaan.',
49754973 'lqt_header_warning_bold' => 'keskustelusivun otsikkoa',
49764974 'lqt_header_warning_new_discussion' => 'aloita uusi keskustelu',
@@ -5056,7 +5054,7 @@
50575055 'lqt-enotif-subject-newthread' => '{{SITENAME}} – Uusi viestiketju: $1',
50585056 'lqt-enotif-newthread' => 'Hei $1,
50595057
5060 -Tämä on ilmoitus sivustolta {{SITENAME}}, että sivulle $5 on luotu uusi ketju, ”$2”,
 5058+Tämä on ilmoitus sivustolta {{SITENAME}}, että sivulle $5 on luotu uusi ketju, ”$2”,
50615059 $3 $4.
50625060
50635061 Näet sen osoitteessa <$6>.',
@@ -10439,7 +10437,7 @@
1044010438 'lqt_protectedfromreply_link' => 'låst',
1044110439 'lqt_subject' => 'Emne:',
1044210440 'lqt_noreason' => 'Ingen grunn gitt.',
10443 - 'lqt_move_placeholder' => 'Denne tråden eksisterer kun for å vise at tråden $1 ble flyttet fra denne siden til en annen diskusjonsside.
 10441+ 'lqt_move_placeholder' => 'Denne tråden eksisterer kun for å vise at tråden $1 ble flyttet fra denne siden til en annen diskusjonsside.
1044410442 Denne flyttingen ble foretatt av $2 $3 $4.
1044510443 Denne tråden ligger nå på $5',
1044610444 'lqt_thread_deleted_for_sysops' => "Denne tråden har blitt '''slettet''' og er kun synlig for administratorer.",
@@ -12460,7 +12458,7 @@
1246112459 'lqt_protectedfromreply_link' => 'көмүскэммит',
1246212460 'lqt_subject' => 'Аата:',
1246312461 'lqt_noreason' => 'Төрүөтэ ыйыллыбатах.',
12464 - 'lqt_move_placeholder' => 'Бу салаа бүөтэ $1 салаа бу сирэйтэн көһөрүллүбүтүн көрдөрөр.
 12462+ 'lqt_move_placeholder' => 'Бу салаа бүөтэ $1 салаа бу сирэйтэн көһөрүллүбүтүн көрдөрөр.
1246512463 Көһөрүүнү $3 $4 сирэйгэ $2 кыттааччы оҥорбут. Онон салаа маннык буолбут $5.',
1246612464 'lqt_thread_deleted_for_sysops' => "Бу салаа '''сотуллубут''', дьаһабылларга эрэ костөр кыахтаах.",
1246712465 'lqt_thread_deleted' => 'Бу салаа сотуллубут.',
@@ -12473,7 +12471,7 @@
1247412472 'lqt_nosuchthread' => 'Ыйбыт салааҥ суох эбит.',
1247512473 'lqt_nosuchthread_title' => 'Маннык салаа суох',
1247612474 'lqt_threadrequired' => 'URL-га салааны ыйыахтааххын.',
12477 - 'lqt_move_movingthread' => '$1 көһөрүү.
 12475+ 'lqt_move_movingthread' => '$1 көһөрүү.
1247812476 Бу салаа $2 сорҕото буолар.',
1247912477 'lqt_move_torename' => "Салааны аатын уларытыаххын баҕарар буоллаххына, $1 уонна 'Аата' диэн түннүгү уларыт.",
1248012478 'lqt_move_torename_edit' => 'маны көннөр',
@@ -12497,7 +12495,7 @@
1249812496 'lqt_delete_show_checkbox' => 'Сотуллубут салаалары көрдөр',
1249912497 'lqt_talkpage_autocreate_summary' => 'Саҥа ырытыы сирэйэ бастакы этии оҥоһуллубутун кэннэ апатмаатынан оҥоһулунна.',
1250012498 'lqt_header_warning_big' => 'Маны эрэдээксийэлиигин $1.',
12501 - 'lqt_header_warning_after_big' => 'Ааттар биллэрии уонна киирии быһыытынан туттуллаллар.
 12499+ 'lqt_header_warning_after_big' => 'Ааттар биллэрии уонна киирии быһыытынан туттуллаллар.
1250212500 Эн маны оҥоруоххун сөп $2.',
1250312501 'lqt_header_warning_bold' => 'ырытар сирэй аата',
1250412502 'lqt_header_warning_new_discussion' => 'саҥа ырытыыны саҕалааһын',
@@ -12582,11 +12580,11 @@
1258312581 'lqt-enotif-subject-reply' => '{{SITENAME}} ырытыы — Хоруй: $1',
1258412582 'lqt-enotif-subject-newthread' => '{{SITENAME}} ырытыы — Саҥа салаа: $1',
1258512583 'lqt-enotif-newthread' => 'Дорообо, $1.
12586 -Бу $3 $4 {{SITENAME}} саайка баар $5 сирэйгэ «$2» диэн саҥа салаа үөскээбитин туһунан биллэрии.
 12584+Бу $3 $4 {{SITENAME}} саайка баар $5 сирэйгэ «$2» диэн саҥа салаа үөскээбитин туһунан биллэрии.
1258712585
1258812586 Бу аадырыска <$6> көрүөххүн сөп.',
1258912587 'lqt-enotif-reply' => 'Дорообо, $1.
12590 -Бу $3 $4 {{SITENAME}} саайка баар $5 сирэй «$2» салаатыгар саҥа хоруй баар буолбутун туһунан биллэрии.
 12588+Бу $3 $4 {{SITENAME}} саайка баар $5 сирэй «$2» салаатыгар саҥа хоруй баар буолбутун туһунан биллэрии.
1259112589
1259212590 Бу аадырыска <$6> көрүөххүн сөп.',
1259312591 'lqt-quote-intro' => '$2 $3, [[User:$1|$1]] суруйбут:',
@@ -13621,7 +13619,7 @@
1362213620 'lqt_subject' => 'Tema:',
1362313621 'lqt_noreason' => 'Sebäp görkezilmedik.',
1362413622 'lqt_move_placeholder' => 'Bu tred , $1 trediniň bu sahypadan başga bir ýere geçirilendigini görkezýän ýer-saklaýjydyr.
13625 -Tred $4 $3 senesinde $2 tarapyndan geçirilipdir.
 13623+Tred $4 $3 senesinde $2 tarapyndan geçirilipdir.
1362613624 Tred häzirki wagtda $5 adresinde ýerleşýär.',
1362713625 'lqt_thread_deleted_for_sysops' => "Bu tred '''öçürilipdir''' we ony diňe administratorlar görüp bilýär.",
1362813626 'lqt_thread_deleted' => 'Bu tred öçürilipdir.',
@@ -13746,7 +13744,7 @@
1374713745
1374813746 Ony <$6> adresinde görüp bilersiňiz.",
1374913747 'lqt-enotif-reply' => "Salam $1,
13750 -Bu {{SITENAME}} saýtynyň uwedomleniýasydyr: $5 sahypasynda $4 $3 senesinde '$2' tredine täze bir jogap döredildi.
 13748+Bu {{SITENAME}} saýtynyň uwedomleniýasydyr: $5 sahypasynda $4 $3 senesinde '$2' tredine täze bir jogap döredildi.
1375113749
1375213750 Ony <$6> adresinde görüp bilersiňiz.",
1375313751 'lqt-quote-intro' => '$2, $3 senesinde [[User:$1|$1]] ýazdy:',
Index: trunk/extensions/LiquidThreads/compat/generateCompatibilityLocalisation.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 // Utility script to generate an extension messages file for backwards-compatibility.
54
65 require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
@@ -7,15 +6,15 @@
87 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
98
109 $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+ 'htmlform-reset',
 11+ 'htmlform-submit',
 12+ 'htmlform-int-invalid',
 13+ 'htmlform-int-toolow',
 14+ 'htmlform-int-toohigh',
 15+ 'htmlform-select-badoption',
 16+ 'htmlform-selectorother-other',
 17+ 'htmlform-invalid-input',
 18+);
2019
2120 $languages = array_keys( Language::getLanguageNames( false ) );
2221 $data = array_fill_keys( $languages, array() );
@@ -35,20 +34,20 @@
3635
3736 foreach ( $languages as $lang ) {
3837 $fallback = Language::getFallbackFor( $lang );
39 -
 38+
4039 print " [$lang from $fallback] ";
4140 $lastFallback = $lang;
42 -
 41+
4342 while ( $fallback && !isset( $originalData[$fallback] ) && $fallback != $lastFallback ) {
4443 $lastFallback = $fallback;
4544 $fallback = Language::getFallbackFor( $lang );
4645 }
47 -
 46+
4847 if ( $fallback && isset( $originalData[$fallback] ) ) {
4948 $fallbackData = $originalData[$fallback];
50 -
 49+
5150 $data[$lang] = array_diff_assoc( $originalData[$lang], $fallbackData );
52 -
 51+
5352 if ( !count( $data[$lang] ) )
5453 unset( $data[$lang] );
5554 }
Index: trunk/extensions/LiquidThreads/compat/HTMLForm.php
@@ -1,13 +1,13 @@
22 <?php
3 -
43 class HTMLForm {
5 -
64 static $jsAdded = false;
75
86 /* The descriptor is an array of arrays.
97 i.e. array(
10 - 'fieldname' => array( 'section' => 'section/subsection',
11 - properties... ),
 8+ 'fieldname' => array(
 9+ 'section' => 'section/subsection',
 10+ properties...
 11+ ),
1212 ...
1313 )
1414 */
@@ -26,7 +26,7 @@
2727
2828 function __construct( $descriptor, $messagePrefix ) {
2929 wfLoadExtensionMessages( 'Lqt-Compat' );
30 -
 30+
3131 $this->mMessagePrefix = $messagePrefix;
3232
3333 // Expand out into a tree.
@@ -112,18 +112,21 @@
113113 }
114114
115115 /** Return values:
116 - * TRUE == Successful submission
117 - * FALSE == No submission attempted
118 - * Anything else == Error to display.
119 - */
 116+ * TRUE == Successful submission
 117+ * FALSE == No submission attempted
 118+ * Anything else == Error to display.
 119+ */
120120 function trySubmit() {
121121 // Check for validation
122122 foreach ( $this->mFlatFields as $fieldname => $field ) {
123123 if ( !empty( $field->mParams['nodata'] ) ) continue;
124 - if ( $field->validate( $this->mFieldData[$fieldname],
125 - $this->mFieldData ) !== true ) {
126 - return isset( $this->mValidationErrorMessage ) ?
127 - $this->mValidationErrorMessage : array( 'htmlform-invalid-input' );
 124+ if ( $field->validate(
 125+ $this->mFieldData[$fieldname],
 126+ $this->mFieldData ) !== true )
 127+ {
 128+ return isset( $this->mValidationErrorMessage )
 129+ ? $this->mValidationErrorMessage
 130+ : array( 'htmlform-invalid-input' );
128131 }
129132 }
130133
@@ -214,7 +217,7 @@
215218 )
216219 ) . "\n";
217220 }
218 -
 221+
219222 return $html;
220223 }
221224
@@ -228,7 +231,7 @@
229232 } else {
230233 $errorstr = $errors;
231234 }
232 -
 235+
233236 $errorstr = Xml::tags( 'div', array( 'class' => 'error' ), $errorstr );
234237
235238 global $wgOut;
@@ -288,8 +291,8 @@
289292 foreach ( $fields as $key => $value ) {
290293 if ( is_object( $value ) ) {
291294 $v = empty( $value->mParams['nodata'] )
292 - ? $this->mFieldData[$key]
293 - : $value->getDefault();
 295+ ? $this->mFieldData[$key]
 296+ : $value->getDefault();
294297 $tableHtml .= $value->getTableRow( $v );
295298
296299 if ( $value->getLabel() != '&nbsp;' )
@@ -456,8 +459,11 @@
457460 $text = wfMsgExt( $msg, 'parseinline' );
458461
459462 if ( !wfEmptyMsg( $msg, $text ) ) {
460 - $row = Xml::tags( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ),
461 - $text );
 463+ $row = Xml::tags(
 464+ 'td',
 465+ array( 'colspan' => 2, 'class' => 'htmlform-tip' ),
 466+ $text
 467+ );
462468
463469 $row = Xml::tags( 'tr', null, $row );
464470
@@ -507,7 +513,7 @@
508514 if ( isset( $this->mParams['maxlength'] ) ) {
509515 $attribs['maxlength'] = $this->mParams['maxlength'];
510516 }
511 -
 517+
512518 if ( !empty( $this->mParams['disabled'] ) ) {
513519 $attribs['disabled'] = 'disabled';
514520 }
@@ -519,7 +525,6 @@
520526 $attribs
521527 );
522528 }
523 -
524529 }
525530
526531 class HTMLIntField extends HTMLTextField {
@@ -661,10 +666,12 @@
662667 $tbAttribs['maxlength'] = $this->mParams['maxlength'];
663668 }
664669
665 - $textbox = Xml::input( $this->mName . '-other',
666 - $this->getSize(),
667 - $valInSelect ? '' : $value,
668 - $tbAttribs );
 670+ $textbox = Xml::input(
 671+ $this->mName . '-other',
 672+ $this->getSize(),
 673+ $valInSelect ? '' : $value,
 674+ $tbAttribs
 675+ );
669676
670677 return "$select<br />\n$textbox";
671678 }
@@ -722,9 +729,11 @@
723730 $html .= $this->formatOptions( $info, $value );
724731 } else {
725732 $thisAttribs = array( 'id' => $this->mID . "-$info", 'value' => $info );
726 -
727 - $checkbox = Xml::check( $this->mName . '[]', in_array( $info, $value ),
728 - $attribs + $thisAttribs );
 733+
 734+ $checkbox = Xml::check(
 735+ $this->mName . '[]', in_array( $info, $value ),
 736+ $attribs + $thisAttribs
 737+ );
729738 $checkbox .= '&nbsp;' . Xml::tags( 'label', array( 'for' => $this->mID . "-$info" ), $label );
730739
731740 $html .= $checkbox . '<br />';
@@ -778,7 +787,7 @@
779788
780789 return $html;
781790 }
782 -
 791+
783792 function formatOptions( $options, $value ) {
784793 $html = '';
785794
Index: trunk/extensions/LiquidThreads/compat/LqtCompatArticle.php
@@ -3,28 +3,26 @@
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 -
119 public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) {
1210 global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache;
13 -
 11+
1412 if ( !$parserOptions ) {
1513 $parserOptions = $wgOut->parserOptions();
1614 }
17 -
 15+
1816 $time = - wfTime();
1917 $parserOutput = $wgParser->parse( $text, $this->mTitle,
2018 $parserOptions, true, true, $this->getRevIdFetched() );
2119 $time += wfTime();
22 -
 20+
2321 # Timing hack
2422 if ( $time > 3 ) {
2523 wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time,
2624 $this->mTitle->getPrefixedDBkey() ) );
2725 }
28 -
 26+
2927 if ( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != - 1 ) {
3028 $parserCache = ParserCache::singleton();
3129 $parserCache->save( $parserOutput, $this, $parserOptions );
@@ -37,34 +35,34 @@
3836 }
3937 return $parserOutput;
4038 }
41 -
 39+
4240 /** Stolen from 1.16-alpha, for compatibility with 1.15 */
4341 /** Lightweight method to get the parser output for a page, checking the parser cache
4442 * and so on. Doesn't consider most of the stuff that Article::view is forced to
4543 * consider, so it's not appropriate to use there. */
4644 function getParserOutput( $oldid = null ) {
4745 global $wgEnableParserCache, $wgUser, $wgOut;
48 -
 46+
4947 // Should the parser cache be used?
5048 $useParserCache = $wgEnableParserCache &&
5149 intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
5250 $this->exists() &&
5351 $oldid === null;
54 -
 52+
5553 wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
5654 if ( $wgUser->getOption( 'stubthreshold' ) ) {
5755 wfIncrStats( 'pcache_miss_stub' );
5856 }
59 -
 57+
6058 $parserOutput = false;
6159 if ( $useParserCache ) {
6260 $parserOutput = ParserCache::singleton()->get( $this, $wgOut->parserOptions() );
6361 }
64 -
 62+
6563 if ( $parserOutput === false ) {
6664 // Cache miss; parse and output it.
6765 $rev = Revision::newFromTitle( $this->getTitle(), $oldid );
68 -
 66+
6967 return $this->getOutputFromWikitext( $rev->getText(), $useParserCache );
7068 } else {
7169 return $parserOutput;
Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) )
54 die();
65
@@ -24,15 +23,15 @@
2524 define( 'LQT_OLDEST_THREADS', 'ot' );
2625
2726 // FIXME: would be neat if it was possible to somehow localise this.
28 -$wgCanonicalNamespaceNames[NS_LQT_THREAD] = 'Thread';
29 -$wgCanonicalNamespaceNames[NS_LQT_THREAD_TALK] = 'Thread_talk';
30 -$wgCanonicalNamespaceNames[NS_LQT_SUMMARY] = 'Summary';
31 -$wgCanonicalNamespaceNames[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
 27+$wgCanonicalNamespaceNames[NS_LQT_THREAD] = 'Thread';
 28+$wgCanonicalNamespaceNames[NS_LQT_THREAD_TALK] = 'Thread_talk';
 29+$wgCanonicalNamespaceNames[NS_LQT_SUMMARY] = 'Summary';
 30+$wgCanonicalNamespaceNames[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
3231
3332 // FIXME: would be neat if it was possible to somehow localise this.
34 -$wgExtraNamespaces[NS_LQT_THREAD] = 'Thread';
35 -$wgExtraNamespaces[NS_LQT_THREAD_TALK] = 'Thread_talk';
36 -$wgExtraNamespaces[NS_LQT_SUMMARY] = 'Summary';
 33+$wgExtraNamespaces[NS_LQT_THREAD] = 'Thread';
 34+$wgExtraNamespaces[NS_LQT_THREAD_TALK] = 'Thread_talk';
 35+$wgExtraNamespaces[NS_LQT_SUMMARY] = 'Summary';
3736 $wgExtraNamespaces[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
3837
3938 // Localisation
@@ -104,7 +103,7 @@
105104 $wgSpecialPages['NewMessages'] = 'SpecialNewMessages';
106105 $wgSpecialPages['SplitThread'] = 'SpecialSplitThread';
107106 $wgSpecialPages['MergeThread'] = 'SpecialMergeThread';
108 -//$wgSpecialPages['HotTopics'] = 'SpecialHotTopics';
 107+// $wgSpecialPages['HotTopics'] = 'SpecialHotTopics';
109108 $wgSpecialPageGroups['NewMessages'] = 'wiki';
110109
111110 // Classes
@@ -160,7 +159,7 @@
161160 $wgLogNames['liquidthreads'] = 'lqt-log-name';
162161 $wgLogHeaders['liquidthreads'] = 'lqt-log-header';
163162
164 -foreach( array( 'move', 'split', 'merge', 'subjectedit', 'resort' ) as $action ) {
 163+foreach ( array( 'move', 'split', 'merge', 'subjectedit', 'resort' ) as $action ) {
165164 $wgLogActionsHandlers["liquidthreads/$action"] = 'LqtLogFormatter::formatLogEntry';
166165 }
167166
@@ -204,9 +203,13 @@
205204 /* Thread actions which do *not* cause threads to be "bumped" to the top */
206205 /* Using numbers because the change type constants are defined in Threads.php, don't
207206 want to have to parse it on every page view */
208 -$wgThreadActionsNoBump = array( 3 /* Edited summary */, 10 /* Merged from */,
209 - 12 /* Split from */, 2 /* Edited root */,
210 - 14 /* Adjusted sortkey */ );
 207+$wgThreadActionsNoBump = array(
 208+ 3 /* Edited summary */,
 209+ 10 /* Merged from */,
 210+ 12 /* Split from */,
 211+ 2 /* Edited root */,
 212+ 14 /* Adjusted sortkey */
 213+);
211214
212215 /** Switch this on if you've migrated from a version before around May 2009 */
213216 $wgLiquidThreadsMigrate = false;
Index: trunk/extensions/LiquidThreads/classes/HotTopics.php
@@ -6,117 +6,115 @@
77 class LqtHotTopicsController {
88 public static function generateHotTopics( $count = 10 ) {
99 $dbr = wfGetDB( DB_SLAVE );
10 -
 10+
1111 $now = wfTimestamp( TS_UNIX, wfTimestampNow() );
12 - $dateCutoff = $dbr->addQuotes( $dbr->timestamp( $now - (7*86400) ) );
13 -
 12+ $dateCutoff = $dbr->addQuotes( $dbr->timestamp( $now - ( 7 * 86400 ) ) );
 13+
1414 $conds = array();
15 -// $conds[] ='th_timestamp>'.$dateCutoff;
16 -
 15+
1716 // Grab the ID cutoff
1817 $idCutoff = $dbr->selectField( 'thread_history', 'th_id',
19 - array( 'th_timestamp>'.$dateCutoff ),
 18+ array( 'th_timestamp>' . $dateCutoff ),
2019 __METHOD__,
2120 array( 'ORDER BY' => 'th_id desc',
2221 'OFFSET' => 10000 )
2322 );
24 -
 23+
2524 if ( $idCutoff ) {
2625 $idCutoff = $dbr->addQuotes( $idCutoff );
27 - $conds[] = 'th_id>'.$idCutoff;
 26+ $conds[] = 'th_id>' . $idCutoff;
2827 }
29 -
 28+
3029 $res = $dbr->select( array( 'thread_history' ),
3130 array( 'th_id', 'th_thread', 'th_timestamp' ),
3231 $conds,
3332 __METHOD__,
3433 array( 'LIMIT' => 10000 )
3534 );
36 -
 35+
3736 $threads = array();
38 -
39 - foreach( $res as $row ) {
 37+
 38+ foreach ( $res as $row ) {
4039 if ( isset( $threads[$row->th_thread] ) ) {
4140 $thread =& $threads[$row->th_thread];
4241 $thread['count']++;
43 -
 42+
4443 if ( $thread['firstpost'] > $row->th_timestamp ) {
4544 $thread['firstpost'] = $row->th_timestamp;
4645 }
47 -
 46+
4847 if ( $thread['lastpost'] < $row->th_timestamp ) {
4948 $thread['lastpost'] = $row->th_timestamp;
5049 }
51 - unset($thread);
 50+ unset( $thread );
5251 } else {
5352 $thread = array();
54 -
 53+
5554 $thread['id'] = $row->th_thread;
5655 $thread['count'] = 1;
5756 $thread['firstpost'] = $row->th_timestamp;
5857 $thread['lastpost'] = $row->th_timestamp;
59 -
 58+
6059 $threads[$row->th_thread] = $thread;
6160 }
6261 }
63 -
64 - foreach( $threads as &$thread ) {
 62+
 63+ foreach ( $threads as &$thread ) {
6564 $thread['rate'] = self::getThreadPostRate( $thread );
6665 }
67 -
 66+
6867 // Filter out useless stuff
6968 $threads = array_filter( $threads, array( __CLASS__, 'threadFilterCallback' ) );
70 -
 69+
7170 // Sort
7271 usort( $threads, array( __CLASS__, 'threadSortCallback' ) );
73 -
 72+
7473 $threads = array_slice( $threads, 0, $count, true );
75 -
 74+
7675 $outputThreads = array();
77 -
78 - foreach( $threads as $thread ) {
 76+
 77+ foreach ( $threads as $thread ) {
7978 $outputThreads[$thread['id']] = $thread['id'];
8079 }
81 -
 80+
8281 return $outputThreads;
8382 }
84 -
 83+
8584 public static function getHotThreads( $count = 10 ) {
8685 $topics = array_values( self::generateHotTopics( $count ) );
87 -
 86+
8887 return Threads::where( array( 'thread_id' => $topics ) );
8988 }
90 -
 89+
9190 public static function threadFilterCallback( $entry ) {
9291 return $entry['count'] > 3;
9392 }
94 -
 93+
9594 public static function threadSortCallback( $a, $b ) {
96 - $rateA = floatval($a['rate']);
97 - $rateB = floatval($b['rate']);
98 -
 95+ $rateA = floatval( $a['rate'] );
 96+ $rateB = floatval( $b['rate'] );
 97+
9998 if ( $rateA == $rateB ) {
10099 $val = 0;
101100 } elseif ( $rateA < $rateB ) {
102101 $val = 1;
103102 } elseif ( $rateA > $rateB ) {
104 - $val = -1;
 103+ $val = - 1;
105104 }
106 -
 105+
107106 return $val;
108107 }
109 -
 108+
110109 public static function getThreadPostRate( $entry ) {
111110 if ( $entry['count'] < 2 ) {
112111 return 0;
113112 }
114 -
 113+
115114 $startTime = wfTimestamp( TS_UNIX, $entry['firstpost'] );
116115 $endTime = wfTimestamp( TS_UNIX, wfTimestampNow() );
117116 $duration = $endTime - $startTime;
118 -
 117+
119118 // Get count over duration, multiply out to give posts per day
120 -
121119 return ( $entry['count'] / $duration ) * 86400;
122120 }
123121 }
Index: trunk/extensions/LiquidThreads/classes/Dispatch.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 class LqtDispatch {
54 /** static cache of per-page LiquidThreads activation setting */
65 static $userLqtOverride = array();
@@ -13,7 +12,7 @@
1413 $output->redirect( $title->getSubjectPage()->getFullUrl() );
1514 return false;
1615 }
17 -
 16+
1817 // If we came here from a red-link, redirect to the thread page.
1918 $redlink = $request->getCheck( 'redlink' ) &&
2019 $request->getText( 'action' ) == 'edit';
@@ -22,21 +21,22 @@
2322 return false;
2423 }
2524
26 - /* Certain actions apply to the "header", which is stored in the actual talkpage
27 - in the database. Drop everything and behave like a normal page if those
28 - actions come up, to avoid hacking the various history, editing, etc. code. */
 25+ /**
 26+ * Certain actions apply to the "header", which is stored in the actual talkpage
 27+ * in the database. Drop everything and behave like a normal page if those
 28+ * actions come up, to avoid hacking the various history, editing, etc. code.
 29+ */
2930 $action = $request->getVal( 'action' );
3031 $header_actions = array( 'history', 'edit', 'submit', 'delete' );
3132 global $wgRequest;
32 -
 33+
3334 $lqt_action = $request->getVal( 'lqt_method' );
3435 if ( $action == 'edit' && $request->getVal( 'section' ) == 'new' ) {
3536 // Hijack section=new for "new thread".
3637 $request->setVal( 'lqt_method', 'talkpage_new_thread' );
3738 $request->setVal( 'section', '' );
38 -
 39+
3940 $viewname = 'TalkpageView';
40 -
4141 } elseif ( !$lqt_action && ( in_array( $action, $header_actions ) ||
4242 $request->getVal( 'diff', null ) !== null ) ) {
4343 // Pass through wrapper
@@ -49,16 +49,15 @@
5050 } else {
5151 $viewname = 'TalkpageView';
5252 }
53 -
 53+
5454 Thread::$titleCacheById[$article->getId()] = $title;
55 -
 55+
5656 $view = new $viewname( $output, $article, $title, $user, $request );
5757 self::$primaryView = $view;
5858 return $view->show();
5959 }
6060
6161 static function threadPermalinkMain( &$output, &$article, &$title, &$user, &$request ) {
62 -
6362 $action = $request->getVal( 'action' );
6463 $lqt_method = $request->getVal( 'lqt_method' );
6564
@@ -82,7 +81,7 @@
8382 } else {
8483 $viewname = 'ThreadPermalinkView';
8584 }
86 -
 85+
8786 $view = new $viewname( $output, $article, $title, $user, $request );
8887 self::$primaryView = $view;
8988 return $view->show();
@@ -94,53 +93,54 @@
9594 self::$primaryView = $view;
9695 return $view->show();
9796 }
98 -
 97+
9998 static function isLqtPage( $title ) {
10099 // Ignore it if it's a thread or a summary, makes no sense to have LiquidThreads there.
101100 if ( $title->getNamespace() == NS_LQT_THREAD ||
102101 $title->getNamespace() == NS_LQT_SUMMARY ) {
103102 return false;
104103 }
105 -
 104+
106105 global $wgLqtPages, $wgLqtTalkPages;
107106 $isTalkPage = ( $title->isTalkPage() && $wgLqtTalkPages ) ||
108107 in_array( $title->getPrefixedText(), $wgLqtPages );
109 -
 108+
110109 if ( $title->exists() ) {
111110 $override = self::getUserLqtOverride( $title );
112111 } else {
113112 $override = null;
114113 }
115 -
 114+
116115 global $wgLiquidThreadsAllowUserControl;
117 - if ( !is_null($override) && $wgLiquidThreadsAllowUserControl ) {
 116+ if ( !is_null( $override ) && $wgLiquidThreadsAllowUserControl ) {
118117 $isTalkPage = $override;
119118 }
120 -
 119+
121120 $isTalkPage = $isTalkPage && !$title->isRedirect();
122 -
 121+
123122 return $isTalkPage;
124123 }
125 -
 124+
126125 static function getUserLqtOverride( $title ) {
127 - if ( ! is_object($title) ) {
 126+ if ( ! is_object( $title ) ) {
128127 return null;
129128 }
130 -
 129+
131130 $articleid = $title->getArticleId();
132 -
 131+
133132 global $wgLiquidThreadsAllowUserControlNamespaces;
134133 global $wgLiquidThreadsAllowUserControl;
135 - if (!$wgLiquidThreadsAllowUserControl) {
 134+
 135+ if ( !$wgLiquidThreadsAllowUserControl ) {
136136 return null;
137137 }
138 -
 138+
139139 $namespaces = $wgLiquidThreadsAllowUserControlNamespaces;
140 -
 140+
141141 if ( !is_null( $namespaces ) && !in_array( $title->getNamespace(), $namespaces ) ) {
142142 return null;
143143 }
144 -
 144+
145145 // Check instance cache.
146146 if ( array_key_exists( $articleid, self::$userLqtOverride ) ) {
147147 $cacheVal = self::$userLqtOverride[$articleid];
@@ -150,15 +150,20 @@
151151
152152 // Load from the database.
153153 $dbr = wfGetDB( DB_SLAVE );
154 -
155 - $row = $dbr->selectRow( 'page_props', 'pp_value',
156 - array( 'pp_propname' => 'use-liquid-threads',
157 - 'pp_page' => $articleid ), __METHOD__ );
158154
159 -
 155+ $row = $dbr->selectRow(
 156+ 'page_props',
 157+ 'pp_value',
 158+ array(
 159+ 'pp_propname' => 'use-liquid-threads',
 160+ 'pp_page' => $articleid
 161+ ),
 162+ __METHOD__
 163+ );
 164+
160165 if ( $row ) {
161166 $dbVal = $row->pp_value;
162 -
 167+
163168 self::$userLqtOverride[$articleid] = $dbVal;
164169 return $dbVal;
165170 } else {
@@ -185,20 +190,20 @@
186191 }
187192 return true;
188193 }
189 -
 194+
190195 static function onSkinTemplateNavigation( $skinTemplate, &$links ) {
191196 if ( !self::$primaryView ) return true;
192 -
 197+
193198 self::$primaryView->customizeNavigation( $skinTemplate, $links );
194 -
 199+
195200 return true;
196201 }
197 -
 202+
198203 static function onSkinTemplateTabs( $skinTemplate, &$links ) {
199204 if ( !self::$primaryView ) return true;
200 -
 205+
201206 self::$primaryView->customizeTabs( $skinTemplate, $links );
202 -
 207+
203208 return true;
204209 }
205210 }
Index: trunk/extensions/LiquidThreads/classes/Hooks.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 class LqtHooks {
54 // Used to inform hooks about edits that are taking place.
65 public static $editType = null;
@@ -7,41 +6,41 @@
87 public static $editAppliesTo = null;
98 public static $editArticle = null;
109 public static $editTalkpage = null;
11 -
 10+
1211 static function customizeOldChangesList( &$changeslist, &$s, $rc ) {
1312 if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD )
1413 return true;
15 -
 14+
1615 $thread = Threads::withRoot( new Article( $rc->getTitle() ) );
1716 if ( !$thread ) return true;
1817
1918 LqtView::addJSandCSS();
2019 wfLoadExtensionMessages( 'LiquidThreads' );
21 -
 20+
2221 global $wgUser, $wgLang;
2322 $sk = $wgUser->getSkin();
2423
2524 // Custom display for new posts.
2625 if ( $rc->mAttribs['rc_new'] ) {
2726 global $wgOut;
28 -
 27+
2928 // Article link, timestamp, user
3029 $s = '';
3130 $s .= $sk->link( $thread->article()->getTitle() );
3231 $changeslist->insertTimestamp( $s, $rc );
3332 $changeslist->insertUserRelatedLinks( $s, $rc );
34 -
 33+
3534 // Action text
3635 $msg = $thread->isTopmostThread()
3736 ? 'lqt_rc_new_discussion' : 'lqt_rc_new_reply';
3837 $link = LqtView::linkInContext( $thread );
39 - $s .= ' '. wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
40 -
 38+ $s .= ' ' . wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
 39+
4140 // add the truncated post content
4241 $quote = $thread->root()->getContent();
4342 $quote = $wgLang->truncate( $quote, 200 );
4443 $s .= ' ' . $sk->commentBlock( $quote );
45 -
 44+
4645 $classes = array();
4746 $changeslist->insertTags( $s, $rc, $classes );
4847 $changeslist->insertExtra( $s, $rc, $classes );
@@ -51,11 +50,11 @@
5251
5352 static function setNewtalkHTML( $skintemplate, $tpl ) {
5453 global $wgUser, $wgTitle, $wgOut;
55 -
 54+
5655 if ( ! LqtDispatch::isLqtPage( $wgUser->getTalkPage() ) ) {
5756 return true;
5857 }
59 -
 58+
6059 wfLoadExtensionMessages( 'LiquidThreads' );
6160 $newmsg_t = SpecialPage::getTitleFor( 'NewMessages' );
6261 $watchlist_t = SpecialPage::getTitleFor( 'Watchlist' );
@@ -75,45 +74,45 @@
7675
7776 return true;
7877 }
79 -
 78+
8079 static function beforeWatchlist( &$conds, &$tables, &$join_conds, &$fields ) {
8180 global $wgOut, $wgUser;
82 -
 81+
8382 $db = wfGetDB( DB_SLAVE );
84 -
 83+
8584 if ( !in_array( 'page', $tables ) ) {
8685 $tables[] = 'page';
8786 // Yes, this is the correct field to join to. Weird naming.
8887 $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
8988 }
9089 $conds[] = "page_namespace != " . $db->addQuotes( NS_LQT_THREAD );
91 -
 90+
9291 $talkpage_messages = NewMessages::newUserMessages( $wgUser );
9392 $tn = count( $talkpage_messages );
94 -
 93+
9594 $watch_messages = NewMessages::watchedThreadsForUser( $wgUser );
9695 $wn = count( $watch_messages );
97 -
 96+
9897 if ( $tn == 0 && $wn == 0 )
9998 return true;
100 -
 99+
101100 LqtView::addJSandCSS();
102101 wfLoadExtensionMessages( 'LiquidThreads' );
103102 $messages_title = SpecialPage::getTitleFor( 'NewMessages' );
104103 $new_messages = wfMsgExt( 'lqt-new-messages', 'parseinline' );
105 -
 104+
106105 $sk = $wgUser->getSkin();
107106 $link = $sk->link( $messages_title, $new_messages,
108107 array( 'class' => 'lqt_watchlist_messages_notice' ) );
109108 $wgOut->addHTML( $link );
110 -
 109+
111110 return true;
112111 }
113 -
 112+
114113 static function getPreferences( $user, &$preferences ) {
115114 global $wgEnableEmail;
116115 wfLoadExtensionMessages( 'LiquidThreads' );
117 -
 116+
118117 if ( $wgEnableEmail ) {
119118 $preferences['lqtnotifytalk'] =
120119 array(
@@ -122,54 +121,55 @@
123122 'section' => 'personal/email'
124123 );
125124 }
126 -
127 -
128 - $preferences['lqt-watch-threads'] =
129 - array(
130 - 'type' => 'toggle',
131 - 'label-message' => 'lqt-preference-watch-threads',
132 - 'section' => 'watchlist/advancedwatchlist',
133 - );
134 -
 125+
 126+ $preferences['lqt-watch-threads'] = array(
 127+ 'type' => 'toggle',
 128+ 'label-message' => 'lqt-preference-watch-threads',
 129+ 'section' => 'watchlist/advancedwatchlist',
 130+ );
 131+
135132 // Display depth and count
136 - $preferences['lqtdisplaydepth'] =
137 - array(
138 - 'type' => 'int',
139 - 'label-message' => 'lqt-preference-display-depth',
140 - 'section' => 'lqt',
141 - );
142 -
143 - $preferences['lqtdisplaycount'] =
144 - array(
145 - 'type' => 'int',
146 - 'label-message' => 'lqt-preference-display-count',
147 - 'section' => 'lqt',
148 - );
149 -
 133+ $preferences['lqtdisplaydepth'] = array(
 134+ 'type' => 'int',
 135+ 'label-message' => 'lqt-preference-display-depth',
 136+ 'section' => 'lqt',
 137+ );
 138+
 139+ $preferences['lqtdisplaycount'] = array(
 140+ 'type' => 'int',
 141+ 'label-message' => 'lqt-preference-display-count',
 142+ 'section' => 'lqt',
 143+ );
 144+
150145 return true;
151146 }
152 -
 147+
153148 static function updateNewtalkOnEdit( $article ) {
154149 $title = $article->getTitle();
155 -
 150+
156151 if ( LqtDispatch::isLqtPage( $title ) ) {
157152 // They're only editing the header, don't update newtalk.
158153 return false;
159154 }
160 -
 155+
161156 return true;
162157 }
163 -
 158+
164159 static function dumpThreadData( $writer, &$out, $row, $title ) {
165 - $editedStati = array( Threads::EDITED_NEVER => 'never',
166 - Threads::EDITED_HAS_REPLY => 'has-reply',
167 - Threads::EDITED_BY_AUTHOR => 'by-author',
168 - Threads::EDITED_BY_OTHERS => 'by-others' );
169 - $threadTypes = array( Threads::TYPE_NORMAL => 'normal',
170 - Threads::TYPE_MOVED => 'moved',
171 - Threads::TYPE_DELETED => 'deleted' );
 160+ $editedStati = array(
 161+ Threads::EDITED_NEVER => 'never',
 162+ Threads::EDITED_HAS_REPLY => 'has-reply',
 163+ Threads::EDITED_BY_AUTHOR => 'by-author',
 164+ Threads::EDITED_BY_OTHERS => 'by-others'
 165+ );
 166+ $threadTypes = array(
 167+ Threads::TYPE_NORMAL => 'normal',
 168+ Threads::TYPE_MOVED => 'moved',
 169+ Threads::TYPE_DELETED => 'deleted'
 170+ );
 171+
172172 // Is it a thread
173 - if ( !empty($row->thread_id) ) {
 173+ if ( !empty( $row->thread_id ) ) {
174174 $thread = Thread::newFromRow( $row );
175175 $threadInfo = "\n";
176176 $attribs = array();
@@ -186,25 +186,25 @@
187187 $attribs['ThreadAuthor'] = $thread->author()->getName();
188188 $attribs['ThreadEditStatus'] = $editedStati[$thread->editedness()];
189189 $attribs['ThreadType'] = $threadTypes[$thread->type()];
190 -
 190+
191191 foreach ( $attribs as $key => $value ) {
192192 $threadInfo .= "\t" . Xml::element( $key, null, $value ) . "\n";
193193 }
194 -
 194+
195195 $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) . "\n";
196196 }
197 -
 197+
198198 return true;
199199 }
200 -
 200+
201201 static function modifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) {
202202 $tables[] = 'thread';
203 -
 203+
204204 $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) );
205 -
 205+
206206 return true;
207207 }
208 -
 208+
209209 static function modifyOAIQuery( &$tables, &$fields, &$conds,
210210 &$options, &$join_conds ) {
211211
@@ -217,21 +217,21 @@
218218
219219 return true;
220220 }
221 -
 221+
222222 static function customiseSearchResultTitle( &$title, &$text, $result, $terms, $page ) {
223223 if ( $title->getNamespace() != NS_LQT_THREAD ) {
224224 return true;
225225 }
226 -
 226+
227227 $thread = Threads::withRoot( new Article( $title ) );
228228 $text = $thread->subject();
229 -
 229+
230230 $title = clone $thread->topmostThread()->title();
231231 $title->setFragment( '#' . $thread->getAnchorName() );
232 -
 232+
233233 return true;
234234 }
235 -
 235+
236236 static function onUserRename( $renameUserSQL ) {
237237 // Always use the job queue, talk page edits will take forever
238238 $renameUserSQL->tablesJob['thread'] =
@@ -240,76 +240,75 @@
241241 array( 'th_user_text', 'th_user', 'th_timestamp' );
242242 return true;
243243 }
244 -
 244+
245245 static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) {
246246 global $wgRequest;
247247 $article = $editPage->getArticle();
248248 $title = $article->getTitle();
249 -
 249+
250250 if ( !$article->exists() && $title->getNamespace() == NS_LQT_THREAD ) {
251251 unset( $checkboxes['minor'] );
252252 }
253 -
 253+
254254 if ( $title->getNamespace() == NS_LQT_THREAD && self::$editType != 'new' ) {
255255 wfLoadExtensionMessages( 'LiquidThreads' );
256256 $label = wfMsgExt( 'lqt-edit-bump', 'parseinline' );
257257 $tooltip = wfMsgExt( 'lqt-edit-bump-tooltip', 'parsemag' );
258 -
 258+
259259 $checked = ! $wgRequest->wasPosted() ||
260260 $wgRequest->getBool( 'wpBumpThread' );
261 -
 261+
262262 $html =
263263 Xml::check( 'wpBumpThread', $checked, array(
264264 'title' => $tooltip, 'id' => 'wpBumpThread'
265265 ) );
266 -
 266+
267267 $html .= Xml::tags( 'label', array( 'for' => 'wpBumpThread',
268268 'title' => $tooltip ), $label );
269 -
 269+
270270 $checkboxes['bump'] = $html;
271271 }
272 -
 272+
273273 return true;
274274 }
275 -
 275+
276276 static function customiseSearchProfiles( &$profiles ) {
277277 wfLoadExtensionMessages( 'LiquidThreads' );
278 -
 278+
279279 $namespaces = array( NS_LQT_THREAD, NS_LQT_SUMMARY );
280 -
 280+
281281 // Add odd namespaces
282282 foreach ( SearchEngine::searchableNamespaces() as $ns => $nsName ) {
283283 if ( $ns % 2 == 1 ) {
284284 $namespaces[] = $ns;
285285 }
286286 }
287 -
 287+
288288 $insert = array(
289 - 'threads' =>
290 - array(
291 - 'message' => 'searchprofile-threads',
292 - 'tooltip' => 'searchprofile-threads-tooltip',
293 - 'namespaces' => $namespaces,
294 - 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ),
295 - ),
 289+ 'threads' => array(
 290+ 'message' => 'searchprofile-threads',
 291+ 'tooltip' => 'searchprofile-threads-tooltip',
 292+ 'namespaces' => $namespaces,
 293+ 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ),
 294+ ),
296295 );
297 -
 296+
298297 $profiles = wfArrayInsertAfter( $profiles, $insert, 'help' );
299 -
 298+
300299 return true;
301300 }
302 -
 301+
303302 public static function onLoadExtensionSchemaUpdates() {
304303 global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields,
305304 $wgExtPGAlteredFields, $wgExtNewIndexes, $wgDBtype;
306305
307306 $dir = realpath( dirname( __FILE__ ) . '/..' );
308 -
 307+
309308 // DB updates
310309 $wgExtNewTables[] = array( 'thread', "$dir/lqt.sql" );
311310 $wgExtNewTables[] = array( 'user_message_state', "$dir/lqt.sql" );
312311 $wgExtNewTables[] = array( 'thread_history', "$dir/schema-changes/thread_history_table.sql" );
313 -
 312+
314313 $wgExtNewFields[] = array( "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql" );
315314 $wgExtNewFields[] = array( "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql" );
316315 $wgExtNewFields[] = array( "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql" );
@@ -324,51 +323,51 @@
325324 $wgExtNewFields[] = array( 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql" );
326325 $wgExtNewFields[] = array( 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql" );
327326 $wgExtNewFields[] = array( 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql" );
328 -
 327+
329328 $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' );
330 -
 329+
331330 return true;
332331 }
333 -
 332+
334333 static function onArticleMoveComplete( &$form, &$ot, &$nt ) {
335334 // Check if it's a talk page.
336335 if ( !LqtDispatch::isLqtPage( $ot ) && !LqtDispatch::isLqtPage( $nt ) ) {
337336 return true;
338337 }
339 -
 338+
340339 // Synchronise the first 500 threads, in reverse order by thread id. If
341340 // there are more threads to synchronise, the job queue will take over.
342341 Threads::synchroniseArticleData( new Article( $nt ), 500, 'cascade' );
343 -
 342+
344343 return true;
345344 }
346 -
 345+
347346 static function onArticleMove( $ot, $nt, $user, &$err, $reason ) {
348347 // Synchronise article data so that moving the article doesn't break any
349348 // article association.
350349 Threads::synchroniseArticleData( new Article( $ot ) );
351 -
 350+
352351 return true;
353352 }
354 -
 353+
355354 static function userIsBlockedFrom( $user, $title, &$isBlocked, &$allowUserTalk ) {
356355 // Limit applicability
357356 if ( !( $isBlocked && $allowUserTalk && $title->getNamespace() == NS_LQT_THREAD ) ) {
358357 return true;
359358 }
360 -
 359+
361360 // Now we're dealing with blocked users with user talk editing allowed editing pages
362361 // in the thread namespace.
363362
364363 if ( $title->exists() ) {
365364 // If the page actually exists, allow the user to edit posts on their own talk page.
366365 $thread = Threads::withRoot( new Article( $title ) );
367 -
 366+
368367 if ( !$thread )
369368 return true;
370 -
 369+
371370 $articleTitle = $thread->article()->getTitle();
372 -
 371+
373372 if ( $articleTitle->getNamespace() == NS_USER_TALK &&
374373 $user->getName() == $title->getText() ) {
375374 $isBlocked = false;
@@ -386,44 +385,43 @@
387386 self::$editAppliesTo->article()->getTitle()->equals( $talkPage ) );
388387 $isOnTalkPage = $isOnTalkPage ||
389388 ( self::$editArticle->getTitle()->equals( $talkPage ) );
390 -
 389+
391390 if ( self::$editArticle->getTitle()->equals( $title ) && $isOnTalkPage ) {
392391 $isBlocked = false;
393392 return true;
394393 }
395394 }
396 -
 395+
397396 return true;
398397 }
399 -
 398+
400399 static function onPersonalUrls( &$personal_urls, &$title ) {
401400 global $wgUser, $wgLang;
402 -
 401+
403402 if ( $wgUser->isAnon() ) return true;
404 -
 403+
405404 wfLoadExtensionMessages( 'LiquidThreads' );
406 -
 405+
407406 $dbr = wfGetDB( DB_SLAVE );
408 -
 407+
409408 $newMessagesCount = NewMessages::newMessageCount( $wgUser );
410 -
 409+
411410 // Add new messages link.
412411 $url = SpecialPage::getTitleFor( 'NewMessages' )->getLocalURL();
413412 $msg = $newMessagesCount ? 'lqt-newmessages-n' : 'lqt_newmessages';
414 - $newMessagesLink =
415 - array(
416 - 'href' => $url,
417 - 'text' => wfMsg( $msg, $wgLang->formatNum( $newMessagesCount ) ),
418 - 'active' => $newMessagesCount > 0,
419 - );
420 -
 413+ $newMessagesLink = array(
 414+ 'href' => $url,
 415+ 'text' => wfMsg( $msg, $wgLang->formatNum( $newMessagesCount ) ),
 416+ 'active' => $newMessagesCount > 0,
 417+ );
 418+
421419 $insertUrls = array( 'newmessages' => $newMessagesLink );
422 -
 420+
423421 $personal_urls = wfArrayInsertAfter( $personal_urls, $insertUrls, 'watchlist' );
424 -
 422+
425423 return true;
426424 }
427 -
 425+
428426 static function onArticleSaveComplete( &$article, &$user, $text, $summary,
429427 $minoredit, $watchthis, $sectionanchor, &$flags, $revision,
430428 &$status, $baseRevId ) {
@@ -431,48 +429,56 @@
432430 // Failed
433431 return true;
434432 }
435 -
 433+
436434 $title = $article->getTitle();
437435 if ( $title->getNamespace() != NS_LQT_THREAD ) {
438436 // Not a thread
439437 return true;
440438 }
441 -
442 - if (!$baseRevId) {
 439+
 440+ if ( !$baseRevId ) {
443441 // New page
444442 return true;
445443 }
446 -
 444+
447445 $thread = Threads::withRoot( $article );
448 -
449 - if (!$thread) {
 446+
 447+ if ( !$thread ) {
450448 // No matching thread.
451449 return true;
452450 }
453 -
454 - LqtView::postEditUpdates( 'editExisting', null, $article, $thread->article(),
455 - $thread->article(), $summary, $thread, $text );
456 -
 451+
 452+ LqtView::postEditUpdates(
 453+ 'editExisting',
 454+ null,
 455+ $article,
 456+ $thread->article(),
 457+ $thread->article(),
 458+ $summary,
 459+ $thread,
 460+ $text
 461+ );
 462+
457463 return true;
458464 }
459 -
 465+
460466 static function getProtectionTypes( $title, &$types ) {
461467 $isLqtPage = LqtDispatch::isLqtPage( $title );
462468 $isThread = $title->getNamespace() == NS_LQT_THREAD;
463 -
 469+
464470 if ( !$isLqtPage && !$isThread ) {
465471 return true;
466472 }
467 -
 473+
468474 if ( $isLqtPage ) {
469475 $types[] = 'newthread';
470476 $types[] = 'reply';
471477 }
472 -
 478+
473479 if ( $isThread ) {
474480 $types[] = 'reply';
475481 }
476 -
 482+
477483 return true;
478484 }
479485 }
Index: trunk/extensions/LiquidThreads/classes/LogFormatter.php
@@ -18,27 +18,27 @@
1919 }
2020 break;
2121 default:
22 - $msg = 'lqt-log-action-'.$action;
 22+ $msg = 'lqt-log-action-' . $action;
2323 break;
2424 }
25 -
26 - $options = array('parseinline');
27 -
 25+
 26+ $options = array( 'parseinline' );
 27+
2828 $forIRC = self::isForIRC();
29 -
30 - if ($forIRC) {
 29+
 30+ if ( $forIRC ) {
3131 global $wgContLang;
3232 $options['language'] = $wgContLang->getCode();
3333 }
34 -
 34+
3535 $replacements = array_merge( array( $title->getPrefixedText() ), $parameters );
36 -
 36+
3737 $html = wfMsgExt( $msg, $options, $replacements );
38 -
39 - if ($forIRC) {
 38+
 39+ if ( $forIRC ) {
4040 $html = StringUtils::delimiterReplace( '<', '>', '', $html );
4141 }
42 -
 42+
4343 return $html;
4444 }
4545 }
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 }
@@ -13,7 +12,7 @@
1413 } else if ( is_integer( $thread ) ) {
1514 $thread_id = $thread;
1615 } else {
17 - throw new MWException( __METHOD__." expected Thread or integer but got $thread" );
 16+ throw new MWException( __METHOD__ . " expected Thread or integer but got $thread" );
1817 }
1918
2019 if ( is_object( $user ) ) {
@@ -21,33 +20,37 @@
2221 } else if ( is_integer( $user ) ) {
2322 $user_id = $user;
2423 } else {
25 - throw new MWException( __METHOD__." expected User or integer but got $user" );
 24+ throw new MWException( __METHOD__ . " expected User or integer but got $user" );
2625 }
27 -
 26+
2827 $dbw = wfGetDB( DB_MASTER );
29 -
30 - $dbw->delete( 'user_message_state',
31 - array( 'ums_user' => $user_id, 'ums_thread' => $thread_id ),
32 - __METHOD__ );
33 -
 28+
 29+ $dbw->delete(
 30+ 'user_message_state',
 31+ array( 'ums_user' => $user_id, 'ums_thread' => $thread_id ),
 32+ __METHOD__
 33+ );
 34+
3435 self::recacheMessageCount( $user_id );
3536 }
36 -
 37+
3738 static function markAllReadByUser( $user ) {
3839 if ( is_object( $user ) ) {
3940 $user_id = $user->getID();
4041 } else if ( is_integer( $user ) ) {
4142 $user_id = $user;
4243 } else {
43 - throw new MWException( __METHOD__." expected User or integer but got $user" );
 44+ throw new MWException( __METHOD__ . " expected User or integer but got $user" );
4445 }
45 -
 46+
4647 $dbw = wfGetDB( DB_MASTER );
47 -
48 - $dbw->delete( 'user_message_state',
49 - array( 'ums_user' => $user_id ),
50 - __METHOD__ );
51 -
 48+
 49+ $dbw->delete(
 50+ 'user_message_state',
 51+ array( 'ums_user' => $user_id ),
 52+ __METHOD__
 53+ );
 54+
5255 self::recacheMessageCount( $user_id );
5356 }
5457
@@ -69,10 +72,12 @@
7073 }
7174
7275 $dbw = wfGetDB( DB_MASTER );
73 - $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ),
74 - array( 'ums_user' => $user_id, 'ums_thread' => $thread_id,
75 - 'ums_read_timestamp' => $timestamp ), __METHOD__ );
76 -
 76+ $dbw->replace(
 77+ 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ),
 78+ array( 'ums_user' => $user_id, 'ums_thread' => $thread_id,
 79+ 'ums_read_timestamp' => $timestamp ), __METHOD__
 80+ );
 81+
7782 self::recacheMessageCount( $user_id );
7883 }
7984
@@ -82,7 +87,7 @@
8388 */
8489 static function writeMessageStateForUpdatedThread( $t, $type, $changeUser ) {
8590 global $wgUser;
86 -
 91+
8792 wfDebugLog( 'LiquidThreads', 'Doing notifications' );
8893
8994 $dbw = wfGetDB( DB_MASTER );
@@ -91,40 +96,51 @@
9297 $root_t = $t->topmostThread()->root()->getTitle();
9398
9499 // Select any applicable watchlist entries for the thread.
95 - $talkpageWhere = array( 'wl_namespace' => $tpTitle->getNamespace(),
96 - 'wl_title' => $tpTitle->getDBkey() );
97 - $rootWhere = array( 'wl_namespace' => $root_t->getNamespace(),
98 - 'wl_title' => $root_t->getDBkey() );
99 -
 100+ $talkpageWhere = array(
 101+ 'wl_namespace' => $tpTitle->getNamespace(),
 102+ 'wl_title' => $tpTitle->getDBkey()
 103+ );
 104+ $rootWhere = array(
 105+ 'wl_namespace' => $root_t->getNamespace(),
 106+ 'wl_title' => $root_t->getDBkey()
 107+ );
 108+
100109 $talkpageWhere = $dbw->makeList( $talkpageWhere, LIST_AND );
101110 $rootWhere = $dbw->makeList( $rootWhere, LIST_AND );
102 -
 111+
103112 $where_clause = $dbw->makeList( array( $talkpageWhere, $rootWhere ), LIST_OR );
104 -
 113+
105114 // <= 1.15 compatibility, it kinda sucks having to do all this up here.
106115 $tables = array( 'watchlist', 'user_message_state' );
107 - $joins = array( 'user_message_state' =>
108 - array( 'left join',
109 - array( 'ums_user=wl_user', 'ums_thread' => $t->id() ) ) );
 116+ $joins = array(
 117+ 'user_message_state' =>
 118+ array(
 119+ 'left join',
 120+ array(
 121+ 'ums_user=wl_user',
 122+ 'ums_thread' => $t->id()
 123+ )
 124+ )
 125+ );
110126 $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp' );
111 -
 127+
112128 $oldPrefCompat = false;
113129 global $wgVersion;
114130 if ( version_compare( $wgVersion, '1.15.999', '<=' ) ) {
115131 $oldPrefCompat = true;
116 -
 132+
117133 $tables[] = 'user';
118134 $joins['user'] = array( 'left join', 'user_id=wl_user' );
119135 $fields[] = 'user_options';
120136 } else {
121137 $tables[] = 'user_properties';
122 - $joins['user_properties'] =
 138+ $joins['user_properties'] = array(
 139+ 'left join',
123140 array(
124 - 'left join',
125 - array( 'up_user=wl_user',
126 - 'up_property' => 'lqtnotifytalk',
127 - )
128 - );
 141+ 'up_user=wl_user',
 142+ 'up_property' => 'lqtnotifytalk',
 143+ )
 144+ );
129145 $fields[] = 'up_value';
130146 }
131147
@@ -133,7 +149,7 @@
134150 // notification.
135151 $dbr = wfGetDB( DB_SLAVE );
136152 $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins );
137 -
 153+
138154 $insert_rows = array();
139155 $update_tuples = array();
140156 $notify_users = array();
@@ -141,24 +157,23 @@
142158 // Don't notify yourself
143159 if ( $changeUser->getId() == $row->wl_user )
144160 continue;
145 -
 161+
146162 if ( $row->ums_user && !$row->ums_read_timestamp ) {
147163 // It's already positive.
148164 } else {
149 - $insert_rows[] =
150 - array(
151 - 'ums_user' => $row->wl_user,
152 - 'ums_thread' => $t->id(),
153 - 'ums_read_timestamp' => null,
154 - );
 165+ $insert_rows[] = array(
 166+ 'ums_user' => $row->wl_user,
 167+ 'ums_thread' => $t->id(),
 168+ 'ums_read_timestamp' => null,
 169+ );
155170 NewMessages::recacheMessageCount( $row->wl_user );
156171 }
157 -
 172+
158173 $wantsTalkNotification = false;
159 -
 174+
160175 if ( $oldPrefCompat ) {
161176 $decodedOptions = self::decodeUserOptions( $row->user_options );
162 -
 177+
163178 $wantsTalkNotification = ( ( !isset( $decodedOptions['lqtnotifytalk'] ) || is_null( $decodedOptions['lqtnotifytalk'] ) ) &&
164179 User::getDefaultOption( 'lqtnotifytalk' ) ) || $row->up_value;
165180 } else {
@@ -166,42 +181,47 @@
167182 ( is_null( $row->up_value ) && User::getDefaultOption( 'lqtnotifytalk' ) )
168183 || $row->up_value;
169184 }
170 -
 185+
171186 if ( $wantsTalkNotification ) {
172187 $notify_users[] = $row->wl_user;
173188 }
174189 }
175 -
 190+
176191 // Add user talk notification
177192 if ( $t->article()->getTitle()->getNamespace() == NS_USER_TALK ) {
178193 $name = $t->article()->getTitle()->getText();
179 -
 194+
180195 $user = User::newFromName( $name );
181196 if ( $user && $user->getName() != $changeUser->getName() ) {
182197 $user->setNewtalk( true );
183 -
184 - $insert_rows[] = array( 'ums_user' => $user->getId(),
185 - 'ums_thread' => $t->id(),
186 - 'ums_read_timestamp' => null );
187 -
 198+
 199+ $insert_rows[] = array(
 200+ 'ums_user' => $user->getId(),
 201+ 'ums_thread' => $t->id(),
 202+ 'ums_read_timestamp' => null
 203+ );
 204+
188205 if ( $user->getOption( 'enotifusertalkpages' ) ) {
189206 $notify_users[] = $user->getId();
190207 }
191208 }
192209 }
193 -
 210+
194211 // Do the actual updates
195212 if ( count( $insert_rows ) ) {
196 - $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ),
197 - $insert_rows, __METHOD__ );
 213+ $dbw->replace(
 214+ 'user_message_state',
 215+ array( array( 'ums_user', 'ums_thread' ) ),
 216+ $insert_rows, __METHOD__
 217+ );
198218 }
199 -
 219+
200220 global $wgLqtEnotif;
201221 if ( count( $notify_users ) && $wgLqtEnotif ) {
202222 self::notifyUsersByMail( $t, $notify_users, wfTimestampNow(), $type );
203223 }
204224 }
205 -
 225+
206226 // Would refactor User::decodeOptions, but the whole point is that this is
207227 // compatible with old code :)
208228 static function decodeUserOptions( $str ) {
@@ -213,10 +233,10 @@
214234 $opts[$m[1]] = $m[2];
215235 }
216236 }
217 -
 237+
218238 return $opts;
219239 }
220 -
 240+
221241 static function notifyUsersByMail( $t, $watching_users, $timestamp, $type ) {
222242 wfLoadExtensionMessages( 'LiquidThreads' );
223243 $messages = array(
@@ -227,7 +247,7 @@
228248 Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply',
229249 Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread',
230250 );
231 -
 251+
232252 if ( !isset( $messages[$type] ) || !isset( $subjects[$type] ) ) {
233253 wfDebugLog( 'LiquidThreads', "Email notification failed: type $type unrecognised" );
234254 return;
@@ -235,7 +255,7 @@
236256 $msgName = $messages[$type];
237257 $subjectMsg = $subjects[$type];
238258 }
239 -
 259+
240260 // Send email notification, fetching all the data in one go
241261
242262 global $wgVersion;
@@ -249,31 +269,33 @@
250270 } else {
251271 $tables[] = 'user_properties as tc_prop';
252272 $fields[] = 'tc_prop.up_value as timecorrection';
253 -
254 - $join_conds['user_properties as tc_prop'] =
255 - array( 'left join',
256 - array(
257 - 'up_user=user_id',
258 - 'up_property' => 'timecorrection',
259 - )
260 - );
261 -
 273+
 274+ $join_conds['user_properties as tc_prop'] = array(
 275+ 'left join',
 276+ array(
 277+ 'up_user=user_id',
 278+ 'up_property' => 'timecorrection',
 279+ )
 280+ );
 281+
262282 $tables[] = 'user_properties as l_prop';
263283 $fields[] = 'l_prop.up_value as language';
264 -
265 - $join_conds['user_properties as l_prop'] =
266 - array( 'left join',
267 - array(
268 - 'up_user=user_id',
269 - 'up_property' => 'language',
270 - )
271 - );
 284+
 285+ $join_conds['user_properties as l_prop'] = array(
 286+ 'left join',
 287+ array(
 288+ 'up_user=user_id',
 289+ 'up_property' => 'language',
 290+ )
 291+ );
272292 }
273 -
274 - $res = $dbr->select( $tables, $fields,
275 - array( 'user_id' => $watching_users ), __METHOD__,
276 - array(), $join_conds );
277 -
 293+
 294+ $res = $dbr->select(
 295+ $tables, $fields,
 296+ array( 'user_id' => $watching_users ), __METHOD__,
 297+ array(), $join_conds
 298+ );
 299+
278300 // Set up one-time data.
279301 global $wgPasswordSender;
280302 $link_title = clone $t->article()->getTitle();
@@ -282,17 +304,12 @@
283305 $talkPage = $t->article()->getTitle()->getPrefixedText();
284306 $from = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
285307 $threadSubject = $t->subject();
286 -
 308+
287309 // Parse content and strip HTML of post content
288 - // Doesn't work for some reason (transaction issues?)
289 -// $content = $t->root()->getContent();
290 -// global $wgOut;
291 -// $html = $wgOut->parse( $content );
292 -// $text = StringUtils::delimiterReplace( '<', '>', '', $html );
293310
294311 while ( $row = $dbr->fetchObject( $res ) ) {
295312 $u = User::newFromRow( $row );
296 -
 313+
297314 if ( $oldPreferenceFormat ) {
298315 $langCode = $u->getOption( 'language' );
299316 } elseif ( $row->language ) {
@@ -301,9 +318,9 @@
302319 global $wgLanguageCode;
303320 $langCode = $wgLanguageCode;
304321 }
305 -
 322+
306323 $lang = Language::factory( $langCode );
307 -
 324+
308325 // Adjust with time correction
309326 if ( $oldPreferenceFormat ) {
310327 $timeCorrection = $u->getOption( 'timecorrection' );
@@ -311,96 +328,113 @@
312329 $timeCorrection = $row->timecorrection;
313330 }
314331 $adjustedTimestamp = $lang->userAdjust( $timestamp, $timeCorrection );
315 -
 332+
316333 $date = $lang->date( $adjustedTimestamp );
317334 $time = $lang->time( $adjustedTimestamp );
318 -
 335+
319336 $params = array( $u->getName(), $t->subjectWithoutIncrement(),
320337 $date, $time, $talkPage, $permalink );
321 -
 338+
322339 // Get message in user's own language, bug 20645
323340 $msg = wfMsgReal( $msgName, $params, true /* use DB */, $langCode,
324341 true /*transform*/ );
325 -
 342+
326343 $to = new MailAddress( $u );
327344 $subject = wfMsgReal( $subjectMsg, array( $threadSubject ), true /* use DB */,
328345 $langCode, true /* transform */ );
329 -
 346+
330347 UserMailer::send( $to, $from, $subject, $msg );
331348 }
332349 }
333350
334351 static function newUserMessages( $user ) {
335352 $talkPage = new Article( $user->getUserPage()->getTalkPage() );
336 -
 353+
337354 $dbr = wfGetDB( DB_SLAVE );
338 -
 355+
339356 $joinConds = array( 'ums_user' => null );
340 - $joinConds[] = $dbr->makeList( array( 'ums_user' => $user->getId(),
341 - 'ums_thread=thread_id' ), LIST_AND );
 357+ $joinConds[] = $dbr->makeList(
 358+ array(
 359+ 'ums_user' => $user->getId(),
 360+ 'ums_thread=thread_id'
 361+ ),
 362+ LIST_AND
 363+ );
342364 $joinClause = $dbr->makeList( $joinConds, LIST_OR );
343 -
344 - $res = $dbr->select( array( 'thread', 'user_message_state' ), '*',
345 - array( 'ums_read_timestamp' => null,
346 - Threads::articleClause( $talkPage ) ),
347 - __METHOD__, array(),
348 - array(
349 - 'user_message_state' =>
350 - array( 'RIGHT JOIN', $joinClause )
351 - ) );
352 -
 365+
 366+ $res = $dbr->select(
 367+ array( 'thread', 'user_message_state' ),
 368+ '*',
 369+ array(
 370+ 'ums_read_timestamp' => null,
 371+ Threads::articleClause( $talkPage )
 372+ ),
 373+ __METHOD__,
 374+ array(),
 375+ array(
 376+ 'user_message_state' =>
 377+ array( 'RIGHT JOIN', $joinClause )
 378+ )
 379+ );
 380+
353381 return Threads::loadFromResult( $res, $dbr );
354382 }
355 -
 383+
356384 static function newMessageCount( $user ) {
357385 global $wgMemc;
358 -
 386+
359387 $cval = $wgMemc->get( wfMemcKey( 'lqt-new-messages-count', $user->getId() ) );
360 -
 388+
361389 if ( $cval )
362390 return $cval;
363 -
 391+
364392 $dbr = wfGetDB( DB_SLAVE );
365 -
 393+
366394 $cond = array( 'ums_user' => $user->getId(), 'ums_read_timestamp' => null );
367395 $options = array( 'LIMIT' => 500 );
368 -
 396+
369397 $res = $dbr->select( 'user_message_state', '1', $cond, __METHOD__, $options );
370 -
 398+
371399 $count = $res->numRows();
372 -
 400+
373401 if ( $count >= 500 ) {
374402 $count = $dbr->estimateRowCount( 'user_message_state', '*', $cond,
375403 __METHOD__ );
376404 }
377 -
 405+
378406 $wgMemc->set( wfMemcKey( 'lqt-new-messages-count', $user->getId() ),
379407 $count, 86400 );
380 -
 408+
381409 return $count;
382410 }
383 -
 411+
384412 static function recacheMessageCount( $uid ) {
385413 global $wgMemc;
386 -
 414+
387415 $wgMemc->delete( wfMemcKey( 'lqt-new-messages-count', $uid ) );
388416 }
389417
390418 static function watchedThreadsForUser( $user ) {
391419 $talkPage = new Article( $user->getUserPage()->getTalkPage() );
392 -
 420+
393421 $dbr = wfGetDB( DB_SLAVE );
394 -
395 - $res = $dbr->select( array( 'thread', 'user_message_state' ), '*',
396 - array( 'ums_read_timestamp' => null,
397 - 'ums_user' => $user->getId(),
398 - 'not (' . Threads::articleClause( $talkPage ) . ')',
399 - ),
400 - __METHOD__, array(),
401 - array( 'user_message_state' =>
402 - array( 'INNER JOIN', 'ums_thread=thread_id' ),
403 - ) );
404 -
 422+
 423+ $res = $dbr->select(
 424+ array( 'thread', 'user_message_state' ),
 425+ '*',
 426+ array(
 427+ 'ums_read_timestamp' => null,
 428+ 'ums_user' => $user->getId(),
 429+ 'not (' . Threads::articleClause( $talkPage ) . ')',
 430+ ),
 431+ __METHOD__,
 432+ array(),
 433+ array(
 434+ 'user_message_state' =>
 435+ array( 'INNER JOIN', 'ums_thread=thread_id' ),
 436+ )
 437+ );
 438+
405439 return Threads::loadFromResult( $res, $dbr );
406440 }
407441 }
Index: trunk/extensions/LiquidThreads/classes/ParserFunctions.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 class LqtParserFunctions {
54 static function useLiquidThreads( &$parser, $param = '1' ) {
65 $offParams = array( 'no', 'off', 'disable' );
@@ -16,7 +15,7 @@
1716 }
1817
1918 static function lqtPageLimit( &$parser, $param = null ) {
20 - if ($param && $param > 0) {
 19+ if ( $param && $param > 0 ) {
2120 $parser->mOutput->setProperty( 'lqt-page-limit', $param );
2221 }
2322 }
Index: trunk/extensions/LiquidThreads/classes/SynchroniseThreadArticleDataJob.php
@@ -1,7 +1,5 @@
22 <?php
3 -
43 class SynchroniseThreadArticleDataJob extends Job {
5 -
64 public function __construct( $title, $params ) {
75 parent::__construct( 'synchroniseThreadArticleData', $title, $params );
86 }
@@ -15,11 +13,11 @@
1614 $article = new Article( $this->title );
1715 $limit = $this->params['limit'];
1816 $cascade = $this->params['cascade'];
19 -
20 - if ( $article )
 17+
 18+ if ( $article ) {
2119 Threads::synchroniseArticleData( $article, $limit, $cascade );
22 -
 20+ }
 21+
2322 return true;
2423 }
25 -
2624 }
Index: trunk/extensions/LiquidThreads/classes/ThreadRevision.php
@@ -4,73 +4,73 @@
55 class ThreadRevision {
66 static $load =
77 array(
8 - 'th_id' => 'mId',
9 - 'th_thread' => 'mThreadId',
10 -
11 - 'th_timestamp' => 'mTimestamp',
12 -
13 - 'th_user' => 'mUserId',
14 - 'th_user_text' => 'mUserText',
15 -
16 - 'th_change_type' => 'mChangeType',
17 - 'th_change_object' => 'mChangeObjectId',
18 - 'th_change_comment' => 'mChangeComment',
19 - 'th_content' => 'mObjSer',
 8+ 'th_id' => 'mId',
 9+ 'th_thread' => 'mThreadId',
 10+
 11+ 'th_timestamp' => 'mTimestamp',
 12+
 13+ 'th_user' => 'mUserId',
 14+ 'th_user_text' => 'mUserText',
 15+
 16+ 'th_change_type' => 'mChangeType',
 17+ 'th_change_object' => 'mChangeObjectId',
 18+ 'th_change_comment' => 'mChangeComment',
 19+ '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 -
29 - if (!$row) return null;
30 -
 28+
 29+ if ( !$row ) return null;
 30+
3131 return self::loadFromRow( $row );
3232 }
33 -
 33+
3434 static function loadFromRow( $row ) {
35 - if (!$row) return null;
36 -
 35+ if ( !$row ) return null;
 36+
3737 $rev = new ThreadRevision;
38 -
 38+
3939 foreach ( self::$load as $col => $field ) {
4040 $rev->$field = $row->$col;
4141 }
42 -
 42+
4343 $rev->mUser = User::newFromName( $rev->mUserText, /* Don't validate */ false );
4444 $rev->mThreadObj = unserialize( $rev->mObjSer );
45 -
 45+
4646 return $rev;
4747 }
48 -
 48+
4949 static function create( $thread, $change_type, $change_object = null, $comment = '',
5050 $user = null, $timestamp = null ) {
5151 if ( is_null( $user ) ) {
5252 global $wgUser;
5353 $user = $wgUser;
5454 }
55 -
 55+
5656 if ( is_null( $timestamp ) ) {
5757 $timestamp = wfTimestampNow();
5858 }
59 -
 59+
6060 if ( is_null( $comment ) ) {
6161 $comment = '';
6262 }
63 -
 63+
6464 $rev = new ThreadRevision;
65 -
 65+
6666 $rev->mThreadId = $thread->topmostThread()->id();
6767 $rev->mTimestamp = $timestamp;
68 -
 68+
6969 $rev->mUser = $user;
7070 $rev->mUserId = $user->getId();
7171 $rev->mUserText = $user->getName();
72 -
 72+
7373 $rev->mChangeType = $change_type;
74 -
 74+
7575 if ( $change_object instanceof Thread ) {
7676 $rev->mChangeObjectId = $change_object->id();
7777 $rev->mChangeObject = $change_object;
@@ -80,128 +80,128 @@
8181 } else {
8282 $rev->mChangeObjectId = $change_object;
8383 }
84 -
 84+
8585 $rev->mChangeComment = $comment;
86 -
 86+
8787 $rev->mThreadObj = $thread->topmostThread();
8888 $rev->mObjSer = serialize( $rev->mThreadObj );
89 -
 89+
9090 $rev->insert();
91 -
 91+
9292 return $rev;
9393 }
94 -
 94+
9595 function insert() {
9696 $dbw = wfGetDB( DB_MASTER );
97 -
 97+
9898 $row = $this->getRow();
9999 $row['th_id'] = $dbw->nextSequenceValue( 'thread_history_th_id' );
100 -
 100+
101101 $dbw->insert( 'thread_history', $row, __METHOD__ );
102 -
 102+
103103 $this->mId = $dbw->insertId();
104104 }
105 -
 105+
106106 function save() {
107107 $row = $this->getRow();
108 -
 108+
109109 $dbw = wfGetDB( DB_MASTER );
110 -
 110+
111111 $dbw->replace( 'thread_history', array( 'th_thread' ), $row, __METHOD__ );
112112 }
113 -
 113+
114114 function getRow() {
115115 $row = array();
116 -
 116+
117117 // First, prep the data for insertion
118118 $dbw = wfGetDB( DB_MASTER );
119119 $this->mTimestamp = $dbw->timestamp( $this->mTimestamp );
120 -
 120+
121121 foreach ( self::$load as $col => $field ) {
122122 $row[$col] = $this->$field;
123123 }
124 -
 124+
125125 return $row;
126126 }
127 -
 127+
128128 function getTimestamp() {
129129 return wfTimestamp( TS_MW, $this->mTimestamp );
130130 }
131 -
 131+
132132 function getUser() {
133133 if ( $this->mUserId ) {
134134 return User::newFromId( $this->mUserId );
135135 }
136 -
 136+
137137 return User::newFromText( $this->mUserText, /* No validation */ false );
138138 }
139 -
 139+
140140 function getChangeType() {
141141 return $this->mChangeType;
142142 }
143 -
 143+
144144 function getChangeObject() {
145 - if ( is_null($this->mChangeObject) && $this->mChangeObjectId ) {
 145+ if ( is_null( $this->mChangeObject ) && $this->mChangeObjectId ) {
146146 $threadObj = $this->getThreadObj();
147 -
 147+
148148 if ( $threadObj instanceof Thread ) {
149149 $objectId = $this->mChangeObjectId;
150150 $this->mChangeObject = $threadObj->replyWithId( $objectId );
151151 }
152 -
 152+
153153 if ( !$this->mChangeObject ) {
154154 $this->mChangeObject = false;
155155 }
156156 }
157 -
 157+
158158 return $this->mChangeObject;
159159 }
160 -
 160+
161161 function getChangeComment() {
162162 return $this->mChangeComment;
163163 }
164 -
 164+
165165 function getId() {
166166 return $this->mId;
167167 }
168 -
 168+
169169 function getThreadObj() {
170 - if ( is_null($this->mThreadObj) && !is_null($this->mObjSer) ) {
 170+ if ( is_null( $this->mThreadObj ) && !is_null( $this->mObjSer ) ) {
171171 $this->mThreadObj = unserialize( $this->mObjSer );
172 - } elseif ( is_null($this->mThreadObj) && is_null($this->mObjSer) ) {
173 - var_dump($this);
 172+ } elseif ( is_null( $this->mThreadObj ) && is_null( $this->mObjSer ) ) {
 173+ var_dump( $this );
174174 throw new MWException( "Missing mObjSer" );
175175 }
176 -
177 - if ( !($this->mThreadObj instanceof Thread) ) {
 176+
 177+ if ( !( $this->mThreadObj instanceof Thread ) ) {
178178 $this->mThreadObj = false;
179179 return false;
180180 }
181 -
 181+
182182 $this->mThreadObj->threadRevision = $this;
183 -
 183+
184184 return $this->mThreadObj;
185185 }
186 -
 186+
187187 function prev() {
188188 $dbr = wfGetDB( DB_SLAVE );
189 -
190 - $cond = 'th_id<' . $dbr->addQuotes( intval($this->getId()) );
 189+
 190+ $cond = 'th_id<' . $dbr->addQuotes( intval( $this->getId() ) );
191191 $row = $dbr->selectRow( 'thread_history', '*',
192192 array( $cond, 'th_thread' => $this->mThreadId ),
193193 __METHOD__ );
194 -
 194+
195195 return self::loadFromRow( $row );
196196 }
197 -
 197+
198198 function next() {
199199 $dbr = wfGetDB( DB_SLAVE );
200 -
201 - $cond = 'th_id>' . $dbr->addQuotes( intval($this->getId()) );
 200+
 201+ $cond = 'th_id>' . $dbr->addQuotes( intval( $this->getId() ) );
202202 $row = $dbr->selectRow( 'thread_history', '*',
203203 array( $cond, 'th_thread' => $this->mThreadId ),
204204 __METHOD__ );
205 -
 205+
206206 return self::loadFromRow( $row );
207207 }
208208 }
Index: trunk/extensions/LiquidThreads/classes/DeletionController.php
@@ -1,27 +1,26 @@
22 <?php
3 -
43 class LqtDeletionController {
54 static $pageids_to_revive;
6 -
 5+
76 static function onArticleDeleteComplete( &$article, &$user, $reason, $id ) {
87 $title = $article->getTitle();
9 -
 8+
109 if ( $title->getNamespace() != NS_LQT_THREAD ) {
1110 return true;
1211 }
13 -
 12+
1413 $threads = Threads::where( array( 'thread_root' => $id ) );
15 -
 14+
1615 if ( !count( $threads ) ) {
1716 wfDebugLog( __METHOD__ . ": no threads with root $id, ignoring...\n" );
1817 return true;
1918 }
20 -
 19+
2120 $thread = array_pop( $threads );
22 -
 21+
2322 // Mark the thread as deleted
2423 $thread->delete( $reason );
25 -
 24+
2625 // Avoid orphaning subthreads, update their parentage.
2726 wfLoadExtensionMessages( 'LiquidThreads' );
2827 if ( $thread->replies() && $thread->isTopmostThread() ) {
@@ -35,14 +34,14 @@
3635 $reply->save( );
3736 }
3837 }
39 -
 38+
4039 // Synchronise the first 500 threads, in reverse order by thread id. If
4140 // there are more threads to synchronise, the job queue will take over.
4241 Threads::synchroniseArticleData( $article, 500, 'cascade' );
43 -
 42+
4443 return true;
4544 }
46 -
 45+
4746 static function recursivelyDeleteReplies( $thread, $reason ) {
4847 foreach ( $thread->replies() as $reply ) {
4948 $reply->root()->doDeleteArticle( $reason, false, $reply->root()->getId() );
@@ -50,36 +49,36 @@
5150 self::recursivelyDeleteReplies( $reply, $reason );
5251 }
5352 }
54 -
 53+
5554 static function onArticleRevisionUndeleted( &$title, $revision, $page_id ) {
5655 if ( $title->getNamespace() == NS_LQT_THREAD ) {
5756 self::$pageids_to_revive[$page_id] = $title;
5857 }
59 -
 58+
6059 return true;
6160 }
62 -
 61+
6362 static function onArticleUndelete( &$udTitle, $created, $comment = '' ) {
6463 if ( empty( self::$pageids_to_revive ) ) {
6564 return true;
6665 }
67 -
 66+
6867 foreach ( self::$pageids_to_revive as $pageid => $title ) {
6968 if ( $pageid == 0 ) {
7069 continue;
7170 }
72 -
 71+
7372 // Try to get comment for old versions where it isn't passed, hacky :(
7473 if ( !$comment ) {
7574 global $wgRequest;
7675 $comment = $wgRequest->getText( 'wpComment' );
7776 }
78 -
 77+
7978 // TX has not been committed yet, so we must select from the master
8079 $dbw = wfGetDB( DB_MASTER );
8180 $res = $dbw->select( 'thread', '*', array( 'thread_root' => $pageid ), __METHOD__ );
8281 $threads = Threads::loadFromResult( $res, $dbw );
83 -
 82+
8483 if ( count( $threads ) ) {
8584 $thread = array_pop( $threads );
8685 $thread->setRoot( new Article( $title ) );
@@ -88,35 +87,39 @@
8988 wfDebug( __METHOD__ . ":No thread found with root set to $pageid (??)\n" );
9089 }
9190 }
92 -
 91+
9392 // Synchronise the first 500 threads, in reverse order by thread id. If
9493 // there are more threads to synchronise, the job queue will take over.
9594 Threads::synchroniseArticleData( new Article( $udTitle ), 500, 'cascade' );
96 -
 95+
9796 return true;
9897 }
99 -
 98+
10099 static function onArticleConfirmDelete( $article, $out, &$reason ) {
101 - if ( $article->getTitle()->getNamespace() != NS_LQT_THREAD ) return true;
102 -
 100+ if ( $article->getTitle()->getNamespace() != NS_LQT_THREAD ) {
 101+ return true;
 102+ }
 103+
103104 $thread = Threads::withRoot( $article );
104 -
 105+
105106 if ( !$thread ) return true;
106 -
 107+
107108 if ( $thread->isTopmostThread() && count( $thread->replies() ) ) {
108109 wfLoadExtensionMessages( 'LiquidThreads' );
109 - $out->wrapWikiMsg( '<strong>$1</strong>',
110 - 'lqt-delete-parent-warning' );
 110+ $out->wrapWikiMsg(
 111+ '<strong>$1</strong>',
 112+ 'lqt-delete-parent-warning'
 113+ );
111114 }
112 -
 115+
113116 return true;
114117 }
115 -
 118+
116119 static function onArticleDelete( $article ) {
117120 // Synchronise article data so that moving the article doesn't break any
118121 // article association.
119122 Threads::synchroniseArticleData( $article );
120 -
 123+
121124 return true;
122125 }
123126 }
Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -33,36 +33,36 @@
3434 protected $authorId;
3535 protected $authorName;
3636 protected $signature;
37 -
 37+
3838 protected $allDataLoaded;
39 -
 39+
4040 protected $isHistorical = false;
41 -
 41+
4242 protected $rootRevision;
4343
4444 /* Flag about who has edited or replied to this thread. */
4545 protected $editedness;
4646
4747 protected $replies;
48 -
 48+
4949 public $dbVersion; // A copy of the thread as it exists in the database.
50 -
 50+
5151 static $titleCacheById = array();
5252 static $replyCacheById = array();
5353 static $articleCacheById = array();
54 -
 54+
5555 static $VALID_TYPES = array( Threads::TYPE_NORMAL, Threads::TYPE_MOVED, Threads::TYPE_DELETED );
5656
5757 function isHistorical() {
5858 return $this->isHistorical;
5959 }
60 -
 60+
6161 static function create( $root, $article, $superthread = null,
62 - $type = Threads::TYPE_NORMAL, $subject = '',
63 - $summary = '', $bump = null, $signature = null ) {
 62+ $type = Threads::TYPE_NORMAL, $subject = '',
 63+ $summary = '', $bump = null, $signature = null ) {
6464
6565 $dbw = wfGetDB( DB_MASTER );
66 -
 66+
6767 $thread = new Thread( null );
6868
6969 if ( !in_array( $type, self::$VALID_TYPES ) ) {
@@ -80,71 +80,73 @@
8181 $timestamp = wfTimestampNow();
8282
8383 $thread->setAuthor( $wgUser );
84 -
85 - if ( is_object( $root ) )
 84+
 85+ if ( is_object( $root ) ) {
8686 $thread->setRoot( $root );
87 - else
 87+ } else {
8888 $thread->setRootId( $root );
 89+ }
 90+
8991 $thread->setSuperthread( $superthread );
9092 $thread->setArticle( $article );
9193 $thread->setSubject( $subject );
9294 $thread->setType( $type );
93 -
94 - if ( !is_null($signature) ) {
 95+
 96+ if ( !is_null( $signature ) ) {
9597 $thread->setSignature( $signature );
9698 }
97 -
 99+
98100 $thread->insert();
99 -
 101+
100102 if ( $superthread ) {
101103 $superthread->addReply( $thread );
102 -
 104+
103105 $superthread->commitRevision( $change_type, $thread, $summary, $bump );
104106 } else {
105107 $hthread = ThreadRevision::create( $thread, $change_type );
106108 }
107 -
 109+
108110 // Create talk page
109111 Threads::createTalkpageIfNeeded( $article );
110112
111113 // Notifications
112114 NewMessages::writeMessageStateForUpdatedThread( $thread, $change_type, $wgUser );
113 -
 115+
114116 if ( $wgUser->getOption( 'lqt-watch-threads', false ) ) {
115117 $thread->topmostThread()->root()->doWatch();
116118 }
117119
118120 return $thread;
119121 }
120 -
 122+
121123 function insert() {
122124 $this->dieIfHistorical();
123 -
 125+
124126 $dbw = wfGetDB( DB_MASTER );
125 -
 127+
126128 $row = $this->getRow();
127129 $row['thread_id'] = $dbw->nextSequenceValue( 'thread_thread_id' );
128 -
 130+
129131 $dbw->insert( 'thread', $row, __METHOD__ );
130132 $this->id = $dbw->insertId();
131 -
 133+
132134 // Touch the root
133135 if ( $this->root() ) {
134136 $this->root()->getTitle()->invalidateCache();
135137 }
136 -
 138+
137139 // Touch the talk page, too.
138140 $this->article()->getTitle()->invalidateCache();
139 -
 141+
140142 $this->dbVersion = clone $this;
141143 unset( $this->dbVersion->dbVersion );
142144 }
143 -
 145+
144146 function setRoot( $article ) {
145147 $this->rootId = $article->getId();
146148 $this->root = $article;
147149 }
148 -
 150+
149151 function setRootId( $article ) {
150152 $this->rootId = $article;
151153 $this->root = null;
@@ -154,26 +156,26 @@
155157 $bump = null ) {
156158 $this->dieIfHistorical();
157159 global $wgUser;
158 -
 160+
159161 global $wgThreadActionsNoBump;
160 - if ( is_null($bump) ) {
 162+ if ( is_null( $bump ) ) {
161163 $bump = !in_array( $change_type, $wgThreadActionsNoBump );
162164 }
163165 if ( $bump ) {
164166 $this->sortkey = wfTimestamp( TS_MW );
165167 }
166 -
 168+
167169 $original = $this->dbVersion;
168170
169171 $this->modified = wfTimestampNow();
170172 $this->updateEditedness( $change_type );
171173 $this->save( __METHOD__ . "/" . wfGetCaller() );
172 -
 174+
173175 $topmost = $this->topmostThread();
174176 $topmost->modified = wfTimestampNow();
175177 if ( $bump ) $topmost->setSortkey( wfTimestamp( TS_MW ) );
176178 $topmost->save();
177 -
 179+
178180 ThreadRevision::create( $this, $change_type, $change_object, $reason );
179181 $this->logChange( $change_type, $original, $change_object, $reason );
180182
@@ -181,14 +183,14 @@
182184 NewMessages::writeMessageStateForUpdatedThread( $this, $change_type, $wgUser );
183185 }
184186 }
185 -
 187+
186188 function logChange( $change_type, $original, $change_object = null, $reason = '' ) {
187189 $log = new LogPage( 'liquidthreads' );
188 -
189 - if ( is_null($reason) ) {
 190+
 191+ if ( is_null( $reason ) ) {
190192 $reason = '';
191193 }
192 -
 194+
193195 switch( $change_type ) {
194196 case Threads::CHANGE_MOVED_TALKPAGE:
195197 $log->addEntry( 'move', $this->title(), $reason,
@@ -209,8 +211,8 @@
210212 $oldParent = $change_object->dbVersion->isTopmostThread()
211213 ? ''
212214 : $change_object->dbVersion->superthread()->title();
213 -
214 -
 215+
 216+
215217 $log->addEntry( 'merge', $this->title(), $reason,
216218 array( $oldParent, $change_object->superthread()->title() ) );
217219 break;
@@ -219,16 +221,16 @@
220222 array( $original->sortkey(), $this->sortkey() ) );
221223 }
222224 }
223 -
 225+
224226 function updateEditedness( $change_type ) {
225227 global $wgUser;
226 -
 228+
227229 if ( $change_type == Threads::CHANGE_REPLY_CREATED
228230 && $this->editedness == Threads::EDITED_NEVER ) {
229231 $this->editedness = Threads::EDITED_HAS_REPLY;
230232 } elseif ( $change_type == Threads::CHANGE_EDITED_ROOT ) {
231233 $originalAuthor = $this->author();
232 -
 234+
233235 if ( ( $wgUser->getId() == 0 && $originalAuthor->getName() != $wgUser->getName() )
234236 || $wgUser->getId() != $originalAuthor->getId() ) {
235237 $this->editedness = Threads::EDITED_BY_OTHERS;
@@ -237,45 +239,45 @@
238240 }
239241 }
240242 }
241 -
 243+
242244 /** Unless you know what you're doing, you want commitRevision */
243245 function save( $fname = null ) {
244246 $this->dieIfHistorical();
245247
246248 $dbr = wfGetDB( DB_MASTER );
247 -
 249+
248250 if ( !$fname ) {
249251 $fname = __METHOD__ . "/" . wfGetCaller();
250252 } else {
251253 $fname = __METHOD__ . "/" . $fname;
252254 }
253 -
 255+
254256 $res = $dbr->update( 'thread',
255257 /* SET */ $this->getRow(),
256258 /* WHERE */ array( 'thread_id' => $this->id, ),
257259 $fname );
258 -
 260+
259261 // Touch the root
260262 if ( $this->root() ) {
261263 $this->root()->getTitle()->invalidateCache();
262264 }
263 -
 265+
264266 // Touch the talk page, too.
265267 $this->article()->getTitle()->invalidateCache();
266 -
 268+
267269 $this->dbVersion = clone $this;
268270 unset( $this->dbVersion->dbVersion );
269271 }
270 -
 272+
271273 function getRow() {
272274 $id = $this->id();
273 -
 275+
274276 $dbw = wfGetDB( DB_MASTER );
275277
276278 if ( !$id ) {
277279 $id = $dbw->nextSequenceValue( 'thread_thread_id' );
278280 }
279 -
 281+
280282 // Reflect schema changes here.
281283
282284 return array(
@@ -299,10 +301,10 @@
300302 'thread_signature' => $this->signature,
301303 );
302304 }
303 -
 305+
304306 function author() {
305307 $this->doLazyUpdates();
306 -
 308+
307309 if ( $this->authorId ) {
308310 return User::newFromId( $this->authorId );
309311 } else {
@@ -315,30 +317,30 @@
316318 $this->type = Threads::TYPE_DELETED;
317319 $this->commitRevision( Threads::CHANGE_DELETED, $this, $reason );
318320 /* Mark thread as read by all users, or we get blank thingies in New Messages. */
319 -
 321+
320322 $this->dieIfHistorical();
321 -
 323+
322324 $dbw = wfGetDB( DB_MASTER );
323 -
 325+
324326 $dbw->delete( 'user_message_state', array( 'ums_thread' => $this->id() ),
325327 __METHOD__ );
326 -
 328+
327329 // Fix reply count.
328330 $t = $this->superthread();
329 -
330 - if ($t) {
 331+
 332+ if ( $t ) {
331333 $t->decrementReplyCount();
332334 $t->save();
333335 }
334336 }
335 -
 337+
336338 function undelete( $reason ) {
337339 $this->type = Threads::TYPE_NORMAL;
338340 $this->commitRevision( Threads::CHANGE_UNDELETED, $this, $reason );
339 -
 341+
340342 // Fix reply count.
341343 $t = $this->superthread();
342 - if ($t) {
 344+ if ( $t ) {
343345 $t->incrementReplyCount( 1 );
344346 $t->save();
345347 }
@@ -347,39 +349,41 @@
348350 function moveToPage( $title, $reason, $leave_trace ) {
349351 if ( !$this->isTopmostThread() )
350352 throw new MWException( "Attempt to move non-toplevel thread to another page" );
351 -
 353+
352354 $this->dieIfHistorical();
353 -
 355+
354356 $dbr = wfGetDB( DB_MASTER );
355357
356358 $oldTitle = $this->article()->getTitle();
357359 $newTitle = $title;
358 -
 360+
359361 $new_articleNamespace = $title->getNamespace();
360362 $new_articleTitle = $title->getDBkey();
361363 $new_articleID = $title->getArticleID();
362 -
 364+
363365 if ( !$new_articleID ) {
364366 $article = new Article( $newTitle );
365367 Threads::createTalkpageIfNeeded( $article );
366368 $new_articleID = $article->getId();
367369 }
368 -
 370+
369371 // Update on *all* subthreads.
370 - $dbr->update( 'thread',
371 - array(
372 - 'thread_article_namespace' => $new_articleNamespace,
373 - 'thread_article_title' => $new_articleTitle,
374 - 'thread_article_id' => $new_articleID,
375 - ),
376 - array( 'thread_ancestor' => $this->id() ),
377 - __METHOD__ );
 372+ $dbr->update(
 373+ 'thread',
 374+ array(
 375+ 'thread_article_namespace' => $new_articleNamespace,
 376+ 'thread_article_title' => $new_articleTitle,
 377+ 'thread_article_id' => $new_articleID,
 378+ ),
 379+ array( 'thread_ancestor' => $this->id() ),
 380+ __METHOD__
 381+ );
378382
379383 $this->articleNamespace = $new_articleNamespace;
380384 $this->articleTitle = $new_articleTitle;
381385 $this->articleId = $new_articleID;
382386 $this->article = null;
383 -
 387+
384388 $this->commitRevision( Threads::CHANGE_MOVED_TALKPAGE, null, $reason );
385389
386390 if ( $leave_trace ) {
@@ -391,14 +395,14 @@
392396 // there.
393397 function leaveTrace( $reason, $oldTitle, $newTitle ) {
394398 $this->dieIfHistorical();
395 -
 399+
396400 $dbw = wfGetDB( DB_MASTER );
397401
398402 // Create redirect text
399403 $mwRedir = MagicWord::get( 'redirect' );
400404 $redirectText = $mwRedir->getSynonym( 0 ) .
401405 ' [[' . $this->title()->getPrefixedText() . "]]\n";
402 -
 406+
403407 // Make the article edit.
404408 $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat( $oldTitle ) );
405409 $redirectArticle = new Article_LQT_Compat( $traceTitle );
@@ -407,7 +411,7 @@
408412 // Add the trace thread to the tracking table.
409413 $thread = Thread::create( $redirectArticle, new Article_LQT_Compat( $oldTitle ), null,
410414 Threads::TYPE_MOVED, $this->subject() );
411 -
 415+
412416 $thread->setSortkey( $this->sortkey() );
413417 $thread->save();
414418 }
@@ -418,52 +422,52 @@
419423 if ( $this->replyCount == - 1 ) {
420424 if ( $this->isTopmostThread() ) {
421425 $dbr = wfGetDB( DB_SLAVE );
422 -
 426+
423427 $count = $dbr->selectField( 'thread', 'count(*)',
424428 array( 'thread_ancestor' => $this->id() ), __METHOD__ );
425429 } else {
426430 $count = self::recursiveGetReplyCount( $this );
427431 }
428 -
 432+
429433 $this->replyCount = $count;
430434 $this->save();
431435 }
432 -
 436+
433437 return $this->replyCount;
434438 }
435 -
 439+
436440 function incrementReplyCount( $val = 1 ) {
437441 $this->replyCount += $val;
438 -
439 - wfDebug( "Incremented reply count for thread ".$this->id()." to ".$this->replyCount."\n" );
440 -
 442+
 443+ wfDebug( "Incremented reply count for thread " . $this->id() . " to " . $this->replyCount . "\n" );
 444+
441445 $thread = $this->superthread();
442 -
 446+
443447 if ( $thread ) {
444448 $thread->incrementReplyCount( $val );
445 - wfDebug( "Saving Incremented thread ".$thread->id().
446 - " with reply count ".$thread->replyCount."\n" );
 449+ wfDebug( "Saving Incremented thread " . $thread->id() .
 450+ " with reply count " . $thread->replyCount . "\n" );
447451 $thread->save();
448452 }
449453 }
450 -
 454+
451455 function decrementReplyCount( $val = 1 ) {
452456 $this->incrementReplyCount( - $val );
453457 }
454 -
 458+
455459 static function newFromRow( $row ) {
456460 $id = $row->thread_id;
457 -
 461+
458462 if ( isset( Threads::$cache_by_id[$id] ) ) {
459463 return Threads::$cache_by_id[$id];
460464 }
461 -
 465+
462466 return new Thread( $row );
463467 }
464468
465469 protected function __construct( $line, $unused = null ) {
466470 /* SCHEMA changes must be reflected here. */
467 -
 471+
468472 if ( is_null( $line ) ) { // For Thread::create().
469473 $dbr = wfGetDB( DB_SLAVE );
470474 $this->modified = $dbr->timestamp( wfTimestampNow() );
@@ -473,34 +477,34 @@
474478 $this->replyCount = 0;
475479 return;
476480 }
477 -
 481+
478482 $dataLoads = array(
479 - 'thread_id' => 'id',
480 - 'thread_root' => 'rootId',
481 - 'thread_article_namespace' => 'articleNamespace',
482 - 'thread_article_title' => 'articleTitle',
483 - 'thread_article_id' => 'articleId',
484 - 'thread_summary_page' => 'summaryId',
485 - 'thread_ancestor' => 'ancestorId',
486 - 'thread_parent' => 'parentId',
487 - 'thread_modified' => 'modified',
488 - 'thread_created' => 'created',
489 - 'thread_type' => 'type',
490 - 'thread_editedness' => 'editedness',
491 - 'thread_subject' => 'subject',
492 - 'thread_author_id' => 'authorId',
493 - 'thread_author_name' => 'authorName',
494 - 'thread_sortkey' => 'sortkey',
495 - 'thread_replies' => 'replyCount',
496 - 'thread_signature' => 'signature',
497 - );
498 -
 483+ 'thread_id' => 'id',
 484+ 'thread_root' => 'rootId',
 485+ 'thread_article_namespace' => 'articleNamespace',
 486+ 'thread_article_title' => 'articleTitle',
 487+ 'thread_article_id' => 'articleId',
 488+ 'thread_summary_page' => 'summaryId',
 489+ 'thread_ancestor' => 'ancestorId',
 490+ 'thread_parent' => 'parentId',
 491+ 'thread_modified' => 'modified',
 492+ 'thread_created' => 'created',
 493+ 'thread_type' => 'type',
 494+ 'thread_editedness' => 'editedness',
 495+ 'thread_subject' => 'subject',
 496+ 'thread_author_id' => 'authorId',
 497+ 'thread_author_name' => 'authorName',
 498+ 'thread_sortkey' => 'sortkey',
 499+ 'thread_replies' => 'replyCount',
 500+ 'thread_signature' => 'signature',
 501+ );
 502+
499503 foreach ( $dataLoads as $db_field => $member_field ) {
500504 if ( isset( $line->$db_field ) ) {
501505 $this->$member_field = $line->$db_field;
502506 }
503507 }
504 -
 508+
505509 if ( isset( $line->page_namespace ) && isset( $line->page_title ) ) {
506510 $root_title = Title::makeTitle( $line->page_namespace, $line->page_title );
507511 $this->root = new Article_LQT_Compat( $root_title );
@@ -511,25 +515,25 @@
512516 } else {
513517 $root_title = Title::newFromID( $this->rootId );
514518 }
515 -
 519+
516520 if ( $root_title ) {
517521 $this->root = new Article_LQT_Compat( $root_title );
518522 }
519523 }
520 -
 524+
521525 Threads::$cache_by_id[$line->thread_id] = $this;
522526 if ( $line->thread_parent ) {
523527 if ( !isset( self::$replyCacheById[$line->thread_parent] ) )
524528 self::$replyCacheById[$line->thread_parent] = array();
525529 self::$replyCacheById[$line->thread_parent][$line->thread_id] = $this;
526530 }
527 -
 531+
528532 $this->doLazyUpdates( $line );
529 -
 533+
530534 $this->dbVersion = clone $this;
531535 unset( $this->dbVersion->dbVersion );
532536 }
533 -
 537+
534538 // Load a list of threads in bulk, including all subthreads.
535539 static function bulkLoad( $rows ) {
536540 // Preload subthreads
@@ -538,11 +542,11 @@
539543 $pageIds = array();
540544 $linkBatch = new LinkBatch();
541545 $userIds = array();
542 -
 546+
543547 if ( !is_array( self::$replyCacheById ) ) {
544548 self::$replyCacheById = array();
545549 }
546 -
 550+
547551 // Build a list of threads for which to pull replies, and page IDs to pull data for.
548552 // Also, pre-initialise the reply cache.
549553 foreach ( $rows as $row ) {
@@ -551,18 +555,18 @@
552556 } else {
553557 $top_thread_ids[] = $row->thread_id;
554558 }
555 -
 559+
556560 // Grab page data while we're here.
557561 if ( $row->thread_root )
558562 $pageIds[] = $row->thread_root;
559563 if ( $row->thread_summary_page )
560564 $pageIds[] = $row->thread_summary_page;
561 -
 565+
562566 if ( !isset( self::$replyCacheById[$row->thread_id] ) ) {
563567 self::$replyCacheById[$row->thread_id] = array();
564568 }
565569 }
566 -
 570+
567571 // Pull replies to the threads provided, and as above, pull page IDs to pull data for,
568572 // pre-initialise the reply cache, and stash the row object for later use.
569573 if ( count( $top_thread_ids ) ) {
@@ -571,19 +575,19 @@
572576 array( 'thread_ancestor' => $top_thread_ids,
573577 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ),
574578 __METHOD__ );
575 -
 579+
576580 while ( $row = $dbr->fetchObject( $res ) ) {
577581 // Grab page data while we're here.
578582 if ( $row->thread_root )
579583 $pageIds[] = $row->thread_root;
580584 if ( $row->thread_summary_page )
581585 $pageIds[] = $row->thread_summary_page;
582 -
 586+
583587 $all_thread_rows[] = $row;
584588 }
585589 }
586 -
587 - // Preload page data (restrictions, and preload Article object with everything from
 590+
 591+ // Preload page data (restrictions, and preload Article object with everything from
588592 // the page table. Also, precache the title and article objects for pulling later.
589593 $articlesById = array();
590594 if ( count( $pageIds ) ) {
@@ -595,103 +599,105 @@
596600 while ( $row = $dbr->fetchObject( $res ) ) {
597601 $restrictionRows[$row->pr_page][] = $row;
598602 }
599 -
 603+
600604 $res = $dbr->select( 'page', '*', array( 'page_id' => $pageIds ), __METHOD__ );
601 -
 605+
602606 while ( $row = $dbr->fetchObject( $res ) ) {
603607 $t = Title::newFromRow( $row );
604 -
 608+
605609 if ( isset( $restrictionRows[$t->getArticleId()] ) ) {
606610 $t->loadRestrictionsFromRows( $restrictionRows[$t->getArticleId()],
607611 $row->page_restrictions );
608612 }
609 -
 613+
610614 $article = new Article_LQT_Compat( $t );
611615 $article->loadPageData( $row );
612 -
 616+
613617 self::$titleCacheById[$t->getArticleId()] = $t;
614618 $articlesById[$article->getId()] = $article;
615 -
 619+
616620 if ( count( self::$titleCacheById ) > 10000 ) {
617621 self::$titleCacheById = array();
618622 }
619623 }
620624 }
621 -
 625+
622626 // For every thread we have a row object for, load a Thread object, add the user and
623627 // user talk pages to a link batch, cache the relevant user id/name pair, and
624628 // populate the reply cache.
625629 foreach ( $all_thread_rows as $row ) {
626630 $thread = Thread::newFromRow( $row, null );
627 -
 631+
628632 if ( isset( $articlesById[$thread->rootId] ) )
629633 $thread->root = $articlesById[$thread->rootId];
630 -
 634+
631635 // User cache data
632636 $t = Title::makeTitleSafe( NS_USER, $row->thread_author_name );
633637 $linkBatch->addObj( $t );
634638 $t = Title::makeTitleSafe( NS_USER_TALK, $row->thread_author_name );
635639 $linkBatch->addObj( $t );
636 -
 640+
637641 User::$idCacheByName[$row->thread_author_name] = $row->thread_author_id;
638642 $userIds[$row->thread_author_id] = true;
639643 }
640 -
 644+
641645 $userIds = array_keys( $userIds );
642 -
 646+
643647 // Pull link batch data.
644648 $linkBatch->execute();
645 -
 649+
646650 $threads = array();
647 -
 651+
648652 // Fill and return an array with the threads that were actually requested.
649653 foreach ( $rows as $row ) {
650654 $threads[$row->thread_id] = Threads::$cache_by_id[$row->thread_id];
651655 }
652 -
 656+
653657 return $threads;
654658 }
655 -
 659+
656660 /**
657661 * Return the User object representing the author of the first revision
658662 * (or null, if the database is screwed up).
659663 */
660664 function loadOriginalAuthorFromRevision( ) {
661665 $this->dieIfHistorical();
662 -
 666+
663667 $dbr = wfGetDB( DB_SLAVE );
664 -
 668+
665669 $article = $this->root();
666670
667 - $line = $dbr->selectRow( 'revision',
668 - 'rev_user_text',
669 - array( 'rev_page' => $article->getID() ),
670 - __METHOD__,
671 - array(
672 - 'ORDER BY' => 'rev_timestamp',
673 - 'LIMIT' => '1'
674 - ) );
 671+ $line = $dbr->selectRow(
 672+ 'revision',
 673+ 'rev_user_text',
 674+ array( 'rev_page' => $article->getID() ),
 675+ __METHOD__,
 676+ array(
 677+ 'ORDER BY' => 'rev_timestamp',
 678+ 'LIMIT' => '1'
 679+ )
 680+ );
675681 if ( $line )
676682 return User::newFromName( $line->rev_user_text, false );
677683 else
678684 return null;
679685 }
680 -
 686+
681687 static function recursiveGetReplyCount( $thread, $level = 1 ) {
682 - if ($level > 80) {
 688+ if ( $level > 80 ) {
683689 return 1;
684690 }
685 -
 691+
686692 $count = 0;
687 -
688 - foreach( $thread->replies() as $reply ) {
 693+
 694+ foreach ( $thread->replies() as $reply ) {
689695 $count++;
690696 $count += self::recursiveGetReplyCount( $reply, $level + 1 );
691697 }
692 -
 698+
693699 return $count;
694700 }
695 -
 701+
696702 // Lazy updates done whenever a thread is loaded.
697703 // Much easier than running a long-running maintenance script.
698704 function doLazyUpdates( ) {
@@ -703,49 +709,49 @@
704710 static $doingUpdates = false;
705711 if ( $doingUpdates ) return;
706712 $doingUpdates = true;
707 -
 713+
708714 // Fix missing ancestry information.
709715 // (there was a bug where this was not saved properly)
710716 if ( $this->parentId && !$this->ancestorId ) {
711717 $this->fixMissingAncestor();
712718 }
713 -
 719+
714720 $ancestor = $this->topmostThread();
715 -
 721+
716722 $set = array();
717 -
 723+
718724 // Fix missing subject information
719725 // (this information only started to be added later)
720726 if ( !$this->subject && $this->root() ) {
721727 $detectedSubject = $this->root()->getTitle()->getText();
722728 $parts = self::splitIncrementFromSubject( $detectedSubject );
723 -
 729+
724730 $this->subject = $detectedSubject = $parts[1];
725 -
 731+
726732 // Update in the DB
727733 $set['thread_subject'] = $detectedSubject;
728734 }
729 -
 735+
730736 // Fix inconsistent subject information
731737 // (in some intermediate versions this was not updated when the subject was changed)
732738 if ( $this->subject() != $ancestor->subject() ) {
733739 $set['thread_subject'] = $ancestor->subject();
734 -
 740+
735741 $this->subject = $ancestor->subject();
736742 }
737 -
 743+
738744 // Fix missing authorship information
739745 // (this information only started to be added later)
740746 if ( !$this->authorName ) {
741747 $author = $this->loadOriginalAuthorFromRevision();
742 -
 748+
743749 $this->authorId = $author->getId();
744750 $this->authorName = $author->getName();
745 -
 751+
746752 $set['thread_author_name'] = $this->authorName;
747753 $set['thread_author_id'] = $this->authorId;
748754 }
749 -
 755+
750756 // Check for article being in subject, not talk namespace.
751757 // If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant
752758 // to be on the corresponding talk page, but only if the talk-page is a LQT page.
@@ -761,31 +767,31 @@
762768 $wgLiquidThreadsMigrate ) {
763769 $newTitle = $articleTitle->getTalkPage();
764770 $newArticle = new Article_LQT_Compat( $newTitle );
765 -
 771+
766772 $set['thread_article_namespace'] = $newTitle->getNamespace();
767773 $set['thread_article_title'] = $newTitle->getDbKey();
768 -
 774+
769775 $this->articleNamespace = $newTitle->getNamespace();
770776 $this->articleTitle = $newTitle->getDbKey();
771777 $this->articleId = $newTitle->getArticleId();
772 -
 778+
773779 $this->article = $newArticle;
774780 }
775 -
 781+
776782 // Check for article corruption from incomplete thread moves.
777783 // (thread moves only updated this on immediate replies, not replies to replies etc)
778784 if ( ! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) {
779785 $title = $ancestor->article()->getTitle();
780786 $set['thread_article_namespace'] = $title->getNamespace();
781787 $set['thread_article_title'] = $title->getDbKey();
782 -
 788+
783789 $this->articleNamespace = $title->getNamespace();
784790 $this->articleTitle = $title->getDbKey();
785791 $this->articleId = $title->getArticleId();
786 -
 792+
787793 $this->article = $ancestor->article();
788794 }
789 -
 795+
790796 // Check for invalid/missing articleId
791797 $articleTitle = null;
792798 $dbTitle = Title::makeTitleSafe( $this->articleNamespace, $this->articleTitle );
@@ -796,17 +802,17 @@
797803 } elseif ( $this->articleId ) {
798804 $articleTitle = Title::newFromID( $this->articleId );
799805 }
800 -
 806+
801807 // If still unfilled, the article ID referred to is no longer valid. Re-fill it
802808 // from the namespace/title pair if an article ID is provided
803809 if ( !$articleTitle && ( $this->articleId != 0 || $dbTitle->getArticleId() != 0 ) ) {
804810 $articleTitle = $dbTitle;
805811 $this->articleId = $articleTitle->getArticleId();
806812 $this->article = new Article_LQT_Compat( $dbTitle );
807 -
 813+
808814 $set['thread_article_id'] = $this->articleId;
809815 wfDebug( "Unfilled or non-existent thread_article_id, refilling to {$this->articleId}\n" );
810 -
 816+
811817 // There are probably problems on the rest of the article, trigger a small update
812818 Threads::synchroniseArticleData( $this->article, 100, 'cascade' );
813819 } elseif ( $articleTitle && !$articleTitle->equals( $dbTitle ) ) {
@@ -814,14 +820,14 @@
815821 wfDebug( "Article ID/Title discrepancy, resetting NS/Title to article provided by ID\n" );
816822 $this->articleNamespace = $articleTitle->getNamespace();
817823 $this->articleTitle = $articleTitle->getDBkey();
818 -
 824+
819825 $set['thread_article_namespace'] = $articleTitle->getNamespace();
820826 $set['thread_article_title'] = $articleTitle->getDBkey();
821 -
 827+
822828 // There are probably problems on the rest of the article, trigger a small update
823829 Threads::synchroniseArticleData( $this->article, 100, 'cascade' );
824830 }
825 -
 831+
826832 // Check for unfilled signature field. This field hasn't existed until
827833 // recently.
828834 if ( is_null( $this->signature ) ) {
@@ -831,100 +837,100 @@
832838 $set['thread_signature'] = $sig;
833839 $this->setSignature( $sig );
834840 }
835 -
 841+
836842 if ( count( $set ) ) {
837843 $dbw = wfGetDB( DB_MASTER );
838 -
 844+
839845 $dbw->update( 'thread', $set, array( 'thread_id' => $this->id() ), __METHOD__ );
840846 }
841 -
 847+
842848 // Done
843849 $doingUpdates = false;
844850 }
845851
846852 function addReply( $thread ) {
847853 $thread->setSuperThread( $this );
848 -
 854+
849855 if ( is_array( $this->replies ) ) {
850856 $this->replies[$thread->id()] = $thread;
851857 } else {
852858 $this->replies();
853859 $this->replies[$thread->id()] = $thread;
854860 }
855 -
 861+
856862 // Increment reply count.
857863 $this->incrementReplyCount( $thread->replyCount() + 1 );
858864 }
859 -
 865+
860866 function removeReply( $thread ) {
861867 if ( is_object( $thread ) ) {
862868 $thread = $thread->id();
863869 }
864 -
 870+
865871 $this->replies();
866 -
 872+
867873 unset( $this->replies[$thread] );
868 -
 874+
869875 // Also, decrement the reply count.
870876 $threadObj = Threads::withId( $thread );
871877 $this->decrementReplyCount( 1 + $threadObj->replyCount() );
872878 }
873 -
 879+
874880 function checkReplies( $replies ) {
875881 // Fixes a bug where some history pages were not working, before
876882 // superthread was properly instance-cached.
877883 if ( $this->isHistorical() ) { return; }
878 - foreach( $replies as $reply ) {
 884+ foreach ( $replies as $reply ) {
879885 if ( ! $reply->hasSuperthread() ) {
880 - throw new MWException( "Post ".$this->id().
881 - " has contaminated reply ".$reply->id().
882 - ". Found no superthread.");
 886+ throw new MWException( "Post " . $this->id() .
 887+ " has contaminated reply " . $reply->id() .
 888+ ". Found no superthread." );
883889 }
884 -
 890+
885891 if ( $reply->superthread()->id() != $this->id() ) {
886 - throw new MWException( "Post ". $this->id() .
887 - " has contaminated reply ".$reply->id().
888 - ". Expected ".$this->id().", got ".
 892+ throw new MWException( "Post " . $this->id() .
 893+ " has contaminated reply " . $reply->id() .
 894+ ". Expected " . $this->id() . ", got " .
889895 $reply->superthread()->id() );
890896 }
891897 }
892898 }
893 -
 899+
894900 function replies() {
895901 if ( !$this->id() ) {
896902 return array();
897903 }
898 -
 904+
899905 if ( !is_null( $this->replies ) ) {
900906 $this->checkReplies( $this->replies );
901907 return $this->replies;
902908 }
903 -
 909+
904910 $this->dieIfHistorical();
905 -
 911+
906912 // Check cache
907913 if ( isset( self::$replyCacheById[$this->id()] ) ) {
908914 return $this->replies = self::$replyCacheById[$this->id()];
909915 }
910 -
 916+
911917 $this->replies = array();
912 -
 918+
913919 $dbr = wfGetDB( DB_SLAVE );
914 -
 920+
915921 $res = $dbr->select( 'thread', '*',
916922 array( 'thread_parent' => $this->id(),
917923 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ),
918924 __METHOD__ );
919 -
 925+
920926 $rows = array();
921927 while ( $row = $dbr->fetchObject( $res ) ) {
922928 $rows[] = $row;
923929 }
924 -
 930+
925931 $this->replies = Thread::bulkLoad( $rows );
926 -
 932+
927933 $this->checkReplies( $this->replies );
928 -
 934+
929935 return $this->replies;
930936 }
931937
@@ -934,10 +940,10 @@
935941 $this->ancestorId = 0;
936942 return;
937943 }
938 -
 944+
939945 $this->parentId = $thread->id();
940946 $this->superthread = $thread;
941 -
 947+
942948 if ( $thread->isTopmostThread() ) {
943949 $this->ancestorId = $thread->id();
944950 $this->ancestor = $thread;
@@ -970,19 +976,19 @@
971977 return $this->ancestor;
972978 } else {
973979 $this->dieIfHistorical();
974 -
 980+
975981 $thread = Threads::withId( $this->ancestorId );
976982
977983 if ( !$thread ) {
978984 $thread = $this->fixMissingAncestor();
979985 }
980 -
 986+
981987 $this->ancestor = $thread;
982 -
 988+
983989 return $thread;
984990 }
985991 }
986 -
 992+
987993 function setAncestor( $newAncestor ) {
988994 if ( is_object( $newAncestor ) ) {
989995 $this->ancestorId = $newAncestor->id();
@@ -995,19 +1001,19 @@
9961002 // Fix the corruption by repeatedly grabbing the parent until we hit the topmost thread.
9971003 function fixMissingAncestor() {
9981004 $thread = $this;
999 -
 1005+
10001006 $this->dieIfHistorical();
1001 -
 1007+
10021008 while ( !$thread->isTopmostThread() ) {
10031009 $thread = $thread->superthread();
10041010 }
1005 -
 1011+
10061012 $this->ancestorId = $thread->id();
1007 -
 1013+
10081014 $dbw = wfGetDB( DB_MASTER );
10091015 $dbw->update( 'thread', array( 'thread_ancestor' => $thread->id() ),
10101016 array( 'thread_id' => $this->id() ), __METHOD__ );
1011 -
 1017+
10121018 return $thread;
10131019 }
10141020
@@ -1022,31 +1028,31 @@
10231029 $this->articleTitle = $a->getTitle()->getDBkey();
10241030 $this->touch();
10251031 }
1026 -
 1032+
10271033 function touch() {
10281034 // Nothing here yet
10291035 }
10301036
10311037 function article() {
10321038 if ( $this->article ) return $this->article;
1033 -
 1039+
10341040 if ( !is_null( $this->articleId ) ) {
10351041 if ( isset( self::$articleCacheById[$this->articleId] ) ) {
10361042 return self::$articleCacheById[$this->articleId];
10371043 }
1038 -
 1044+
10391045 if ( isset( self::$titleCacheById[$this->articleId] ) ) {
10401046 $title = self::$titleCacheById[$this->articleId];
10411047 } else {
10421048 $title = Title::newFromID( $this->articleId );
10431049 }
1044 -
 1050+
10451051 if ( $title ) {
10461052 $article = new Article_LQT_Compat( $title );
10471053 self::$articleCacheById[$this->articleId] = $article;
10481054 }
10491055 }
1050 -
 1056+
10511057 if ( isset( $article ) && $article->exists() ) {
10521058 $this->article = $article;
10531059 return $article;
@@ -1072,15 +1078,15 @@
10731079 $this->root = self::$articleCacheById[$this->rootId];
10741080 return $this->root;
10751081 }
1076 -
 1082+
10771083 if ( isset( self::$titleCacheById[$this->rootId] ) ) {
10781084 $title = self::$titleCacheById[$this->rootId];
10791085 } else {
10801086 $title = Title::newFromID( $this->rootId );
10811087 }
1082 -
 1088+
10831089 if ( !$title ) return null;
1084 -
 1090+
10851091 $this->root = new Article_LQT_Compat( $title );
10861092 }
10871093 return $this->root;
@@ -1093,20 +1099,20 @@
10941100 function summary() {
10951101 if ( !$this->summaryId )
10961102 return null;
1097 -
 1103+
10981104 if ( !$this->summary ) {
10991105 $title = Title::newFromID( $this->summaryId );
1100 -
 1106+
11011107 if ( !$title ) {
11021108 wfDebug( __METHOD__ . ": supposed summary doesn't exist" );
11031109 $this->summaryId = null;
11041110 return null;
11051111 }
1106 -
 1112+
11071113 $this->summary = new Article_LQT_Compat( $title );
11081114
11091115 }
1110 -
 1116+
11111117 return $this->summary;
11121118 }
11131119
@@ -1140,15 +1146,15 @@
11411147 function subject() {
11421148 return $this->subject;
11431149 }
1144 -
 1150+
11451151 function formattedSubject() {
11461152 return LqtView::formatSubject( $this->subject() );
11471153 }
1148 -
 1154+
11491155 function setSubject( $subject ) {
11501156 $this->subject = $subject;
1151 -
1152 - foreach( $this->replies() as $reply ) {
 1157+
 1158+ foreach ( $this->replies() as $reply ) {
11531159 $reply->setSubject( $subject );
11541160 }
11551161 }
@@ -1183,7 +1189,7 @@
11841190 function type() {
11851191 return $this->type;
11861192 }
1187 -
 1193+
11881194 function setType( $t ) {
11891195 $this->type = $t;
11901196 }
@@ -1192,7 +1198,7 @@
11931199 $rev = Revision::newFromId( $this->root()->getLatest() );
11941200 $rtitle = Title::newFromRedirect( $rev->getRawText() );
11951201 if ( !$rtitle ) return null;
1196 -
 1202+
11971203 $this->dieIfHistorical();
11981204 $rthread = Threads::withRoot( new Article_LQT_Compat( $rtitle ) );
11991205 return $rthread;
@@ -1218,68 +1224,50 @@
12191225 }
12201226
12211227 }
1222 -
 1228+
12231229 function getAnchorName() {
1224 - $wantedId = $this->subject()."_{$this->id()}";
 1230+ $wantedId = $this->subject() . "_{$this->id()}";
12251231 return Sanitizer::escapeId( $wantedId );
12261232 }
1227 -
 1233+
12281234 function updateHistory() {
1229 -// $dbr = wfGetDB( DB_SLAVE );
1230 -//
1231 -// $res = $dbr->select( 'historical_thread', '*',
1232 -// array( 'hthread_id' => $this->id() ),
1233 -// __METHOD__,
1234 -// array( 'ORDER BY' => 'hthread_revision ASC' ) );
1235 -//
1236 -// foreach( $row as $res ) {
1237 -// $historical_thread = HistoricalThread::fromTextRepresentation( $row->hthread_content );
1238 -//
1239 -// // Insert a revision into the database.
1240 -// $rev = ThreadRevision::create( $historical_thread,
1241 -// $historical_thread->changeType(),
1242 -// $historical_thread->changeObject(),
1243 -// $historical_thread->changeComment(),
1244 -// $historical_thread->changeUser(),
1245 -// $historical_thread->modified() );
1246 -// }
12471235 }
1248 -
 1236+
12491237 function setAuthor( $user ) {
12501238 $this->authorId = $user->getId();
12511239 $this->authorName = $user->getName();
12521240 }
1253 -
 1241+
12541242 // Load all lazy-loaded data in prep for (e.g.) serialization.
12551243 function loadAllData() {
12561244 // Make sure superthread and topmost thread are loaded.
12571245 $this->superthread();
12581246 $this->topmostThread();
1259 -
 1247+
12601248 // Make sure replies, and all the data therein, is loaded.
12611249 foreach ( $this->replies() as $reply ) {
12621250 $reply->loadAllData();
12631251 }
12641252 }
1265 -
 1253+
12661254 // On serialization, load all data because it will be different in the DB when we wake up.
12671255 function __sleep() {
12681256 $this->loadAllData();
1269 -
 1257+
12701258 $fields = array_keys( get_object_vars( $this ) );
1271 -
 1259+
12721260 // Filter out article objects, there be dragons (or unserialization problems)
12731261 $fields = array_diff( $fields, array( 'root', 'article', 'summary', 'sleeping',
12741262 'dbVersion' ) );
1275 -
 1263+
12761264 return $fields;
12771265 }
1278 -
 1266+
12791267 function __wakeup() {
12801268 // Mark as historical.
12811269 $this->isHistorical = true;
12821270 }
1283 -
 1271+
12841272 // This is a safety valve that makes sure that the DB is NEVER touched by a historical
12851273 // thread (even for reading, because the data will be out of date).
12861274 function dieIfHistorical() {
@@ -1287,196 +1275,196 @@
12881276 throw new MWException( "Attempted write or DB operation on historical thread" );
12891277 }
12901278 }
1291 -
 1279+
12921280 function rootRevision() {
12931281 if ( !$this->isHistorical() || !isset( $this->topmostThread()->threadRevision ) ) {
12941282 return null;
12951283 }
1296 -
 1284+
12971285 $dbr = wfGetDB( DB_SLAVE );
1298 -
 1286+
12991287 $revision = $this->topmostThread()->threadRevision;
13001288 $timestamp = $dbr->timestamp( $revision->getTimestamp() );
1301 -
 1289+
13021290 $conds = array(
1303 - 'rev_timestamp<=' . $dbr->addQuotes( $timestamp ),
1304 - 'page_namespace' => $this->root()->getTitle()->getNamespace(),
1305 - 'page_title' => $this->root()->getTitle()->getDBKey(),
1306 - );
1307 -
 1291+ 'rev_timestamp<=' . $dbr->addQuotes( $timestamp ),
 1292+ 'page_namespace' => $this->root()->getTitle()->getNamespace(),
 1293+ 'page_title' => $this->root()->getTitle()->getDBKey(),
 1294+ );
 1295+
13081296 $join_conds = array( 'page' => array( 'JOIN', 'rev_page=page_id' ) );
1309 -
 1297+
13101298 $row = $dbr->selectRow( array( 'revision', 'page' ), '*', $conds, __METHOD__,
13111299 array( 'ORDER BY' => 'rev_timestamp DESC' ), $join_conds );
1312 -
 1300+
13131301 return $row->rev_id;
13141302 }
1315 -
 1303+
13161304 function sortkey() {
13171305 return $this->sortkey;
13181306 }
1319 -
 1307+
13201308 function setSortKey( $k = null ) {
13211309 if ( is_null( $k ) ) {
13221310 $dbr = wfGetDB( DB_SLAVE );
13231311 $k = wfTimestamp( TS_MW );
13241312 }
1325 -
 1313+
13261314 $this->sortkey = $k;
13271315 }
1328 -
 1316+
13291317 function replyWithId( $id ) {
13301318 if ( $this->id() == $id ) {
13311319 return $this;
13321320 }
1333 -
1334 - foreach( $this->replies() as $reply ) {
1335 - if ( $obj = $reply->replyWithId($id) ) {
 1321+
 1322+ foreach ( $this->replies() as $reply ) {
 1323+ if ( $obj = $reply->replyWithId( $id ) ) {
13361324 return $obj;
13371325 }
13381326 }
1339 -
 1327+
13401328 return null;
13411329 }
1342 -
 1330+
13431331 static function createdSortCallback( $a, $b ) {
13441332 $a = $a->created();
13451333 $b = $b->created();
1346 -
 1334+
13471335 if ( $a == $b ) {
13481336 return 0;
13491337 } elseif ( $a > $b ) {
13501338 return 1;
13511339 } else {
1352 - return -1;
 1340+ return - 1;
13531341 }
13541342 }
1355 -
 1343+
13561344 public function split( $newSubject, $reason = '', $newSortkey = null ) {
13571345 $oldTopThread = $this->topmostThread();
13581346 $oldParent = $this->superthread();
1359 -
 1347+
13601348 $original = $this->dbVersion;
1361 -
 1349+
13621350 self::recursiveSet( $this, $newSubject, $this, null );
1363 -
 1351+
13641352 $oldParent->removeReply( $this );
1365 -
 1353+
13661354 $bump = null;
1367 - if ( !is_null($newSortkey) ) {
 1355+ if ( !is_null( $newSortkey ) ) {
13681356 $this->setSortkey( $newSortkey );
13691357 $bump = false;
13701358 }
1371 -
 1359+
13721360 // For logging purposes, will be reset by the time this call returns.
13731361 $this->dbVersion = $original;
1374 -
 1362+
13751363 $this->commitRevision( Threads::CHANGE_SPLIT, null, $reason, $bump );
13761364 $oldTopThread->commitRevision( Threads::CHANGE_SPLIT_FROM, $this, $reason );
13771365 }
1378 -
 1366+
13791367 public function moveToParent( $newParent, $reason = '' ) {
13801368 $newSubject = $newParent->subject();
1381 -
 1369+
13821370 $original = $this->dbVersion;
1383 -
 1371+
13841372 $oldTopThread = $newParent->topmostThread();
13851373 $oldParent = $this->superthread();
1386 -
 1374+
13871375 Thread::recursiveSet( $this, $newSubject, $newParent, $newParent );
13881376
13891377 $newParent->addReply( $this );
1390 -
 1378+
13911379 if ( $oldParent ) {
13921380 $oldParent->removeReply( $this );
13931381 }
1394 -
 1382+
13951383 $this->dbVersion = $original;
1396 -
 1384+
13971385 $oldTopThread->commitRevision( Threads::CHANGE_MERGED_FROM, $this, $reason );
13981386 $newParent->commitRevision( Threads::CHANGE_MERGED_TO, $this, $reason );
13991387 }
1400 -
 1388+
14011389 static function recursiveSet( $thread, $subject, $ancestor, $superthread = false ) {
14021390 $thread->setSubject( $subject );
14031391 $thread->setAncestor( $ancestor->id() );
1404 -
 1392+
14051393 if ( $superthread !== false ) {
14061394 $thread->setSuperThread( $superthread );
14071395 }
1408 -
 1396+
14091397 $thread->save();
1410 -
 1398+
14111399 foreach ( $thread->replies() as $subThread ) {
14121400 self::recursiveSet( $subThread, $subject, $ancestor );
14131401 }
14141402 }
1415 -
 1403+
14161404 static function validateSubject( $subject, &$title, $replyTo, $article ) {
14171405 $t = null;
14181406 $ok = true;
1419 -
 1407+
14201408 while ( !$t ) {
14211409 try {
14221410 global $wgUser;
1423 -
 1411+
14241412 if ( !$replyTo && $subject ) {
14251413 $t = Threads::newThreadTitle( $subject, $article );
14261414 } elseif ( $replyTo ) {
14271415 $t = Threads::newReplyTitle( $replyTo, $wgUser );
14281416 }
1429 -
 1417+
14301418 if ( $t )
14311419 break;
14321420 } catch ( Exception $e ) { }
1433 -
 1421+
14341422 $subject = md5( mt_rand() ); // Just a random title
14351423 $ok = false;
14361424 }
1437 -
 1425+
14381426 $title = $t;
1439 -
 1427+
14401428 return $ok;
14411429 }
1442 -
 1430+
14431431 /* N.B. Returns true, or a string with either thread or talkpage, noting which is
14441432 protected */
14451433 public function canUserReply( $user ) {
1446 - $threadRestrictions = $this->topmostThread()->title()->getRestrictions('reply');
1447 - $talkpageRestrictions = $this->article()->getTitle()->getRestrictions('reply');
1448 -
 1434+ $threadRestrictions = $this->topmostThread()->title()->getRestrictions( 'reply' );
 1435+ $talkpageRestrictions = $this->article()->getTitle()->getRestrictions( 'reply' );
 1436+
14491437 $threadRestrictions = array_fill_keys( $threadRestrictions, 'thread' );
14501438 $talkpageRestrictions = array_fill_keys( $talkpageRestrictions, 'talkpage' );
1451 -
 1439+
14521440 $restrictions = array_merge( $threadRestrictions, $talkpageRestrictions );
1453 -
1454 - foreach( $restrictions as $right => $source ) {
 1441+
 1442+ foreach ( $restrictions as $right => $source ) {
14551443 if ( $right == 'sysop' ) $right = 'protect';
14561444 if ( !$user->isAllowed( $right ) ) {
14571445 return $source;
14581446 }
14591447 }
1460 -
 1448+
14611449 return true;
14621450 }
1463 -
 1451+
14641452 public static function canUserPost( $user, $talkpage ) {
1465 - $restrictions = $talkpage->getTitle()->getRestrictions('newthread');
1466 -
1467 - foreach( $restrictions as $right ) {
 1453+ $restrictions = $talkpage->getTitle()->getRestrictions( 'newthread' );
 1454+
 1455+ foreach ( $restrictions as $right ) {
14681456 if ( !$user->isAllowed( $right ) ) {
14691457 return false;
14701458 }
14711459 }
1472 -
 1460+
14731461 return true;
14741462 }
1475 -
 1463+
14761464 public function signature() {
14771465 return $this->signature;
14781466 }
1479 -
1480 - public function setSignature($sig) {
 1467+
 1468+ public function setSignature( $sig ) {
14811469 $sig = LqtView::signaturePST( $sig, $this->author() );
14821470 $this->signature = $sig;
14831471 }
Index: trunk/extensions/LiquidThreads/classes/ThreadHistoryPager.php
@@ -2,14 +2,13 @@
33
44 class ThreadHistoryPager extends TablePager {
55 static $change_names;
6 -
76
87 function __construct( $view, $thread ) {
98 parent::__construct();
10 -
 9+
1110 $this->thread = $thread;
1211 $this->view = $view;
13 -
 12+
1413 self::$change_names =
1514 array(
1615 Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ),
@@ -28,19 +27,18 @@
2928 Threads::CHANGE_ADJUSTED_SORTKEY => wfMsgNoTrans( 'lqt_hist_adjusted_sortkey' ),
3029 );
3130 }
32 -
 31+
3332 function getQueryInfo() {
34 - $queryInfo =
35 - array(
36 - 'tables' => array( 'thread_history' ),
37 - 'fields' => '*',
38 - 'conds' => array( 'th_thread' => $this->thread->id() ),
39 - 'options' => array( 'order by' => 'th_timestamp desc' ),
40 - );
41 -
 33+ $queryInfo = array(
 34+ 'tables' => array( 'thread_history' ),
 35+ 'fields' => '*',
 36+ 'conds' => array( 'th_thread' => $this->thread->id() ),
 37+ 'options' => array( 'order by' => 'th_timestamp desc' ),
 38+ );
 39+
4240 return $queryInfo;
4341 }
44 -
 42+
4543 function getFieldMessages() {
4644 $headers = array(
4745 'th_timestamp' => 'lqt-history-time',
@@ -48,24 +46,24 @@
4947 'th_change_type' => 'lqt-history-action',
5048 'th_change_comment' => 'lqt-history-comment',
5149 );
52 -
 50+
5351 return $headers;
5452 }
55 -
 53+
5654 function getFieldNames() {
5755 static $headers = null;
5856
5957 if ( !empty( $headers ) ) {
6058 return $headers;
6159 }
62 -
 60+
6361 $headers = $this->getFieldMessages();
6462
6563 $headers = array_map( 'wfMsg', $headers );
6664
6765 return $headers;
6866 }
69 -
 67+
7068 function formatValue( $name, $value ) {
7169 global $wgOut, $wgLang, $wgTitle;
7270
@@ -83,11 +81,18 @@
8482 switch( $name ) {
8583 case 'th_timestamp':
8684 $formatted = $wgLang->timeanddate( $value );
87 - return $sk->link( $wgTitle, $formatted, array(),
88 - array( 'lqt_oldid' => $row->th_id ) );
 85+ return $sk->link(
 86+ $wgTitle,
 87+ $formatted,
 88+ array(),
 89+ array( 'lqt_oldid' => $row->th_id )
 90+ );
8991 case 'th_user_text':
90 - return $sk->userLink( $row->th_user, $row->th_user_text ) . ' ' .
91 - $sk->userToolLinks( $row->th_user, $row->th_user_text );
 92+ return $sk->userLink(
 93+ $row->th_user,
 94+ $row->th_user_text
 95+ ) .
 96+ ' ' . $sk->userToolLinks( $row->th_user, $row->th_user_text );
9297 case 'th_change_type':
9398 return $this->getActionDescription( $value );
9499 case 'th_change_comment':
@@ -97,29 +102,29 @@
98103 break;
99104 }
100105 }
101 -
 106+
102107 function getActionDescription( $type ) {
103108 global $wgOut;
104 -
 109+
105110 $args = array();
106111 $revision = ThreadRevision::loadFromRow( $this->mCurrentRow );
107112 $changeObject = $revision->getChangeObject();
108 -
 113+
109114 if ( $revision && $revision->prev() ) {
110115 $lastChangeObject = $revision->prev()->getChangeObject();
111116 }
112 -
 117+
113118 if ( $changeObject && $changeObject->title() ) {
114119 $args[] = $changeObject->title()->getPrefixedText();
115120 } else {
116121 $args[] = '';
117122 }
118 -
 123+
119124 $msg = self::$change_names[$type];
120 -
 125+
121126 switch( $type ) {
122127 case Threads::CHANGE_EDITED_SUBJECT:
123 - if ($changeObject && $lastChangeObject) {
 128+ if ( $changeObject && $lastChangeObject ) {
124129 $args[] = $lastChangeObject->subject();
125130 $args[] = $changeObject->subject();
126131 } else {
@@ -129,7 +134,7 @@
130135 case Threads::CHANGE_EDITED_ROOT:
131136 case Threads::CHANGE_ROOT_BLANKED:
132137 $view = $this->view;
133 -
 138+
134139 if ( $changeObject && $changeObject->title() ) {
135140 $diffLink = $view->diffPermalinkURL( $changeObject, $revision );
136141 $args[] = $diffLink;
@@ -138,15 +143,15 @@
139144 }
140145 break;
141146 }
142 -
 147+
143148 $content = wfMsgReplaceArgs( $msg, $args );
144149 return $wgOut->parseInline( $content );
145150 }
146 -
 151+
147152 function getIndexField() {
148153 return 'th_timestamp';
149154 }
150 -
 155+
151156 function getDefaultSort() {
152157 return 'th_timestamp';
153158 }
@@ -155,6 +160,6 @@
156161 $sortable_fields = array( 'th_timestamp', 'th_user_text', 'th_change_type' );
157162 return in_array( $name, $sortable_fields );
158163 }
159 -
 164+
160165 function getDefaultDirections() { return true; /* descending */ }
161166 }
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;
@@ -46,7 +45,10 @@
4746 $line = $dbr->selectRow(
4847 'historical_thread',
4948 'hthread_contents',
50 - array( 'hthread_id' => $id, 'hthread_revision' => $rev ),
 49+ array(
 50+ 'hthread_id' => $id,
 51+ 'hthread_revision' => $rev
 52+ ),
5153 __METHOD__ );
5254 if ( $line )
5355 return HistoricalThread::fromTextRepresentation( $line->hthread_contents );
@@ -57,12 +59,12 @@
5860 function isHistorical() {
5961 return true;
6062 }
61 -
6263
 64+
6365 function changeType() {
6466 return $this->changeType;
6567 }
66 -
 68+
6769 function changeObject() {
6870 return $this->replyWithId( $this->changeObject );
6971 }
@@ -95,7 +97,7 @@
9698 function changeComment() {
9799 return $this->changeComment;
98100 }
99 -
 101+
100102 function setChangeUser( $user ) {
101103 $this->changeUser = $user->getId();
102104 $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;
@@ -24,7 +23,7 @@
2524 const CHANGE_SPLIT_FROM = 12;
2625 const CHANGE_ROOT_BLANKED = 13;
2726 const CHANGE_ADJUSTED_SORTKEY = 14;
28 -
 27+
2928 static $VALID_CHANGE_TYPES = array(
3029 self::CHANGE_EDITED_SUMMARY,
3130 self::CHANGE_EDITED_ROOT,
@@ -61,39 +60,41 @@
6261 if ( ! $talkpage->exists() ) {
6362 try {
6463 wfLoadExtensionMessages( 'LiquidThreads' );
65 - $talkpage->doEdit( "",
 64+ $talkpage->doEdit(
 65+ "",
6666 wfMsgForContent( 'lqt_talkpage_autocreate_summary' ),
67 - EDIT_NEW | EDIT_SUPPRESS_RC );
 67+ EDIT_NEW | EDIT_SUPPRESS_RC
 68+ );
6869 } catch ( DBQueryError $e ) {
6970 // The article already existed by now. No need to do anything.
7071 wfDebug( __METHOD__ . ": Article already exists." );
7172 }
7273 }
7374 }
74 -
 75+
7576 static function loadFromResult( $res, $db, $bulkLoad = false ) {
7677 $rows = array();
7778 $threads = array();
78 -
 79+
7980 while ( $row = $db->fetchObject( $res ) ) {
8081 $rows[] = $row;
81 -
82 - if (!$bulkLoad) {
 82+
 83+ if ( !$bulkLoad ) {
8384 $threads[$row->thread_id] = Thread::newFromRow( $row );
8485 }
8586 }
86 -
87 - if (!$bulkLoad) {
 87+
 88+ if ( !$bulkLoad ) {
8889 return $threads;
8990 }
90 -
 91+
9192 return Thread::bulkLoad( $rows );
9293 }
9394
9495 static function where( $where, $options = array(), $bulkLoad = true ) {
9596 global $wgDBprefix;
9697 $dbr = wfGetDB( DB_SLAVE );
97 -
 98+
9899 $res = $dbr->select( 'thread', '*', $where, __METHOD__, $options );
99100 $threads = Threads::loadFromResult( $res, $dbr, $bulkLoad );
100101
@@ -113,8 +114,14 @@
114115 }
115116
116117 private static function assertSingularity( $threads, $attribute, $value ) {
117 - if ( count( $threads ) == 0 ) { return null; }
118 - if ( count( $threads ) == 1 ) { return array_pop( $threads ); }
 118+ if ( count( $threads ) == 0 ) {
 119+ return null;
 120+ }
 121+
 122+ if ( count( $threads ) == 1 ) {
 123+ return array_pop( $threads );
 124+ }
 125+
119126 if ( count( $threads ) > 1 ) {
120127 Threads::databaseError( "More than one thread with $attribute = $value." );
121128 return null;
@@ -126,14 +133,14 @@
127134 // No articles outside the thread namespace have threads associated with them;
128135 return null;
129136 }
130 -
 137+
131138 if ( array_key_exists( $post->getID(), self::$cache_by_root ) ) {
132139 return self::$cache_by_root[$post->getID()];
133140 }
134 -
 141+
135142 $ts = Threads::where( array( 'thread_root' => $post->getID() ), array(),
136143 $bulkLoad );
137 -
 144+
138145 return self::assertSingularity( $ts, 'thread_root', $post->getID() );
139146 }
140147
@@ -141,65 +148,65 @@
142149 if ( array_key_exists( $id, self::$cache_by_id ) ) {
143150 return self::$cache_by_id[$id];
144151 }
145 -
 152+
146153 $ts = Threads::where( array( 'thread_id' => $id ), array(), $bulkLoad );
147 -
 154+
148155 return self::assertSingularity( $ts, 'thread_id', $id );
149156 }
150157
151158 static function withSummary( $article, $bulkLoad = true ) {
152159 $ts = Threads::where( array( 'thread_summary_page' => $article->getId() ),
153 - array(), $bulkLoad);
 160+ array(), $bulkLoad );
154161 return self::assertSingularity( $ts, 'thread_summary_page', $article->getId() );
155162 }
156163
157164 static function articleClause( $article ) {
158165 $dbr = wfGetDB( DB_SLAVE );
159 -
 166+
160167 $titleCond = array( 'thread_article_title' => $article->getTitle()->getDBKey(),
161168 'thread_article_namespace' => $article->getTitle()->getNamespace() );
162169 $titleCond = $dbr->makeList( $titleCond, LIST_AND );
163 -
 170+
164171 $conds = array( $titleCond );
165 -
 172+
166173 if ( $article->getId() ) {
167174 $idCond = array( 'thread_article_id' => $article->getId() );
168175 $conds[] = $dbr->makeList( $idCond, LIST_AND );
169176 }
170 -
 177+
171178 return $dbr->makeList( $conds, LIST_OR );
172179 }
173180
174181 static function topLevelClause() {
175182 $dbr = wfGetDB( DB_SLAVE );
176 -
 183+
177184 $arr = array( 'thread_ancestor=thread_id', 'thread_parent' => null );
178 -
 185+
179186 return $dbr->makeList( $arr, LIST_OR );
180187 }
181 -
 188+
182189 static function newThreadTitle( $subject, $article ) {
183190 wfLoadExtensionMessages( 'LiquidThreads' );
184 -
 191+
185192 $base = $article->getTitle()->getPrefixedText() . "/$subject";
186 -
 193+
187194 return self::incrementedTitle( $base, NS_LQT_THREAD );
188195 }
189 -
 196+
190197 static function newSummaryTitle( $t ) {
191198 return self::incrementedTitle( $t->title()->getText(), NS_LQT_SUMMARY );
192199 }
193 -
 200+
194201 static function newReplyTitle( $thread, $user ) {
195202 wfLoadExtensionMessages( 'LiquidThreads' );
196203 $topThread = $thread->topmostThread();
197 -
 204+
198205 $base = $topThread->title()->getText() . '/'
199 - . wfMsgForContent('lqt-reply-subpage');
200 -
 206+ . wfMsgForContent( 'lqt-reply-subpage' );
 207+
201208 return self::incrementedTitle( $base, NS_LQT_THREAD );
202209 }
203 -
 210+
204211 // This will attempt to replace invalid characters and sequences in a title with
205212 // a safe replacement (_, currently). Before doing this, it will parse any wikitext
206213 // and strip the HTML, before converting HTML entities back into their corresponding
@@ -207,9 +214,9 @@
208215 public static function makeTitleValid( $text ) {
209216 $text = self::stripWikitext( $text );
210217 $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
211 -
 218+
212219 static $rxTc;
213 -
 220+
214221 if ( is_callable( array( 'Title', 'getTitleInvalidRegex' ) ) ) {
215222 $rxTc = Title::getTitleInvalidRegex();
216223 } elseif ( !$rxTc ) { // Back-compat
@@ -225,47 +232,47 @@
226233 '|&#x[0-9A-Fa-f]+;' .
227234 '/S';
228235 }
229 -
 236+
230237 $text = preg_replace( $rxTc, '_', $text );
231 -
 238+
232239 return $text;
233240 }
234 -
 241+
235242 // This will strip wikitext of its formatting.
236243 public static function stripWikitext( $text ) {
237244 global $wgOut;
238245 $text = $wgOut->parseInline( $text );
239 -
 246+
240247 $text = StringUtils::delimiterReplace( '<', '>', '', $text );
241 -
 248+
242249 return $text;
243250 }
244 -
 251+
245252 public static function stripHTML( $text ) {
246253 return StringUtils::delimiterReplace( '<', '>', '', $text );
247254 }
248 -
 255+
249256 /** Keep trying titles starting with $basename until one is unoccupied. */
250257 public static function incrementedTitle( $basename, $namespace ) {
251258 $i = 2;
252 -
 259+
253260 // Try to make the title valid.
254261 $basename = Threads::makeTitleValid( $basename );
255 -
 262+
256263 $t = Title::makeTitleSafe( $namespace, $basename );
257264 while ( !$t || $t->exists() ||
258265 in_array( $t->getPrefixedDBkey(), self::$occupied_titles ) ) {
259 -
 266+
260267 if ( !$t ) {
261268 throw new MWException( "Error in creating title for basename $basename" );
262269 }
263 -
 270+
264271 $t = Title::makeTitleSafe( $namespace, $basename . ' (' . $i . ')' );
265272 $i++;
266273 }
267274 return $t;
268275 }
269 -
 276+
270277 // Called just before any function that might cause a loss of article association.
271278 // by breaking either a NS-title reference (by moving the article), or a page-id
272279 // reference (by deleting the article).
@@ -281,50 +288,50 @@
282289 static function synchroniseArticleData( $article, $limit = false, $queueMore = false ) {
283290 $dbr = wfGetDB( DB_SLAVE );
284291 $dbw = wfGetDB( DB_MASTER );
285 -
 292+
286293 $title = $article->getTitle();
287294 $id = $article->getId();
288 -
 295+
289296 $titleCond = array( 'thread_article_namespace' => $title->getNamespace(),
290297 'thread_article_title' => $title->getDBkey() );
291298 $titleCondText = $dbr->makeList( $titleCond, LIST_AND );
292 -
 299+
293300 $idCond = array( 'thread_article_id' => $id );
294301 $idCondText = $dbr->makeList( $idCond, LIST_AND );
295 -
 302+
296303 $fixTitleCond = array( $idCondText, "NOT ($titleCondText)" );
297304 $fixIdCond = array( $titleCondText, "NOT ($idCondText)" );
298 -
 305+
299306 // Try to hit the most recent threads first.
300307 $options = array( 'LIMIT' => 500, 'ORDER BY' => 'thread_id DESC' );
301 -
 308+
302309 // Batch in 500s
303310 if ( $limit ) $options['LIMIT'] = min( $limit, 500 );
304 -
 311+
305312 $rowsAffected = 0;
306313 $roundRowsAffected = 1;
307314 while ( ( !$limit || $rowsAffected < $limit ) && $roundRowsAffected > 0 ) {
308315 $roundRowsAffected = 0;
309 -
 316+
310317 // Fix wrong title.
311318 $res = $dbw->update( 'thread', $titleCond, $fixTitleCond,
312319 __METHOD__, $options );
313320 $roundRowsAffected += $dbw->affectedRows();
314 -
 321+
315322 // Fix wrong ID
316323 $res = $dbw->update( 'thread', $idCond, $fixIdCond, __METHOD__, $options );
317324 $roundRowsAffected += $dbw->affectedRows();
318 -
 325+
319326 $rowsAffected += $roundRowsAffected;
320327 }
321 -
 328+
322329 if ( $limit && ( $rowsAffected >= $limit ) && $queueMore ) {
323330 $jobParams = array( 'limit' => $limit, 'cascade' => true );
324331 $job = new SynchroniseThreadArticleDataJob( $article->getTitle(),
325332 $jobParams );
326333 $job->insert();
327334 }
328 -
 335+
329336 return $limit ? ( $rowsAffected < $limit ) : true;
330337 }
331338 }
Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * @package MediaWiki
65 * @subpackage LiquidThreads
@@ -19,7 +18,7 @@
2019 public $title;
2120 public $request;
2221
23 - protected $headerLevel = 2; /* h1, h2, h3, etc. */
 22+ protected $headerLevel = 2; /* h1, h2, h3, etc. */
2423 protected $lastUnindentedSuperthread;
2524
2625 public $threadNestingLevel = 0;
@@ -48,8 +47,8 @@
4948 }
5049
5150 /*************************
52 - * (1) linking to liquidthreads pages and
53 - * (2) figuring out what page you're on and what you need to do.
 51+ * (1) linking to liquidthreads pages and
 52+ * (2) figuring out what page you're on and what you need to do.
5453 *************************/
5554
5655 function methodAppliesToThread( $method, $thread ) {
@@ -126,15 +125,15 @@
127126
128127 $query['lqt_mustshow'] = $thread->id();
129128
130 - $title->setFragment( '#'.$thread->getAnchorName() );
 129+ $title->setFragment( '#' . $thread->getAnchorName() );
131130
132131 return array( $title, $query );
133132 }
134133
135134 static function linkInContext( $thread, $contextType = 'page', $text = null ) {
136135 list( $title, $query ) = self::linkInContextData( $thread, $contextType );
137 -
138 - if ( is_null($text) ) {
 136+
 137+ if ( is_null( $text ) ) {
139138 $text = Threads::stripHTML( $thread->formattedSubject() );
140139 }
141140
@@ -157,9 +156,11 @@
158157 $prev_rev = $curr_rev->getPrevious();
159158 $oldid = $prev_rev ? $prev_rev->getId() : "";
160159
161 - $query = array( 'lqt_method' => 'diff',
162 - 'diff' => $curr_rev_id,
163 - 'oldid' => $oldid );
 160+ $query = array(
 161+ 'lqt_method' => 'diff',
 162+ 'diff' => $curr_rev_id,
 163+ 'oldid' => $oldid
 164+ );
164165
165166 return $query;
166167 }
@@ -178,9 +179,11 @@
179180 $includeFragment = true, $attribs = array(),
180181 $options = array(), $perpetuateOffset = true )
181182 {
182 - list( $title, $query ) = self::talkpageLinkData( $title, $method, $operand,
183 - $includeFragment,
184 - $perpetuateOffset );
 183+ list( $title, $query ) = self::talkpageLinkData(
 184+ $title, $method, $operand,
 185+ $includeFragment,
 186+ $perpetuateOffset
 187+ );
185188
186189 global $wgUser;
187190 $sk = $wgUser->getSkin();
@@ -189,8 +192,8 @@
190193 }
191194
192195 static function talkpageLinkData( $title, $method = null, $operand = null,
193 - $includeFragment = true,
194 - $perpetuateOffset = true ) {
 196+ $includeFragment = true, $perpetuateOffset = true )
 197+ {
195198 global $wgRequest;
196199 $query = array();
197200
@@ -231,10 +234,13 @@
232235 return array( $title, $query );
233236 }
234237
235 - /* If you want $perpetuateOffset to perpetuate from a specific request, pass that instead
236 - of true */
 238+ /**
 239+ * If you want $perpetuateOffset to perpetuate from a specific request,
 240+ * pass that instead of true
 241+ */
237242 static function talkpageUrl( $title, $method = null, $operand = null,
238 - $includeFragment = true, $perpetuateOffset = true ) {
 243+ $includeFragment = true, $perpetuateOffset = true )
 244+ {
239245 global $wgUser;
240246 $sk = $wgUser->getSkin();
241247
@@ -247,10 +253,10 @@
248254
249255
250256 /**
251 - * Return a URL for the current page, including Title and query vars,
 257+ * Return a URL for the current page, including Title and query vars,
252258 * with the given replacements made.
253 - * @param $repls array( 'name'=>new_value, ... )
254 - */
 259+ * @param $repls array( 'name'=>new_value, ... )
 260+ */
255261 function queryReplaceLink( $repls ) {
256262 $query = $this->getReplacedQuery( $repls );
257263
@@ -268,10 +274,10 @@
269275 }
270276
271277 /*************************************************************
272 - * Editing methods (here be dragons) *
273 - * Forget dragons: This section distorts the rest of the code *
274 - * like a star bending spacetime around itself. *
275 - *************************************************************/
 278+ * Editing methods (here be dragons) *
 279+ * Forget dragons: This section distorts the rest of the code *
 280+ * like a star bending spacetime around itself. *
 281+ *************************************************************/
276282
277283 /**
278284 * Return an HTML form element whose value is gotten from the request.
@@ -331,13 +337,13 @@
332338 }
333339
334340 private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) {
335 - /*
336 - EditPage needs an Article. If there isn't a real one, as for new posts,
337 - replies, and new summaries, we need to generate a title. Auto-generated
338 - titles are based on the subject line. If the subject line is blank, we
339 - can temporarily use a random scratch title. It's fine if the title changes
340 - throughout the edit cycle, since the article doesn't exist yet anyways.
341 - */
 341+ /**
 342+ * EditPage needs an Article. If there isn't a real one, as for new posts,
 343+ * replies, and new summaries, we need to generate a title. Auto-generated
 344+ * titles are based on the subject line. If the subject line is blank, we
 345+ * can temporarily use a random scratch title. It's fine if the title changes
 346+ * throughout the edit cycle, since the article doesn't exist yet anyways.
 347+ */
342348
343349 // Check permissions
344350 if ( $edit_type == 'new' ) {
@@ -441,8 +447,11 @@
442448
443449 $reply_subject = $edit_applies_to->subject();
444450 $reply_title = $edit_applies_to->title()->getPrefixedText();
445 - $summary = wfMsgForContent( 'lqt-reply-summary',
446 - $reply_subject, $reply_title );
 451+ $summary = wfMsgForContent(
 452+ 'lqt-reply-summary',
 453+ $reply_subject,
 454+ $reply_title
 455+ );
447456 $wgRequest->setVal( 'wpSummary', $summary );
448457 }
449458
@@ -463,7 +472,7 @@
464473
465474 $signatureText = $this->request->getVal( 'wpLqtSignature', null );
466475
467 - if ( is_null($signatureText) ) {
 476+ if ( is_null( $signatureText ) ) {
468477 if ( !$thread && $edit_type != 'summarize' ) {
469478 $signatureText = LqtView::getUserSignature( $this->user );
470479 } else {
@@ -474,12 +483,18 @@
475484 $signatureHTML = LqtView::parseSignature( $signatureText );
476485
477486 // Signature edit box
478 - $signaturePreview = Xml::tags( 'span',
479 - array( 'class' => 'lqt-signature-preview',
480 - 'style' => 'display: none;' ),
481 - $signatureHTML );
482 - $signatureEditBox = Xml::input( 'wpLqtSignature', 45, $signatureText,
483 - array( 'class' => 'lqt-signature-edit' ) );
 487+ $signaturePreview = Xml::tags(
 488+ 'span',
 489+ array(
 490+ 'class' => 'lqt-signature-preview',
 491+ 'style' => 'display: none;'
 492+ ),
 493+ $signatureHTML
 494+ );
 495+ $signatureEditBox = Xml::input(
 496+ 'wpLqtSignature', 45, $signatureText,
 497+ array( 'class' => 'lqt-signature-edit' )
 498+ );
484499
485500 $signatureEditor = $signaturePreview . $signatureEditBox;
486501
@@ -564,13 +579,13 @@
565580 }
566581
567582 static function postEditUpdates( $edit_type, $edit_applies_to, $edit_page, $article,
568 - $subject, $edit_summary, $thread, $new_text,
569 - $bump = null, $signature = null ) {
 583+ $subject, $edit_summary, $thread, $new_text, $bump = null, $signature = null )
 584+ {
570585 // Update metadata - create and update thread and thread revision objects as
571586 // appropriate.
572587
573588 $noSignature = false;
574 - if ( is_null($signature) ) {
 589+ if ( is_null( $signature ) ) {
575590 global $wgUser;
576591 $signature = LqtView::getUserSignature( $wgUser );
577592 $noSignature = true;
@@ -579,17 +594,21 @@
580595 if ( $edit_type == 'reply' ) {
581596 $subject = $edit_applies_to->subject();
582597
583 - $thread = Thread::create( $edit_page, $article, $edit_applies_to,
584 - Threads::TYPE_NORMAL, $subject,
585 - $edit_summary, $bump, $signature );
 598+ $thread = Thread::create(
 599+ $edit_page, $article, $edit_applies_to,
 600+ Threads::TYPE_NORMAL, $subject,
 601+ $edit_summary, $bump, $signature
 602+ );
586603
587604 global $wgUser;
588605 NewMessages::markThreadAsReadByUser( $edit_applies_to, $wgUser );
589606 } elseif ( $edit_type == 'summarize' ) {
590607 $edit_applies_to->setSummary( $edit_page );
591 - $edit_applies_to->commitRevision( Threads::CHANGE_EDITED_SUMMARY,
592 - $edit_applies_to, $edit_summary,
593 - $bump);
 608+ $edit_applies_to->commitRevision(
 609+ Threads::CHANGE_EDITED_SUMMARY,
 610+ $edit_applies_to, $edit_summary,
 611+ $bump
 612+ );
594613 } elseif ( $edit_type == 'editExisting' ) {
595614 // Use a separate type if the content is blanked.
596615 $type = strlen( trim( $new_text ) )
@@ -603,9 +622,11 @@
604623 // Add the history entry.
605624 $thread->commitRevision( $type, $thread, $edit_summary, $bump );
606625 } else {
607 - $thread = Thread::create( $edit_page, $article, null,
608 - Threads::TYPE_NORMAL, $subject,
609 - $edit_summary, null, $signature );
 626+ $thread = Thread::create(
 627+ $edit_page, $article, null,
 628+ Threads::TYPE_NORMAL, $subject,
 629+ $edit_summary, null, $signature
 630+ );
610631 }
611632
612633 return $thread;
@@ -640,7 +661,6 @@
641662 }
642663
643664 # Variables beginning with 'o' for old article 'n' for new article
644 -
645665 $ot = $old_title;
646666 $nt = $this->incrementedTitle( $new_subject, $old_title->getNamespace() );
647667
@@ -686,9 +706,11 @@
687707 }
688708
689709 $history_url = self::permalinkUrlWithQuery( $thread, array( 'action' => 'history' ) );
690 - $commands['history'] = array( 'label' => wfMsgExt( 'history_short', 'parseinline' ),
691 - 'href' => $history_url,
692 - 'enabled' => true );
 710+ $commands['history'] = array( 'label' => wfMsgExt(
 711+ 'history_short', 'parseinline' ),
 712+ 'href' => $history_url,
 713+ 'enabled' => true
 714+ );
693715
694716 if ( $thread->isHistorical() ) {
695717 return array();
@@ -696,25 +718,36 @@
697719 $user_can_edit = $thread->root()->getTitle()->quickUserCan( 'edit' );
698720 $editMsg = $user_can_edit ? 'edit' : 'viewsource';
699721
700 - $commands['edit'] = array( 'label' => wfMsgExt( $editMsg, 'parseinline' ),
701 - 'href' => $this->talkpageUrl( $this->title, 'edit', $thread,
702 - true /* include fragment */ , $this->request ),
703 - 'enabled' => true );
 722+ $commands['edit'] = array(
 723+ 'label' => wfMsgExt( $editMsg, 'parseinline' ),
 724+ 'href' => $this->talkpageUrl(
 725+ $this->title,
 726+ 'edit', $thread,
 727+ true, /* include fragment */
 728+ $this->request
 729+ ),
 730+ 'enabled' => true
 731+ );
704732
705733 if ( $this->user->isAllowed( 'delete' ) ) {
706734 $delete_url = $thread->title()->getFullURL( 'action=delete' );
707735 $deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete';
708736
709 - $commands['delete'] = array( 'label' => wfMsgExt( $deleteMsg, 'parseinline' ),
710 - 'href' => $delete_url,
711 - 'enabled' => true );
 737+ $commands['delete'] = array(
 738+ 'label' => wfMsgExt( $deleteMsg, 'parseinline' ),
 739+ 'href' => $delete_url,
 740+ 'enabled' => true
 741+ );
712742 }
713743
714744 if ( !$thread->isTopmostThread() && $this->user->isAllowed( 'lqt-split' ) ) {
715745 $splitUrl = SpecialPage::getTitleFor( 'SplitThread',
716746 $thread->title()->getPrefixedText() )->getFullURL();
717 - $commands['split'] = array( 'label' => wfMsgExt( 'lqt-thread-split', 'parseinline' ),
718 - 'href' => $splitUrl, 'enabled' => true );
 747+ $commands['split'] = array(
 748+ 'label' => wfMsgExt( 'lqt-thread-split', 'parseinline' ),
 749+ 'href' => $splitUrl,
 750+ 'enabled' => true
 751+ );
719752 }
720753
721754 if ( $this->user->isAllowed( 'lqt-merge' ) ) {
@@ -726,8 +759,11 @@
727760 $mergeUrl = $this->title->getFullURL( wfArrayToCGI( $mergeParams ) );
728761 $label = wfMsgExt( 'lqt-thread-merge', 'parseinline' );
729762
730 - $commands['merge'] = array( 'label' => $label,
731 - 'href' => $mergeUrl, 'enabled' => true );
 763+ $commands['merge'] = array(
 764+ 'label' => $label,
 765+ 'href' => $mergeUrl,
 766+ 'enabled' => true
 767+ );
732768 }
733769
734770 return $commands;
@@ -761,8 +797,11 @@
762798 $mergeUrl = $mergeTitle->getFullURL( 'dest=' . $thread->id() );
763799 $label = wfMsgExt( 'lqt-thread-merge-to', 'parseinline' );
764800
765 - $commands['merge-to'] = array( 'label' => $label, 'href' => $mergeUrl,
766 - 'enabled' => true, 'tooltip' => $label );
 801+ $commands['merge-to'] = array(
 802+ 'label' => $label, 'href' => $mergeUrl,
 803+ 'enabled' => true,
 804+ 'tooltip' => $label
 805+ );
767806 }
768807
769808 $commands['link'] = array(
@@ -773,16 +812,6 @@
774813 'showlabel' => true,
775814 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' )
776815 );
777 - /*
778 - if ( $thread->root()->getTitle()->quickUserCan( 'edit' ) ) {
779 - $commands['edit'] = array(
780 - 'label' => wfMsgExt( 'edit', 'parseinline' ),
781 - 'href' => $this->talkpageUrl( $this->title, 'edit', $thread,
782 - true, $this->request ),
783 - 'enabled' => true, 'icon' => 'edit.png',
784 - 'tooltip' => wfMsgExt( 'edit', 'parseinline' ) );
785 - }
786 - */
787816
788817 return $commands;
789818 }
@@ -791,16 +820,20 @@
792821 wfLoadExtensionMessages( 'LiquidThreads' );
793822 $commands = array();
794823
795 - $commands['history'] = array( 'label' => wfMsg( 'history_short' ),
796 - 'href' => self::permalinkUrl( $thread, 'thread_history' ),
797 - 'enabled' => true );
 824+ $commands['history'] = array(
 825+ 'label' => wfMsg( 'history_short' ),
 826+ 'href' => self::permalinkUrl( $thread, 'thread_history' ),
 827+ 'enabled' => true
 828+ );
798829
799830 if ( $this->user->isAllowed( 'move' ) ) {
800831 $move_href = SpecialPage::getTitleFor( 'MoveThread' )->getFullURL()
801832 . '/' . $thread->title()->getPrefixedURL();
802 - $commands['move'] = array( 'label' => wfMsg( 'lqt-movethread' ),
803 - 'href' => $move_href,
804 - 'enabled' => true );
 833+ $commands['move'] = array(
 834+ 'label' => wfMsg( 'lqt-movethread' ),
 835+ 'href' => $move_href,
 836+ 'enabled' => true
 837+ );
805838 }
806839
807840 if ( $this->user->isAllowed( 'protect' ) ) {
@@ -813,19 +846,25 @@
814847 $label = wfMsg( 'unprotect' );
815848 }
816849
817 - $commands['protect'] = array( 'label' => $label,
818 - 'href' => $protect_href,
819 - 'enabled' => true, );
 850+ $commands['protect'] = array(
 851+ 'label' => $label,
 852+ 'href' => $protect_href,
 853+ 'enabled' => true
 854+ );
820855 }
821856
822857 if ( !$this->user->isAnon() && !$thread->title()->userIsWatching() ) {
823 - $commands['watch'] = array( 'label' => wfMsg( 'watch' ),
824 - 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ),
825 - 'enabled' => true );
 858+ $commands['watch'] = array(
 859+ 'label' => wfMsg( 'watch' ),
 860+ 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ),
 861+ 'enabled' => true
 862+ );
826863 } else if ( !$this->user->isAnon() ) {
827 - $commands['unwatch'] = array( 'label' => wfMsg( 'unwatch' ),
828 - 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ),
829 - 'enabled' => true );
 864+ $commands['unwatch'] = array(
 865+ 'label' => wfMsg( 'unwatch' ),
 866+ 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ),
 867+ 'enabled' => true
 868+ );
830869 }
831870
832871 $summarizeUrl = self::permalinkUrl( $thread, 'summarize', $thread->id() );
@@ -926,11 +965,11 @@
927966 }
928967
929968 $parserOutput = $post->getParserOutput( $oldid );
930 -
 969+
931970 // Remove title, so that it stays set correctly.
932971 $parserOutput->setTitleText( '' );
933 -
934 -
 972+
 973+
935974 $wgOut->addParserOutputNoText( $parserOutput );
936975
937976 return $parserOutput->getText();
@@ -964,7 +1003,7 @@
9651004 'lqt-command-icon', 'style' => 'display: none;' ),
9661005 $triggerText );
9671006
968 - if ( count($commands) ) {
 1007+ if ( count( $commands ) ) {
9691008 $headerParts[] = Xml::tags( 'li',
9701009 array( 'class' => 'lqt-thread-toolbar-menu' ),
9711010 $dropDownTrigger );
@@ -986,9 +1025,11 @@
9871026 foreach ( $commands as $key => $command ) {
9881027 $thisCommand = $this->contentForCommand( $command );
9891028
990 - $thisCommand = Xml::tags( 'li',
991 - array( 'class' => 'lqt-command lqt-command-' . $key ),
992 - $thisCommand );
 1029+ $thisCommand = Xml::tags(
 1030+ 'li',
 1031+ array( 'class' => 'lqt-command lqt-command-' . $key ),
 1032+ $thisCommand
 1033+ );
9931034
9941035 $result[] = $thisCommand;
9951036 }
@@ -1121,7 +1162,7 @@
11221163 $editedNotice );
11231164 }
11241165
1125 - if ( ! count($infoElements) ) {
 1166+ if ( ! count( $infoElements ) ) {
11261167 return '';
11271168 }
11281169
@@ -1185,13 +1226,13 @@
11861227
11871228 $article = new Article( $thread->title() );
11881229 $target = Title::newFromRedirect( $article->getContent() );
1189 -
1190 - if (!$target) {
1191 - throw new MWException( "Thread ".$thread->id().' purports to be moved, '.
1192 - 'but no redirect found in text of '.
1193 - $thread->title()->getPrefixedText().'. Dying.' );
 1230+
 1231+ if ( !$target ) {
 1232+ throw new MWException( "Thread " . $thread->id() . ' purports to be moved, ' .
 1233+ 'but no redirect found in text of ' .
 1234+ $thread->title()->getPrefixedText() . '. Dying.' );
11941235 }
1195 -
 1236+
11961237 $t_thread = Threads::withRoot( new Article( $target ) );
11971238
11981239 // Grab data about the new post.
@@ -1206,7 +1247,7 @@
12071248 $sig,
12081249 $wgLang->date( $thread->modified() ),
12091250 $wgLang->time( $thread->modified() ),
1210 - $sk->link($newTalkpage)
 1251+ $sk->link( $newTalkpage )
12111252 );
12121253
12131254 $this->output->addHTML( $html );
@@ -1280,7 +1321,7 @@
12811322 $walk_thread = Threads::withId( $walk_thread );
12821323 }
12831324
1284 - if (!is_object( $walk_thread ) ) {
 1325+ if ( !is_object( $walk_thread ) ) {
12851326 continue;
12861327 }
12871328
@@ -1327,11 +1368,11 @@
13281369 static function threadContainsRepliesWithContent( $thread ) {
13291370 $replies = $thread->replies();
13301371
1331 - foreach( $replies as $reply ) {
 1372+ foreach ( $replies as $reply ) {
13321373 $content = '';
13331374 if ( $reply->root() ) $content = $reply->root()->getContent();
13341375
1335 - if ( trim($content) != '' ) {
 1376+ if ( trim( $content ) != '' ) {
13361377 return true;
13371378 }
13381379
@@ -1376,7 +1417,7 @@
13771418 // We've shown too many threads.
13781419 $link = $this->getShowMore( $thread, $st, $i );
13791420
1380 - $this->output->addHTML( $div.$link );
 1421+ $this->output->addHTML( $div . $link );
13811422 $showThreads = false;
13821423 continue;
13831424 }
@@ -1385,7 +1426,7 @@
13861427 if ( $showCount == 1 ) {
13871428 // There's a post sep before each reply group to
13881429 // separate from the parent thread.
1389 - $this->output->addHTML( $sep.$div );
 1430+ $this->output->addHTML( $sep . $div );
13901431 }
13911432
13921433 $this->showThread( $st, $i, $subthreadCount, $cascadeOptions );
@@ -1446,7 +1487,7 @@
14471488 if ( $thread->root() ) $content = $thread->root()->getContent();
14481489
14491490 if (
1450 - trim($content) == '' &&
 1491+ trim( $content ) == '' &&
14511492 $thread->type() != Threads::TYPE_MOVED &&
14521493 ! self::threadContainsRepliesWithContent( $thread ) &&
14531494 ! array_key_exists( $thread->id(), $mustShowThreads )
@@ -1555,7 +1596,7 @@
15561597 $cascadeOptions = $options;
15571598 unset( $cascadeOptions['startAt'] );
15581599
1559 - if ( ($hasSubthreads && $showThreads) ) {
 1600+ if ( ( $hasSubthreads && $showThreads ) ) {
15601601 $this->showThreadReplies( $thread, $startAt, $maxCount, $showThreads,
15611602 $cascadeOptions );
15621603 } elseif ( $hasSubthreads && !$showThreads ) {
@@ -1573,7 +1614,7 @@
15741615 Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&nbsp;' ) );
15751616
15761617 if ( $replyTo ) {
1577 - $class = 'lqt-thread-replies lqt-thread-replies-'.
 1618+ $class = 'lqt-thread-replies lqt-thread-replies-' .
15781619 $this->threadNestingLevel;
15791620 $html = Xml::openElement( 'div', array( 'class' => $class ) );
15801621 $html .= Xml::openElement( 'div',
@@ -1598,7 +1639,7 @@
15991640 }
16001641
16011642 if ( $this->threadNestingLevel == 1 ) {
1602 - if ( !($hasSubthreads && $showThreads) ) {
 1643+ if ( !( $hasSubthreads && $showThreads ) ) {
16031644 $this->showReplyBox( $thread );
16041645 $finishDiv = '';
16051646 $finishDiv .= Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ),
@@ -1742,7 +1783,7 @@
17431784 global $wgParser, $wgOut, $wgTitle;
17441785
17451786 static $parseCache = array();
1746 - $sigKey = md5($sig);
 1787+ $sigKey = md5( $sig );
17471788
17481789 if ( isset( $parseCache[$sigKey] ) ) {
17491790 return $parseCache[$sigKey];
@@ -1790,7 +1831,7 @@
17911832 function show() {
17921833 return true; // No-op
17931834 }
1794 -
 1835+
17951836 // Copy-and-modify of Linker::formatComment
17961837 static function formatSubject( $s ) {
17971838 wfProfileIn( __METHOD__ );
Index: trunk/extensions/LiquidThreads/pages/ThreadDiffView.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class ThreadDiffView extends LqtView {
@@ -10,15 +9,15 @@
1110
1211 $content_actions['history']['class'] = 'selected';
1312 }
14 -
 13+
1514 function customizeNavigation( $skin, &$links ) {
1615 $remove = array( 'views/edit', 'views/viewsource' );
1716
18 - foreach( $remove as $rem ) {
19 - list($section, $item) = explode( '/', $rem, 2 );
 17+ foreach ( $remove as $rem ) {
 18+ list( $section, $item ) = explode( '/', $rem, 2 );
2019 unset( $links[$section][$item] );
2120 }
22 -
 21+
2322 $links['views']['history']['class'] = 'selected';
2423 }
2524 }
Index: trunk/extensions/LiquidThreads/pages/TalkpageHeaderView.php
@@ -1,8 +1,7 @@
22 <?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die;
34
4 -if ( !defined( 'MEDIAWIKI' ) ) die;
55 // Pass-through wrapper with an extra note at the top
6 -
76 class TalkpageHeaderView extends LqtView {
87 function customizeTabs( $skintemplate, &$content_actions ) {
98 unset( $content_actions['edit'] );
@@ -18,16 +17,20 @@
1918 'href' => '',
2019 );
2120 }
22 -
 21+
2322 function customizeNavigation( $skin, &$links ) {
24 - $remove = array( 'actions/edit', 'actions/addsection', 'views/history',
25 - 'actions/watch', 'actions/move' );
26 -
27 - foreach( $remove as $rem ) {
28 - list($section, $item) = explode( '/', $rem, 2 );
 23+ $remove = array(
 24+ 'actions/edit',
 25+ 'actions/addsection',
 26+ 'views/history',
 27+ 'actions/watch','actions/move'
 28+ );
 29+
 30+ foreach ( $remove as $rem ) {
 31+ list( $section, $item ) = explode( '/', $rem, 2 );
2932 unset( $links[$section][$item] );
3033 }
31 -
 34+
3235 $links['views']['header'] = array(
3336 'class' => 'selected',
3437 'text' => wfMsg( 'lqt-talkpage-history-tab' ),
@@ -40,30 +43,44 @@
4144
4245 if ( $wgRequest->getVal( 'action' ) === 'edit' ) {
4346 wfLoadExtensionMessages( 'LiquidThreads' );
44 -
 47+
4548 $html = '';
46 -
47 - $warn_bold = Xml::tags( 'strong', null,
48 - wfMsgExt( 'lqt_header_warning_bold', 'parseinline' ) );
49 -
50 - $warn_link =
51 - $this->talkpageLink( $wgTitle, wfMsgExt( 'lqt_header_warning_new_discussion',
52 - 'parseinline' ), 'talkpage_new_thread' );
53 -
54 - $html .= wfMsgExt( 'lqt_header_warning_before_big',
55 - array( 'parseinline', 'replaceafter' ),
56 - array( $warn_bold, $warn_link ) );
57 - $html .= Xml::tags( 'big', null,
58 - wfMsgExt( 'lqt_header_warning_big',
59 - array( 'parseinline', 'replaceafter' ),
60 - array( $warn_bold, $warn_link ) ) );
 49+
 50+ $warn_bold = Xml::tags(
 51+ 'strong',
 52+ null,
 53+ wfMsgExt( 'lqt_header_warning_bold', 'parseinline' )
 54+ );
 55+
 56+ $warn_link = $this->talkpageLink(
 57+ $wgTitle,
 58+ wfMsgExt( 'lqt_header_warning_new_discussion', 'parseinline' ),
 59+ 'talkpage_new_thread'
 60+ );
 61+
 62+ $html .= wfMsgExt(
 63+ 'lqt_header_warning_before_big',
 64+ array( 'parseinline', 'replaceafter' ),
 65+ array( $warn_bold, $warn_link )
 66+ );
 67+ $html .= Xml::tags(
 68+ 'big',
 69+ null,
 70+ wfMsgExt(
 71+ 'lqt_header_warning_big',
 72+ array( 'parseinline', 'replaceafter' ),
 73+ array( $warn_bold, $warn_link )
 74+ )
 75+ );
6176 $html .= wfMsg( 'word-separator' );
62 - $html .= wfMsgExt( 'lqt_header_warning_after_big',
63 - array( 'parseinline', 'replaceafter' ),
64 - array( $warn_bold, $warn_link ) );
65 -
 77+ $html .= wfMsgExt(
 78+ 'lqt_header_warning_after_big',
 79+ array( 'parseinline', 'replaceafter' ),
 80+ array( $warn_bold, $warn_link )
 81+ );
 82+
6683 $html = Xml::tags( 'p', array( 'class' => 'lqt_header_warning' ), $html );
67 -
 84+
6885 $wgOut->addHTML( $html );
6986 }
7087
Index: trunk/extensions/LiquidThreads/pages/ThreadProtectionFormView.php
@@ -1,35 +1,34 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 // Pass-through wrapper
76 class ThreadProtectionFormView extends LqtView {
87 function customizeTabs( $skintemplate, &$content_actions ) {
98 ThreadPermalinkView::customizeThreadTabs( $skintemplate, $content_actions, $this );
10 -
 9+
1110 if ( array_key_exists( 'protect', $content_actions ) )
1211 $content_actions['protect']['class'] = 'selected';
1312 else if ( array_key_exists( 'unprotect', $content_actions ) )
1413 $content_actions['unprotect']['class'] = 'selected';
1514 }
16 -
 15+
1716 function customizeNavigation( $skintemplate, &$links ) {
1817 ThreadPermalinkView::customizeThreadNavigation( $skintemplate, $links, $this );
19 -
 18+
2019 if ( isset( $links['actions']['protect'] ) ) {
2120 $links['actions']['protect']['class'] = 'selected';
2221 }
23 -
 22+
2423 if ( isset( $links['actions']['unprotect'] ) ) {
2524 $links['actions']['unprotect']['class'] = 'selected';
2625 }
2726 }
28 -
 27+
2928 function __construct( &$output, &$article, &$title, &$user, &$request ) {
3029 parent::__construct( $output, $article, $title, $user, $request );
3130
3231 $t = Threads::withRoot( $this->article );
33 -
 32+
3433 $this->thread = $t;
3534 if ( !$t ) {
3635 return;
Index: trunk/extensions/LiquidThreads/pages/IndividualThreadHistoryView.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class IndividualThreadHistoryView extends ThreadPermalinkView {
@@ -10,7 +9,7 @@
1110 parent::customizeTabs( $skintemplate, $content_actions );
1211 return true;
1312 }
14 -
 13+
1514 function customizeNavigation( $skin, &$links ) {
1615 $links['views']['history']['class'] = 'selected';
1716 parent::customizeNavigation( $skin, $links );
@@ -22,12 +21,16 @@
2322 function customizeSubtitle() {
2423 wfLoadExtensionMessages( 'LiquidThreads' );
2524 $msg = wfMsgExt( 'lqt_hist_view_whole_thread', 'parseinline' );
26 - $threadhist = $this->permalink( $this->thread->topmostThread(),
27 - $msg,
28 - 'thread_history' );
29 - $this->output->setSubtitle( parent::getSubtitle() . '<br />' .
30 - $this->output->getSubtitle() .
31 - "<br />$threadhist" );
 25+ $threadhist = $this->permalink(
 26+ $this->thread->topmostThread(),
 27+ $msg,
 28+ 'thread_history'
 29+ );
 30+ $this->output->setSubtitle(
 31+ parent::getSubtitle() . '<br />' .
 32+ $this->output->getSubtitle() .
 33+ "<br />$threadhist"
 34+ );
3235 return true;
3336 }
3437
@@ -40,7 +43,7 @@
4144
4245 function show() {
4346 global $wgHooks;
44 -
 47+
4548 if ( !$this->thread ) {
4649 $this->showMissingThreadPage();
4750 return false;
Index: trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php
@@ -1,9 +1,7 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class SpecialMoveThread extends ThreadActionPage {
7 -
86 /**
97 * @see SpecialPage::getDescription
108 */
@@ -11,61 +9,71 @@
1210 wfLoadExtensionMessages( 'LiquidThreads' );
1311 return wfMsg( 'lqt_movethread' );
1412 }
15 -
 13+
1614 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 - );
 15+ return array(
 16+ 'dest-title' => array(
 17+ 'label-message' => 'lqt_move_destinationtitle',
 18+ 'type' => 'text',
 19+ 'validation-callback' => array( $this, 'validateTarget' ),
 20+ ),
 21+ 'reason' => array(
 22+ 'label-message' => 'movereason',
 23+ 'type' => 'text',
 24+ )
 25+ );
3126 }
32 -
 27+
3328 function getPageName() { return 'MoveThread'; }
34 -
 29+
3530 function getSubmitText() {
3631 wfLoadExtensionMessages( 'LiquidThreads' );
3732 return wfMsg( 'lqt_move_move' );
3833 }
39 -
 34+
4035 function buildForm() {
4136 $form = parent::buildForm();
42 -
 37+
4338 // Generate introduction
4439 $intro = '';
45 -
 40+
4641 global $wgUser;
4742 $sk = $wgUser->getSkin();
4843 $page = $article_name = $this->mThread->article()->getTitle()->getPrefixedText();
49 -
 44+
5045 $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 -
 46+ $edit_link = $sk->link(
 47+ $this->mThread->title(),
 48+ $edit_text,
 49+ array(),
 50+ array(
 51+ 'lqt_method' => 'edit',
 52+ 'lqt_operand' => $this->mThread->id()
 53+ )
 54+ );
 55+
 56+ $intro .= wfMsgExt(
 57+ 'lqt_move_movingthread',
 58+ 'parse',
 59+ array( '[[' . $this->mTarget . ']]', '[[' . $page . ']]' )
 60+ );
 61+ $intro .= wfMsgExt(
 62+ 'lqt_move_torename',
 63+ array( 'parse', 'replaceafter' ),
 64+ array( $edit_link )
 65+ );
 66+
5967 $form->setIntro( $intro );
60 -
 68+
6169 return $form;
6270 }
63 -
 71+
6472 function checkUserRights( $oldTitle, $newTitle ) {
6573 global $wgUser, $wgOut;
66 -
 74+
6775 $oldErrors = $oldTitle->getUserPermissionsErrors( 'move', $wgUser );
6876 $newErrors = $newTitle->getUserPermissionsErrors( 'move', $wgUser );
69 -
 77+
7078 // Custom merge/unique function because we don't have the second parameter to
7179 // array_unique on Wikimedia.
7280 $mergedErrors = array();
@@ -76,54 +84,53 @@
7785 $mergedErrors[] = $value;
7886 }
7987 }
80 -
 88+
8189 if ( count( $mergedErrors ) > 0 ) {
82 - return $wgOut->parse(
83 - $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' )
84 - );
 90+ return $wgOut->parse(
 91+ $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' )
 92+ );
8593 }
8694
8795 return true;
8896 }
89 -
 97+
9098 function trySubmit( $data ) {
9199 // Load data
92100 $tmp = $data['dest-title'];
93101 $newtitle = Title::newFromText( $tmp );
94102 $reason = $data['reason'];
95 -
 103+
96104 $rightsResult = $this->checkUserRights( $this->mThread->title(), $newtitle );
97 -
 105+
98106 if ( $rightsResult !== true )
99107 return $rightsResult;
100108
101109 // TODO no status code from this method.
102110 $this->mThread->moveToPage( $newtitle, $reason, true );
103 -
 111+
104112 global $wgOut, $wgUser;
105113 $sk = $wgUser->getSkin();
106114 $wgOut->addHTML( wfMsgExt( 'lqt_move_success', array( 'parse', 'replaceafter' ),
107115 array( $sk->link( $newtitle ) ) ) );
108 -
 116+
109117 return true;
110118 }
111 -
 119+
112120 function validateTarget( $target ) {
113121 if ( !$target ) {
114122 return wfMsgExt( 'lqt_move_nodestination', 'parseinline' );
115123 }
116 -
 124+
117125 $title = Title::newFromText( $target );
118 -
 126+
119127 if ( !$title || !LqtDispatch::isLqtPage( $title ) ) {
120128 return wfMsgExt( 'lqt_move_thread_bad_destination', 'parseinline' );
121129 }
122 -
 130+
123131 if ( $title->equals( $this->mThread->article()->getTitle() ) ) {
124132 return wfMsgExt( 'lqt_move_samedestination', 'parseinline' );
125133 }
126 -
 134+
127135 return true;
128136 }
129 -
130137 }
Index: trunk/extensions/LiquidThreads/pages/ThreadActionPage.php
@@ -1,45 +1,44 @@
22 <?php
3 -
43 abstract class ThreadActionPage extends UnlistedSpecialPage {
54 protected $user, $output, $request, $title, $mThread;
65
76 function __construct() {
87 parent::__construct( $this->getPageName(), $this->getRightRequirement() );
98 $this->includable( false );
10 -
 9+
1110 global $wgOut, $wgUser, $wgRequest;
1211 $this->output = $wgOut;
1312 $this->user = $wgUser;
1413 $this->request = $wgRequest;
1514 }
16 -
 15+
1716 abstract function getPageName();
18 -
 17+
1918 abstract function getFormFields();
20 -
 19+
2120 protected function getRightRequirement() { return ''; }
2221
2322 function execute( $par ) {
2423 wfLoadExtensionMessages( 'LiquidThreads' );
25 -
 24+
2625 global $wgOut, $wgUser;
27 -
 26+
2827 if ( !$this->userCanExecute( $wgUser ) ) {
2928 $this->displayRestrictionError();
3029 return;
3130 }
32 -
 31+
3332 // Page title
3433 $wgOut->setPageTitle( $this->getDescription() );
35 -
 34+
3635 if ( !$this->checkParameters( $par ) ) {
3736 return;
3837 }
39 -
 38+
4039 $form = $this->buildForm();
4140 $form->show();
4241 }
43 -
 42+
4443 // Loads stuff like the thread and so on
4544 function checkParameters( $par ) {
4645 // Handle parameter
@@ -49,32 +48,31 @@
5049 $this->output->addHTML( wfMsg( 'lqt_threadrequired' ) );
5150 return false;
5251 }
53 -
 52+
5453 $thread = Threads::withRoot( new Article( Title::newFromURL( $par ) ) );
5554 if ( !$thread ) {
5655 $this->output->addHTML( wfMsg( 'lqt_nosuchthread' ) );
5756 return false;
5857 }
59 -
 58+
6059 $this->mThread = $thread;
61 -
 60+
6261 return true;
6362 }
64 -
 63+
6564 abstract function getSubmitText();
66 -
 65+
6766 function buildForm() {
6867 $form = new HTMLForm( $this->getFormFields(), 'lqt-' . $this->getPageName() );
69 -
 68+
7069 $par = $this->mThread->title()->getPrefixedText();
71 -
 70+
7271 $form->setSubmitText( $this->getSubmitText() );
7372 $form->setTitle( SpecialPage::getTitleFor( $this->getPageName(), $par ) );
7473 $form->setSubmitCallback( array( $this, 'trySubmit' ) );
75 -
 74+
7675 return $form;
7776 }
78 -
79 - abstract function trySubmit( $data );
8077
 78+ abstract function trySubmit( $data );
8179 }
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php
@@ -1,9 +1,7 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class ThreadHistoricalRevisionView extends ThreadPermalinkView {
7 -
86 public $mDisplayRevision = null;
97
108 /* TOOD: customize tabs so that History is highlighted. */
@@ -12,16 +10,16 @@
1311 $changedObject = $this->mDisplayRevision->getChangeObject();
1412 $is_changed_thread = $changedObject &&
1513 ( $changedObject->id() == $thread->id() );
16 -
 14+
1715 $class = parent::postDivClass( $thread );
18 -
 16+
1917 if ( $is_changed_thread ) {
2018 return "$class lqt_post_changed_by_history";
2119 } else {
2220 return $class;
2321 }
2422 }
25 -
 23+
2624 function getMessageForChangeType( $ct ) {
2725 static $messages = array(
2826 Threads::CHANGE_NEW_THREAD => 'lqt_change_new_thread',
@@ -38,11 +36,11 @@
3937 Threads::CHANGE_ROOT_BLANKED => 'lqt_change_root_blanked',
4038 Threads::CHANGE_EDITED_ROOT => 'lqt_change_edited_root',
4139 );
42 -
 40+
4341 if ( isset( $messages[$ct] ) ) {
4442 return $messages[$ct];
4543 }
46 -
 44+
4745 return '';
4846 }
4947
@@ -50,54 +48,55 @@
5149 global $wgLang;
5250 wfLoadExtensionMessages( 'LiquidThreads' );
5351
54 - $html = '';
55 - $html .= wfMsgExt( 'lqt_revision_as_of', 'parseinline',
 52+ $html = wfMsgExt(
 53+ 'lqt_revision_as_of',
 54+ 'parseinline',
5655 array(
5756 $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ),
5857 $wgLang->date( $this->mDisplayRevision->getTimestamp() ),
5958 $wgLang->time( $this->mDisplayRevision->getTimestamp() )
6059 )
6160 );
62 -
 61+
6362 $html .= '<br />';
64 -
6563 $html .= $this->getChangeDescription();
66 -
 64+
6765 $html = Xml::tags( 'div', array( 'class' => 'lqt_history_info' ), $html );
68 -
 66+
6967 $this->output->addHTML( $html );
7068 }
71 -
 69+
7270 function getChangeDescription( ) {
7371 $args = array();
74 -
 72+
7573 $revision = $this->mDisplayRevision;
7674 $change_type = $revision->getChangeType();
77 -
 75+
7876 $post = $revision->getChangeObject();
7977 $args[] = LqtView::linkInContextURL( $post );
80 -
 78+
8179 $msg = $this->getMessageForChangeType( $change_type );
82 -
 80+
8381 switch( $change_type ) {
8482 case Threads::CHANGE_EDITED_SUBJECT:
8583 $args[] = $revision->prev()->getChangeObject()->subject();
8684 $args[] = $revision->getChangeObject()->subject();
8785 break;
8886 }
89 -
 87+
9088 $html = wfMsgExt( $msg, 'parseinline', $args );
91 -
 89+
9290 if ( $change_type == Threads::CHANGE_ROOT_BLANKED ||
9391 $change_type == Threads::CHANGE_EDITED_ROOT ) {
94 - $diff_link = $this->diffPermalink( $post,
95 - wfMsgExt( 'diff', 'parseinline' ),
96 - $this->mDisplayRevision );
97 -
 92+ $diff_link = $this->diffPermalink(
 93+ $post,
 94+ wfMsgExt( 'diff', 'parseinline' ),
 95+ $this->mDisplayRevision
 96+ );
 97+
9898 $html .= " [$diff_link]";
 99+ }
99100
100 - }
101 -
102101 return $html;
103102 }
104103
@@ -106,31 +105,38 @@
107106 $this->showMissingThreadPage();
108107 return false;
109108 }
110 -
 109+
111110 $oldid = $this->request->getInt( 'lqt_oldid' );
112111 $this->mDisplayRevision = ThreadRevision::loadFromId( $oldid );
113112
114113 $this->thread = $this->mDisplayRevision->getThreadObj();
115 -
116 - if (!$this->mDisplayRevision) {
 114+
 115+ if ( !$this->mDisplayRevision ) {
117116 $this->showMissingThreadPage();
118117 return false;
119118 } elseif ( !$this->thread ) {
120119 $this->output->addWikiMsg( 'lqt-historicalrevision-error' );
121120 return false;
122121 }
123 -
 122+
124123 $this->showHistoryInfo();
125124
126125 self::addJSandCSS();
127126 $this->output->setSubtitle( $this->getSubtitle() );
128 -
 127+
129128 $changedObject = $this->mDisplayRevision->getChangeObject();
130129
131 - $this->showThread( $this->thread, 1, 1,
132 - array( 'maxDepth' => - 1, 'maxCount' => - 1,
133 - 'mustShowThreads' => array( $changedObject->id() ) ) );
134 -
 130+ $this->showThread(
 131+ $this->thread,
 132+ 1,
 133+ 1,
 134+ array(
 135+ 'maxDepth' => - 1,
 136+ 'maxCount' => - 1,
 137+ 'mustShowThreads' => array( $changedObject->id() )
 138+ )
 139+ );
 140+
135141 $this->output->setPageTitle( $this->thread->subject() );
136142 return false;
137143 }
Index: trunk/extensions/LiquidThreads/pages/TalkpageHistoryView.php
@@ -1,44 +1,43 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class TalkpageHistoryView extends TalkpageView {
76 function show() {
87 global $wgUser;
9 -
 8+
109 self::addJSandCSS();
1110 wfLoadExtensionMessages( 'LiquidThreads' );
12 -
 11+
1312 $sk = $wgUser->getSkin();
14 -
 13+
1514 $talkpageTitle = $this->article->getTitle();
1615 $talkpageLink = $sk->link( $talkpageTitle );
1716
1817 $this->output->setPageTitle( wfMsg( 'lqt-talkpage-history-title' ) );
19 - $this->output->setSubtitle(
20 - wfMsgExt( 'lqt-talkpage-history-subtitle',
21 - array( 'replaceafter', 'parseinline' ),
22 - $talkpageLink )
23 - );
24 -
 18+ $this->output->setSubtitle( wfMsgExt(
 19+ 'lqt-talkpage-history-subtitle',
 20+ array( 'replaceafter', 'parseinline' ),
 21+ $talkpageLink
 22+ ) );
 23+
2524 $pager = new TalkpageHistoryPager( $this, $this->article );
26 -
 25+
2726 $html = $pager->getNavigationBar() .
28 - $pager->getBody() .
29 - $pager->getNavigationBar();
30 -
 27+ $pager->getBody() .
 28+ $pager->getNavigationBar();
 29+
3130 $this->output->addHTML( $html );
32 -
 31+
3332 return false;
3433 }
35 -
 34+
3635 function customizeTabs( $skin, &$links ) {
3736 TalkpageView::customizeTalkpageTabs( $skin, $links, $this );
38 -
 37+
3938 $tabid = $this->article->getTitle()->getNamespaceKey();
4039 $links['history']['class'] = 'selected';
4140 }
42 -
 41+
4342 function customizeNavigation( $skin, &$links ) {
4443 TalkpageView::customizeTalkpageNavigation( $skin, $links, $this );
4544 $links['views']['history']['class'] = 'selected';
@@ -49,10 +48,10 @@
5049 class TalkpageHistoryPager extends ThreadHistoryPager {
5150 function __construct( $view, $talkpage ) {
5251 $this->talkpage = $talkpage;
53 -
 52+
5453 parent::__construct( $view, null );
5554 }
56 -
 55+
5756 function getFieldMessages() {
5857 $headers = array(
5958 'th_timestamp' => 'lqt-history-time',
@@ -61,26 +60,25 @@
6261 'th_change_type' => 'lqt-history-action',
6362 'th_change_comment' => 'lqt-history-comment',
6463 );
65 -
 64+
6665 return $headers;
6766 }
68 -
 67+
6968 function getQueryInfo() {
70 - $queryInfo =
71 - array(
72 - 'tables' => array( 'thread_history', 'thread', 'page' ),
73 - 'fields' => '*',
74 - 'conds' => array( Threads::articleClause( $this->talkpage ) ),
75 - 'options' => array( 'order by' => 'th_timestamp desc' ),
76 - 'join_conds' => array(
77 - 'thread' => array( 'LEFT JOIN', 'thread_id=th_thread' ),
78 - 'page' => array( 'LEFT JOIN', 'thread_root=page_id' ),
79 - ),
80 - );
81 -
 69+ $queryInfo = array(
 70+ 'tables' => array( 'thread_history', 'thread', 'page' ),
 71+ 'fields' => '*',
 72+ 'conds' => array( Threads::articleClause( $this->talkpage ) ),
 73+ 'options' => array( 'order by' => 'th_timestamp desc' ),
 74+ 'join_conds' => array(
 75+ 'thread' => array( 'LEFT JOIN', 'thread_id=th_thread' ),
 76+ 'page' => array( 'LEFT JOIN', 'thread_root=page_id' ),
 77+ ),
 78+ );
 79+
8280 return $queryInfo;
8381 }
84 -
 82+
8583 function formatValue( $name, $value ) {
8684 global $wgOut, $wgLang, $wgTitle;
8785
@@ -92,23 +90,36 @@
9391 }
9492
9593 $row = $this->mCurrentRow;
96 -
 94+
9795 switch( $name ) {
9896 case 'thread_subject':
99 - $title = Title::makeTitleSafe( $row->page_namespace,
100 - $row->page_title );
101 -
102 - $link = $sk->link( $title, $value, array(), array(),
103 - array( 'known' ) );
104 -
 97+ $title = Title::makeTitleSafe(
 98+ $row->page_namespace,
 99+ $row->page_title
 100+ );
 101+
 102+ $link = $sk->link(
 103+ $title,
 104+ $value,
 105+ array(),
 106+ array(),
 107+ array( 'known' )
 108+ );
 109+
105110 return $link;
106111 case 'th_timestamp':
107112 $formatted = $wgLang->timeanddate( $value );
108 - $title = Title::makeTitleSafe( $row->page_namespace,
109 - $row->page_title );
110 -
111 - return $sk->link( $title, $formatted, array(),
112 - array( 'lqt_oldid' => $row->th_id ) );
 113+ $title = Title::makeTitleSafe(
 114+ $row->page_namespace,
 115+ $row->page_title
 116+ );
 117+
 118+ return $sk->link(
 119+ $title,
 120+ $formatted,
 121+ array(),
 122+ array( 'lqt_oldid' => $row->th_id )
 123+ );
113124 default:
114125 return parent::formatValue( $name, $value );
115126 }
Index: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php
@@ -1,42 +1,41 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class ThreadPermalinkView extends LqtView {
76 protected $thread;
8 -
 7+
98 function customizeTabs( $skin, &$links ) {
109 self::customizeThreadTabs( $skin, $links, $this );
1110 }
12 -
 11+
1312 function customizeNavigation( $skin, &$links ) {
1413 self::customizeThreadNavigation( $skin, $links, $this );
1514 }
1615
1716 static function customizeThreadTabs( $skintemplate, &$content_actions, $view ) {
1817 wfLoadExtensionMessages( 'LiquidThreads' );
19 -
 18+
2019 if ( !$view->thread ) {
2120 return true;
2221 }
23 -
 22+
2423 // Insert 'article' and 'discussion' tabs before the thread tab.
25 -
 24+
2625 $tabs = self::getCustomTabs( $view );
2726 $content_actions = $tabs + $content_actions;
2827
2928 unset( $content_actions['edit'] );
3029 unset( $content_actions['viewsource'] );
3130 unset( $content_actions['talk'] );
32 -
 31+
3332 $subpage = $view->thread->title()->getPrefixedText();
34 -
 33+
3534 // Repoint move/delete/history tabs
3635 if ( array_key_exists( 'move', $content_actions ) && $view->thread ) {
3736 $content_actions['move']['href'] =
3837 SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL();
3938 }
40 -
 39+
4140 if ( array_key_exists( 'delete', $content_actions ) && $view->thread ) {
4241 $content_actions['delete']['href'] =
4342 $view->thread->title()->getFullURL( 'action=delete' );
@@ -51,40 +50,40 @@
5251
5352 return true;
5453 }
55 -
 54+
5655 static function customizeThreadNavigation( $skin, &$links, $view ) {
5756 if ( !$view->thread ) {
5857 return true;
5958 }
60 -
 59+
6160 // Insert 'article' and 'discussion' namespace-tabs
6261 $new_nstabs = self::getCustomTabs( $view );
63 -
 62+
6463 $nstabs =& $links['namespaces'];
6564
66 - $talkKey = $view->thread->title()->getNamespaceKey('').'_talk';
 65+ $talkKey = $view->thread->title()->getNamespaceKey( '' ) . '_talk';
6766 unset( $nstabs[$talkKey] );
6867 $nstabs = $new_nstabs + $nstabs;
69 -
 68+
7069 // Remove some views.
7170 $views =& $links['views'];
7271 unset( $views['viewsource'] );
7372 unset( $views['edit'] );
74 -
 73+
7574 // Re-point move, delete and history actions
7675 $subpage = $view->thread->title()->getPrefixedText();
7776 $actions =& $links['actions'];
78 - if ( isset($actions['move']) ) {
 77+ if ( isset( $actions['move'] ) ) {
7978 $actions['move']['href'] =
8079 SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL();
8180 }
82 -
83 - if ( isset($actions['delete']) ) {
 81+
 82+ if ( isset( $actions['delete'] ) ) {
8483 $actions['delete']['href'] =
8584 $view->thread->title()->getFullURL( 'action=delete' );
8685 }
87 -
88 - if ( isset($views['history']) ) {
 86+
 87+ if ( isset( $views['history'] ) ) {
8988 $views['history']['href'] =
9089 self::permalinkUrl( $view->thread, 'thread_history' );
9190 if ( $view->methodApplies( 'thread_history' ) ) {
@@ -92,30 +91,30 @@
9392 }
9493 }
9594 }
96 -
 95+
9796 // Pre-generates the tabs to be included, for customizeTabs and customizeNavigation
9897 // to insert in the appropriate place
9998 static function getCustomTabs( $view ) {
10099 $tabs = array();
101 -
 100+
102101 $articleTitle = $view->thread->article()->getTitle()->getSubjectPage();
103102 $talkTitle = $view->thread->article()->getTitle()->getTalkPage();
104 -
 103+
105104 $articleClasses = array();
106105 if ( !$articleTitle->exists() ) $articleClasses[] = 'new';
107106 if ( $articleTitle->equals( $view->thread->article()->getTitle() ) )
108107 $articleClasses[] = 'selected';
109 -
 108+
110109 $talkClasses = array();
111110 if ( !$talkTitle->exists() ) $talkClasses[] = 'new';
112 -
 111+
113112 $tabs['article'] =
114113 array(
115114 'text' => wfMsg( $articleTitle->getNamespaceKey() ),
116115 'href' => $articleTitle->getFullURL(),
117116 'class' => implode( ' ', $articleClasses ),
118117 );
119 -
 118+
120119 $tabs['lqt_talk'] =
121120 array(
122121 // talkpage certainly exists since this thread is from it.
@@ -123,7 +122,7 @@
124123 'href' => $talkTitle->getFullURL(),
125124 'class' => implode( ' ', $talkClasses ),
126125 );
127 -
 126+
128127 return $tabs;
129128 }
130129
@@ -144,33 +143,39 @@
145144
146145 function getSubtitle() {
147146 wfLoadExtensionMessages( 'LiquidThreads' );
148 -
 147+
149148 $sk = $this->user->getSkin();
150149 $fragment = '#' . $this->anchorName( $this->thread );
151 -
 150+
152151 if ( $this->thread->isHistorical() ) {
153152 // TODO: Point to the relevant part of the archive.
154153 $query = '';
155154 } else {
156155 $query = '';
157156 }
158 -
 157+
159158 $talkpage = $this->thread->article()->getTitle();
160159 $talkpage->setFragment( $fragment );
161160 $talkpage_link = $sk->link( $talkpage );
162 -
 161+
163162 if ( $this->thread->hasSuperthread() ) {
164163 $topmostTitle = $this->thread->topmostThread()->title();
165164 $topmostTitle->setFragment( $fragment );
166 -
 165+
167166 $linkText = wfMsgExt( 'lqt_discussion_link', 'parseinline' );
168167 $permalink = $sk->link( $topmostTitle, $linkText );
169 -
170 - return wfMsgExt( 'lqt_fragment', array( 'parseinline', 'replaceafter' ),
171 - array( $permalink, $talkpage_link ) );
 168+
 169+ return wfMsgExt(
 170+ 'lqt_fragment',
 171+ array( 'parseinline', 'replaceafter' ),
 172+ array( $permalink, $talkpage_link )
 173+ );
172174 } else {
173 - return wfMsgExt( 'lqt_from_talk', array( 'parseinline', 'replaceafter' ),
174 - array( $talkpage_link ) );
 175+ return wfMsgExt(
 176+ 'lqt_from_talk',
 177+ array( 'parseinline', 'replaceafter' ),
 178+ array( $talkpage_link )
 179+ );
175180 }
176181 }
177182
@@ -178,7 +183,7 @@
179184 parent::__construct( $output, $article, $title, $user, $request );
180185
181186 $t = Threads::withRoot( $this->article );
182 -
 187+
183188 $this->thread = $t;
184189 if ( !$t ) {
185190 return;
@@ -194,24 +199,27 @@
195200 $this->showMissingThreadPage();
196201 return false;
197202 }
198 -
 203+
199204 if ( $this->request->getBool( 'lqt_inline' ) ) {
200205 $this->doInlineEditForm();
201206 return false;
202207 }
203 -
 208+
204209 // Handle action=edit stuff
205210 if ( $this->request->getVal( 'action' ) == 'edit' ) {
206211 // Rewrite to lqt_method = edit
207212 $this->request->setVal( 'lqt_method', 'edit' );
208213 $this->request->setVal( 'lqt_operand', $this->thread->id() );
209214 }
210 -
 215+
211216 // Expose feed links.
212217 global $wgFeedClasses, $wgScriptPath, $wgServer;
213218 $thread = $this->thread->topmostThread()->title()->getPrefixedText();
214 - $apiParams = array( 'action' => 'feedthreads', 'type' => 'replies|newthreads',
215 - 'thread' => $thread );
 219+ $apiParams = array(
 220+ 'action' => 'feedthreads',
 221+ 'type' => 'replies|newthreads',
 222+ 'thread' => $thread
 223+ );
216224 $urlPrefix = wfScript( 'api' ) . '?';
217225 foreach ( $wgFeedClasses as $format => $class ) {
218226 $theseParams = $apiParams + array( 'feedformat' => $format );
@@ -228,7 +236,7 @@
229237 $this->showSplitForm( $this->thread );
230238
231239 $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => - 1, 'maxCount' => - 1 ) );
232 -
 240+
233241 $this->output->setPageTitle( $this->thread->subject() );
234242 return false;
235243 }
Index: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php
@@ -1,9 +1,7 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class NewUserMessagesView extends LqtView {
7 -
86 protected $threads;
97 protected $tops;
108 protected $targets;
@@ -13,11 +11,16 @@
1412 $html = '';
1513 $html .= Xml::hidden( 'lqt_method', 'mark_as_read' );
1614 $html .= Xml::hidden( 'lqt_operand', $ids_s );
17 - $html .= Xml::submitButton( $label,
18 - array( 'name' => 'lqt_read_button',
19 - 'title' => $title, 'class' => 'lqt-read-button' ) );
 15+ $html .= Xml::submitButton(
 16+ $label,
 17+ array(
 18+ 'name' => 'lqt_read_button',
 19+ 'title' => $title,
 20+ 'class' => 'lqt-read-button'
 21+ )
 22+ );
2023 $html = Xml::tags( 'form', array( 'method' => 'post', 'class' => $class ), $html );
21 -
 24+
2225 return $html;
2326 }
2427
@@ -25,16 +28,16 @@
2629 wfLoadExtensionMessages( 'LiquidThreads' );
2730 $ids = array_map( create_function( '$t', 'return $t->id();' ), $threads ); // ew
2831 return $this->htmlForReadButton(
29 - wfMsg( 'lqt-read-all' ),
30 - wfMsg( 'lqt-read-all-tooltip' ),
31 - "lqt_newmessages_read_all_button",
32 - $ids
33 - );
 32+ wfMsg( 'lqt-read-all' ),
 33+ wfMsg( 'lqt-read-all-tooltip' ),
 34+ "lqt_newmessages_read_all_button",
 35+ $ids
 36+ );
3437 }
3538
3639 function getUndoButton( $ids ) {
3740 wfLoadExtensionMessages( 'LiquidThreads' );
38 -
 41+
3942 if ( count( $ids ) == 1 ) {
4043 $t = Threads::withId( $ids[0] );
4144 if ( !$t )
@@ -45,49 +48,56 @@
4649 $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) );
4750 }
4851 $operand = implode( ',', $ids );
49 -
 52+
5053 $html = '';
5154 $html .= $msg;
5255 $html .= Xml::hidden( 'lqt_method', 'mark_as_unread' );
5356 $html .= Xml::hidden( 'lqt_operand', $operand );
54 - $html .= Xml::submitButton( wfMsg( 'lqt-email-undo' ), array( 'name' => 'lqt_read_button',
55 - 'title' => wfMsg( 'lqt-email-info-undo' ) ) );
56 -
57 - $html = Xml::tags( 'form',
58 - array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ),
59 - $html );
60 -
 57+ $html .= Xml::submitButton(
 58+ wfMsg( 'lqt-email-undo' ),
 59+ array(
 60+ 'name' => 'lqt_read_button',
 61+ 'title' => wfMsg( 'lqt-email-info-undo' )
 62+ )
 63+ );
 64+
 65+ $html = Xml::tags(
 66+ 'form',
 67+ array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ),
 68+ $html
 69+ );
 70+
6171 return $html;
6272 }
6373
6474 function postDivClass( $thread ) {
6575 $origClass = parent::postDivClass( $thread );
66 -
 76+
6777 $topid = $thread->topmostThread()->id();
68 -
 78+
6979 if ( isset( $this->targets[$topid] ) && is_array( $this->targets[$topid] ) &&
7080 in_array( $thread->id(), $this->targets[$topid] ) )
7181 return "$origClass lqt_post_new_message";
72 -
 82+
7383 return $origClass;
7484 }
7585
7686 function showOnce() {
7787 self::addJSandCSS();
78 -
 88+
7989 static $scriptDone = false;
80 -
 90+
8191 if ( !$scriptDone ) {
8292 global $wgOut, $wgScriptPath, $wgLiquidThreadsExtensionName;
8393 $prefix = "{$wgScriptPath}/extensions/{$wgLiquidThreadsExtensionName}";
8494 $wgOut->addScriptFile( "$prefix/newmessages.js" );
8595 }
86 -
 96+
8797 $this->user->setNewtalk( false );
8898
8999 if ( $this->methodApplies( 'mark_as_unread' ) ) {
90100 $ids = explode( ',', $this->request->getVal( 'lqt_operand', '' ) );
91 -
 101+
92102 if ( $ids !== false ) {
93103 foreach ( $ids as $id ) {
94104 $tmp_thread = Threads::withId( $id ); if ( $tmp_thread )
@@ -124,7 +134,7 @@
125135 $this->tops = array();
126136 foreach ( $this->threads as $t ) {
127137 $top = $t->topmostThread();
128 -
 138+
129139 // It seems that in some cases $top is zero.
130140 if ( !$top )
131141 throw new MWException( "{$t->id()} seems to have no topmost thread" );
@@ -135,7 +145,7 @@
136146 $this->targets[$top->id()] = array();
137147 $this->targets[$top->id()][] = $t->id();
138148 }
139 -
 149+
140150 $this->output->addHTML( '<table class="lqt-new-messages"><tbody>' );
141151
142152 foreach ( $this->tops as $t ) {
@@ -145,42 +155,49 @@
146156
147157 $this->showWrappedThread( $t );
148158 }
149 -
 159+
150160 $this->output->addHTML( '</tbody></table>' );
151 -
 161+
152162 return false;
153163 }
154 -
 164+
155165 function showWrappedThread( $t ) {
156166 wfLoadExtensionMessages( 'LiquidThreads' );
157 -
 167+
158168 $read_button = $this->htmlForReadButton(
159169 wfMsg( 'lqt-read-message' ),
160170 wfMsg( 'lqt-read-message-tooltip' ),
161171 'lqt_newmessages_read_button',
162172 $this->targets[$t->id()] );
163 -
 173+
164174 // Left-hand column read button and context link to the full thread.
165175 global $wgUser;
166176 $topmostThread = $t->topmostThread();
167177 $sk = $wgUser->getSkin();
168178 $title = clone $topmostThread->article()->getTitle();
169179 $title->setFragment( '#' . $t->getAnchorName() );
170 -
 180+
171181 // Make sure it points to the right page. The Pager seems to use the DB
172182 // representation of a timestamp for its offset field, odd.
173183 $dbr = wfGetDB( DB_SLAVE );
174184 $offset = wfTimestamp( TS_UNIX, $topmostThread->modified() ) + 1;
175185 $offset = $dbr->timestamp( $offset );
176 -
177 - $contextLink = $sk->link( $title,
178 - wfMsgExt( 'lqt-newmessages-context', 'parseinline' ), array(),
179 - array( 'offset' => $offset ), array( 'known' ) );
180 -
 186+
 187+ $contextLink = $sk->link(
 188+ $title,
 189+ wfMsgExt( 'lqt-newmessages-context', 'parseinline' ),
 190+ array(),
 191+ array( 'offset' => $offset ),
 192+ array( 'known' )
 193+ );
 194+
181195 $talkpageLink = $sk->link( $topmostThread->article()->getTitle() );
182 - $talkpageInfo = wfMsgExt( 'lqt-newmessages-from',
183 - array( 'parse', 'replaceafter' ), $talkpageLink );
184 -
 196+ $talkpageInfo = wfMsgExt(
 197+ 'lqt-newmessages-from',
 198+ array( 'parse', 'replaceafter' ),
 199+ $talkpageLink
 200+ );
 201+
185202 $leftColumn = Xml::tags( 'p', null, $read_button ) .
186203 Xml::tags( 'p', null, $contextLink ) .
187204 $talkpageInfo;
@@ -192,7 +209,7 @@
193210 $mustShowThreads = $this->targets[$t->id()];
194211
195212 $this->showThread( $t, 1, 1, array( 'mustShowThreads' => $mustShowThreads ) );
196 -
 213+
197214 $this->output->addHTML( "</td></tr>" );
198215 }
199216
Index: trunk/extensions/LiquidThreads/pages/SpecialHotTopics.php
@@ -1,31 +1,30 @@
22 <?php
3 -
43 class SpecialHotTopics extends SpecialPage {
54 function __construct() {
65 parent::__construct( 'HotTopics' );
76 }
8 -
 7+
98 function execute( $par ) {
109 global $wgOut;
11 -
 10+
1211 wfLoadExtensionMessages( 'LiquidThreads' );
13 -
 12+
1413 $this->setHeaders();
15 -
 14+
1615 $wgOut->setPageTitle( wfMsg( 'lqt-hot-topics' ) );
1716 $view = LqtView::getView();
18 -
 17+
1918 LqtView::addJsAndCss();
20 -
 19+
2120 // Get hot topics
2221 $topics = LqtHotTopicsController::getHotThreads();
23 -
24 - foreach( $topics as $thread ) {
 22+
 23+ foreach ( $topics as $thread ) {
2524 $view->showThread( $thread );
2625 }
2726 }
28 -
29 - function getPageName() {
 27+
 28+ function getPageName() {
3029 return wfMsg( 'lqt-hot-topics' );
3130 }
3231 }
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoryListingView.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class ThreadHistoryListingView extends ThreadPermalinkView {
@@ -10,36 +9,37 @@
1110 }
1211 self::addJSandCSS();
1312 wfLoadExtensionMessages( 'LiquidThreads' );
14 -
 13+
1514 $this->thread->updateHistory();
1615
1716 $this->output->setPageTitle( wfMsg( 'lqt-history-title' ) );
18 - $this->output->setSubtitle( $this->getSubtitle() . '<br />' .
19 - wfMsg( 'lqt_hist_listing_subtitle' ) );
 17+ $this->output->setSubtitle(
 18+ $this->getSubtitle() . '<br />' .
 19+ wfMsg( 'lqt_hist_listing_subtitle' )
 20+ );
2021 $this->showThreadHeading( $this->thread );
21 -
 22+
2223 $pager = new ThreadHistoryPager( $this, $this->thread );
23 -
 24+
2425 $html = $pager->getNavigationBar() .
2526 $pager->getBody() .
2627 $pager->getNavigationBar();
27 -
 28+
2829 $this->output->addHTML( $html );
29 -
 30+
3031 $this->showThread( $this->thread );
31 -
 32+
3233 return false;
3334 }
34 -
 35+
3536 function customizeTabs( $skin, &$links ) {
3637 parent::customizeTabs( $skin, $links );
3738 $links['history']['class'] = 'selected';
3839 }
39 -
40 - function customizeNavigation( $skin, &$links ) {
 40+
 41+ function customizeNavigation( $skin, &$links ) {
4142 parent::customizeNavigation( $skin, $links );
4243 $links['views']['history']['class'] = 'selected';
4344 $links['views']['view']['class'] = '';
4445 }
4546 }
46 -
Index: trunk/extensions/LiquidThreads/pages/SpecialNewMessages.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class SpecialNewMessages extends SpecialPage {
@@ -26,16 +25,16 @@
2726 $this->request = $wgRequest;
2827
2928 $this->setHeaders();
30 -
 29+
3130 $article = new Article( $this->getTitle() );
3231 $title = $this->getTitle();
33 -
 32+
3433 // Clear newtalk
3534 $this->user->setNewtalk( false );
3635
3736 $view = new NewUserMessagesView( $this->output, $article,
3837 $title, $this->user, $this->request );
39 -
 38+
4039 if ( $this->request->getBool( 'lqt_inline' ) ) {
4140 $view->doInlineEditForm();
4241 return;
@@ -50,21 +49,27 @@
5150 $wgOut->addWikitext( wfMsg( 'lqt-no-new-messages' ) );
5251 return;
5352 }
54 -
 53+
5554 $html = '';
56 -
 55+
5756 $html .= $view->getReadAllButton( $both_sets );
5857
5958 $view->setHeaderLevel( 3 );
6059
61 - $html .= Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ),
62 - wfMsgExt( 'lqt-messages-sent', 'parseinline' ) );
 60+ $html .= Xml::tags(
 61+ 'h2',
 62+ array( 'class' => 'lqt_newmessages_section' ),
 63+ wfMsgExt( 'lqt-messages-sent', 'parseinline' )
 64+ );
6365 $wgOut->addHTML( $html );
6466 $view->setThreads( $first_set );
6567 $view->show();
6668
67 - $wgOut->addHTML( Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ),
68 - wfMsgExt( 'lqt-other-messages', 'parseinline' ) ) );
 69+ $wgOut->addHTML( Xml::tags(
 70+ 'h2',
 71+ array( 'class' => 'lqt_newmessages_section' ),
 72+ wfMsgExt( 'lqt-other-messages', 'parseinline' )
 73+ ) );
6974 $view->setThreads( $second_set );
7075 $view->show();
7176 }
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class TalkpageView extends LqtView {
@@ -17,33 +16,33 @@
1817 $content_actions['history']['href'] = $history_url;
1918 }
2019 }
21 -
 20+
2221 static function customizeTalkpageNavigation( $skin, &$links, $view ) {
2322 $remove = array( 'views/edit', 'views/viewsource', 'actions/delete' );
24 -
25 - foreach( $remove as $rem ) {
26 - list($section, $item) = explode( '/', $rem, 2 );
 23+
 24+ foreach ( $remove as $rem ) {
 25+ list( $section, $item ) = explode( '/', $rem, 2 );
2726 unset( $links[$section][$item] );
2827 }
29 -
 28+
3029 if ( isset( $links['views']['history'] ) ) {
3130 $title = $view->article->getTitle();
3231 $history_url = $title->getFullURL( 'lqt_method=talkpage_history' );
3332 $links['views']['history']['href'] = $history_url;
3433 }
3534 }
36 -
 35+
3736 function customizeTabs( $skintemplate, &$links ) {
3837 self::customizeTalkpageTabs( $skintemplate, $links, $this );
3938 }
40 -
 39+
4140 function customizeNavigation( $skintemplate, &$links ) {
4241 self::customizeTalkpageNavigation( $skintemplate, $links, $this );
4342 }
4443
4544 function showHeader() {
4645 /* Show the contents of the actual talkpage article if it exists. */
47 -
 46+
4847 global $wgUser;
4948 $sk = $wgUser->getSkin();
5049
@@ -56,23 +55,32 @@
5756 // when the first thread was posted to make the links blue.
5857 if ( $article->exists() ) {
5958 $html = '';
60 -
 59+
6160 $article->view();
62 -
 61+
6362 $actionLinks = array();
64 - $actionLinks[] = $sk->link( $this->title,
65 - wfMsgExt( 'edit', 'parseinline' ) . "&uarr;",
66 - array(), array( 'action' => 'edit' ) );
67 - $actionLinks[] = $sk->link( $this->title,
68 - wfMsgExt( 'history_short', 'parseinline' ) . "&uarr;",
69 - array(), array( 'action' => 'history' ) );
70 -
 63+ $actionLinks[] = $sk->link(
 64+ $this->title,
 65+ wfMsgExt( 'edit', 'parseinline' ) . "&uarr;",
 66+ array(),
 67+ array( 'action' => 'edit' )
 68+ );
 69+ $actionLinks[] = $sk->link(
 70+ $this->title,
 71+ wfMsgExt( 'history_short', 'parseinline' ) . "&uarr;",
 72+ array(),
 73+ array( 'action' => 'history' )
 74+ );
 75+
7176 if ( $wgUser->isAllowed( 'delete' ) ) {
72 - $actionLinks[] = $sk->link( $this->title,
73 - wfMsgExt( 'delete', 'parseinline' ) . '&uarr;',
74 - array(), array( 'action' => 'delete' ) );
 77+ $actionLinks[] = $sk->link(
 78+ $this->title,
 79+ wfMsgExt( 'delete', 'parseinline' ) . '&uarr;',
 80+ array(),
 81+ array( 'action' => 'delete' )
 82+ );
7583 }
76 -
 84+
7785 $actions = '';
7886 foreach ( $actionLinks as $link ) {
7987 $actions .= Xml::tags( 'li', null, "[$link]" ) . "\n";
@@ -81,30 +89,34 @@
8290 $html .= $actions;
8391
8492 $html = Xml::tags( 'div', array( 'class' => 'lqt_header_content' ), $html );
85 -
 93+
8694 $this->output->addHTML( $html );
8795 } else {
88 -
89 - $editLink = $sk->link( $this->title, wfMsgExt( 'lqt_add_header', 'parseinline' ),
90 - array(), array( 'action' => 'edit' ) );
91 -
 96+
 97+ $editLink = $sk->link(
 98+ $this->title,
 99+ wfMsgExt( 'lqt_add_header', 'parseinline' ),
 100+ array(),
 101+ array( 'action' => 'edit' )
 102+ );
 103+
92104 $html = Xml::tags( 'p', array( 'class' => 'lqt_header_notice' ), "[$editLink]" );
93 -
 105+
94106 $this->output->addHTML( $html );
95107 }
96108 }
97 -
 109+
98110 function getTOC( $threads ) {
99111 global $wgLang;
100 -
 112+
101113 wfLoadExtensionMessages( 'LiquidThreads' );
102114
103115 $sk = $this->user->getSkin();
104 -
 116+
105117 $html = '';
106 -
 118+
107119 $h2_header = Xml::tags( 'h2', null, wfMsgExt( 'lqt_contents_title', 'parseinline' ) );
108 -
 120+
109121 // Header row
110122 $headerRow = '';
111123 $headers = array( 'lqt_toc_thread_title',
@@ -114,7 +126,7 @@
115127 }
116128 $headerRow = Xml::tags( 'tr', null, $headerRow );
117129 $headerRow = Xml::tags( 'thead', null, $headerRow );
118 -
 130+
119131 // Table body
120132 $rows = array();
121133 foreach ( $threads as $thread ) {
@@ -122,42 +134,42 @@
123135 !LqtView::threadContainsRepliesWithContent( $thread ) ) {
124136 continue;
125137 }
126 -
 138+
127139 $row = '';
128140 $anchor = '#' . $this->anchorName( $thread );
129141 $subject = Xml::tags( 'a', array( 'href' => $anchor ),
130142 Threads::stripHTML( $thread->formattedSubject() ) );
131143 $row .= Xml::tags( 'td', null, $subject );
132 -
 144+
133145 $row .= Xml::element( 'td', null, $thread->replyCount() );
134 -
 146+
135147 $timestamp = $wgLang->timeanddate( $thread->modified(), true );
136148 $row .= Xml::element( 'td', null, $timestamp );
137 -
 149+
138150 $row = Xml::tags( 'tr', null, $row );
139151 $rows[] = $row;
140152 }
141 -
 153+
142154 $html .= $headerRow . "\n" . Xml::tags( 'tbody', null, implode( "\n", $rows ) );
143155 $html = $h2_header . Xml::tags( 'table', array( 'class' => 'lqt_toc' ), $html );
144 -
 156+
145157 return $html;
146158 }
147 -
 159+
148160 function getList( $kind, $class, $id, $contents ) {
149161 $html = '';
150162 foreach ( $contents as $li ) {
151163 $html .= Xml::tags( 'li', null, $li );
152164 }
153165 $html = Xml::tags( $kind, array( 'class' => $class, 'id' => $id ), $html );
154 -
 166+
155167 return $html;
156168 }
157169
158170 function getArchiveWidget( ) {
159171 wfLoadExtensionMessages( 'LiquidThreads' );
160172 $url = $this->talkpageUrl( $this->title, 'talkpage_archive' );
161 -
 173+
162174 $html = '';
163175 $html = Xml::tags( 'div', array( 'class' => 'lqt_archive_teaser' ), $html );
164176 return $html;
@@ -169,32 +181,44 @@
170182 if ( $article->exists() ) {
171183 $form_action_url = $this->talkpageUrl( $this->title, 'talkpage_sort_order' );
172184 $go = wfMsg( 'go' );
173 -
 185+
174186 $html = '';
175 -
 187+
176188 $html .= Xml::label( wfMsg( 'lqt_sorting_order' ), 'lqt_sort_select' ) . ' ';
177189
178190 $sortOrderSelect =
179191 new XmlSelect( 'lqt_order', 'lqt_sort_select', $this->getSortType() );
180 -
 192+
181193 $sortOrderSelect->setAttribute( 'class', 'lqt_sort_select' );
182 - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_changes' ),
183 - LQT_NEWEST_CHANGES );
184 - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_threads' ),
185 - LQT_NEWEST_THREADS );
186 - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_oldest_threads' ),
187 - LQT_OLDEST_THREADS );
 194+ $sortOrderSelect->addOption(
 195+ wfMsg( 'lqt_sort_newest_changes' ),
 196+ LQT_NEWEST_CHANGES
 197+ );
 198+ $sortOrderSelect->addOption(
 199+ wfMsg( 'lqt_sort_newest_threads' ),
 200+ LQT_NEWEST_THREADS
 201+ );
 202+ $sortOrderSelect->addOption(
 203+ wfMsg( 'lqt_sort_oldest_threads' ),
 204+ LQT_OLDEST_THREADS
 205+ );
188206 $html .= $sortOrderSelect->getHTML();
189 -
 207+
190208 $html .= Xml::submitButton( wfMsg( 'go' ), array( 'class' => 'lqt_go_sort' ) );
191209 $html .= Xml::hidden( 'title', $this->title->getPrefixedText() );
192 -
193 -
194 - $html = Xml::tags( 'form', array( 'action' => $form_action_url,
195 - 'method' => 'get',
196 - 'name' => 'lqt_sort' ), $html );
 210+
 211+
 212+ $html = Xml::tags(
 213+ 'form',
 214+ array(
 215+ 'action' => $form_action_url,
 216+ 'method' => 'get',
 217+ 'name' => 'lqt_sort'
 218+ ),
 219+ $html
 220+ );
197221 $html = Xml::tags( 'div', array( 'class' => 'lqt_view_options' ), $html );
198 -
 222+
199223 return $html;
200224 }
201225 }
@@ -204,7 +228,7 @@
205229
206230 $this->output->setPageTitle( $this->title->getPrefixedText() );
207231 self::addJSandCSS();
208 -
 232+
209233 // Expose feed links.
210234 global $wgFeedClasses, $wgScriptPath, $wgServer;
211235 $apiParams = array( 'action' => 'feedthreads', 'type' => 'replies|newthreads',
@@ -215,58 +239,65 @@
216240 $url = $urlPrefix . wfArrayToCGI( $theseParams );
217241 $this->output->addFeedLink( $format, $url );
218242 }
219 -
 243+
220244 $sk = $this->user->getSkin();
221 -
 245+
222246 $article = new Article( $this->title );
223 -
 247+
224248 if ( $this->request->getBool( 'lqt_inline' ) ) {
225249 $this->doInlineEditForm();
226250 return false;
227251 }
228 -
 252+
229253 // Search!
230254 if ( $this->request->getCheck( 'lqt_search' ) ) {
231255 $q = $this->request->getText( 'lqt_search' );
232256 $q .= ' ondiscussionpage:' . $article->getTitle()->getPrefixedText();
233 -
234 - $params = array( 'search' => $q,
235 - 'fulltext' => 1,
236 - 'ns' . NS_LQT_THREAD => 1,
237 - );
238 -
 257+
 258+ $params = array(
 259+ 'search' => $q,
 260+ 'fulltext' => 1,
 261+ 'ns' . NS_LQT_THREAD => 1,
 262+ );
 263+
239264 $t = SpecialPage::getTitleFor( 'Search' );
240265 $url = $t->getLocalURL( wfArrayToCGI( $params ) );
241 -
 266+
242267 $this->output->redirect( $url );
243 -
244268 }
245269
246270 $this->showHeader();
247 -
 271+
248272 $html = '';
249 -
 273+
250274 // Set up a per-page header for new threads, search box, and sorting stuff.
251275
252276 $talkpageHeader = '';
253 -
 277+
254278 if ( Thread::canUserPost( $this->user, $this->article ) ) {
255279 $newThreadText = wfMsgExt( 'lqt_new_thread', 'parseinline' );
256 - $newThreadLink = $sk->link( $this->title, $newThreadText,
257 - array( ),
258 - array( 'lqt_method' => 'talkpage_new_thread' ),
259 - array( 'known' ) );
260 -
261 - $talkpageHeader .= Xml::tags( 'strong',
262 - array( 'class' => 'lqt_start_discussion' ),
263 - $newThreadLink );
 280+ $newThreadLink = $sk->link(
 281+ $this->title, $newThreadText,
 282+ array( ),
 283+ array( 'lqt_method' => 'talkpage_new_thread' ),
 284+ array( 'known' )
 285+ );
 286+
 287+ $talkpageHeader .= Xml::tags(
 288+ 'strong',
 289+ array( 'class' => 'lqt_start_discussion' ),
 290+ $newThreadLink
 291+ );
264292 }
265 -
 293+
266294 $talkpageHeader .= $this->getSearchBox();
267295 $talkpageHeader .= $this->showTalkpageViewOptions( $article );
268 - $talkpageHeader = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-header' ),
269 - $talkpageHeader );
270 -
 296+ $talkpageHeader = Xml::tags(
 297+ 'div',
 298+ array( 'class' => 'lqt-talkpage-header' ),
 299+ $talkpageHeader
 300+ );
 301+
271302 $this->output->addHTML( $talkpageHeader );
272303
273304 global $wgRequest;
@@ -279,9 +310,9 @@
280311 $this->output->addHTML( Xml::tags( 'div',
281312 array( 'class' => 'lqt-new-thread lqt-edit-form' ), '' ) );
282313 }
283 -
 314+
284315 $pager = $this->getPager();
285 -
 316+
286317 $threads = $this->getPageThreads( $pager );
287318
288319 if ( count( $threads ) > 0 ) {
@@ -290,52 +321,57 @@
291322 $html .= Xml::tags( 'div', array( 'class' => 'lqt-no-threads' ),
292323 wfMsgExt( 'lqt-no-threads', 'parseinline' ) );
293324 }
294 -
 325+
295326 $html .= $pager->getNavigationBar();
296 -
 327+
297328 $this->output->addHTML( $html );
298329
299330 foreach ( $threads as $t ) {
300331 $this->showThread( $t );
301332 }
302 -
 333+
303334 $this->output->addHTML( $pager->getNavigationBar() );
304 -
 335+
305336 return false;
306337 }
307 -
 338+
308339 function getSearchBox() {
309340 $html = '';
310 - $html .= Xml::inputLabel( wfMsg( 'lqt-search-label' ), 'lqt_search', 'lqt-search-box',
311 - 45 );
312 -
 341+ $html .= Xml::inputLabel(
 342+ wfMsg( 'lqt-search-label' ),
 343+ 'lqt_search',
 344+ 'lqt-search-box',
 345+ 45
 346+ );
 347+
313348 $html .= ' ' . Xml::submitButton( wfMsg( 'lqt-search-button' ) );
314349 $html .= Xml::hidden( 'title', $this->title->getPrefixedText() );
315 - $html = Xml::tags( 'form',
316 - array( 'action' => $this->title->getLocalURL(),
317 - 'method' => 'get' ),
318 - $html );
319 -
320 -# $html = Xml::fieldset( wfMsg('lqt-search-legend' ), $html,
321 -# array( 'class' => 'lqt-talkpage-search' ) );
 350+ $html = Xml::tags(
 351+ 'form',
 352+ array(
 353+ 'action' => $this->title->getLocalURL(),
 354+ 'method' => 'get'
 355+ ),
 356+ $html
 357+ );
322358
323359 $html = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-search' ), $html );
324 -
 360+
325361 return $html;
326362 }
327 -
 363+
328364 function getPager() {
329 -
 365+
330366 $sortType = $this->getSortType();
331367 return new LqtDiscussionPager( $this->article, $sortType );
332368 }
333 -
 369+
334370 function getPageThreads( $pager ) {
335371 $rows = $pager->getRows();
336 -
 372+
337373 return Thread::bulkLoad( $rows );
338374 }
339 -
 375+
340376 function getSortType() {
341377 // Determine sort order
342378 if ( $this->request->getCheck( 'lqt_order' ) ) {
@@ -350,69 +386,66 @@
351387 return LQT_OLDEST_THREADS;
352388 }
353389 }
354 -
 390+
355391 // Default
356392 return LQT_NEWEST_CHANGES;
357393 }
358394 }
359395
360396 class LqtDiscussionPager extends IndexPager {
361 -
362397 function __construct( $article, $orderType ) {
363398 $this->article = $article;
364399 $this->orderType = $orderType;
365 -
 400+
366401 parent::__construct();
367 -
 402+
368403 $this->mLimit = $this->getPageLimit();
369404 }
370 -
 405+
371406 function getPageLimit() {
372407 $article = $this->article;
373 -
 408+
374409 global $wgRequest;
375410 $requestedLimit = $wgRequest->getVal( 'limit', null );
376411 if ( $requestedLimit ) {
377412 return $requestedLimit;
378413 }
379 -
 414+
380415 if ( $article->exists() ) {
381416 $pout = $article->getParserOutput();
382 - $setLimit = $pout->getProperty('lqt-page-limit');
383 - if ($setLimit) return $setLimit;
 417+ $setLimit = $pout->getProperty( 'lqt-page-limit' );
 418+ if ( $setLimit ) return $setLimit;
384419 }
385 -
 420+
386421 global $wgLiquidThreadsDefaultPageLimit;
387422 return $wgLiquidThreadsDefaultPageLimit;
388423 }
389 -
 424+
390425 function getQueryInfo() {
391 - $queryInfo =
392 - array(
393 - 'tables' => array( 'thread' ),
394 - 'fields' => '*',
395 - 'conds' =>
396 - array(
397 - Threads::articleClause( $this->article ),
398 - Threads::topLevelClause(),
399 - 'thread_type != ' . $this->mDb->addQuotes( Threads::TYPE_DELETED ),
400 - ),
401 - );
402 -
 426+ $queryInfo = array(
 427+ 'tables' => array( 'thread' ),
 428+ 'fields' => '*',
 429+ 'conds' => array(
 430+ Threads::articleClause( $this->article ),
 431+ Threads::topLevelClause(),
 432+ 'thread_type != ' . $this->mDb->addQuotes( Threads::TYPE_DELETED ),
 433+ ),
 434+ );
 435+
403436 return $queryInfo;
404437 }
405 -
 438+
406439 // Adapted from getBody().
407440 function getRows() {
408441 if ( !$this->mQueryDone ) {
409442 $this->doQuery();
410443 }
411 -
 444+
412445 # Don't use any extra rows returned by the query
413446 $numRows = min( $this->mResult->numRows(), $this->mLimit );
414447
415448 $rows = array();
416 -
 449+
417450 if ( $numRows ) {
418451 if ( $this->mIsBackwards ) {
419452 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
@@ -428,14 +461,14 @@
429462 }
430463 }
431464 }
432 -
 465+
433466 return $rows;
434467 }
435 -
 468+
436469 function formatRow( $row ) {
437470 // No-op, we get the list of rows from getRows()
438471 }
439 -
 472+
440473 function getIndexField() {
441474 switch( $this->orderType ) {
442475 case LQT_NEWEST_CHANGES:
@@ -447,7 +480,7 @@
448481 throw new MWException( "Unknown sort order " . $this->orderType );
449482 }
450483 }
451 -
 484+
452485 function getDefaultDirections() {
453486 switch( $this->orderType ) {
454487 case LQT_NEWEST_CHANGES:
@@ -459,7 +492,7 @@
460493 throw new MWException( "Unknown sort order " . $this->orderType );
461494 }
462495 }
463 -
 496+
464497 /**
465498 * A navigation bar with images
466499 * Stolen from TablePager because it's pretty.
@@ -509,7 +542,7 @@
510543 $s .= "</tr></table>\n";
511544 return $s;
512545 }
513 -
 546+
514547 function getNavClass() {
515548 return 'TalkpagePager_nav';
516549 }
Index: trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php
@@ -1,29 +1,24 @@
22 <?php
3 -
43 // TODO access control
54 class SpecialSplitThread extends ThreadActionPage {
6 -
75 function getFormFields() {
86 $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 - ),
 7+ 'src' => array(
 8+ 'type' => 'info',
 9+ 'label-message' => 'lqt-thread-split-thread',
 10+ 'default' => LqtView::permalink( $this->mThread ),
 11+ 'raw' => 1,
 12+ ),
 13+ 'subject' => array(
 14+ 'type' => 'text',
 15+ 'label-message' => 'lqt-thread-split-subject',
 16+ ),
 17+ 'reason' => array(
 18+ 'label-message' => 'movereason',
 19+ 'type' => 'text',
 20+ ),
2621 );
27 -
 22+
2823 return $splitForm;
2924 }
3025
@@ -34,46 +29,46 @@
3530 wfLoadExtensionMessages( 'LiquidThreads' );
3631 return wfMsg( 'lqt_split_thread' );
3732 }
38 -
 33+
3934 protected function getRightRequirement() { return 'lqt-split'; }
40 -
 35+
4136 function trySubmit( $data ) {
4237 // Load data
4338 $newSubject = $data['subject'];
4439 $reason = $data['reason'];
45 -
 40+
4641 $this->mThread->split( $newSubject, $reason );
47 -
 42+
4843 $link = LqtView::linkInContext( $this->mThread );
49 -
 44+
5045 global $wgOut;
5146 $wgOut->addHTML( wfMsgExt( 'lqt-split-success', array( 'parseinline', 'replaceafter' ),
5247 $link ) );
53 -
 48+
5449 return true;
5550 }
56 -
 51+
5752 function validateSubject( $target ) {
5853 if ( !$target ) {
5954 return wfMsgExt( 'lqt_split_nosubject', 'parseinline' );
6055 }
61 -
 56+
6257 $title = null;
6358 $article = $this->mThread->article();
64 -
 59+
6560 $ok = Thread::validateSubject( $target, $title, null, $article );
66 -
 61+
6762 if ( !$ok ) {
6863 return wfMsgExt( 'lqt_split_badsubject', 'parseinline' );
6964 }
70 -
 65+
7166 return true;
7267 }
73 -
 68+
7469 function getPageName() {
7570 return 'SplitThread';
7671 }
77 -
 72+
7873 function getSubmitText() {
7974 wfLoadExtensionMessages( 'LiquidThreads' );
8075 return wfMsg( 'lqt-split-submit' );
Index: trunk/extensions/LiquidThreads/pages/SummaryPageView.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class SummaryPageView extends LqtView {
@@ -8,12 +7,16 @@
98 $thread = Threads::withSummary( $this->article );
109 if ( $thread && $thread->root() ) {
1110 global $wgUser;
12 -
 11+
1312 $t = $thread->root()->getTitle();
1413 $link = $wgUser->getSkin()->link( $t );
1514 $this->output->setSubtitle(
16 - wfMsgExt( 'lqt_summary_subtitle', array( 'parseinline', 'replaceafter' ),
17 - $link ) );
 15+ wfMsgExt(
 16+ 'lqt_summary_subtitle',
 17+ array( 'parseinline', 'replaceafter' ),
 18+ $link
 19+ )
 20+ );
1821 }
1922 return true;
2023 }
Index: trunk/extensions/LiquidThreads/pages/SpecialMergeThread.php
@@ -2,73 +2,68 @@
33
44 // TODO access control
55 class SpecialMergeThread extends ThreadActionPage {
6 -
76 function getFormFields() {
87 $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 - ),
 8+ 'src' => array(
 9+ 'type' => 'info',
 10+ 'label-message' => 'lqt-thread-merge-source',
 11+ 'default' => $this->formatThreadField( 'src', $this->mThread->id() ),
 12+ 'raw' => 1
 13+ ),
 14+ 'dest' => array(
 15+ 'type' => 'info',
 16+ 'label-message' => 'lqt-thread-merge-dest',
 17+ 'default' => $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ),
 18+ 'raw' => 1
 19+ ),
 20+ 'reason' => array(
 21+ 'label-message' => 'movereason',
 22+ 'type' => 'text'
 23+ )
2924 );
30 -
 25+
3126 return $splitForm;
3227 }
33 -
 28+
3429 protected function getRightRequirement() { return 'lqt-merge'; }
35 -
 30+
3631 public function checkParameters( $par ) {
3732 global $wgOut;
3833 if ( !parent::checkParameters( $par ) ) {
3934 return false;
4035 }
41 -
 36+
4237 $dest = $this->request->getVal( 'dest' );
43 -
 38+
4439 if ( !$dest ) {
4540 $wgOut->addWikiMsg( 'lqt_threadrequired' );
4641 return false;
4742 }
48 -
 43+
4944 $thread = Threads::withId( $dest );
50 -
 45+
5146 if ( !$thread ) {
5247 $wgOut->addWikiMsg( 'lqt_nosuchthread' );
5348 return false;
5449 }
55 -
 50+
5651 $this->mDestThread = $thread;
57 -
 52+
5853 return true;
5954 }
6055
6156 function formatThreadField( $field, $threadid ) {
62 -
 57+
6358 if ( !is_object( $threadid ) ) {
6459 $t = Threads::withId( $threadid );
6560 } else {
6661 $t = $threadid;
6762 $threadid = $t->id();
6863 }
69 -
 64+
7065 $out = Xml::hidden( $field, $threadid );
7166 $out .= LqtView::permalink( $t );
72 -
 67+
7368 return $out;
7469 }
7570
@@ -79,29 +74,29 @@
8075 wfLoadExtensionMessages( 'LiquidThreads' );
8176 return wfMsg( 'lqt_merge_thread' );
8277 }
83 -
 78+
8479 function trySubmit( $data ) {
8580 // Load data
8681 $srcThread = $this->mThread;
8782 $dstThread = $this->mDestThread;
8883 $reason = $data['reason'];
89 -
 84+
9085 $srcThread->moveToParent( $dstThread, $reason );
91 -
 86+
9287 $srcLink = LqtView::linkInContext( $srcThread );
9388 $dstLink = LqtView::linkInContext( $dstThread );
94 -
 89+
9590 global $wgOut;
9691 $wgOut->addHTML( wfMsgExt( 'lqt-merge-success', array( 'parseinline', 'replaceafter' ),
9792 $srcLink, $dstLink ) );
98 -
 93+
9994 return true;
10095 }
101 -
 96+
10297 function getPageName() {
10398 return 'MergeThread';
10499 }
105 -
 100+
106101 function getSubmitText() {
107102 wfLoadExtensionMessages( 'LiquidThreads' );
108103 return wfMsg( 'lqt-merge-submit' );
Index: trunk/extensions/LiquidThreads/pages/ThreadWatchView.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 if ( !defined( 'MEDIAWIKI' ) ) die;
54
65 class ThreadWatchView extends ThreadPermalinkView {

Follow-up revisions

RevisionCommit summaryAuthorDate
r62342LiquidThreads alpha updates: Merge r62114-62229. Merging r62230 separately as...werdna23:18, 11 February 2010
r62343Merge LiquidThreads r62230, whitespace/formatting changes.werdna23:21, 11 February 2010

Status & tagging log