Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -3,11 +3,11 @@ |
4 | 4 | die(); |
5 | 5 | |
6 | 6 | $wgExtensionCredits['other'][] = array( |
7 | | - 'path' => __FILE__, |
8 | | - 'name' => 'Liquid Threads', |
9 | | - 'version' => '2.0-alpha', |
10 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:LiquidThreads', |
11 | | - 'author' => array( 'David McCabe', 'Andrew Garrett' ), |
| 7 | + 'path' => __FILE__, |
| 8 | + 'name' => 'Liquid Threads', |
| 9 | + 'version' => '2.0-alpha', |
| 10 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:LiquidThreads', |
| 11 | + 'author' => array( 'David McCabe', 'Andrew Garrett' ), |
12 | 12 | 'descriptionmsg' => 'lqt-desc', |
13 | 13 | ); |
14 | 14 | |
— | — | @@ -22,15 +22,15 @@ |
23 | 23 | define( 'LQT_OLDEST_THREADS', 'ot' ); |
24 | 24 | |
25 | 25 | // FIXME: would be neat if it was possible to somehow localise this. |
26 | | -$wgCanonicalNamespaceNames[NS_LQT_THREAD] = 'Thread'; |
27 | | -$wgCanonicalNamespaceNames[NS_LQT_THREAD_TALK] = 'Thread_talk'; |
28 | | -$wgCanonicalNamespaceNames[NS_LQT_SUMMARY] = 'Summary'; |
| 26 | +$wgCanonicalNamespaceNames[NS_LQT_THREAD] = 'Thread'; |
| 27 | +$wgCanonicalNamespaceNames[NS_LQT_THREAD_TALK] = 'Thread_talk'; |
| 28 | +$wgCanonicalNamespaceNames[NS_LQT_SUMMARY] = 'Summary'; |
29 | 29 | $wgCanonicalNamespaceNames[NS_LQT_SUMMARY_TALK] = 'Summary_talk'; |
30 | 30 | |
31 | 31 | // FIXME: would be neat if it was possible to somehow localise this. |
32 | | -$wgExtraNamespaces[NS_LQT_THREAD] = 'Thread'; |
33 | | -$wgExtraNamespaces[NS_LQT_THREAD_TALK] = 'Thread_talk'; |
34 | | -$wgExtraNamespaces[NS_LQT_SUMMARY] = 'Summary'; |
| 32 | +$wgExtraNamespaces[NS_LQT_THREAD] = 'Thread'; |
| 33 | +$wgExtraNamespaces[NS_LQT_THREAD_TALK] = 'Thread_talk'; |
| 34 | +$wgExtraNamespaces[NS_LQT_SUMMARY] = 'Summary'; |
35 | 35 | $wgExtraNamespaces[NS_LQT_SUMMARY_TALK] = 'Summary_talk'; |
36 | 36 | |
37 | 37 | // Localisation |
— | — | @@ -171,8 +171,8 @@ |
172 | 172 | |
173 | 173 | // Logging |
174 | 174 | $wgLogTypes[] = 'liquidthreads'; |
175 | | -$wgLogNames['liquidthreads'] = 'lqt-log-name'; |
176 | | -$wgLogHeaders['liquidthreads'] = 'lqt-log-header'; |
| 175 | +$wgLogNames['liquidthreads'] = 'lqt-log-name'; |
| 176 | +$wgLogHeaders['liquidthreads'] = 'lqt-log-header'; |
177 | 177 | |
178 | 178 | foreach ( array( 'move', 'split', 'merge', 'subjectedit', 'resort' ) as $action ) { |
179 | 179 | $wgLogActionsHandlers["liquidthreads/$action"] = 'LqtLogFormatter::formatLogEntry'; |
— | — | @@ -192,8 +192,8 @@ |
193 | 193 | $wgAutoloadClasses['ApiThreadAction'] = "$dir/api/ApiThreadAction.php"; |
194 | 194 | $wgAPIModules['threadaction'] = 'ApiThreadAction'; |
195 | 195 | |
196 | | -// Name of the extension (wmf-specific, for splitting to versions) |
197 | | -$wgLiquidThreadsExtensionName = 'LiquidThreads'; |
| 196 | +// Path to the LQT directory |
| 197 | +$wgLiquidThreadsExtensionPath = "{$wgScriptPath}/extensions/LiquidThreads"; |
198 | 198 | |
199 | 199 | /** CONFIGURATION SECTION */ |
200 | 200 | |
Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | if ( $operand ) { |
82 | 82 | $query['lqt_operand'] = $operand; |
83 | 83 | } |
84 | | - |
| 84 | + |
85 | 85 | if ( ! $thread ) { |
86 | 86 | throw new MWException( "Empty thread passed to ".__METHOD__ ); |
87 | 87 | } |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | |
116 | 116 | static function linkInContextData( $thread, $contextType = 'page' ) { |
117 | 117 | $query = array(); |
118 | | - |
| 118 | + |
119 | 119 | if ( ! $thread ) { |
120 | 120 | throw new MWException( "Null thread passed to linkInContextData" ); |
121 | 121 | } |
— | — | @@ -282,9 +282,9 @@ |
283 | 283 | } |
284 | 284 | |
285 | 285 | /************************************************************* |
286 | | - * Editing methods (here be dragons) * |
| 286 | + * Editing methods (here be dragons) * |
287 | 287 | * Forget dragons: This section distorts the rest of the code * |
288 | | - * like a star bending spacetime around itself. * |
| 288 | + * like a star bending spacetime around itself. * |
289 | 289 | *************************************************************/ |
290 | 290 | |
291 | 291 | /** |
— | — | @@ -311,7 +311,7 @@ |
312 | 312 | $operand = $this->request->getVal( 'lqt_operand' ); |
313 | 313 | |
314 | 314 | $thread = Threads::withId( intval( $operand ) ); |
315 | | - |
| 315 | + |
316 | 316 | $hookResult = wfRunHooks( 'LiquidThreadsDoInlineEditForm', |
317 | 317 | array( |
318 | 318 | $thread, |
— | — | @@ -331,20 +331,20 @@ |
332 | 332 | |
333 | 333 | $this->output->setArticleBodyOnly( true ); |
334 | 334 | } |
335 | | - |
| 335 | + |
336 | 336 | function showNewThreadForm( $talkpage ) { |
337 | 337 | $submitted_nonce = $this->request->getVal( 'lqt_nonce' ); |
338 | 338 | $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() ); |
339 | 339 | if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return; |
340 | | - |
| 340 | + |
341 | 341 | if ( Thread::canUserPost( $this->user, $this->article ) !== true ) { |
342 | 342 | $this->output->addWikiMsg( 'lqt-protected-newthread' ); |
343 | 343 | return; |
344 | 344 | } |
345 | 345 | $subject = $this->request->getVal( 'lqt_subject_field', false ); |
346 | | - |
| 346 | + |
347 | 347 | $t = null; |
348 | | - |
| 348 | + |
349 | 349 | $subjectOk = Thread::validateSubject( $subject, $t, |
350 | 350 | null, $this->article ); |
351 | 351 | if ( ! $subjectOk ) { |
— | — | @@ -354,65 +354,65 @@ |
355 | 355 | $t = $this->scratchTitle(); |
356 | 356 | } |
357 | 357 | } |
358 | | - |
| 358 | + |
359 | 359 | $article = new Article( $t ); |
360 | | - |
| 360 | + |
361 | 361 | LqtHooks::$editTalkpage = $talkpage; |
362 | 362 | LqtHooks::$editArticle = $article; |
363 | 363 | LqtHooks::$editThread = null; |
364 | 364 | LqtHooks::$editType = 'new'; |
365 | 365 | LqtHooks::$editAppliesTo = null; |
366 | | - |
| 366 | + |
367 | 367 | wfRunHooks( 'LiquidThreadsShowNewThreadForm', array( &$e, $talkpage ) ); |
368 | | - |
| 368 | + |
369 | 369 | $e = new EditPage( $article ); |
370 | | - |
| 370 | + |
371 | 371 | global $wgRequest; |
372 | 372 | // Quietly force a preview if no subject has been specified. |
373 | 373 | if ( !$subjectOk ) { |
374 | 374 | // Dirty hack to prevent saving from going ahead |
375 | 375 | $wgRequest->setVal( 'wpPreview', true ); |
376 | | - |
| 376 | + |
377 | 377 | if ( $this->request->wasPosted() ) { |
378 | 378 | if ( !$subject ) { |
379 | 379 | $msg = 'lqt_empty_subject'; |
380 | 380 | } else { |
381 | 381 | $msg = 'lqt_invalid_subject'; |
382 | 382 | } |
383 | | - |
| 383 | + |
384 | 384 | $e->editFormPageTop .= |
385 | 385 | Xml::tags( 'div', array( 'class' => 'error' ), |
386 | 386 | wfMsgExt( $msg, 'parse' ) ); |
387 | 387 | } |
388 | 388 | } |
389 | | - |
| 389 | + |
390 | 390 | $e->suppressIntro = true; |
391 | 391 | $e->editFormTextBeforeContent .= |
392 | 392 | $this->perpetuate( 'lqt_method', 'hidden' ) . |
393 | 393 | $this->perpetuate( 'lqt_operand', 'hidden' ) . |
394 | 394 | Xml::hidden( 'lqt_nonce', wfGenerateToken() ); |
395 | | - |
| 395 | + |
396 | 396 | $e->mShowSummaryField = false; |
397 | | - |
| 397 | + |
398 | 398 | $summary = wfMsgForContent( 'lqt-newpost-summary', $subject ); |
399 | 399 | $wgRequest->setVal( 'wpSummary', $summary ); |
400 | | - |
| 400 | + |
401 | 401 | list( $signatureEditor, $signatureHTML ) = $this->getSignatureEditor( $this->user ); |
402 | | - |
| 402 | + |
403 | 403 | $e->editFormTextAfterContent .= |
404 | 404 | $signatureEditor; |
405 | 405 | $e->previewTextAfterContent .= |
406 | 406 | Xml::tags( 'p', null, $signatureHTML ); |
407 | | - |
| 407 | + |
408 | 408 | $e->editFormTextBeforeContent .= $this->getSubjectEditor( '', $subject ); |
409 | | - |
| 409 | + |
410 | 410 | wfRunHooks( 'LiquidThreadsAfterShowNewThreadForm', array( &$e, $talkpage ) ); |
411 | | - |
| 411 | + |
412 | 412 | $e->edit(); |
413 | | - |
| 413 | + |
414 | 414 | if ( $e->didSave ) { |
415 | 415 | $signature = $this->request->getVal( 'wpLqtSignature', null ); |
416 | | - |
| 416 | + |
417 | 417 | $info = |
418 | 418 | array( |
419 | 419 | 'talkpage' => $talkpage, |
— | — | @@ -422,66 +422,66 @@ |
423 | 423 | 'root' => $article, |
424 | 424 | 'subject' => $subject, |
425 | 425 | ); |
426 | | - |
| 426 | + |
427 | 427 | wfRunHooks( 'LiquidThreadsSaveNewThread', |
428 | 428 | array( &$info, &$e, &$talkpage ) ); |
429 | | - |
| 429 | + |
430 | 430 | $thread = LqtView::newPostMetadataUpdates( $info ); |
431 | | - |
| 431 | + |
432 | 432 | if ( $submitted_nonce && $nonce_key ) { |
433 | 433 | global $wgMemc; |
434 | 434 | $wgMemc->set( $nonce_key, 1, 3600 ); |
435 | 435 | } |
436 | 436 | } |
437 | | - |
| 437 | + |
438 | 438 | if ( $this->output->getRedirect() != '' ) { |
439 | | - $redirectTitle = clone $talkpage->getTitle(); |
440 | | - if ( !empty($thread) ) { |
441 | | - $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
442 | | - } |
443 | | - $this->output->redirect( $this->title->getFullURL() ); |
| 439 | + $redirectTitle = clone $talkpage->getTitle(); |
| 440 | + if ( !empty($thread) ) { |
| 441 | + $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
| 442 | + } |
| 443 | + $this->output->redirect( $this->title->getFullURL() ); |
444 | 444 | } |
445 | | - |
| 445 | + |
446 | 446 | } |
447 | | - |
| 447 | + |
448 | 448 | function showReplyForm( $thread ) { |
449 | 449 | global $wgRequest; |
450 | | - |
| 450 | + |
451 | 451 | $submitted_nonce = $this->request->getVal( 'lqt_nonce' ); |
452 | 452 | $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() ); |
453 | 453 | if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return; |
454 | | - |
| 454 | + |
455 | 455 | $perm_result = $thread->canUserReply( $this->user ); |
456 | 456 | if ( $perm_result !== true ) { |
457 | 457 | $this->showReplyProtectedNotice( $thread ); |
458 | 458 | return; |
459 | 459 | } |
460 | | - |
| 460 | + |
461 | 461 | $html = Xml::openElement( 'div', |
462 | 462 | array( 'class' => 'lqt-reply-form' ) ); |
463 | 463 | $this->output->addHTML( $html ); |
464 | 464 | |
465 | | - |
| 465 | + |
466 | 466 | try { |
467 | 467 | $t = $this->newReplyTitle( null, $thread ); |
468 | 468 | } catch ( MWException $excep ) { |
469 | 469 | $t = $this->scratchTitle(); |
470 | 470 | $valid_subject = false; |
471 | 471 | } |
472 | | - |
| 472 | + |
473 | 473 | $article = new Article( $t ); |
474 | 474 | $talkpage = $thread->article(); |
475 | | - |
| 475 | + |
476 | 476 | LqtHooks::$editTalkpage = $talkpage; |
477 | 477 | LqtHooks::$editArticle = $article; |
478 | 478 | LqtHooks::$editThread = $thread; |
479 | 479 | LqtHooks::$editType = 'reply'; |
480 | 480 | LqtHooks::$editAppliesTo = $thread; |
481 | | - |
| 481 | + |
482 | 482 | $e = new EditPage( $article ); |
483 | | - |
| 483 | + |
484 | 484 | $e->mShowSummaryField = false; |
485 | | - |
| 485 | + |
486 | 486 | $reply_subject = $thread->subject(); |
487 | 487 | $reply_title = $thread->title()->getPrefixedText(); |
488 | 488 | $summary = wfMsgForContent( |
— | — | @@ -490,37 +490,37 @@ |
491 | 491 | $reply_title |
492 | 492 | ); |
493 | 493 | $wgRequest->setVal( 'wpSummary', $summary ); |
494 | | - |
| 494 | + |
495 | 495 | // Add an offset so it works if it's on the wrong page. |
496 | 496 | $dbr = wfGetDB( DB_SLAVE ); |
497 | 497 | $offset = wfTimestamp( TS_UNIX, $thread->topmostThread()->sortkey() ); |
498 | 498 | $offset++; |
499 | 499 | $offset = $dbr->timestamp( $offset ); |
500 | | - |
| 500 | + |
501 | 501 | $e->suppressIntro = true; |
502 | 502 | $e->editFormTextBeforeContent .= |
503 | 503 | $this->perpetuate( 'lqt_method', 'hidden' ) . |
504 | 504 | $this->perpetuate( 'lqt_operand', 'hidden' ) . |
505 | 505 | Xml::hidden( 'lqt_nonce', wfGenerateToken() ) . |
506 | 506 | Xml::hidden( 'offset', $offset ); |
507 | | - |
| 507 | + |
508 | 508 | list( $signatureEditor, $signatureHTML ) = $this->getSignatureEditor( $this->user ); |
509 | | - |
| 509 | + |
510 | 510 | $e->editFormTextAfterContent .= |
511 | 511 | $signatureEditor; |
512 | 512 | $e->previewTextAfterContent .= |
513 | 513 | Xml::tags( 'p', null, $signatureHTML ); |
514 | | - |
| 514 | + |
515 | 515 | $wgRequest->setVal( 'wpWatchThis', false ); |
516 | | - |
| 516 | + |
517 | 517 | wfRunHooks( 'LiquidThreadsShowReplyForm', array( &$e, $thread ) ); |
518 | | - |
| 518 | + |
519 | 519 | $e->edit(); |
520 | | - |
| 520 | + |
521 | 521 | if ( $e->didSave ) { |
522 | 522 | $bump = $this->request->getBool( 'wpBumpThread' ); |
523 | 523 | $signature = $this->request->getVal( 'wpLqtSignature', null ); |
524 | | - |
| 524 | + |
525 | 525 | $info = array( |
526 | 526 | 'replyTo' => $thread, |
527 | 527 | 'text' => $e->textbox1, |
— | — | @@ -529,106 +529,106 @@ |
530 | 530 | 'signature' => $signature, |
531 | 531 | 'root' => $article, |
532 | 532 | ); |
533 | | - |
| 533 | + |
534 | 534 | wfRunHooks( 'LiquidThreadsSaveReply', |
535 | 535 | array( &$info, &$e, &$thread ) ); |
536 | | - |
| 536 | + |
537 | 537 | $newThread = LqtView::replyMetadataUpdates( $info ); |
538 | | - |
| 538 | + |
539 | 539 | if ( $submitted_nonce && $nonce_key ) { |
540 | 540 | global $wgMemc; |
541 | 541 | $wgMemc->set( $nonce_key, 1, 3600 ); |
542 | 542 | } |
543 | 543 | } |
544 | | - |
| 544 | + |
545 | 545 | if ( $this->output->getRedirect() != '' ) { |
546 | | - $redirectTitle = clone $talkpage->getTitle(); |
547 | | - if ( !empty( $newThread ) ) { |
548 | | - $redirectTitle->setFragment( '#' . |
549 | | - $this->anchorName( $newThread ) ); |
550 | | - } |
551 | | - $this->output->redirect( $this->title->getFullURL() ); |
| 546 | + $redirectTitle = clone $talkpage->getTitle(); |
| 547 | + if ( !empty( $newThread ) ) { |
| 548 | + $redirectTitle->setFragment( '#' . |
| 549 | + $this->anchorName( $newThread ) ); |
| 550 | + } |
| 551 | + $this->output->redirect( $this->title->getFullURL() ); |
552 | 552 | } |
553 | | - |
| 553 | + |
554 | 554 | $this->output->addHTML( '</div>' ); |
555 | 555 | } |
556 | | - |
| 556 | + |
557 | 557 | function showPostEditingForm( $thread ) { |
558 | 558 | $submitted_nonce = $this->request->getVal( 'lqt_nonce' ); |
559 | 559 | $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() ); |
560 | 560 | if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return; |
561 | | - |
| 561 | + |
562 | 562 | $subject_expected = $thread->isTopmostThread(); |
563 | 563 | $subject = $this->request->getVal( 'lqt_subject_field', '' ); |
564 | | - |
| 564 | + |
565 | 565 | if ( !$subject ) { |
566 | 566 | $subject = $thread->subject(); |
567 | 567 | } |
568 | | - |
| 568 | + |
569 | 569 | $t = null; |
570 | 570 | $subjectOk = Thread::validateSubject( $subject, $t, |
571 | 571 | $thread->superthread(), $this->article ); |
572 | 572 | if ( ! $subjectOk ) { |
573 | 573 | $subject = false; |
574 | 574 | } |
575 | | - |
| 575 | + |
576 | 576 | $article = $thread->root(); |
577 | 577 | $talkpage = $thread->article(); |
578 | | - |
| 578 | + |
579 | 579 | wfRunHooks( 'LiquidThreadsEditFormContent', array( $thread, &$article, $talkpage ) ); |
580 | | - |
| 580 | + |
581 | 581 | LqtHooks::$editTalkpage = $talkpage; |
582 | 582 | LqtHooks::$editArticle = $article; |
583 | 583 | LqtHooks::$editThread = $thread; |
584 | 584 | LqtHooks::$editType = 'edit'; |
585 | 585 | LqtHooks::$editAppliesTo = $thread; |
586 | | - |
| 586 | + |
587 | 587 | $e = new EditPage( $article ); |
588 | | - |
| 588 | + |
589 | 589 | global $wgRequest; |
590 | 590 | // Quietly force a preview if no subject has been specified. |
591 | 591 | if ( !$subjectOk ) { |
592 | 592 | // Dirty hack to prevent saving from going ahead |
593 | 593 | $wgRequest->setVal( 'wpPreview', true ); |
594 | | - |
| 594 | + |
595 | 595 | if ( $this->request->wasPosted() ) { |
596 | 596 | $e->editFormPageTop .= |
597 | 597 | Xml::tags( 'div', array( 'class' => 'error' ), |
598 | 598 | wfMsgExt( 'lqt_invalid_subject', 'parse' ) ); |
599 | 599 | } |
600 | 600 | } |
601 | | - |
| 601 | + |
602 | 602 | // Add an offset so it works if it's on the wrong page. |
603 | 603 | $dbr = wfGetDB( DB_SLAVE ); |
604 | 604 | $offset = wfTimestamp( TS_UNIX, $thread->topmostThread()->sortkey() ); |
605 | 605 | $offset++; |
606 | 606 | $offset = $dbr->timestamp( $offset ); |
607 | | - |
| 607 | + |
608 | 608 | $e->suppressIntro = true; |
609 | 609 | $e->editFormTextBeforeContent .= |
610 | 610 | $this->perpetuate( 'lqt_method', 'hidden' ) . |
611 | 611 | $this->perpetuate( 'lqt_operand', 'hidden' ) . |
612 | 612 | Xml::hidden( 'lqt_nonce', wfGenerateToken() ) . |
613 | 613 | Xml::hidden( 'offset', $offset ); |
614 | | - |
| 614 | + |
615 | 615 | list( $signatureEditor, $signatureHTML ) = $this->getSignatureEditor( $thread ); |
616 | | - |
| 616 | + |
617 | 617 | $e->editFormTextAfterContent .= |
618 | 618 | $signatureEditor; |
619 | 619 | $e->previewTextAfterContent .= |
620 | 620 | Xml::tags( 'p', null, $signatureHTML ); |
621 | | - |
| 621 | + |
622 | 622 | if ( $thread->isTopmostThread() ) { |
623 | 623 | $e->editFormTextBeforeContent .= |
624 | 624 | $this->getSubjectEditor( $thread->subject(), $subject ); |
625 | 625 | } |
626 | | - |
| 626 | + |
627 | 627 | $e->edit(); |
628 | | - |
| 628 | + |
629 | 629 | if ( $e->didSave ) { |
630 | 630 | $bump = $this->request->getBool( 'wpBumpThread' ); |
631 | 631 | $signature = $this->request->getVal( 'wpLqtSignature', null ); |
632 | | - |
| 632 | + |
633 | 633 | LqtView::editMetadataUpdates( |
634 | 634 | array( |
635 | 635 | 'thread' => $thread, |
— | — | @@ -640,63 +640,63 @@ |
641 | 641 | 'root' => $article, |
642 | 642 | ) |
643 | 643 | ); |
644 | | - |
| 644 | + |
645 | 645 | if ( $submitted_nonce && $nonce_key ) { |
646 | 646 | global $wgMemc; |
647 | 647 | $wgMemc->set( $nonce_key, 1, 3600 ); |
648 | 648 | } |
649 | 649 | } |
650 | | - |
| 650 | + |
651 | 651 | if ( $this->output->getRedirect() != '' ) { |
652 | | - $redirectTitle = clone $talkpage->getTitle(); |
653 | | - $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
654 | | - $this->output->redirect( $this->title->getFullURL() ); |
| 652 | + $redirectTitle = clone $talkpage->getTitle(); |
| 653 | + $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
| 654 | + $this->output->redirect( $this->title->getFullURL() ); |
655 | 655 | } |
656 | | - |
| 656 | + |
657 | 657 | } |
658 | | - |
| 658 | + |
659 | 659 | function showSummarizeForm( $thread ) { |
660 | 660 | $submitted_nonce = $this->request->getVal( 'lqt_nonce' ); |
661 | 661 | $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() ); |
662 | 662 | if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return; |
663 | | - |
| 663 | + |
664 | 664 | if ( $thread->summary() ) { |
665 | 665 | $article = $thread->summary(); |
666 | 666 | } else { |
667 | 667 | $t = $this->newSummaryTitle( $thread ); |
668 | 668 | $article = new Article( $t ); |
669 | 669 | } |
670 | | - |
| 670 | + |
671 | 671 | $this->output->addWikiMsg( 'lqt-summarize-intro' ); |
672 | | - |
| 672 | + |
673 | 673 | $talkpage = $thread->article(); |
674 | | - |
| 674 | + |
675 | 675 | LqtHooks::$editTalkpage = $talkpage; |
676 | 676 | LqtHooks::$editArticle = $article; |
677 | 677 | LqtHooks::$editThread = $thread; |
678 | 678 | LqtHooks::$editType = 'summarize'; |
679 | 679 | LqtHooks::$editAppliesTo = $thread; |
680 | | - |
| 680 | + |
681 | 681 | $e = new EditPage( $article ); |
682 | | - |
| 682 | + |
683 | 683 | // Add an offset so it works if it's on the wrong page. |
684 | 684 | $dbr = wfGetDB( DB_SLAVE ); |
685 | 685 | $offset = wfTimestamp( TS_UNIX, $thread->topmostThread()->sortkey() ); |
686 | 686 | $offset++; |
687 | 687 | $offset = $dbr->timestamp( $offset ); |
688 | | - |
| 688 | + |
689 | 689 | $e->suppressIntro = true; |
690 | 690 | $e->editFormTextBeforeContent .= |
691 | 691 | $this->perpetuate( 'lqt_method', 'hidden' ) . |
692 | 692 | $this->perpetuate( 'lqt_operand', 'hidden' ) . |
693 | 693 | Xml::hidden( 'lqt_nonce', wfGenerateToken() ) . |
694 | 694 | Xml::hidden( 'offset', $offset ); |
695 | | - |
| 695 | + |
696 | 696 | $e->edit(); |
697 | | - |
| 697 | + |
698 | 698 | if ( $e->didSave ) { |
699 | 699 | $bump = $this->request->getBool( 'wpBumpThread' ); |
700 | | - |
| 700 | + |
701 | 701 | LqtView::summarizeMetadataUpdates( |
702 | 702 | array( |
703 | 703 | 'thread' => $thread, |
— | — | @@ -705,25 +705,25 @@ |
706 | 706 | 'bump' => $bump, |
707 | 707 | ) |
708 | 708 | ); |
709 | | - |
| 709 | + |
710 | 710 | if ( $submitted_nonce && $nonce_key ) { |
711 | 711 | global $wgMemc; |
712 | 712 | $wgMemc->set( $nonce_key, 1, 3600 ); |
713 | 713 | } |
714 | 714 | } |
715 | | - |
| 715 | + |
716 | 716 | if ( $this->output->getRedirect() != '' ) { |
717 | | - $redirectTitle = clone $talkpage->getTitle(); |
718 | | - $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
719 | | - $this->output->redirect( $this->title->getFullURL() ); |
| 717 | + $redirectTitle = clone $talkpage->getTitle(); |
| 718 | + $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
| 719 | + $this->output->redirect( $this->title->getFullURL() ); |
720 | 720 | } |
721 | | - |
| 721 | + |
722 | 722 | } |
723 | | - |
| 723 | + |
724 | 724 | public function handleNonce( $submitted_nonce, $nonce_key ) { |
725 | 725 | // Add a one-time random string to a hidden field. Store the random string |
726 | | - // in memcached on submit and don't allow the edit to go ahead if it's already |
727 | | - // been added. |
| 726 | + // in memcached on submit and don't allow the edit to go ahead if it's already |
| 727 | + // been added. |
728 | 728 | if ( $submitted_nonce ) { |
729 | 729 | global $wgMemc; |
730 | 730 | |
— | — | @@ -732,13 +732,13 @@ |
733 | 733 | return false; |
734 | 734 | } |
735 | 735 | } |
736 | | - |
| 736 | + |
737 | 737 | return true; |
738 | 738 | } |
739 | | - |
| 739 | + |
740 | 740 | public function getSubjectEditor( $db_subject, $subject ) { |
741 | 741 | if ( $subject === false ) $subject = $db_subject; |
742 | | - |
| 742 | + |
743 | 743 | $subject_label = wfMsg( 'lqt_subject' ); |
744 | 744 | |
745 | 745 | $attr = array( 'tabindex' => 1 ); |
— | — | @@ -747,7 +747,7 @@ |
748 | 748 | 'lqt_subject_field', 60, $subject, $attr ) . |
749 | 749 | Xml::element( 'br' ); |
750 | 750 | } |
751 | | - |
| 751 | + |
752 | 752 | public function getSignatureEditor( $from ) { |
753 | 753 | $signatureText = $this->request->getVal( 'wpLqtSignature', null ); |
754 | 754 | |
— | — | @@ -776,19 +776,19 @@ |
777 | 777 | ); |
778 | 778 | |
779 | 779 | $signatureEditor = $signaturePreview . $signatureEditBox; |
780 | | - |
| 780 | + |
781 | 781 | return array( $signatureEditor, $signatureHTML ); |
782 | 782 | } |
783 | | - |
| 783 | + |
784 | 784 | static function replyMetadataUpdates( $data = array() ) { |
785 | 785 | $requiredFields = array( 'replyTo', 'root', 'text' ); |
786 | | - |
| 786 | + |
787 | 787 | foreach ( $requiredFields as $f ) { |
788 | 788 | if ( !isset( $data[$f] ) ) { |
789 | 789 | throw new MWException( "Missing required field $f" ); |
790 | 790 | } |
791 | 791 | } |
792 | | - |
| 792 | + |
793 | 793 | $signature = null; |
794 | 794 | if ( isset( $data['signature'] ) ) { |
795 | 795 | $signature = $data['signature']; |
— | — | @@ -796,72 +796,72 @@ |
797 | 797 | global $wgUser; |
798 | 798 | $signature = LqtView::getUserSignature( $wgUser ); |
799 | 799 | } |
800 | | - |
| 800 | + |
801 | 801 | $summary = isset( $data['summary'] ) ? $data['summary'] : ''; |
802 | | - |
| 802 | + |
803 | 803 | $replyTo = $data['replyTo']; |
804 | 804 | $root = $data['root']; |
805 | 805 | $text = $data['text']; |
806 | 806 | $bump = !empty( $data['bump'] ); |
807 | | - |
| 807 | + |
808 | 808 | $subject = $replyTo->subject(); |
809 | 809 | $talkpage = $replyTo->article(); |
810 | | - |
| 810 | + |
811 | 811 | $thread = Thread::create( |
812 | 812 | $root, $talkpage, $replyTo, Threads::TYPE_NORMAL, $subject, |
813 | 813 | $summary, $bump, $signature |
814 | 814 | ); |
815 | | - |
| 815 | + |
816 | 816 | wfRunHooks( 'LiquidThreadsAfterReplyMetadataUpdates', array( &$thread ) ); |
817 | | - |
| 817 | + |
818 | 818 | return $thread; |
819 | 819 | } |
820 | | - |
| 820 | + |
821 | 821 | static function summarizeMetadataUpdates( $data = array() ) { |
822 | 822 | $requiredFields = array( 'thread', 'article', 'summary' ); |
823 | | - |
| 823 | + |
824 | 824 | foreach ( $requiredFields as $f ) { |
825 | 825 | if ( !isset( $data[$f] ) ) { |
826 | 826 | throw new MWException( "Missing required field $f" ); |
827 | 827 | } |
828 | 828 | } |
829 | | - |
| 829 | + |
830 | 830 | extract( $data ); |
831 | | - |
| 831 | + |
832 | 832 | $bump = isset( $bump ) ? $bump : null; |
833 | | - |
| 833 | + |
834 | 834 | $thread->setSummary( $article ); |
835 | 835 | $thread->commitRevision( |
836 | 836 | Threads::CHANGE_EDITED_SUMMARY, $thread, $summary, $bump ); |
837 | | - |
| 837 | + |
838 | 838 | return $thread; |
839 | 839 | } |
840 | | - |
| 840 | + |
841 | 841 | static function editMetadataUpdates( $data = array() ) { |
842 | 842 | $requiredFields = array( 'thread', 'text', 'summary' ); |
843 | | - |
| 843 | + |
844 | 844 | foreach ( $requiredFields as $f ) { |
845 | 845 | if ( !isset( $data[$f] ) ) { |
846 | 846 | throw new MWException( "Missing required field $f" ); |
847 | 847 | } |
848 | 848 | } |
849 | | - |
| 849 | + |
850 | 850 | $thread = $data['thread']; |
851 | | - |
| 851 | + |
852 | 852 | // Use a separate type if the content is blanked. |
853 | 853 | $type = strlen( trim( $data['text'] ) ) |
854 | 854 | ? Threads::CHANGE_EDITED_ROOT |
855 | 855 | : Threads::CHANGE_ROOT_BLANKED; |
856 | | - |
| 856 | + |
857 | 857 | if ( isset( $data['signature'] ) ) { |
858 | 858 | $thread->setSignature( $data['signature'] ); |
859 | 859 | } |
860 | | - |
| 860 | + |
861 | 861 | $bump = !empty( $data['bump'] ); |
862 | 862 | |
863 | 863 | // Add the history entry. |
864 | 864 | $thread->commitRevision( $type, $thread, $data['summary'], $bump ); |
865 | | - |
| 865 | + |
866 | 866 | // Update subject if applicable. |
867 | 867 | if ( $thread->isTopmostThread() && !empty( $data['subject'] ) && |
868 | 868 | $data['subject'] != $thread->subject() ) { |
— | — | @@ -872,20 +872,20 @@ |
873 | 873 | // Disabled page-moving for now. |
874 | 874 | // $this->renameThread( $thread, $subject, $e->summary ); |
875 | 875 | } |
876 | | - |
| 876 | + |
877 | 877 | return $thread; |
878 | 878 | } |
879 | 879 | |
880 | 880 | static function newPostMetadataUpdates( $data ) |
881 | 881 | { |
882 | 882 | $requiredFields = array( 'talkpage', 'root', 'text', 'subject' ); |
883 | | - |
| 883 | + |
884 | 884 | foreach ( $requiredFields as $f ) { |
885 | 885 | if ( !isset( $data[$f] ) ) { |
886 | 886 | throw new MWException( "Missing required field $f" ); |
887 | 887 | } |
888 | 888 | } |
889 | | - |
| 889 | + |
890 | 890 | $signature = null; |
891 | 891 | if ( isset( $data['signature'] ) ) { |
892 | 892 | $signature = $data['signature']; |
— | — | @@ -893,9 +893,9 @@ |
894 | 894 | global $wgUser; |
895 | 895 | $signature = LqtView::getUserSignature( $wgUser ); |
896 | 896 | } |
897 | | - |
| 897 | + |
898 | 898 | $summary = isset( $data['summary'] ) ? $data['summary'] : ''; |
899 | | - |
| 899 | + |
900 | 900 | $talkpage = $data['talkpage']; |
901 | 901 | $root = $data['root']; |
902 | 902 | $text = $data['text']; |
— | — | @@ -906,7 +906,7 @@ |
907 | 907 | Threads::TYPE_NORMAL, $subject, |
908 | 908 | $summary, null, $signature |
909 | 909 | ); |
910 | | - |
| 910 | + |
911 | 911 | wfRunHooks( 'LiquidThreadsAfterNewPostMetadataUpdates', array( &$thread ) ); |
912 | 912 | |
913 | 913 | return $thread; |
— | — | @@ -958,21 +958,21 @@ |
959 | 959 | |
960 | 960 | return true; |
961 | 961 | } |
962 | | - |
| 962 | + |
963 | 963 | function scratchTitle() { |
964 | 964 | return Title::makeTitle( NS_LQT_THREAD, wfGenerateToken() ); |
965 | 965 | } |
966 | 966 | |
967 | 967 | /** |
968 | 968 | * Example return value: |
969 | | - * array ( |
970 | | - * edit => array( 'label' => 'Edit', |
971 | | - * 'href' => 'http...', |
972 | | - * 'enabled' => false ), |
973 | | - * reply => array( 'label' => 'Reply', |
974 | | - * 'href' => 'http...', |
975 | | - * 'enabled' => true ) |
976 | | - * ) |
| 969 | + * array ( |
| 970 | + * edit => array( 'label' => 'Edit', |
| 971 | + * 'href' => 'http...', |
| 972 | + * 'enabled' => false ), |
| 973 | + * reply => array( 'label' => 'Reply', |
| 974 | + * 'href' => 'http...', |
| 975 | + * 'enabled' => true ) |
| 976 | + * ) |
977 | 977 | */ |
978 | 978 | function threadCommands( $thread ) { |
979 | 979 | wfLoadExtensionMessages( 'LiquidThreads' ); |
— | — | @@ -1038,7 +1038,7 @@ |
1039 | 1039 | 'enabled' => true |
1040 | 1040 | ); |
1041 | 1041 | } |
1042 | | - |
| 1042 | + |
1043 | 1043 | $commands['link'] = array( |
1044 | 1044 | 'label' => wfMsgExt( 'lqt_permalink', 'parseinline' ), |
1045 | 1045 | 'href' => $thread->title()->getFullURL(), |
— | — | @@ -1046,7 +1046,7 @@ |
1047 | 1047 | 'showlabel' => true, |
1048 | 1048 | 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' ) |
1049 | 1049 | ); |
1050 | | - |
| 1050 | + |
1051 | 1051 | wfRunHooks( 'LiquidThreadsThreadCommands', array( $thread, &$commands ) ); |
1052 | 1052 | |
1053 | 1053 | return $commands; |
— | — | @@ -1086,7 +1086,7 @@ |
1087 | 1087 | 'tooltip' => $label |
1088 | 1088 | ); |
1089 | 1089 | } |
1090 | | - |
| 1090 | + |
1091 | 1091 | if ( $thread->canUserReply( $this->user ) === true ) { |
1092 | 1092 | $commands['reply'] = array( |
1093 | 1093 | 'label' => wfMsgExt( 'lqt_reply', 'parseinline' ), |
— | — | @@ -1098,12 +1098,12 @@ |
1099 | 1099 | 'icon' => 'reply.png', |
1100 | 1100 | ); |
1101 | 1101 | } |
1102 | | - |
| 1102 | + |
1103 | 1103 | // Parent post link |
1104 | 1104 | if ( !$thread->isTopmostThread() ) { |
1105 | 1105 | $parent = $thread->superthread(); |
1106 | 1106 | $anchor = $parent->getAnchorName(); |
1107 | | - |
| 1107 | + |
1108 | 1108 | $commands['parent'] = array( |
1109 | 1109 | 'label' => wfMsgExt( 'lqt-parent', 'parseinline' ), |
1110 | 1110 | 'href' => '#' . $anchor, |
— | — | @@ -1111,7 +1111,7 @@ |
1112 | 1112 | 'showlabel' => 1, |
1113 | 1113 | ); |
1114 | 1114 | } |
1115 | | - |
| 1115 | + |
1116 | 1116 | wfRunHooks( 'LiquidThreadsThreadMajorCommands', |
1117 | 1117 | array( $thread, &$commands ) ); |
1118 | 1118 | |
— | — | @@ -1175,14 +1175,14 @@ |
1176 | 1176 | 'href' => $summarizeUrl, |
1177 | 1177 | 'enabled' => true, |
1178 | 1178 | ); |
1179 | | - |
| 1179 | + |
1180 | 1180 | wfRunHooks( 'LiquidThreadsTopLevelCommands', array( $thread, &$commands ) ); |
1181 | 1181 | |
1182 | 1182 | return $commands; |
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /************************* |
1186 | | - * Output methods * |
| 1186 | + * Output methods * |
1187 | 1187 | *************************/ |
1188 | 1188 | |
1189 | 1189 | static function addJSandCSS() { |
— | — | @@ -1191,29 +1191,27 @@ |
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | global $wgOut, $wgStylePath; |
1195 | | - global $wgScriptPath, $wgStyleVersion; |
| 1195 | + global $wgStyleVersion; |
1196 | 1196 | global $wgEnableJS2system; |
1197 | | - global $wgLiquidThreadsExtensionName; |
| 1197 | + global $wgLiquidThreadsExtensionPath; |
1198 | 1198 | |
1199 | 1199 | LqtHooks::$scriptVariables['wgLqtMessages'] = self::exportJSLocalisation(); |
1200 | 1200 | |
1201 | | - $basePath = "$wgScriptPath/extensions/$wgLiquidThreadsExtensionName"; |
1202 | | - |
1203 | 1201 | if ( method_exists( $wgOut, 'includeJQuery' ) ) { |
1204 | 1202 | $wgOut->includeJQuery(); |
1205 | | - $wgOut->addScriptFile( "$basePath/jquery/plugins.js" ); |
| 1203 | + $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/plugins.js" ); |
1206 | 1204 | } else { |
1207 | | - $wgOut->addScriptFile( "$basePath/jquery/js2.combined.js" ); |
| 1205 | + $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js" ); |
1208 | 1206 | } |
1209 | | - |
1210 | | - $wgOut->addExtensionStyle( "$basePath/jquery/jquery-ui-1.7.2.css" ); |
1211 | 1207 | |
1212 | | - $wgOut->addScriptFile( "$basePath/jquery/jquery.autogrow.js" ); |
| 1208 | + $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" ); |
1213 | 1209 | |
1214 | | - $wgOut->addScriptFile( "$basePath/lqt.js" ); |
1215 | | - $wgOut->addScriptFile( "$basePath/js/lqt.toolbar.js" ); |
1216 | | - $wgOut->addExtensionStyle( "$basePath/lqt.css?{$wgStyleVersion}" ); |
1217 | | - |
| 1210 | + $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js" ); |
| 1211 | + |
| 1212 | + $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/lqt.js" ); |
| 1213 | + $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/js/lqt.toolbar.js" ); |
| 1214 | + $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/lqt.css?{$wgStyleVersion}" ); |
| 1215 | + |
1218 | 1216 | if ( class_exists( 'WikiEditorHooks' ) ) { |
1219 | 1217 | $temp = null; |
1220 | 1218 | WikiEditorHooks::addModules( $temp ); |
— | — | @@ -1361,7 +1359,6 @@ |
1362 | 1360 | $tooltip = isset( $command['tooltip'] ) ? $command['tooltip'] : ''; |
1363 | 1361 | |
1364 | 1362 | if ( isset( $command['icon'] ) ) { |
1365 | | - global $wgScriptPath; |
1366 | 1363 | $icon = Xml::tags( 'div', array( 'title' => $label, |
1367 | 1364 | 'class' => 'lqt-command-icon' ), ' ' ); |
1368 | 1365 | if ( $icon_divs ) { |
— | — | @@ -1424,12 +1421,12 @@ |
1425 | 1422 | $html = ''; |
1426 | 1423 | |
1427 | 1424 | // No way am I refactoring EditForm to return its output as HTML. |
1428 | | - // so I'm just flushing the HTML and displaying it as-is. |
| 1425 | + // so I'm just flushing the HTML and displaying it as-is. |
1429 | 1426 | $this->showPostEditingForm( $thread ); |
1430 | 1427 | $html .= Xml::closeElement( 'div' ); |
1431 | 1428 | } elseif ( $showAnything ) { |
1432 | 1429 | $html .= Xml::openElement( 'div', array( 'class' => $divClass ) ); |
1433 | | - |
| 1430 | + |
1434 | 1431 | $show = wfRunHooks( 'LiquidThreadsShowPostContent', |
1435 | 1432 | array( $thread, &$post ) ); |
1436 | 1433 | if ( $show ) { |
— | — | @@ -1438,7 +1435,7 @@ |
1439 | 1436 | $html .= Xml::closeElement( 'div' ); |
1440 | 1437 | $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0' ), |
1441 | 1438 | ' ' ); |
1442 | | - |
| 1439 | + |
1443 | 1440 | wfRunHooks( 'LiquidThreadsShowPostThreadBody', |
1444 | 1441 | array( $thread, $this->request, &$html ) ); |
1445 | 1442 | |
— | — | @@ -1463,11 +1460,11 @@ |
1464 | 1461 | $signature = Xml::tags( 'span', array( 'class' => 'lqt-thread-user-signature' ), |
1465 | 1462 | $signature ); |
1466 | 1463 | |
1467 | | - $timestamp = $wgLang->timeanddate( $thread->created(), true ); |
| 1464 | + $timestamp = $wgLang->timeanddate( $thread->created(), true ); |
1468 | 1465 | $signature .= Xml::element( 'span', |
1469 | 1466 | array( 'class' => 'lqt-thread-toolbar-timestamp' ), |
1470 | 1467 | $timestamp ); |
1471 | | - |
| 1468 | + |
1472 | 1469 | wfRunHooks( 'LiquidThreadsThreadSignature', array( $thread, &$signature ) ); |
1473 | 1470 | |
1474 | 1471 | $signature = Xml::tags( 'div', array( 'class' => 'lqt-thread-signature' ), |
— | — | @@ -1493,22 +1490,22 @@ |
1494 | 1491 | $lastEdit = $wgLang->timeanddate( $lastEdit, true ); |
1495 | 1492 | $editors = ''; |
1496 | 1493 | $editorCount = 0; |
1497 | | - |
| 1494 | + |
1498 | 1495 | if ( $editedFlag > Threads::EDITED_BY_AUTHOR ) { |
1499 | 1496 | $editors = $thread->editors(); |
1500 | 1497 | $editorCount = count( $editors ); |
1501 | 1498 | $formattedEditors = array(); |
1502 | | - |
| 1499 | + |
1503 | 1500 | foreach ( $editors as $ed ) { |
1504 | 1501 | $id = IP::isIPAddress( $ed ) ? 0 : 1; |
1505 | 1502 | $fEditor = $sk->userLink( $id, $ed ) . |
1506 | 1503 | $sk->userToolLinks( $id, $ed ); |
1507 | 1504 | $formattedEditors[] = $fEditor; |
1508 | 1505 | } |
1509 | | - |
| 1506 | + |
1510 | 1507 | $editors = $wgLang->commaList( $formattedEditors ); |
1511 | 1508 | } |
1512 | | - |
| 1509 | + |
1513 | 1510 | if ( isset( $ebLookup[$editedFlag] ) ) { |
1514 | 1511 | $editedBy = $ebLookup[$editedFlag]; |
1515 | 1512 | // Used messages: lqt-thread-edited-author, lqt-thread-edited-others |
— | — | @@ -1521,7 +1518,7 @@ |
1522 | 1519 | 'lqt-thread-toolbar-edited-' . $editedBy ), |
1523 | 1520 | $editedNotice ); |
1524 | 1521 | } |
1525 | | - |
| 1522 | + |
1526 | 1523 | wfRunHooks( 'LiquidThreadsThreadInfoPanel', array( $thread, &$infoElements ) ); |
1527 | 1524 | |
1528 | 1525 | if ( ! count( $infoElements ) ) { |
— | — | @@ -1551,10 +1548,10 @@ |
1552 | 1549 | $id = 'lqt-header-' . $thread->id(); |
1553 | 1550 | |
1554 | 1551 | $html = $thread->formattedSubject(); |
1555 | | - |
| 1552 | + |
1556 | 1553 | $show = wfRunHooks( 'LiquidThreadsShowThreadHeading', |
1557 | 1554 | array( $thread, &$html ) ); |
1558 | | - |
| 1555 | + |
1559 | 1556 | if ( $show ) { |
1560 | 1557 | $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html ); |
1561 | 1558 | $html .= Xml::hidden( 'raw-header', $thread->subject() ); |
— | — | @@ -1562,7 +1559,7 @@ |
1563 | 1560 | array( 'class' => 'lqt_header', 'id' => $id ), |
1564 | 1561 | $html ) . $commands_html; |
1565 | 1562 | } |
1566 | | - |
| 1563 | + |
1567 | 1564 | // wrap it all in a container |
1568 | 1565 | $html = Xml::tags( 'div', |
1569 | 1566 | array( 'class' => 'lqt_thread_heading' ), |
— | — | @@ -1764,11 +1761,11 @@ |
1765 | 1762 | $cascadeOptions, $interruption = false ) { |
1766 | 1763 | $repliesClass = 'lqt-thread-replies lqt-thread-replies-' . |
1767 | 1764 | $this->threadNestingLevel; |
1768 | | - |
| 1765 | + |
1769 | 1766 | if ( $interruption ) { |
1770 | 1767 | $repliesClass .= ' lqt-thread-replies-interruption'; |
1771 | 1768 | } |
1772 | | - |
| 1769 | + |
1773 | 1770 | $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) ); |
1774 | 1771 | $sep = Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ); |
1775 | 1772 | |
— | — | @@ -1802,7 +1799,7 @@ |
1803 | 1800 | ++$showCount; |
1804 | 1801 | if ( $showCount == 1 ) { |
1805 | 1802 | // There's a post sep before each reply group to |
1806 | | - // separate from the parent thread. |
| 1803 | + // separate from the parent thread. |
1807 | 1804 | $this->output->addHTML( $sep . $div ); |
1808 | 1805 | } |
1809 | 1806 | |
— | — | @@ -1812,7 +1809,7 @@ |
1813 | 1810 | |
1814 | 1811 | // Handle must-show threads. |
1815 | 1812 | // FIXME this thread will be duplicated if somebody clicks the |
1816 | | - // "show more" link (probably needs fixing in the JS) |
| 1813 | + // "show more" link (probably needs fixing in the JS) |
1817 | 1814 | if ( $st->type() != Threads::TYPE_DELETED && !$shown && |
1818 | 1815 | array_key_exists( $st->id(), $mustShowThreads ) ) { |
1819 | 1816 | |
— | — | @@ -1846,7 +1843,7 @@ |
1847 | 1844 | $this->threadNestingLevel++; |
1848 | 1845 | |
1849 | 1846 | // Figure out which threads *need* to be shown because they're involved in an |
1850 | | - // operation |
| 1847 | + // operation |
1851 | 1848 | $mustShowOption = array(); |
1852 | 1849 | if ( isset( $options['mustShowThreads'] ) ) { |
1853 | 1850 | $mustShowOption = $options['mustShowThreads' ]; |
— | — | @@ -1907,7 +1904,7 @@ |
1908 | 1905 | |
1909 | 1906 | $sk = $this->user->getSkin(); |
1910 | 1907 | $html = ''; |
1911 | | - |
| 1908 | + |
1912 | 1909 | $html .= Xml::openElement( 'div', array( 'class' => 'lqt-thread-wrapper' ) ); |
1913 | 1910 | |
1914 | 1911 | $html .= Xml::element( 'a', array( 'name' => $this->anchorName( $thread ) ), ' ' ); |
— | — | @@ -1951,7 +1948,7 @@ |
1952 | 1949 | array( 'id' => 'lqt-thread-sortkey-' . $thread->id() ) |
1953 | 1950 | ); |
1954 | 1951 | } |
1955 | | - |
| 1952 | + |
1956 | 1953 | if ( ! $thread->title() ) { |
1957 | 1954 | throw new MWException( "Thread " . $thread->id() . " has null title" ); |
1958 | 1955 | } |
— | — | @@ -1975,7 +1972,7 @@ |
1976 | 1973 | |
1977 | 1974 | $cascadeOptions = $options; |
1978 | 1975 | unset( $cascadeOptions['startAt'] ); |
1979 | | - |
| 1976 | + |
1980 | 1977 | $replyInterruption = $levelNum < $totalInLevel; |
1981 | 1978 | |
1982 | 1979 | if ( ( $hasSubthreads && $showThreads ) ) { |
— | — | @@ -1984,11 +1981,11 @@ |
1985 | 1982 | $cascadeOptions, $replyInterruption ); |
1986 | 1983 | } elseif ( $hasSubthreads && !$showThreads ) { |
1987 | 1984 | // If the thread has subthreads, but we don't want to show them, then |
1988 | | - // show the reply form if necessary, and add the "Show X replies" link. |
| 1985 | + // show the reply form if necessary, and add the "Show X replies" link. |
1989 | 1986 | if ( $replyTo ) { |
1990 | 1987 | $this->showReplyForm( $thread ); |
1991 | 1988 | } |
1992 | | - |
| 1989 | + |
1993 | 1990 | // Add a "show subthreads" link. |
1994 | 1991 | $link = $this->getShowReplies( $thread ); |
1995 | 1992 | |
— | — | @@ -2000,7 +1997,7 @@ |
2001 | 1998 | } |
2002 | 1999 | } elseif ( $levelNum < $totalInLevel ) { |
2003 | 2000 | // If we have no replies, and we're not at the end of this level, add the post separator |
2004 | | - // and a reply box if necessary. |
| 2001 | + // and a reply box if necessary. |
2005 | 2002 | $this->output->addHTML( |
2006 | 2003 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
2007 | 2004 | |
— | — | @@ -2009,7 +2006,7 @@ |
2010 | 2007 | $this->threadNestingLevel; |
2011 | 2008 | $html = Xml::openElement( 'div', array( 'class' => $class ) ); |
2012 | 2009 | $this->output->addHTML( $html ); |
2013 | | - |
| 2010 | + |
2014 | 2011 | $this->showReplyForm( $thread ); |
2015 | 2012 | |
2016 | 2013 | $finishDiv = Xml::tags( 'div', |
— | — | @@ -2024,14 +2021,14 @@ |
2025 | 2022 | } |
2026 | 2023 | } elseif ( !$hasSubthreads && $replyTo ) { |
2027 | 2024 | // If we have no replies, we're at the end of this level, and we want to reply, |
2028 | | - // show the reply box. |
| 2025 | + // show the reply box. |
2029 | 2026 | $class = 'lqt-thread-replies lqt-thread-replies-' . |
2030 | 2027 | $this->threadNestingLevel; |
2031 | 2028 | $html = Xml::openElement( 'div', array( 'class' => $class ) ); |
2032 | 2029 | $this->output->addHTML( $html ); |
2033 | | - |
| 2030 | + |
2034 | 2031 | $this->showReplyForm( $thread ); |
2035 | | - |
| 2032 | + |
2036 | 2033 | $html = Xml::tags( 'div', |
2037 | 2034 | array( 'class' => 'lqt-replies-finish' ), |
2038 | 2035 | Xml::tags( 'div', |
— | — | @@ -2043,16 +2040,16 @@ |
2044 | 2041 | } |
2045 | 2042 | |
2046 | 2043 | // I don't remember why this is here, commenting out. |
2047 | | -// if ( $this->threadNestingLevel == 1 ) { |
2048 | | -// if ( !( $hasSubthreads && $showThreads && !$replyTo ) ) { |
2049 | | -// $this->showReplyBox( $thread ); |
2050 | | -// $finishDiv = ''; |
2051 | | -// $finishDiv .= Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ), |
2052 | | -// Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), ' ' ) ); |
2053 | | -// |
2054 | | -// $this->output->addHTML( $finishDiv ); |
2055 | | -// } |
2056 | | -// } |
| 2044 | +// if ( $this->threadNestingLevel == 1 ) { |
| 2045 | +// if ( !( $hasSubthreads && $showThreads && !$replyTo ) ) { |
| 2046 | +// $this->showReplyBox( $thread ); |
| 2047 | +// $finishDiv = ''; |
| 2048 | +// $finishDiv .= Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ), |
| 2049 | +// Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), ' ' ) ); |
| 2050 | +// |
| 2051 | +// $this->output->addHTML( $finishDiv ); |
| 2052 | +// } |
| 2053 | +// } |
2057 | 2054 | |
2058 | 2055 | $this->output->addHTML( Xml::closeElement( 'div' ) . Xml::closeElement( 'div' ) ); |
2059 | 2056 | |
— | — | @@ -2071,7 +2068,7 @@ |
2072 | 2069 | $html = ''; |
2073 | 2070 | $html .= Xml::tags( 'div', |
2074 | 2071 | array( 'class' => 'lqt-reply-form lqt-edit-form', |
2075 | | - 'style' => 'display: none;' ), |
| 2072 | + 'style' => 'display: none;' ), |
2076 | 2073 | '' ); |
2077 | 2074 | |
2078 | 2075 | $this->output->addHTML( $html ); |
— | — | @@ -2194,7 +2191,7 @@ |
2195 | 2192 | |
2196 | 2193 | static function signaturePST( $sig, $user ) { |
2197 | 2194 | global $wgParser, $wgOut, $wgTitle; |
2198 | | - |
| 2195 | + |
2199 | 2196 | $title = $wgTitle ? $wgTitle : $user->getUserPage(); |
2200 | 2197 | |
2201 | 2198 | // Parser gets antsy about parser options here if it hasn't parsed anything before. |
Index: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | |
28 | 28 | function getReadAllButton( $threads ) { |
29 | 29 | wfLoadExtensionMessages( 'LiquidThreads' ); |
30 | | - $ids = array_map( create_function( '$t', 'return $t->id();' ), $threads ); // ew |
| 30 | + $ids = array_map( create_function( '$t', 'return $t->id();' ), $threads ); // ew |
31 | 31 | return $this->htmlForReadButton( |
32 | 32 | wfMsg( 'lqt-read-all' ), |
33 | 33 | wfMsg( 'lqt-read-all-tooltip' ), |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array( $t->subject() ) ); |
47 | 47 | } else { |
48 | 48 | $count = count( $ids ); |
49 | | - $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) ); |
| 49 | + $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) ); |
50 | 50 | } |
51 | 51 | $operand = implode( ',', $ids ); |
52 | 52 | |
— | — | @@ -84,15 +84,14 @@ |
85 | 85 | |
86 | 86 | function showOnce() { |
87 | 87 | self::addJSandCSS(); |
88 | | - |
| 88 | + |
89 | 89 | NewMessages::recacheMessageCount( $this->user->getId() ); |
90 | 90 | |
91 | 91 | static $scriptDone = false; |
92 | 92 | |
93 | 93 | if ( !$scriptDone ) { |
94 | | - global $wgOut, $wgScriptPath, $wgLiquidThreadsExtensionName; |
95 | | - $prefix = "{$wgScriptPath}/extensions/{$wgLiquidThreadsExtensionName}"; |
96 | | - $wgOut->addScriptFile( "$prefix/newmessages.js" ); |
| 94 | + global $wgOut, $wgLiquidThreadsExtensionPath |
| 95 | + $wgOut->addScriptFile( "$wgLiquidThreadExtensionPath/newmessages.js" ); |
97 | 96 | } |
98 | 97 | |
99 | 98 | $this->user->setNewtalk( false ); |
— | — | @@ -180,7 +179,7 @@ |
181 | 180 | $title->setFragment( '#' . $t->getAnchorName() ); |
182 | 181 | |
183 | 182 | // Make sure it points to the right page. The Pager seems to use the DB |
184 | | - // representation of a timestamp for its offset field, odd. |
| 183 | + // representation of a timestamp for its offset field, odd. |
185 | 184 | $dbr = wfGetDB( DB_SLAVE ); |
186 | 185 | $offset = wfTimestamp( TS_UNIX, $topmostThread->modified() ) + 1; |
187 | 186 | $offset = $dbr->timestamp( $offset ); |