Index: trunk/extensions/TalkHere/TalkHere.php |
— | — | @@ -31,62 +31,15 @@ |
32 | 32 | $wgExtensionMessagesFiles['TalkHere'] = $dir . 'TalkHere.i18n.php'; |
33 | 33 | |
34 | 34 | ///// hook it up ///////////////////////////////////////////////////// |
35 | | -$wgAutoloadClasses['TalkHereArticle'] = $dir . 'TalkHereArticle.php'; |
36 | | -$wgAutoloadClasses['TalkHereEditTarget'] = $dir . 'TalkHereArticle.php'; |
| 35 | +$wgAutoloadClasses['TalkHereHooks'] = $dir . 'TalkHereHooks.php'; |
37 | 36 | |
38 | | -$wgHooks['BeforePageDisplay'][] = 'wfTalkHereBeforePageDisplay'; |
39 | | -$wgHooks['ArticleFromTitle'][] = 'wfTalkHereArticleFromTitle'; |
40 | | -$wgHooks['CustomEditor'][] = 'wfTalkHereCustomEditor'; |
41 | | -$wgHooks['EditPage::showEditForm:fields'][] = 'wfTalkHereShowEditFormFields'; |
| 37 | +$wgHooks['BeforePageDisplay'][] = 'TalkHereHooks::onBeforePageDisplay'; |
| 38 | +$wgHooks['CustomEditor'][] = 'TalkHereHooks::onCustomEditor'; |
| 39 | +$wgHooks['EditPage::showEditForm:fields'][] = 'TalkHereHooks::onShowEditFormFields'; |
| 40 | +$wgHooks['ArticleViewFooter'][] = 'TalkHereHooks::onArticleViewFooter'; |
42 | 41 | |
43 | 42 | $wgAjaxExportList[] = 'wfTalkHereAjaxEditor'; |
44 | 43 | |
45 | | -function wfTalkHereBeforePageDisplay( $out, $skin ) { |
46 | | - global $wgScriptPath, $wgJsMimeType, $wgUseAjax; |
47 | | - |
48 | | - $out->addExtensionStyle( $wgScriptPath . '/extensions/TalkHere/TalkHere.css' ); |
49 | | - |
50 | | - if ( $wgUseAjax ) { |
51 | | - $out->addScriptFile( $wgScriptPath . '/extensions/TalkHere/TalkHere.js' ); |
52 | | - } |
53 | | - |
54 | | - return true; |
55 | | -} |
56 | | - |
57 | | -function wfTalkHereArticleFromTitle( &$title, &$article ) { |
58 | | - global $wgRequest, $wgTalkHereNamespaces; |
59 | | - |
60 | | - if ( isset( $title->noTalkHere ) ) { |
61 | | - return true; //stop recursion |
62 | | - } |
63 | | - |
64 | | - $action = $wgRequest->getVal( 'action' ); |
65 | | - $oldid = $wgRequest->getVal( 'oldid' ); |
66 | | - $diff = $wgRequest->getVal( 'diff' ); |
67 | | - |
68 | | - if ($action == 'purge') $action = null; //"purge" is not considered an action in this context |
69 | | - |
70 | | - if ( $action || $oldid || $diff ) return true; |
71 | | - |
72 | | - $ns = $title->getNamespace(); |
73 | | - |
74 | | - if ( !MWNamespace::isTalk($ns) && MWNamespace::canTalk($ns) && $title->exists() |
75 | | - && ( !$wgTalkHereNamespaces || in_array($ns, $wgTalkHereNamespaces) ) ) { |
76 | | - $tns = MWNamespace::getTalk($ns); |
77 | | - $talk = Title::makeTitle($tns, $title->getDBkey()); |
78 | | - |
79 | | - if ($talk && $talk->userCan('read')) { |
80 | | - $t = clone $title; |
81 | | - $t->noTalkHere = true; //stop recursion |
82 | | - |
83 | | - $a = MediaWiki::articleFromTitle( $t ); |
84 | | - $article = new TalkHereArticle( $a, $talk ); |
85 | | - } |
86 | | - } |
87 | | - |
88 | | - return true; |
89 | | -} |
90 | | - |
91 | 44 | function mangleEditForm( &$out, $returnto = false, $ajax = false ) { //HACK! too bad we need this :( |
92 | 45 | global $wgUser; |
93 | 46 | $sk = $wgUser->getSkin(); |
— | — | @@ -105,41 +58,6 @@ |
106 | 59 | $out->addHTML($html); |
107 | 60 | } |
108 | 61 | |
109 | | -function wfTalkHereCustomEditor( $article, $user ) { |
110 | | - global $wgRequest, $wgOut; |
111 | | - |
112 | | - $action = $wgRequest->getVal( 'action' ); |
113 | | - $oldid = $wgRequest->getVal( 'oldid' ); |
114 | | - $returnto = $wgRequest->getVal( 'wpReturnTo' ); |
115 | | - $talkhere = $wgRequest->getVal( 'wpTalkHere' ); |
116 | | - if (!$talkhere || $action != 'submit' || !$returnto || $oldid) return true; //go on as normal |
117 | | - |
118 | | - $to = Title::newFromText($returnto); |
119 | | - if (!$to) return true; //go on as normal |
120 | | - |
121 | | - //use a wrapper to override redirection target |
122 | | - $a = new TalkHereEditTarget( $article, $to ); |
123 | | - $editor = new EditPage( $a ); |
124 | | - $editor->submit(); |
125 | | - |
126 | | - mangleEditForm( $wgOut, $returnto ); //HACK. This sucks. |
127 | | - return false; |
128 | | -} |
129 | | - |
130 | | -function wfTalkHereShowEditFormFields( &$editor, &$out ) { |
131 | | - global $wgRequest; |
132 | | - |
133 | | - $returnto = $wgRequest->getVal( 'wpReturnTo' ); |
134 | | - $talkhere = $wgRequest->getVal( 'wpTalkHere' ); |
135 | | - |
136 | | - if ($talkhere && $returnto) { |
137 | | - $out->addHTML('<input type="hidden" value="1" name="wpTalkHere" id="wpTalkHere" />'); |
138 | | - $out->addHTML('<input type="hidden" value="'.htmlspecialchars($returnto).'" name="wpReturnTo" id="wpReturnTo" />'); |
139 | | - } |
140 | | - |
141 | | - return true; |
142 | | -} |
143 | | - |
144 | 62 | function wfTalkHereAjaxEditor( $page, $section, $returnto ) { |
145 | 63 | global $wgRequest, $wgTitle, $wgOut; |
146 | 64 | |