r69712 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69711‎ | r69712 | r69713 >
Date:00:14, 22 July 2010
Author:mah
Status:deferred (Comments)
Tags:
Comment:
Don't hard-code the path so that the extension must be installed under $IP/extensions to work.
* Eliminate $wgLiquidThreadExtensionName (which was only used internally to create a path for CSS and JS)
* Create $wgLiquidThreadExtensionPath so that the extension can be installed outside of the /extensions dir or even in a sub-dir of /extensions.
* Note that this eliminates what was a WMF-specific variable (comments said *Name was wmf-specific) while still allowing the same functionality.
* Eliminate a spurious use of “global”
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -3,11 +3,11 @@
44 die();
55
66 $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' ),
1212 'descriptionmsg' => 'lqt-desc',
1313 );
1414
@@ -22,15 +22,15 @@
2323 define( 'LQT_OLDEST_THREADS', 'ot' );
2424
2525 // 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';
2929 $wgCanonicalNamespaceNames[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
3030
3131 // 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';
3535 $wgExtraNamespaces[NS_LQT_SUMMARY_TALK] = 'Summary_talk';
3636
3737 // Localisation
@@ -171,8 +171,8 @@
172172
173173 // Logging
174174 $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';
177177
178178 foreach ( array( 'move', 'split', 'merge', 'subjectedit', 'resort' ) as $action ) {
179179 $wgLogActionsHandlers["liquidthreads/$action"] = 'LqtLogFormatter::formatLogEntry';
@@ -192,8 +192,8 @@
193193 $wgAutoloadClasses['ApiThreadAction'] = "$dir/api/ApiThreadAction.php";
194194 $wgAPIModules['threadaction'] = 'ApiThreadAction';
195195
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";
198198
199199 /** CONFIGURATION SECTION */
200200
Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -80,7 +80,7 @@
8181 if ( $operand ) {
8282 $query['lqt_operand'] = $operand;
8383 }
84 -
 84+
8585 if ( ! $thread ) {
8686 throw new MWException( "Empty thread passed to ".__METHOD__ );
8787 }
@@ -114,7 +114,7 @@
115115
116116 static function linkInContextData( $thread, $contextType = 'page' ) {
117117 $query = array();
118 -
 118+
119119 if ( ! $thread ) {
120120 throw new MWException( "Null thread passed to linkInContextData" );
121121 }
@@ -282,9 +282,9 @@
283283 }
284284
285285 /*************************************************************
286 - * Editing methods (here be dragons) *
 286+ * Editing methods (here be dragons) *
287287 * 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. *
289289 *************************************************************/
290290
291291 /**
@@ -311,7 +311,7 @@
312312 $operand = $this->request->getVal( 'lqt_operand' );
313313
314314 $thread = Threads::withId( intval( $operand ) );
315 -
 315+
316316 $hookResult = wfRunHooks( 'LiquidThreadsDoInlineEditForm',
317317 array(
318318 $thread,
@@ -331,20 +331,20 @@
332332
333333 $this->output->setArticleBodyOnly( true );
334334 }
335 -
 335+
336336 function showNewThreadForm( $talkpage ) {
337337 $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
338338 $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() );
339339 if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return;
340 -
 340+
341341 if ( Thread::canUserPost( $this->user, $this->article ) !== true ) {
342342 $this->output->addWikiMsg( 'lqt-protected-newthread' );
343343 return;
344344 }
345345 $subject = $this->request->getVal( 'lqt_subject_field', false );
346 -
 346+
347347 $t = null;
348 -
 348+
349349 $subjectOk = Thread::validateSubject( $subject, $t,
350350 null, $this->article );
351351 if ( ! $subjectOk ) {
@@ -354,65 +354,65 @@
355355 $t = $this->scratchTitle();
356356 }
357357 }
358 -
 358+
359359 $article = new Article( $t );
360 -
 360+
361361 LqtHooks::$editTalkpage = $talkpage;
362362 LqtHooks::$editArticle = $article;
363363 LqtHooks::$editThread = null;
364364 LqtHooks::$editType = 'new';
365365 LqtHooks::$editAppliesTo = null;
366 -
 366+
367367 wfRunHooks( 'LiquidThreadsShowNewThreadForm', array( &$e, $talkpage ) );
368 -
 368+
369369 $e = new EditPage( $article );
370 -
 370+
371371 global $wgRequest;
372372 // Quietly force a preview if no subject has been specified.
373373 if ( !$subjectOk ) {
374374 // Dirty hack to prevent saving from going ahead
375375 $wgRequest->setVal( 'wpPreview', true );
376 -
 376+
377377 if ( $this->request->wasPosted() ) {
378378 if ( !$subject ) {
379379 $msg = 'lqt_empty_subject';
380380 } else {
381381 $msg = 'lqt_invalid_subject';
382382 }
383 -
 383+
384384 $e->editFormPageTop .=
385385 Xml::tags( 'div', array( 'class' => 'error' ),
386386 wfMsgExt( $msg, 'parse' ) );
387387 }
388388 }
389 -
 389+
390390 $e->suppressIntro = true;
391391 $e->editFormTextBeforeContent .=
392392 $this->perpetuate( 'lqt_method', 'hidden' ) .
393393 $this->perpetuate( 'lqt_operand', 'hidden' ) .
394394 Xml::hidden( 'lqt_nonce', wfGenerateToken() );
395 -
 395+
396396 $e->mShowSummaryField = false;
397 -
 397+
398398 $summary = wfMsgForContent( 'lqt-newpost-summary', $subject );
399399 $wgRequest->setVal( 'wpSummary', $summary );
400 -
 400+
401401 list( $signatureEditor, $signatureHTML ) = $this->getSignatureEditor( $this->user );
402 -
 402+
403403 $e->editFormTextAfterContent .=
404404 $signatureEditor;
405405 $e->previewTextAfterContent .=
406406 Xml::tags( 'p', null, $signatureHTML );
407 -
 407+
408408 $e->editFormTextBeforeContent .= $this->getSubjectEditor( '', $subject );
409 -
 409+
410410 wfRunHooks( 'LiquidThreadsAfterShowNewThreadForm', array( &$e, $talkpage ) );
411 -
 411+
412412 $e->edit();
413 -
 413+
414414 if ( $e->didSave ) {
415415 $signature = $this->request->getVal( 'wpLqtSignature', null );
416 -
 416+
417417 $info =
418418 array(
419419 'talkpage' => $talkpage,
@@ -422,66 +422,66 @@
423423 'root' => $article,
424424 'subject' => $subject,
425425 );
426 -
 426+
427427 wfRunHooks( 'LiquidThreadsSaveNewThread',
428428 array( &$info, &$e, &$talkpage ) );
429 -
 429+
430430 $thread = LqtView::newPostMetadataUpdates( $info );
431 -
 431+
432432 if ( $submitted_nonce && $nonce_key ) {
433433 global $wgMemc;
434434 $wgMemc->set( $nonce_key, 1, 3600 );
435435 }
436436 }
437 -
 437+
438438 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() );
444444 }
445 -
 445+
446446 }
447 -
 447+
448448 function showReplyForm( $thread ) {
449449 global $wgRequest;
450 -
 450+
451451 $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
452452 $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() );
453453 if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return;
454 -
 454+
455455 $perm_result = $thread->canUserReply( $this->user );
456456 if ( $perm_result !== true ) {
457457 $this->showReplyProtectedNotice( $thread );
458458 return;
459459 }
460 -
 460+
461461 $html = Xml::openElement( 'div',
462462 array( 'class' => 'lqt-reply-form' ) );
463463 $this->output->addHTML( $html );
464464
465 -
 465+
466466 try {
467467 $t = $this->newReplyTitle( null, $thread );
468468 } catch ( MWException $excep ) {
469469 $t = $this->scratchTitle();
470470 $valid_subject = false;
471471 }
472 -
 472+
473473 $article = new Article( $t );
474474 $talkpage = $thread->article();
475 -
 475+
476476 LqtHooks::$editTalkpage = $talkpage;
477477 LqtHooks::$editArticle = $article;
478478 LqtHooks::$editThread = $thread;
479479 LqtHooks::$editType = 'reply';
480480 LqtHooks::$editAppliesTo = $thread;
481 -
 481+
482482 $e = new EditPage( $article );
483 -
 483+
484484 $e->mShowSummaryField = false;
485 -
 485+
486486 $reply_subject = $thread->subject();
487487 $reply_title = $thread->title()->getPrefixedText();
488488 $summary = wfMsgForContent(
@@ -490,37 +490,37 @@
491491 $reply_title
492492 );
493493 $wgRequest->setVal( 'wpSummary', $summary );
494 -
 494+
495495 // Add an offset so it works if it's on the wrong page.
496496 $dbr = wfGetDB( DB_SLAVE );
497497 $offset = wfTimestamp( TS_UNIX, $thread->topmostThread()->sortkey() );
498498 $offset++;
499499 $offset = $dbr->timestamp( $offset );
500 -
 500+
501501 $e->suppressIntro = true;
502502 $e->editFormTextBeforeContent .=
503503 $this->perpetuate( 'lqt_method', 'hidden' ) .
504504 $this->perpetuate( 'lqt_operand', 'hidden' ) .
505505 Xml::hidden( 'lqt_nonce', wfGenerateToken() ) .
506506 Xml::hidden( 'offset', $offset );
507 -
 507+
508508 list( $signatureEditor, $signatureHTML ) = $this->getSignatureEditor( $this->user );
509 -
 509+
510510 $e->editFormTextAfterContent .=
511511 $signatureEditor;
512512 $e->previewTextAfterContent .=
513513 Xml::tags( 'p', null, $signatureHTML );
514 -
 514+
515515 $wgRequest->setVal( 'wpWatchThis', false );
516 -
 516+
517517 wfRunHooks( 'LiquidThreadsShowReplyForm', array( &$e, $thread ) );
518 -
 518+
519519 $e->edit();
520 -
 520+
521521 if ( $e->didSave ) {
522522 $bump = $this->request->getBool( 'wpBumpThread' );
523523 $signature = $this->request->getVal( 'wpLqtSignature', null );
524 -
 524+
525525 $info = array(
526526 'replyTo' => $thread,
527527 'text' => $e->textbox1,
@@ -529,106 +529,106 @@
530530 'signature' => $signature,
531531 'root' => $article,
532532 );
533 -
 533+
534534 wfRunHooks( 'LiquidThreadsSaveReply',
535535 array( &$info, &$e, &$thread ) );
536 -
 536+
537537 $newThread = LqtView::replyMetadataUpdates( $info );
538 -
 538+
539539 if ( $submitted_nonce && $nonce_key ) {
540540 global $wgMemc;
541541 $wgMemc->set( $nonce_key, 1, 3600 );
542542 }
543543 }
544 -
 544+
545545 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() );
552552 }
553 -
 553+
554554 $this->output->addHTML( '</div>' );
555555 }
556 -
 556+
557557 function showPostEditingForm( $thread ) {
558558 $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
559559 $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() );
560560 if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return;
561 -
 561+
562562 $subject_expected = $thread->isTopmostThread();
563563 $subject = $this->request->getVal( 'lqt_subject_field', '' );
564 -
 564+
565565 if ( !$subject ) {
566566 $subject = $thread->subject();
567567 }
568 -
 568+
569569 $t = null;
570570 $subjectOk = Thread::validateSubject( $subject, $t,
571571 $thread->superthread(), $this->article );
572572 if ( ! $subjectOk ) {
573573 $subject = false;
574574 }
575 -
 575+
576576 $article = $thread->root();
577577 $talkpage = $thread->article();
578 -
 578+
579579 wfRunHooks( 'LiquidThreadsEditFormContent', array( $thread, &$article, $talkpage ) );
580 -
 580+
581581 LqtHooks::$editTalkpage = $talkpage;
582582 LqtHooks::$editArticle = $article;
583583 LqtHooks::$editThread = $thread;
584584 LqtHooks::$editType = 'edit';
585585 LqtHooks::$editAppliesTo = $thread;
586 -
 586+
587587 $e = new EditPage( $article );
588 -
 588+
589589 global $wgRequest;
590590 // Quietly force a preview if no subject has been specified.
591591 if ( !$subjectOk ) {
592592 // Dirty hack to prevent saving from going ahead
593593 $wgRequest->setVal( 'wpPreview', true );
594 -
 594+
595595 if ( $this->request->wasPosted() ) {
596596 $e->editFormPageTop .=
597597 Xml::tags( 'div', array( 'class' => 'error' ),
598598 wfMsgExt( 'lqt_invalid_subject', 'parse' ) );
599599 }
600600 }
601 -
 601+
602602 // Add an offset so it works if it's on the wrong page.
603603 $dbr = wfGetDB( DB_SLAVE );
604604 $offset = wfTimestamp( TS_UNIX, $thread->topmostThread()->sortkey() );
605605 $offset++;
606606 $offset = $dbr->timestamp( $offset );
607 -
 607+
608608 $e->suppressIntro = true;
609609 $e->editFormTextBeforeContent .=
610610 $this->perpetuate( 'lqt_method', 'hidden' ) .
611611 $this->perpetuate( 'lqt_operand', 'hidden' ) .
612612 Xml::hidden( 'lqt_nonce', wfGenerateToken() ) .
613613 Xml::hidden( 'offset', $offset );
614 -
 614+
615615 list( $signatureEditor, $signatureHTML ) = $this->getSignatureEditor( $thread );
616 -
 616+
617617 $e->editFormTextAfterContent .=
618618 $signatureEditor;
619619 $e->previewTextAfterContent .=
620620 Xml::tags( 'p', null, $signatureHTML );
621 -
 621+
622622 if ( $thread->isTopmostThread() ) {
623623 $e->editFormTextBeforeContent .=
624624 $this->getSubjectEditor( $thread->subject(), $subject );
625625 }
626 -
 626+
627627 $e->edit();
628 -
 628+
629629 if ( $e->didSave ) {
630630 $bump = $this->request->getBool( 'wpBumpThread' );
631631 $signature = $this->request->getVal( 'wpLqtSignature', null );
632 -
 632+
633633 LqtView::editMetadataUpdates(
634634 array(
635635 'thread' => $thread,
@@ -640,63 +640,63 @@
641641 'root' => $article,
642642 )
643643 );
644 -
 644+
645645 if ( $submitted_nonce && $nonce_key ) {
646646 global $wgMemc;
647647 $wgMemc->set( $nonce_key, 1, 3600 );
648648 }
649649 }
650 -
 650+
651651 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() );
655655 }
656 -
 656+
657657 }
658 -
 658+
659659 function showSummarizeForm( $thread ) {
660660 $submitted_nonce = $this->request->getVal( 'lqt_nonce' );
661661 $nonce_key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() );
662662 if ( ! $this->handleNonce( $submitted_nonce, $nonce_key ) ) return;
663 -
 663+
664664 if ( $thread->summary() ) {
665665 $article = $thread->summary();
666666 } else {
667667 $t = $this->newSummaryTitle( $thread );
668668 $article = new Article( $t );
669669 }
670 -
 670+
671671 $this->output->addWikiMsg( 'lqt-summarize-intro' );
672 -
 672+
673673 $talkpage = $thread->article();
674 -
 674+
675675 LqtHooks::$editTalkpage = $talkpage;
676676 LqtHooks::$editArticle = $article;
677677 LqtHooks::$editThread = $thread;
678678 LqtHooks::$editType = 'summarize';
679679 LqtHooks::$editAppliesTo = $thread;
680 -
 680+
681681 $e = new EditPage( $article );
682 -
 682+
683683 // Add an offset so it works if it's on the wrong page.
684684 $dbr = wfGetDB( DB_SLAVE );
685685 $offset = wfTimestamp( TS_UNIX, $thread->topmostThread()->sortkey() );
686686 $offset++;
687687 $offset = $dbr->timestamp( $offset );
688 -
 688+
689689 $e->suppressIntro = true;
690690 $e->editFormTextBeforeContent .=
691691 $this->perpetuate( 'lqt_method', 'hidden' ) .
692692 $this->perpetuate( 'lqt_operand', 'hidden' ) .
693693 Xml::hidden( 'lqt_nonce', wfGenerateToken() ) .
694694 Xml::hidden( 'offset', $offset );
695 -
 695+
696696 $e->edit();
697 -
 697+
698698 if ( $e->didSave ) {
699699 $bump = $this->request->getBool( 'wpBumpThread' );
700 -
 700+
701701 LqtView::summarizeMetadataUpdates(
702702 array(
703703 'thread' => $thread,
@@ -705,25 +705,25 @@
706706 'bump' => $bump,
707707 )
708708 );
709 -
 709+
710710 if ( $submitted_nonce && $nonce_key ) {
711711 global $wgMemc;
712712 $wgMemc->set( $nonce_key, 1, 3600 );
713713 }
714714 }
715 -
 715+
716716 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() );
720720 }
721 -
 721+
722722 }
723 -
 723+
724724 public function handleNonce( $submitted_nonce, $nonce_key ) {
725725 // 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.
728728 if ( $submitted_nonce ) {
729729 global $wgMemc;
730730
@@ -732,13 +732,13 @@
733733 return false;
734734 }
735735 }
736 -
 736+
737737 return true;
738738 }
739 -
 739+
740740 public function getSubjectEditor( $db_subject, $subject ) {
741741 if ( $subject === false ) $subject = $db_subject;
742 -
 742+
743743 $subject_label = wfMsg( 'lqt_subject' );
744744
745745 $attr = array( 'tabindex' => 1 );
@@ -747,7 +747,7 @@
748748 'lqt_subject_field', 60, $subject, $attr ) .
749749 Xml::element( 'br' );
750750 }
751 -
 751+
752752 public function getSignatureEditor( $from ) {
753753 $signatureText = $this->request->getVal( 'wpLqtSignature', null );
754754
@@ -776,19 +776,19 @@
777777 );
778778
779779 $signatureEditor = $signaturePreview . $signatureEditBox;
780 -
 780+
781781 return array( $signatureEditor, $signatureHTML );
782782 }
783 -
 783+
784784 static function replyMetadataUpdates( $data = array() ) {
785785 $requiredFields = array( 'replyTo', 'root', 'text' );
786 -
 786+
787787 foreach ( $requiredFields as $f ) {
788788 if ( !isset( $data[$f] ) ) {
789789 throw new MWException( "Missing required field $f" );
790790 }
791791 }
792 -
 792+
793793 $signature = null;
794794 if ( isset( $data['signature'] ) ) {
795795 $signature = $data['signature'];
@@ -796,72 +796,72 @@
797797 global $wgUser;
798798 $signature = LqtView::getUserSignature( $wgUser );
799799 }
800 -
 800+
801801 $summary = isset( $data['summary'] ) ? $data['summary'] : '';
802 -
 802+
803803 $replyTo = $data['replyTo'];
804804 $root = $data['root'];
805805 $text = $data['text'];
806806 $bump = !empty( $data['bump'] );
807 -
 807+
808808 $subject = $replyTo->subject();
809809 $talkpage = $replyTo->article();
810 -
 810+
811811 $thread = Thread::create(
812812 $root, $talkpage, $replyTo, Threads::TYPE_NORMAL, $subject,
813813 $summary, $bump, $signature
814814 );
815 -
 815+
816816 wfRunHooks( 'LiquidThreadsAfterReplyMetadataUpdates', array( &$thread ) );
817 -
 817+
818818 return $thread;
819819 }
820 -
 820+
821821 static function summarizeMetadataUpdates( $data = array() ) {
822822 $requiredFields = array( 'thread', 'article', 'summary' );
823 -
 823+
824824 foreach ( $requiredFields as $f ) {
825825 if ( !isset( $data[$f] ) ) {
826826 throw new MWException( "Missing required field $f" );
827827 }
828828 }
829 -
 829+
830830 extract( $data );
831 -
 831+
832832 $bump = isset( $bump ) ? $bump : null;
833 -
 833+
834834 $thread->setSummary( $article );
835835 $thread->commitRevision(
836836 Threads::CHANGE_EDITED_SUMMARY, $thread, $summary, $bump );
837 -
 837+
838838 return $thread;
839839 }
840 -
 840+
841841 static function editMetadataUpdates( $data = array() ) {
842842 $requiredFields = array( 'thread', 'text', 'summary' );
843 -
 843+
844844 foreach ( $requiredFields as $f ) {
845845 if ( !isset( $data[$f] ) ) {
846846 throw new MWException( "Missing required field $f" );
847847 }
848848 }
849 -
 849+
850850 $thread = $data['thread'];
851 -
 851+
852852 // Use a separate type if the content is blanked.
853853 $type = strlen( trim( $data['text'] ) )
854854 ? Threads::CHANGE_EDITED_ROOT
855855 : Threads::CHANGE_ROOT_BLANKED;
856 -
 856+
857857 if ( isset( $data['signature'] ) ) {
858858 $thread->setSignature( $data['signature'] );
859859 }
860 -
 860+
861861 $bump = !empty( $data['bump'] );
862862
863863 // Add the history entry.
864864 $thread->commitRevision( $type, $thread, $data['summary'], $bump );
865 -
 865+
866866 // Update subject if applicable.
867867 if ( $thread->isTopmostThread() && !empty( $data['subject'] ) &&
868868 $data['subject'] != $thread->subject() ) {
@@ -872,20 +872,20 @@
873873 // Disabled page-moving for now.
874874 // $this->renameThread( $thread, $subject, $e->summary );
875875 }
876 -
 876+
877877 return $thread;
878878 }
879879
880880 static function newPostMetadataUpdates( $data )
881881 {
882882 $requiredFields = array( 'talkpage', 'root', 'text', 'subject' );
883 -
 883+
884884 foreach ( $requiredFields as $f ) {
885885 if ( !isset( $data[$f] ) ) {
886886 throw new MWException( "Missing required field $f" );
887887 }
888888 }
889 -
 889+
890890 $signature = null;
891891 if ( isset( $data['signature'] ) ) {
892892 $signature = $data['signature'];
@@ -893,9 +893,9 @@
894894 global $wgUser;
895895 $signature = LqtView::getUserSignature( $wgUser );
896896 }
897 -
 897+
898898 $summary = isset( $data['summary'] ) ? $data['summary'] : '';
899 -
 899+
900900 $talkpage = $data['talkpage'];
901901 $root = $data['root'];
902902 $text = $data['text'];
@@ -906,7 +906,7 @@
907907 Threads::TYPE_NORMAL, $subject,
908908 $summary, null, $signature
909909 );
910 -
 910+
911911 wfRunHooks( 'LiquidThreadsAfterNewPostMetadataUpdates', array( &$thread ) );
912912
913913 return $thread;
@@ -958,21 +958,21 @@
959959
960960 return true;
961961 }
962 -
 962+
963963 function scratchTitle() {
964964 return Title::makeTitle( NS_LQT_THREAD, wfGenerateToken() );
965965 }
966966
967967 /**
968968 * 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+ * )
977977 */
978978 function threadCommands( $thread ) {
979979 wfLoadExtensionMessages( 'LiquidThreads' );
@@ -1038,7 +1038,7 @@
10391039 'enabled' => true
10401040 );
10411041 }
1042 -
 1042+
10431043 $commands['link'] = array(
10441044 'label' => wfMsgExt( 'lqt_permalink', 'parseinline' ),
10451045 'href' => $thread->title()->getFullURL(),
@@ -1046,7 +1046,7 @@
10471047 'showlabel' => true,
10481048 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' )
10491049 );
1050 -
 1050+
10511051 wfRunHooks( 'LiquidThreadsThreadCommands', array( $thread, &$commands ) );
10521052
10531053 return $commands;
@@ -1086,7 +1086,7 @@
10871087 'tooltip' => $label
10881088 );
10891089 }
1090 -
 1090+
