Index: trunk/extensions/TalkHere/TalkHere.php |
— | — | @@ -34,18 +34,17 @@ |
35 | 35 | $wgAutoloadClasses['TalkHereArticle'] = $dir . 'TalkHereArticle.php'; |
36 | 36 | $wgAutoloadClasses['TalkHereEditTarget'] = $dir . 'TalkHereArticle.php'; |
37 | 37 | |
38 | | -$wgExtensionFunctions[] = 'wfTalkHereExtension'; |
39 | | - |
40 | | -$wgHooks['ArticleFromTitle'][] = 'wfTalkHereArticleFromTitle'; |
| 38 | +$wgHooks['BeforePageDisplay'][] = 'wfTalkHereBeforePageDisplay'; |
| 39 | +#$wgHooks['ArticleFromTitle'][] = 'wfTalkHereArticleFromTitle'; |
41 | 40 | $wgHooks['CustomEditor'][] = 'wfTalkHereCustomEditor'; |
42 | 41 | $wgHooks['EditPage::showEditForm:fields'][] = 'wfTalkHereShowEditFormFields'; |
43 | 42 | |
44 | 43 | $wgAjaxExportList[] = 'wfTalkHereAjaxEditor'; |
45 | 44 | |
46 | | -function wfTalkHereExtension( ) { |
47 | | - global $wgOut, $wgScriptPath, $wgJsMimeType, $wgUseAjax; |
| 45 | +function wfTalkHereBeforePageDisplay( $out, $skin ) { |
| 46 | + global $wgScriptPath, $wgJsMimeType, $wgUseAjax; |
48 | 47 | |
49 | | - $wgOut->addLink( |
| 48 | + $out->addLink( |
50 | 49 | array( |
51 | 50 | 'rel' => 'stylesheet', |
52 | 51 | 'type' => 'text/css', |
— | — | @@ -53,10 +52,12 @@ |
54 | 53 | ) |
55 | 54 | ); |
56 | 55 | |
57 | | - if ( $wgUseAjax ) $wgOut->addScript( |
| 56 | + if ( $wgUseAjax ) $out->addScript( |
58 | 57 | "<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}/extensions/TalkHere/TalkHere.js\">" . |
59 | 58 | "</script>\n" |
60 | 59 | ); |
| 60 | + |
| 61 | + return true; |
61 | 62 | } |
62 | 63 | |
63 | 64 | function wfTalkHereArticleFromTitle( &$title, &$article ) { |
— | — | @@ -109,7 +110,7 @@ |
110 | 111 | $out->addHTML($html); |
111 | 112 | } |
112 | 113 | |
113 | | -function wfTalkHereCustomEditor( &$article, &$user ) { |
| 114 | +function wfTalkHereCustomEditor( $article, $user ) { |
114 | 115 | global $wgRequest, $wgOut; |
115 | 116 | |
116 | 117 | $action = $wgRequest->getVal( 'action' ); |
— | — | @@ -145,20 +146,24 @@ |
146 | 147 | } |
147 | 148 | |
148 | 149 | function wfTalkHereAjaxEditor( $page, $section, $returnto ) { |
149 | | - global $wgRequest, $wgTitle, $wgArticle, $wgOut; |
| 150 | + global $wgRequest, $wgTitle, $wgOut; |
150 | 151 | |
151 | | - $wgTitle = Title::newFromText($page); |
152 | | - if ( !$wgTitle ) return false; |
| 152 | + $wgTitle = Title::newFromText( $page ); |
| 153 | + if ( !$wgTitle ) { |
| 154 | + return false; |
| 155 | + } |
153 | 156 | |
154 | 157 | //fake editor environment |
155 | | - $args = array( 'wpTalkHere' => '1', |
156 | | - 'wpReturnTo' => $returnto, |
157 | | - 'action' => 'edit', |
158 | | - 'section' => $section ); |
| 158 | + $args = array( |
| 159 | + 'wpTalkHere' => '1', |
| 160 | + 'wpReturnTo' => $returnto, |
| 161 | + 'action' => 'edit', |
| 162 | + 'section' => $section |
| 163 | + ); |
159 | 164 | |
160 | 165 | $wgRequest = new FauxRequest( $args ); |
161 | | - $wgArticle = MediaWiki::articleFromTitle( $wgTitle ); |
162 | | - $editor = new EditPage( $wgArticle ); |
| 166 | + $article = MediaWiki::articleFromTitle( $wgTitle ); |
| 167 | + $editor = new EditPage( $article ); |
163 | 168 | |
164 | 169 | //generate form |
165 | 170 | $editor->importFormData( $wgRequest ); |