Index: trunk/extensions/ArticleComments/ArticleComments.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * ArticleComments.php - A MediaWiki extension for adding comment sections to articles. |
5 | 5 | * @author Jim R. Wilson |
6 | 6 | * @author Platonides |
7 | | - * @version 0.5 |
| 7 | + * @version 0.5.1 |
8 | 8 | * @copyright Copyright (C) 2007 Jim R. Wilson |
9 | 9 | * @license The MIT License - http://www.opensource.org/licenses/mit-license.php |
10 | 10 | * ----------------------------------------------------------------------- |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | * @param Array $params A hash of parameters containing rendering options. |
174 | 174 | */ |
175 | 175 | function wfArticleCommentForm( $title, $params = array() ) { |
176 | | - global $wgArticleCommentDefaults; |
| 176 | + global $wgArticleCommentDefaults, $wgOut; |
177 | 177 | |
178 | 178 | # Merge in global defaults if specified |
179 | 179 | $tmp = $wgArticleCommentDefaults; |
— | — | @@ -211,10 +211,10 @@ |
212 | 212 | } |
213 | 213 | |
214 | 214 | # Inline JavaScript to make form behavior more rich (must degrade well in JS-disabled browsers) |
215 | | - $content .= "<script type='text/javascript'>//<![CDATA[\n(function(){\n"; |
| 215 | + $js .= "<script type=\"text/javascript\">//<![CDATA[\n(function(){\n"; |
216 | 216 | |
217 | 217 | # Prefill the name field if the user is logged in. |
218 | | - $content .= |
| 218 | + $js .= |
219 | 219 | 'var prefillUserName = function(){' . "\n" . |
220 | 220 | 'var ptu=document.getElementById("pt-userpage");' . "\n" . |
221 | 221 | 'if (ptu) document.getElementById("commenterName").value=' . |
— | — | @@ -230,7 +230,7 @@ |
231 | 231 | # to manually delete it) and would break parser output caching |
232 | 232 | $pretext = wfMsgForContent( 'article-comments-prefilled-comment-text' ); |
233 | 233 | if ( $pretext ) { |
234 | | - $content .= |
| 234 | + $js .= |
235 | 235 | 'var comment = document.getElementById("comment");' . "\n" . |
236 | 236 | 'comment._everFocused=false;' . "\n" . |
237 | 237 | 'comment.innerHTML="' . htmlspecialchars( $pretext ) . '";' . "\n" . |
— | — | @@ -248,9 +248,9 @@ |
249 | 249 | # Hides the commentForm until the "Make a comment" link is clicked |
250 | 250 | # Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in LocalSettings.php |
251 | 251 | if ( !isset( $params['hideform'] ) || |
252 | | - ( $params['hideform'] != 'false' && |
| 252 | + ( $params['hideform'] !== 'false' && |
253 | 253 | !$params['hideform'] === false ) ) { |
254 | | - $content .= |
| 254 | + $js .= |
255 | 255 | 'var cf=document.getElementById("commentForm");' . "\n" . |
256 | 256 | 'cf.style.display="none";' . "\n" . |
257 | 257 | 'var p=document.createElement("p");' . "\n" . |
— | — | @@ -261,7 +261,9 @@ |
262 | 262 | 'cf.parentNode.insertBefore(p,cf);' . "\n"; |
263 | 263 | } |
264 | 264 | |
265 | | - $content .= "})();\n//]]></script>"; |
| 265 | + $js .= "})();\n//]]></script>"; |
| 266 | + $wgOut->addScript( $js ); |
| 267 | + |
266 | 268 | return $content; |
267 | 269 | } |
268 | 270 | |