10911091 if ( $thread->canUserReply( $this->user ) === true ) {
10921092 $commands['reply'] = array(
10931093 'label' => wfMsgExt( 'lqt_reply', 'parseinline' ),
@@ -1098,12 +1098,12 @@
10991099 'icon' => 'reply.png',
11001100 );
11011101 }
1102 -
 1102+
11031103 // Parent post link
11041104 if ( !$thread->isTopmostThread() ) {
11051105 $parent = $thread->superthread();
11061106 $anchor = $parent->getAnchorName();
1107 -
 1107+
11081108 $commands['parent'] = array(
11091109 'label' => wfMsgExt( 'lqt-parent', 'parseinline' ),
11101110 'href' => '#' . $anchor,
@@ -1111,7 +1111,7 @@
11121112 'showlabel' => 1,
11131113 );
11141114 }
1115 -
 1115+
11161116 wfRunHooks( 'LiquidThreadsThreadMajorCommands',
11171117 array( $thread, &$commands ) );
11181118
@@ -1175,14 +1175,14 @@
11761176 'href' => $summarizeUrl,
11771177 'enabled' => true,
11781178 );
1179 -
 1179+
11801180 wfRunHooks( 'LiquidThreadsTopLevelCommands', array( $thread, &$commands ) );
11811181
11821182 return $commands;
11831183 }
11841184
11851185 /*************************
1186 - * Output methods *
 1186+ * Output methods *
11871187 *************************/
11881188
11891189 static function addJSandCSS() {
@@ -1191,29 +1191,27 @@
11921192 }
11931193
11941194 global $wgOut, $wgStylePath;
1195 - global $wgScriptPath, $wgStyleVersion;
 1195+ global $wgStyleVersion;
