Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | class LqtHooks { |
4 | 5 | // Used to inform hooks about edits that are taking place. |
5 | 6 | public static $editType = null; |
— | — | @@ -7,7 +8,7 @@ |
8 | 9 | public static $editArticle = null; |
9 | 10 | public static $editTalkpage = null; |
10 | 11 | public static $scriptVariables = array(); |
11 | | - |
| 12 | + |
12 | 13 | public static $editedStati = array( |
13 | 14 | Threads::EDITED_NEVER => 'never', |
14 | 15 | Threads::EDITED_HAS_REPLY => 'has-reply', |
— | — | @@ -21,28 +22,28 @@ |
22 | 23 | ); |
23 | 24 | |
24 | 25 | static function customizeOldChangesList( &$changeslist, &$s, $rc ) { |
25 | | - if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD ) |
| 26 | + if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD ) { |
26 | 27 | return true; |
| 28 | + } |
27 | 29 | |
28 | 30 | $thread = Threads::withRoot( new Article( $rc->getTitle() ) ); |
29 | 31 | if ( !$thread ) { |
30 | 32 | return true; |
31 | 33 | } |
32 | 34 | |
33 | | - global $wgUser, $wgLang, $wgOut; |
34 | | - $sk = $wgUser->getSkin(); |
| 35 | + global $wgLang, $wgOut; |
35 | 36 | $wgOut->addModules( 'ext.liquidThreads' ); |
36 | 37 | |
37 | 38 | // Custom display for new posts. |
38 | 39 | if ( $rc->mAttribs['rc_new'] ) { |
39 | 40 | // Article link, timestamp, user |
40 | 41 | $s = ''; |
41 | | - $s .= $sk->link( $thread->getTitle() ); |
| 42 | + $s .= Linker::link( $thread->getTitle() ); |
42 | 43 | $changeslist->insertTimestamp( $s, $rc ); |
43 | 44 | $changeslist->insertUserRelatedLinks( $s, $rc ); |
44 | 45 | |
45 | 46 | // Action text |
46 | | - $msg = $thread->isTopmostThread() |
| 47 | + $msg = $thread->isTopmostThread() |
47 | 48 | ? 'lqt_rc_new_discussion' : 'lqt_rc_new_reply'; |
48 | 49 | $link = LqtView::linkInContext( $thread ); |
49 | 50 | $s .= ' ' . wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link ); |
— | — | @@ -52,18 +53,19 @@ |
53 | 54 | // add the truncated post content |
54 | 55 | $quote = $thread->root()->getContent(); |
55 | 56 | $quote = $wgLang->truncate( $quote, 200 ); |
56 | | - $s .= ' ' . $sk->commentBlock( $quote ); |
| 57 | + $s .= ' ' . Linker::commentBlock( $quote ); |
57 | 58 | |
58 | 59 | $classes = array(); |
59 | 60 | $changeslist->insertTags( $s, $rc, $classes ); |
60 | 61 | $changeslist->insertExtra( $s, $rc, $classes ); |
61 | 62 | } |
| 63 | + |
62 | 64 | return true; |
63 | 65 | } |
64 | 66 | |
65 | 67 | static function setNewtalkHTML( $skintemplate, $tpl ) { |
66 | 68 | global $wgUser, $wgTitle, $wgOut; |
67 | | - |
| 69 | + |
68 | 70 | // If the user isn't using LQT on their talk page, bail out |
69 | 71 | if ( ! LqtDispatch::isLqtPage( $wgUser->getTalkPage() ) ) { |
70 | 72 | return true; |
— | — | @@ -89,7 +91,7 @@ |
90 | 92 | } |
91 | 93 | |
92 | 94 | static function beforeWatchlist( &$conds, &$tables, &$join_conds, &$fields ) { |
93 | | - global $wgOut, $wgUser; |
| 95 | + global $wgOut; |
94 | 96 | |
95 | 97 | $db = wfGetDB( DB_SLAVE ); |
96 | 98 | |
— | — | @@ -113,8 +115,7 @@ |
114 | 116 | $messages_title = SpecialPage::getTitleFor( 'NewMessages' ); |
115 | 117 | $new_messages = wfMsgExt( 'lqt-new-messages', 'parseinline' ); |
116 | 118 | |
117 | | - $sk = $wgUser->getSkin(); |
118 | | - $link = $sk->link( $messages_title, $new_messages, |
| 119 | + $link = Linker::link( $messages_title, $new_messages, |
119 | 120 | array( 'class' => 'lqt_watchlist_messages_notice' ) ); |
120 | 121 | $wgOut->addHTML( $link ); |
121 | 122 | |
— | — | @@ -173,25 +174,29 @@ |
174 | 175 | if ( empty( $row->thread_id ) ) { |
175 | 176 | return true; |
176 | 177 | } |
177 | | - |
| 178 | + |
178 | 179 | $thread = Thread::newFromRow( $row ); |
179 | 180 | $threadInfo = "\n"; |
180 | 181 | $attribs = array(); |
181 | 182 | $attribs['ThreadSubject'] = $thread->subject(); |
| 183 | + |
182 | 184 | if ( $thread->hasSuperThread() ) { |
183 | 185 | if ( $thread->superThread()->title() ) { |
184 | 186 | $attribs['ThreadParent'] = $thread->superThread()->title()->getPrefixedText(); |
185 | 187 | } |
186 | | - |
| 188 | + |
187 | 189 | if ( $thread->topmostThread()->title() ) { |
188 | 190 | $attribs['ThreadAncestor'] = $thread->topmostThread()->title()->getPrefixedText(); |
189 | 191 | } |
190 | 192 | } |
| 193 | + |
191 | 194 | $attribs['ThreadPage'] = $thread->getTitle()->getPrefixedText(); |
192 | 195 | $attribs['ThreadID'] = $thread->id(); |
| 196 | + |
193 | 197 | if ( $thread->hasSummary() && $thread->summary() ) { |
194 | 198 | $attribs['ThreadSummaryPage'] = $thread->summary()->getTitle()->getPrefixedText(); |
195 | 199 | } |
| 200 | + |
196 | 201 | $attribs['ThreadAuthor'] = $thread->author()->getName(); |
197 | 202 | $attribs['ThreadEditStatus'] = self::$editedStati[$thread->editedness()]; |
198 | 203 | $attribs['ThreadType'] = self::$threadTypes[$thread->type()]; |
— | — | @@ -250,11 +255,13 @@ |
251 | 256 | array( 'thread_author_name', 'thread_author_id', 'thread_modified' ); |
252 | 257 | $renameUserSQL->tablesJob['thread_history'] = |
253 | 258 | array( 'th_user_text', 'th_user', 'th_timestamp' ); |
| 259 | + |
254 | 260 | return true; |
255 | 261 | } |
256 | 262 | |
257 | 263 | static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) { |
258 | 264 | global $wgRequest; |
| 265 | + |
259 | 266 | $article = $editPage->getArticle(); |
260 | 267 | $title = $article->getTitle(); |
261 | 268 | |
— | — | @@ -399,8 +406,9 @@ |
400 | 407 | // If the page actually exists, allow the user to edit posts on their own talk page. |
401 | 408 | $thread = Threads::withRoot( new Article( $title ) ); |
402 | 409 | |
403 | | - if ( !$thread ) |
| 410 | + if ( !$thread ) { |
404 | 411 | return true; |
| 412 | + } |
405 | 413 | |
406 | 414 | $articleTitle = $thread->getTitle(); |
407 | 415 | |
— | — | @@ -547,12 +555,14 @@ |
548 | 556 | |
549 | 557 | static function afterUserMessage( $user, $article, $subject, $text, $signature, $summary, $editor ) { |
550 | 558 | global $wgLqtTalkPages; |
| 559 | + |
551 | 560 | $talk = $user->getTalkPage(); |
552 | 561 | |
553 | 562 | if ( $wgLqtTalkPages && LqtDispatch::isLqtPage( $talk ) ) { |
554 | 563 | // Need to edit as another user. Lqt does not provide an interface to alternative users, |
555 | 564 | // so replacing $wgUser here. |
556 | 565 | global $wgUser; |
| 566 | + |
557 | 567 | $parkedUser = $wgUser; |
558 | 568 | $wgUser = $editor; |
559 | 569 | |
— | — | @@ -573,13 +583,16 @@ |
574 | 584 | |
575 | 585 | // Set $wgUser back to the newly created user |
576 | 586 | $wgUser = $parkedUser; |
| 587 | + |
577 | 588 | return false; |
578 | 589 | } |
| 590 | + |
579 | 591 | return true; |
580 | 592 | } |
581 | 593 | |
582 | 594 | public static function onMakeGlobalVariablesScript( &$vars ) { |
583 | 595 | $vars += self::$scriptVariables; |
| 596 | + |
584 | 597 | return true; |
585 | 598 | } |
586 | 599 | |
— | — | @@ -607,7 +620,7 @@ |
608 | 621 | return ''; |
609 | 622 | } |
610 | 623 | } |
611 | | - |
| 624 | + |
612 | 625 | /** |
613 | 626 | * Handles tags in Page sections of XML dumps |
614 | 627 | */ |
— | — | @@ -617,7 +630,7 @@ |
618 | 631 | $reader->name == 'DiscussionThreading' ) ) { |
619 | 632 | return true; |
620 | 633 | } |
621 | | - |
| 634 | + |
622 | 635 | $pageInfo['DiscussionThreading'] = array(); |
623 | 636 | $fields = array( |
624 | 637 | 'ThreadSubject', |
— | — | @@ -631,38 +644,38 @@ |
632 | 645 | 'ThreadType', |
633 | 646 | 'ThreadSignature', |
634 | 647 | ); |
635 | | - |
| 648 | + |
636 | 649 | $skip = false; |
637 | | - |
| 650 | + |
638 | 651 | while ( $skip ? $reader->next() : $reader->read() ) { |
639 | 652 | if ( $reader->nodeType == XmlReader::END_ELEMENT && |
640 | 653 | $reader->name == 'DiscussionThreading') { |
641 | 654 | break; |
642 | 655 | } |
643 | | - |
| 656 | + |
644 | 657 | $tag = $reader->name; |
645 | | - |
| 658 | + |
646 | 659 | if ( in_array( $tag, $fields ) ) { |
647 | 660 | $pageInfo['DiscussionThreading'][$tag] = $reader->nodeContents(); |
648 | 661 | } |
649 | 662 | } |
650 | | - |
| 663 | + |
651 | 664 | return false; |
652 | 665 | } |
653 | | - |
| 666 | + |
654 | 667 | // Processes discussion threading data in XML dumps (extracted in handlePageXMLTag). |
655 | 668 | public static function afterImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) { |
656 | 669 | // in-process cache of pending thread relationships |
657 | 670 | static $pendingRelationships = null; |
658 | | - |
| 671 | + |
659 | 672 | if ( $pendingRelationships === null ) { |
660 | 673 | $pendingRelationships = self::loadPendingRelationships(); |
661 | 674 | } |
662 | | - |
| 675 | + |
663 | 676 | $titlePendingRelationships = array(); |
664 | 677 | if ( isset($pendingRelationships[$title->getPrefixedText()]) ) { |
665 | 678 | $titlePendingRelationships = $pendingRelationships[$title->getPrefixedText()]; |
666 | | - |
| 679 | + |
667 | 680 | foreach( $titlePendingRelationships as $k => $v ) { |
668 | 681 | if ( $v['type'] == 'article' ) { |
669 | 682 | self::applyPendingArticleRelationship( $v, $title ); |
— | — | @@ -670,34 +683,35 @@ |
671 | 684 | } |
672 | 685 | } |
673 | 686 | } |
674 | | - |
| 687 | + |
675 | 688 | if ( ! isset( $pageInfo['DiscussionThreading'] ) ) { |
676 | 689 | return true; |
677 | 690 | } |
678 | | - |
| 691 | + |
679 | 692 | $statusValues = array_flip( self::$editedStati ); |
680 | 693 | $typeValues = array_flip( self::$threadTypes ); |
681 | | - |
| 694 | + |
682 | 695 | $info = $pageInfo['DiscussionThreading']; |
683 | | - |
| 696 | + |
684 | 697 | $root = new Article( $title ); |
685 | 698 | $article = new Article( Title::newFromText( $info['ThreadPage'] ) ); |
686 | 699 | $type = $typeValues[$info['ThreadType']]; |
687 | 700 | $editedness = $statusValues[$info['ThreadEditStatus']]; |
688 | 701 | $subject = $info['ThreadSubject']; |
689 | 702 | $summary = wfMsgForContent( 'lqt-imported' ); |
690 | | - |
| 703 | + |
691 | 704 | $signature = null; |
692 | 705 | if ( isset( $info['ThreadSignature'] ) ) { |
693 | 706 | $signature = $info['ThreadSignature']; |
694 | 707 | } |
695 | | - |
| 708 | + |
696 | 709 | $thread = Thread::create( $root, $article, null, $type, |
697 | 710 | $subject, $summary, null, $signature ); |
698 | | - |
| 711 | + |
699 | 712 | if ( isset( $info['ThreadSummaryPage'] ) ) { |
700 | 713 | $summaryPageName = $info['ThreadSummaryPage']; |
701 | 714 | $summaryPage = new Article( Title::newFromText( $summaryPageName ) ); |
| 715 | + |
702 | 716 | if ( $summaryPage->exists() ) { |
703 | 717 | $thread->setSummaryPage( $summaryPage ); |
704 | 718 | } else { |
— | — | @@ -705,12 +719,12 @@ |
706 | 720 | $summaryPageName, 'article', $pendingRelationships ); |
707 | 721 | } |
708 | 722 | } |
709 | | - |
| 723 | + |
710 | 724 | if ( isset( $info['ThreadParent'] ) ) { |
711 | 725 | $threadPageName = $info['ThreadParent']; |
712 | 726 | $parentArticle = new Article( Title::newFromText( $threadPageName ) ); |
713 | 727 | $superthread = Threads::withRoot( $parentArticle ); |
714 | | - |
| 728 | + |
715 | 729 | if ( $superthread ) { |
716 | 730 | $thread->setSuperthread( $superthread ); |
717 | 731 | } else { |
— | — | @@ -718,48 +732,48 @@ |
719 | 733 | $threadPageName, 'thread', $pendingRelationships ); |
720 | 734 | } |
721 | 735 | } |
722 | | - |
| 736 | + |
723 | 737 | $thread->save(); |
724 | | - |
| 738 | + |
725 | 739 | foreach( $titlePendingRelationships as $k => $v ) { |
726 | 740 | if ( $v['type'] == 'thread' ) { |
727 | 741 | self::applyPendingThreadRelationship( $v, $thread ); |
728 | 742 | unset( $titlePendingRelationships[$k] ); |
729 | 743 | } |
730 | 744 | } |
731 | | - |
| 745 | + |
732 | 746 | return true; |
733 | 747 | } |
734 | | - |
| 748 | + |
735 | 749 | public static function applyPendingThreadRelationship( $pendingRelationship, $thread ) { |
736 | 750 | if ( $pendingRelationship['relationship'] == 'thread_parent' ) { |
737 | 751 | $childThread = Threads::withID( $pendingRelationship['thread'] ); |
738 | | - |
| 752 | + |
739 | 753 | $childThread->setSuperthread( $thread ); |
740 | 754 | $childThread->save(); |
741 | 755 | $thread->save(); |
742 | 756 | } |
743 | 757 | } |
744 | | - |
| 758 | + |
745 | 759 | public static function applyPendingArticleRelationship( $pendingRelationship, $title ) { |
746 | 760 | $articleID = $title->getArticleId(); |
747 | | - |
| 761 | + |
748 | 762 | $dbw = wfGetDB( DB_MASTER ); |
749 | | - |
| 763 | + |
750 | 764 | $dbw->update( 'thread', array( $pendingRelationship['relationship'] => $articleID ), |
751 | 765 | array( 'thread_id' => $pendingRelationship['thread'] ), |
752 | 766 | __METHOD__ ); |
753 | | - |
| 767 | + |
754 | 768 | $dbw->delete( 'thread_pending_relationship', |
755 | 769 | array( 'tpr_title' => $pendingRelationship['title'] ), __METHOD__ ); |
756 | 770 | } |
757 | | - |
| 771 | + |
758 | 772 | public static function loadPendingRelationships() { |
759 | 773 | $dbr = wfGetDB( DB_MASTER ); |
760 | 774 | $arr = array(); |
761 | | - |
| 775 | + |
762 | 776 | $res = $dbr->select( 'thread_pending_relationship', '*', array(1), __METHOD__ ); |
763 | | - |
| 777 | + |
764 | 778 | foreach( $res as $row ) { |
765 | 779 | $title = $row->tpr_title; |
766 | 780 | $entry = array( |
— | — | @@ -768,17 +782,17 @@ |
769 | 783 | 'title' => $title, |
770 | 784 | 'type' => $row->tpr_type, |
771 | 785 | ); |
772 | | - |
| 786 | + |
773 | 787 | if ( !isset($arr[$title]) ) { |
774 | 788 | $arr[$title] = array(); |
775 | 789 | } |
776 | | - |
| 790 | + |
777 | 791 | $arr[$title][] = $entry; |
778 | 792 | } |
779 | | - |
| 793 | + |
780 | 794 | return $arr; |
781 | 795 | } |
782 | | - |
| 796 | + |
783 | 797 | public static function addPendingRelationship( $thread, $relationship, $title, $type, &$array ) { |
784 | 798 | $entry = array( |
785 | 799 | 'thread' => $thread, |
— | — | @@ -786,19 +800,19 @@ |
787 | 801 | 'title' => $title, |
788 | 802 | 'type' => $type, |
789 | 803 | ); |
790 | | - |
| 804 | + |
791 | 805 | $row = array(); |
792 | 806 | foreach( $entry as $k => $v ) { |
793 | 807 | $row['tpr_'.$k] = $v; |
794 | 808 | } |
795 | | - |
| 809 | + |
796 | 810 | $dbw = wfGetDB( DB_MASTER ); |
797 | 811 | $dbw->insert( 'thread_pending_relationship', $row, __METHOD__ ); |
798 | | - |
| 812 | + |
799 | 813 | if ( !isset( $array[$title] ) ) { |
800 | 814 | $array[$title] = array(); |
801 | 815 | } |
802 | | - |
| 816 | + |
803 | 817 | $array[$title][] = $entry; |
804 | 818 | } |
805 | 819 | |
— | — | @@ -809,8 +823,9 @@ |
810 | 824 | |
811 | 825 | $thread = Threads::withRoot( new Article($title) ); |
812 | 826 | |
813 | | - if ( ! $thread ) |
| 827 | + if ( ! $thread ) { |
814 | 828 | return true; |
| 829 | + } |
815 | 830 | |
816 | 831 | $talkpage = $thread->article(); |
817 | 832 | |
— | — | @@ -834,9 +849,9 @@ |
835 | 850 | 'lqtpagelimit', |
836 | 851 | array( 'LqtParserFunctions', 'lqtPageLimit' ) |
837 | 852 | ); |
838 | | - |
| 853 | + |
839 | 854 | global $wgLiquidThreadsAllowEmbedding; |
840 | | - |
| 855 | + |
841 | 856 | if ( $wgLiquidThreadsAllowEmbedding ) { |
842 | 857 | $parser->setHook( 'talkpage', array( 'LqtParserFunctions', 'lqtTalkPage' ) ); |
843 | 858 | $parser->setHook( 'thread', array( 'LqtParserFunctions', 'lqtThread' ) ); |
Index: trunk/extensions/LiquidThreads/pages/SpecialNewMessages.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) ) die; |
4 | 3 | |
5 | 4 | class SpecialNewMessages extends SpecialPage { |
6 | 5 | private $user, $output, $request; |
— | — | @@ -10,8 +9,8 @@ |
11 | 10 | } |
12 | 11 | |
13 | 12 | /** |
14 | | - * @see SpecialPage::getDescription |
15 | | - */ |
| 13 | + * @see SpecialPage::getDescription |
| 14 | + */ |
16 | 15 | function getDescription() { |
17 | 16 | return wfMsg( 'lqt_newmessages-title' ); |
18 | 17 | } |