11961196 global $wgEnableJS2system;
1197 - global $wgLiquidThreadsExtensionName;
 1197+ global $wgLiquidThreadsExtensionPath;
11981198
11991199 LqtHooks::$scriptVariables['wgLqtMessages'] = self::exportJSLocalisation();
12001200
1201 - $basePath = "$wgScriptPath/extensions/$wgLiquidThreadsExtensionName";
1202 -
12031201 if ( method_exists( $wgOut, 'includeJQuery' ) ) {
12041202 $wgOut->includeJQuery();
1205 - $wgOut->addScriptFile( "$basePath/jquery/plugins.js" );
 1203+ $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/plugins.js" );
12061204 } else {
1207 - $wgOut->addScriptFile( "$basePath/jquery/js2.combined.js" );
 1205+ $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js" );
12081206 }
1209 -
1210 - $wgOut->addExtensionStyle( "$basePath/jquery/jquery-ui-1.7.2.css" );
12111207
1212 - $wgOut->addScriptFile( "$basePath/jquery/jquery.autogrow.js" );
 1208+ $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" );
12131209
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+
12181216 if ( class_exists( 'WikiEditorHooks' ) ) {
12191217 $temp = null;
12201218 WikiEditorHooks::addModules( $temp );
@@ -1361,7 +1359,6 @@
13621360 $tooltip = isset( $command['tooltip'] ) ? $command['tooltip'] : '';
13631361
13641362 if ( isset( $command['icon'] ) ) {
1365 - global $wgScriptPath;
13661363 $icon = Xml::tags( 'div', array( 'title' => $label,
13671364 'class' => 'lqt-command-icon' ), '&#160;' );
13681365 if ( $icon_divs ) {
@@ -1424,12 +1421,12 @@
14251422 $html = '';
14261423
14271424 // 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.
14291426 $this->showPostEditingForm( $thread );
14301427 $html .= Xml::closeElement( 'div' );
14311428 } elseif ( $showAnything ) {
14321429 $html .= Xml::openElement( 'div', array( 'class' => $divClass ) );
1433 -
 1430+
14341431 $show = wfRunHooks( 'LiquidThreadsShowPostContent',
14351432 array( $thread, &$post ) );
14361433 if ( $show ) {
@@ -1438,7 +1435,7 @@
14391436 $html .= Xml::closeElement( 'div' );
14401437 $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0' ),
14411438 '&#160;' );
1442 -
 1439+
14431440 wfRunHooks( 'LiquidThreadsShowPostThreadBody',
14441441 array( $thread, $this->request, &$html ) );
14451442
@@ -1463,11 +1460,11 @@
14641461 $signature = Xml::tags( 'span', array( 'class' => 'lqt-thread-user-signature' ),
14651462 $signature );
14661463
1467 - $timestamp = $wgLang->timeanddate( $thread->created(), true );
 1464+ $timestamp = $wgLang->timeanddate( $thread->created(), true );
14681465 $signature .= Xml::element( 'span',
14691466 array( 'class' => 'lqt-thread-toolbar-timestamp' ),
14701467 $timestamp );
1471 -
 1468+
14721469 wfRunHooks( 'LiquidThreadsThreadSignature', array( $thread, &$signature ) );
14731470
14741471 $signature = Xml::tags( 'div', array( 'class' => 'lqt-thread-signature' ),
@@ -1493,22 +1490,22 @@
14941491 $lastEdit = $wgLang->timeanddate( $lastEdit, true );
14951492 $editors = '';
14961493 $editorCount = 0;
1497 -
 1494+
14981495 if ( $editedFlag > Threads::EDITED_BY_AUTHOR ) {
14991496 $editors = $thread->editors();
15001497 $editorCount = count( $editors );
15011498 $formattedEditors = array();
1502 -
 1499+
15031500 foreach ( $editors as $ed ) {
15041501 $id = IP::isIPAddress( $ed ) ? 0 : 1;
15051502 $fEditor = $sk->userLink( $id, $ed ) .
15061503 $sk->userToolLinks( $id, $ed );
15071504 $formattedEditors[] = $fEditor;
15081505 }
1509 -
 1506+
15101507 $editors = $wgLang->commaList( $formattedEditors );
15111508 }
1512 -
 1509+
15131510 if ( isset( $ebLookup[$editedFlag] ) ) {
15141511 $editedBy = $ebLookup[$editedFlag];
15151512 // Used messages: lqt-thread-edited-author, lqt-thread-edited-others
@@ -1521,7 +1518,7 @@
15221519 'lqt-thread-toolbar-edited-' . $editedBy ),
15231520 $editedNotice );
15241521 }
1525 -
 1522+
15261523 wfRunHooks( 'LiquidThreadsThreadInfoPanel', array( $thread, &$infoElements ) );
15271524
15281525 if ( ! count( $infoElements ) ) {
@@ -1551,10 +1548,10 @@
15521549 $id = 'lqt-header-' . $thread->id();
15531550
15541551 $html = $thread->formattedSubject();
1555 -
 1552+
15561553 $show = wfRunHooks( 'LiquidThreadsShowThreadHeading',
15571554 array( $thread, &$html ) );
1558 -
 1555+
15591556 if ( $show ) {
15601557 $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html );
15611558 $html .= Xml::hidden( 'raw-header', $thread->subject() );
@@ -1562,7 +1559,7 @@
15631560 array( 'class' => 'lqt_header', 'id' => $id ),
15641561 $html ) . $commands_html;
15651562 }
1566 -
 1563+
15671564 // wrap it all in a container
15681565 $html = Xml::tags( 'div',
15691566 array( 'class' => 'lqt_thread_heading' ),
@@ -1764,11 +1761,11 @@
17651762 $cascadeOptions, $interruption = false ) {
17661763 $repliesClass = 'lqt-thread-replies lqt-thread-replies-' .
17671764 $this->threadNestingLevel;
1768 -
 1765+
17691766 if ( $interruption ) {
17701767 $repliesClass .= ' lqt-thread-replies-interruption';
17711768 }
1772 -
 1769+
17731770 $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) );
17741771 $sep = Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&#160;' );
17751772
@@ -1802,7 +1799,7 @@
18031800 ++$showCount;
18041801 if ( $showCount == 1 ) {
18051802 // There's a post sep before each reply group to
1806 - // separate from the parent thread.
 1803+ // separate from the parent thread.
18071804 $this->output->addHTML( $sep . $div );
18081805 }
18091806
@@ -1812,7 +1809,7 @@
18131810
18141811 // Handle must-show threads.
18151812 // 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)
18171814 if ( $st->type() != Threads::TYPE_DELETED && !$shown &&
18181815 array_key_exists( $st->id(), $mustShowThreads ) ) {
18191816
@@ -1846,7 +1843,7 @@
18471844 $this->threadNestingLevel++;
18481845
18491846 // Figure out which threads *need* to be shown because they're involved in an
1850 - // operation
 1847+ // operation
18511848 $mustShowOption = array();
18521849 if ( isset( $options['mustShowThreads'] ) ) {
18531850 $mustShowOption = $options['mustShowThreads' ];
@@ -1907,7 +1904,7 @@
19081905
19091906 $sk = $this->user->getSkin();
19101907 $html = '';
1911 -
 1908+
19121909 $html .= Xml::openElement( 'div', array( 'class' => 'lqt-thread-wrapper' ) );
19131910
19141911 $html .= Xml::element( 'a', array( 'name' => $this->anchorName( $thread ) ), ' ' );
@@ -1951,7 +1948,7 @@
19521949 array( 'id' => 'lqt-thread-sortkey-' . $thread->id() )
19531950 );
19541951 }
1955 -
 1952+
19561953 if ( ! $thread->title() ) {
19571954 throw new MWException( "Thread " . $thread->id() . " has null title" );
19581955 }
@@ -1975,7 +1972,7 @@
19761973
19771974 $cascadeOptions = $options;
19781975 unset( $cascadeOptions['startAt'] );
1979 -
 1976+
19801977 $replyInterruption = $levelNum < $totalInLevel;
19811978
19821979 if ( ( $hasSubthreads && $showThreads ) ) {
@@ -1984,11 +1981,11 @@
19851982 $cascadeOptions, $replyInterruption );
19861983 } elseif ( $hasSubthreads && !$showThreads ) {
19871984 // 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.
19891986 if ( $replyTo ) {
19901987 $this->showReplyForm( $thread );
19911988 }
1992 -
 1989+
19931990 // Add a "show subthreads" link.
19941991 $link = $this->getShowReplies( $thread );
19951992
@@ -2000,7 +1997,7 @@
20011998 }
20021999 } elseif ( $levelNum < $totalInLevel ) {
20032000 // 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.
20052002 $this->output->addHTML(
20062003 Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&#160;' ) );
20072004
@@ -2009,7 +2006,7 @@
20102007 $this->threadNestingLevel;
20112008 $html = Xml::openElement( 'div', array( 'class' => $class ) );
20122009 $this->output->addHTML( $html );
2013 -
 2010+
20142011 $this->showReplyForm( $thread );
20152012
20162013 $finishDiv = Xml::tags( 'div',
@@ -2024,14 +2021,14 @@
20252022 }
20262023 } elseif ( !$hasSubthreads && $replyTo ) {
20272024 // 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.
20292026 $class = 'lqt-thread-replies lqt-thread-replies-' .
20302027 $this->threadNestingLevel;
20312028 $html = Xml::openElement( 'div', array( 'class' => $class ) );
20322029 $this->output->addHTML( $html );
2033 -
 2030+
20342031 $this->showReplyForm( $thread );
2035 -
 2032+
20362033 $html = Xml::tags( 'div',
20372034 array( 'class' => 'lqt-replies-finish' ),
20382035 Xml::tags( 'div',
@@ -2043,16 +2040,16 @@
20442041 }
20452042
20462043 // 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' ), '&#160;' ) );
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' ), '&#160;' ) );
 2050+//
 2051+// $this->output->addHTML( $finishDiv );
 2052+// }
 2053+// }
20572054
20582055 $this->output->addHTML( Xml::closeElement( 'div' ) . Xml::closeElement( 'div' ) );
20592056
@@ -2071,7 +2068,7 @@
20722069 $html = '';
20732070 $html .= Xml::tags( 'div',
20742071 array( 'class' => 'lqt-reply-form lqt-edit-form',
2075 - 'style' => 'display: none;' ),
 2072+ 'style' => 'display: none;' ),
20762073 '' );
20772074
20782075 $this->output->addHTML( $html );
@@ -2194,7 +2191,7 @@
21952192
21962193 static function signaturePST( $sig, $user ) {
21972194 global $wgParser, $wgOut, $wgTitle;
2198 -
 2195+
21992196 $title = $wgTitle ? $wgTitle : $user->getUserPage();
22002197
22012198 // 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 @@
2727
2828 function getReadAllButton( $threads ) {
2929 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
3131 return $this->htmlForReadButton(
3232 wfMsg( 'lqt-read-all' ),
3333 wfMsg( 'lqt-read-all-tooltip' ),
@@ -45,7 +45,7 @@
4646 $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array( $t->subject() ) );
4747 } else {
4848 $count = count( $ids );
49 - $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) );
 49+ $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) );
5050 }
5151 $operand = implode( ',', $ids );
5252
@@ -84,15 +84,14 @@
8585
8686 function showOnce() {
8787 self::addJSandCSS();
88 -
 88+
8989 NewMessages::recacheMessageCount( $this->user->getId() );
9090
9191 static $scriptDone = false;
9292
9393 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" );
9796 }
9897
9998 $this->user->setNewtalk( false );
@@ -180,7 +179,7 @@
181180 $title->setFragment( '#' . $t->getAnchorName() );
182181
183182 // 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.
185184 $dbr = wfGetDB( DB_SLAVE );
186185 $offset = wfTimestamp( TS_UNIX, $topmostThread->modified() ) + 1;
187186 $offset = $dbr->timestamp( $offset );

Follow-up revisions

RevisionCommit summaryAuthorDate
r69718Follow-up r69712: Fix syntax errorraymond08:44, 22 July 2010
r69720Follow-up r69712: Fix another syntax errorraymond08:51, 22 July 2010

Comments

#Comment by Simetrical (talk | contribs)   20:44, 22 July 2010

Could you please not make huge amounts of whitespace changes every time you commit? It makes it really hard to read the actual commit.

#Comment by Werdna (talk | contribs)   00:47, 26 July 2010

Seriously. Also, please at least run php -l on your code before you commit it. Testing it would be nice too.

#Comment by Simetrical (talk | contribs)   13:28, 26 July 2010

Well, no one actually bothers running php -l on their code before they commit it, that's just something we all say everyone should do whenever anyone makes a syntax error, without actually doing it ourselves. It's kind of a waste of time, since people tend to almost never add syntax errors that they don't catch before committing. I'm guessing mah tested the commit, but didn't test anything that would load NewUserMessagesView.php. If we had a real test suite, now . . .

Status & tagging log