r74154 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74153‎ | r74154 | r74155 >
Date:21:20, 2 October 2010
Author:platonides
Status:ok
Tags:
Comment:
Tabify. It was using spaces with a space tab of 4.
23:15:47: ArticleComments.php: replaced 72 occurrences of "^ ([^ ])" with "\t\\1".
23:16:24: ArticleComments.php: replaced 50 occurrences of "^ ([^ ])" with "\t\t\\1".
23:16:40: ArticleComments.php: replaced 9 occurrences of "^ ([^ ])" with "\t\t\t\\1".
Modified paths:
  • /trunk/extensions/ArticleComments/ArticleComments.i18n.php (modified) (history)
  • /trunk/extensions/ArticleComments/ArticleComments.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleComments/ArticleComments.php
@@ -76,11 +76,11 @@
7777
7878 # Credits
7979 $wgExtensionCredits['other'][] = array(
80 - 'name' => 'ArticleComments',
81 - 'author' => 'Jim R. Wilson - wilson.jim.r <at> gmail.com',
82 - 'url' => 'http://jimbojw.com/wiki/index.php?title=ArticleComments',
83 - 'description' => 'Enables comment sections on article pages.',
84 - 'version' => '0.5'
 80+ 'name' => 'ArticleComments',
 81+ 'author' => 'Jim R. Wilson - wilson.jim.r <at> gmail.com',
 82+ 'url' => 'http://jimbojw.com/wiki/index.php?title=ArticleComments',
 83+ 'description' => 'Enables comment sections on article pages.',
 84+ 'version' => '0.5'
8585 );
8686
8787 # Add Extension Functions
@@ -113,22 +113,22 @@
114114 $wgExtensionFunctions[] = 'setupSpecialProcessComment';
115115
116116 function setupSpecialProcessComment() {
117 - SpecialPage::addPage( new SpecialPage( 'ProcessComment', '', true, 'specialProcessComment', false ) );
 117+ SpecialPage::addPage( new SpecialPage( 'ProcessComment', '', true, 'specialProcessComment', false ) );
118118 }
119119
120120 # Sets up the ArticleComments Parser hook for <comments />
121121 function wfArticleCommentsParserSetup( &$parser ) {
122 - $parser->setHook( 'comments', 'wfArticleCommentsParserHook' );
123 - return true;
 122+ $parser->setHook( 'comments', 'wfArticleCommentsParserHook' );
 123+ return true;
124124 }
125125
126126 function wfArticleCommentsParserHook( $text, $params = array(), $parser ) {
127 - # Generate a comment form for display
128 - $commentForm = wfArticleCommentForm( $parser->mTitle, $params );
 127+ # Generate a comment form for display
 128+ $commentForm = wfArticleCommentForm( $parser->mTitle, $params );
129129
130 - # Hide content from the Parser using base64 to avoid mangling.
131 - # Note: Content will be decoded after Tidy has finished its processing of the page.
132 - return '<pre>@ENCODED@' . base64_encode( $commentForm ) . '@ENCODED@</pre>';
 130+ # Hide content from the Parser using base64 to avoid mangling.
 131+ # Note: Content will be decoded after Tidy has finished its processing of the page.
 132+ return '<pre>@ENCODED@' . base64_encode( $commentForm ) . '@ENCODED@</pre>';
133133 }
134134
135135 /**
@@ -138,33 +138,33 @@
139139 */
140140 function wfArticleCommentsAfterContent( $data, $skin ) {
141141
142 - global $wgRequest, $wgArticleCommentsNSDisplayList;
 142+ global $wgRequest, $wgArticleCommentsNSDisplayList;
143143
144 - # Short circuit for anything other than action=view or action=purge
145 - if ( $wgRequest->getVal( 'action' ) &&
146 - $wgRequest->getVal( 'action' ) != 'view' &&
147 - $wgRequest->getVal( 'action' ) != 'purge'
148 - ) return true;
 144+ # Short circuit for anything other than action=view or action=purge
 145+ if ( $wgRequest->getVal( 'action' ) &&
 146+ $wgRequest->getVal( 'action' ) != 'view' &&
 147+ $wgRequest->getVal( 'action' ) != 'purge'
 148+ ) return true;
149149
150 - # Short-circuit if displaylist is undefined, empty or null
151 - if ( $wgArticleCommentsNSDisplayList == null )
 150+ # Short-circuit if displaylist is undefined, empty or null
 151+ if ( $wgArticleCommentsNSDisplayList == null )
152152 return true;
153153
154154 $title = $skin->getTitle();
155 - if ( !$title->exists() ) {
 155+ if ( !$title->exists() ) {
156156 return true;
157157 }
158158
159 - # Ensure that the namespace list is an actual list
160 - $nsList = $wgArticleCommentsNSDisplayList;
161 - if ( !is_array( $nsList ) ) $nsList = array( $nsList );
 159+ # Ensure that the namespace list is an actual list
 160+ $nsList = $wgArticleCommentsNSDisplayList;
 161+ if ( !is_array( $nsList ) ) $nsList = array( $nsList );
162162
163 - # Display the form
164 - if ( in_array( $title->getNamespace(), $nsList ) ) {
165 - $data .= wfArticleCommentForm( $title );
166 - }
 163+ # Display the form
 164+ if ( in_array( $title->getNamespace(), $nsList ) ) {
 165+ $data .= wfArticleCommentForm( $title );
 166+ }
167167
168 - return true;
 168+ return true;
169169 }
170170
171171 /**
@@ -181,7 +181,7 @@
182182 $tmp[strtolower( $k )] = (bool)strcasecmp( $v, "false" );
183183 }
184184 $params = $tmp;
185 - $ac = 'article-comments-';
 185+ $ac = 'article-comments-';
186186
187187 # Build out the comment form.
188188 $content = '<div id="commentForm">';
@@ -207,64 +207,64 @@
208208 $content .= '<p>' . Html::input( 'comment-submit', wfMsgForContent( $ac . 'submit-button' ), 'submit' ) . '</p>';
209209 $content .= '</form></div>';
210210
211 - # Short-circuit if noScript has been set to anything other than false
212 - if ( $params['noscript'] ) {
213 - return $content;
214 - }
 211+ # Short-circuit if noScript has been set to anything other than false
 212+ if ( $params['noscript'] ) {
 213+ return $content;
 214+ }
215215
216 - # Inline JavaScript to make form behavior more rich (must degrade well in JS-disabled browsers)
217 - $content .= "<script type='text/javascript'>//<![CDATA[\n(function(){\n";
 216+ # Inline JavaScript to make form behavior more rich (must degrade well in JS-disabled browsers)
 217+ $content .= "<script type='text/javascript'>//<![CDATA[\n(function(){\n";
218218
219 - # Prefill the name field if the user is logged in.
220 - $content .=
221 - 'var prefillUserName = function(){' . "\n" .
222 - 'var ptu=document.getElementById("pt-userpage");' . "\n" .
223 - 'if (ptu) document.getElementById("commenterName").value=' .
224 - 'ptu.getElementsByTagName("a")[0].innerHTML;};' . "\n" .
225 - 'if (window.addEventListener) window.addEventListener' .
226 - '("load",prefillUserName,false);' . "\n" .
227 - 'else if (window.attachEvent) window.attachEvent' .
228 - '("onload",prefillUserName);' . "\n";
 219+ # Prefill the name field if the user is logged in.
 220+ $content .=
 221+ 'var prefillUserName = function(){' . "\n" .
 222+ 'var ptu=document.getElementById("pt-userpage");' . "\n" .
 223+ 'if (ptu) document.getElementById("commenterName").value=' .
 224+ 'ptu.getElementsByTagName("a")[0].innerHTML;};' . "\n" .
 225+ 'if (window.addEventListener) window.addEventListener' .
 226+ '("load",prefillUserName,false);' . "\n" .
 227+ 'else if (window.attachEvent) window.attachEvent' .
 228+ '("onload",prefillUserName);' . "\n";
229229
230 - # Prefill comment text if it has been specified by a system message
231 - # Note: This is done dynamically with JavaScript since it would be annoying
232 - # for JS-disabled browsers to have the prefilled text (since they'd have
233 - # to manually delete it) and would break parser output caching
234 - $pretext = wfMsgForContent( $ac . 'prefilled-comment-text' );
235 - if ( $pretext ) {
236 - $content .=
237 - 'var comment = document.getElementById("comment");' . "\n" .
238 - 'comment._everFocused=false;' . "\n" .
239 - 'comment.innerHTML="' . htmlspecialchars( $pretext ) . '";' . "\n" .
240 - 'var clearCommentOnFirstFocus = function() {' . "\n" .
241 - 'var c=document.getElementById("comment");' . "\n" .
242 - 'if (!c._everFocused) {' . "\n" .
243 - 'c._everFocused=true;' . "\n" .
244 - 'c.value="";}}' . "\n" .
245 - 'if (comment.addEventListener) comment.addEventListener' .
246 - '("focus",clearCommentOnFirstFocus,false);' . "\n" .
247 - 'else if (comment.attachEvent) comment.attachEvent' .
248 - '("onfocus",clearCommentOnFirstFocus);' . "\n";
249 - }
 230+ # Prefill comment text if it has been specified by a system message
 231+ # Note: This is done dynamically with JavaScript since it would be annoying
 232+ # for JS-disabled browsers to have the prefilled text (since they'd have
 233+ # to manually delete it) and would break parser output caching
 234+ $pretext = wfMsgForContent( $ac . 'prefilled-comment-text' );
 235+ if ( $pretext ) {
 236+ $content .=
 237+ 'var comment = document.getElementById("comment");' . "\n" .
 238+ 'comment._everFocused=false;' . "\n" .
 239+ 'comment.innerHTML="' . htmlspecialchars( $pretext ) . '";' . "\n" .
 240+ 'var clearCommentOnFirstFocus = function() {' . "\n" .
 241+ 'var c=document.getElementById("comment");' . "\n" .
 242+ 'if (!c._everFocused) {' . "\n" .
 243+ 'c._everFocused=true;' . "\n" .
 244+ 'c.value="";}}' . "\n" .
 245+ 'if (comment.addEventListener) comment.addEventListener' .
 246+ '("focus",clearCommentOnFirstFocus,false);' . "\n" .
 247+ 'else if (comment.attachEvent) comment.attachEvent' .
 248+ '("onfocus",clearCommentOnFirstFocus);' . "\n";
 249+ }
250250
251 - # Hides the commentForm until the "Make a comment" link is clicked
252 - # Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in LocalSettings.php
253 - if ( !isset( $params['hideform'] ) ||
254 - ( $params['hideform'] != 'false' &&
255 - !$params['hideform'] === false ) ) {
256 - $content .=
257 - 'var cf=document.getElementById("commentForm");' . "\n" .
258 - 'cf.style.display="none";' . "\n" .
259 - 'var p=document.createElement("p");' . "\n" .
260 - 'p.innerHTML="<a href=\'javascript:void(0)\' onclick=\'' .
261 - 'document.getElementById(\\"commentForm\\").style.display=\\"block\\";' .
262 - 'this.style.display=\\"none\\";false' .
263 - '\'>' . wfMsgForContent( $ac . 'leave-comment-link' ) . '</a>";' . "\n" .
264 - 'cf.parentNode.insertBefore(p,cf);' . "\n";
265 - }
 251+ # Hides the commentForm until the "Make a comment" link is clicked
 252+ # Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in LocalSettings.php
 253+ if ( !isset( $params['hideform'] ) ||
 254+ ( $params['hideform'] != 'false' &&
 255+ !$params['hideform'] === false ) ) {
 256+ $content .=
 257+ 'var cf=document.getElementById("commentForm");' . "\n" .
 258+ 'cf.style.display="none";' . "\n" .
 259+ 'var p=document.createElement("p");' . "\n" .
 260+ 'p.innerHTML="<a href=\'javascript:void(0)\' onclick=\'' .
 261+ 'document.getElementById(\\"commentForm\\").style.display=\\"block\\";' .
 262+ 'this.style.display=\\"none\\";false' .
 263+ '\'>' . wfMsgForContent( $ac . 'leave-comment-link' ) . '</a>";' . "\n" .
 264+ 'cf.parentNode.insertBefore(p,cf);' . "\n";
 265+ }
266266
267 - $content .= "})();\n//]]></script>";
268 - return $content;
 267+ $content .= "})();\n//]]></script>";
 268+ return $content;
269269 }
270270
271271 /**
@@ -275,12 +275,12 @@
276276 * @return Boolean Always tru to give other hooking methods a chance to run.
277277 */
278278 function wfProcessEncodedContent( $out, $text ) {
279 - $text = preg_replace(
280 - '/<pre>\n@ENCODED@([0-9a-zA-Z\\+\\/]+=*)@ENCODED@\n<\\/pre>/e',
281 - 'base64_decode("$1")',
282 - $text
283 - );
284 - return true;
 279+ $text = preg_replace(
 280+ '/<pre>\n@ENCODED@([0-9a-zA-Z\\+\\/]+=*)@ENCODED@\n<\\/pre>/e',
 281+ 'base64_decode("$1")',
 282+ $text
 283+ );
 284+ return true;
285285 }
286286
287287 /**
@@ -288,13 +288,13 @@
289289 */
290290 function specialProcessComment() {
291291
292 - global $wgOut, $wgParser, $wgUser, $wgContLang, $wgRequest;
 292+ global $wgOut, $wgParser, $wgUser, $wgContLang, $wgRequest;
293293
294 - # Retrieve submitted values
295 - $titleText = $wgRequest->getVal( 'commentArticle' );
296 - $commenterName = $wgRequest->getVal( 'commenterName' );
297 - $commenterURL = trim( $wgRequest->getVal( 'commenterURL' ) );
298 - $comment = $wgRequest->getVal( 'comment' );
 294+ # Retrieve submitted values
 295+ $titleText = $wgRequest->getVal( 'commentArticle' );
 296+ $commenterName = $wgRequest->getVal( 'commenterName' );
 297+ $commenterURL = trim( $wgRequest->getVal( 'commenterURL' ) );
 298+ $comment = $wgRequest->getVal( 'comment' );
299299
300300 // The default value is the same as not providing a URL
301301 if ( $commenterURL == 'http://' ) {
@@ -303,144 +303,144 @@
304304
305305 $title = Title::newFromText( $titleText );
306306
307 - # Perform validation checks on supplied fields
308 - $ac = 'article-comments-';
309 - $messages = array();
 307+ # Perform validation checks on supplied fields
 308+ $ac = 'article-comments-';
 309+ $messages = array();
310310
311311 if ( !$wgRequest->wasPosted() )
312312 $messages[] = wfMsgForContent( $ac . 'not-posted' );
313313
314 - if ( $titleText === '' || !$title ) {
 314+ if ( $titleText === '' || !$title ) {
315315 $messages[] = wfMsgForContent(
316 - $ac . 'invalid-field', wfMsgForContent( $ac . 'title-string' ), $titleText );
 316+ $ac . 'invalid-field', wfMsgForContent( $ac . 'title-string' ), $titleText );
317317 }
318318
319 - if ( !$commenterName ) $messages[] = wfMsgForContent(
320 - $ac . 'required-field', wfMsgForContent( $ac . 'name-string' ) );
 319+ if ( !$commenterName ) $messages[] = wfMsgForContent(
 320+ $ac . 'required-field', wfMsgForContent( $ac . 'name-string' ) );
321321
322322 if ( !preg_match( "/^(" . wfUrlProtocols() . ')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) )
323323 $messages[] = wfMsgForContent(
324 - $ac . 'invalid-field', wfMsgForContent( $ac . 'url-string' ), $commenterURL );
 324+ $ac . 'invalid-field', wfMsgForContent( $ac . 'url-string' ), $commenterURL );
325325
326 - if ( !$comment ) $messages[] = wfMsgForContent(
327 - $ac . 'required-field', wfMsgForContent( $ac . 'comment-string' ) );
328 - if ( !empty( $messages ) ) {
329 - $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
330 - $wikiText = "<div class='errorbox'>";
331 - $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
332 - foreach ( $messages as $message ) {
333 - $wikiText .= "* $message\n";
334 - }
335 - $wgOut->addWikiText( $wikiText . "</div>" );
336 - return;
337 - }
 326+ if ( !$comment ) $messages[] = wfMsgForContent(
 327+ $ac . 'required-field', wfMsgForContent( $ac . 'comment-string' ) );
 328+ if ( !empty( $messages ) ) {
 329+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
 330+ $wikiText = "<div class='errorbox'>";
 331+ $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
 332+ foreach ( $messages as $message ) {
 333+ $wikiText .= "* $message\n";
 334+ }
 335+ $wgOut->addWikiText( $wikiText . "</div>" );
 336+ return;
 337+ }
338338
339 - # Setup title and talkTitle object
340 - $article = new Article( $title );
 339+ # Setup title and talkTitle object
 340+ $article = new Article( $title );
341341
342 - $talkTitle = $title->getTalkPage();
343 - $talkArticle = new Article( $talkTitle );
 342+ $talkTitle = $title->getTalkPage();
 343+ $talkArticle = new Article( $talkTitle );
344344
345 - # Check whether user is blocked from editing the talk page
346 - if ( $wgUser->isBlockedFrom( $talkTitle ) ) {
347 - $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
348 - $wikiText = "<div class='errorbox'>";
349 - $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
350 - $wikiText .= '* ' . wfMsgForContent( $ac . 'user-is-blocked', $talkTitle->getPrefixedText() ) . "\n";
351 - $wgOut->addWikiText( $wikiText . "</div>" );
352 - return;
353 - }
 345+ # Check whether user is blocked from editing the talk page
 346+ if ( $wgUser->isBlockedFrom( $talkTitle ) ) {
 347+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
 348+ $wikiText = "<div class='errorbox'>";
 349+ $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
 350+ $wikiText .= '* ' . wfMsgForContent( $ac . 'user-is-blocked', $talkTitle->getPrefixedText() ) . "\n";
 351+ $wgOut->addWikiText( $wikiText . "</div>" );
 352+ return;
 353+ }
354354
355 - # Retrieve article content
356 - $articleContent = '';
357 - if ( $title->exists() ) {
358 - $articleContent = $article->getContent();
359 - }
 355+ # Retrieve article content
 356+ $articleContent = '';
 357+ if ( $title->exists() ) {
 358+ $articleContent = $article->getContent();
 359+ }
360360
361 - # Retrieve existing talk content
362 - $talkContent = '';
363 - if ( $talkTitle->exists() ) {
364 - $talkContent = $talkArticle->getContent();
365 - }
 361+ # Retrieve existing talk content
 362+ $talkContent = '';
 363+ if ( $talkTitle->exists() ) {
 364+ $talkContent = $talkArticle->getContent();
 365+ }
366366
367367
368 - # Check if talk NS is in the Namespace display list
369 - # Note: if so, then there's no need to confirm that <comments /> appears in the article or talk page.
370 - global $wgArticleCommentsNSDisplayList;
371 - $skipCheck = (
372 - is_array( $wgArticleCommentsNSDisplayList ) ?
373 - in_array( $talkTitle->getNamespace(), $wgArticleCommentsNSDisplayList ):
374 - false
375 - );
 368+ # Check if talk NS is in the Namespace display list
 369+ # Note: if so, then there's no need to confirm that <comments /> appears in the article or talk page.
 370+ global $wgArticleCommentsNSDisplayList;
 371+ $skipCheck = (
 372+ is_array( $wgArticleCommentsNSDisplayList ) ?
 373+ in_array( $talkTitle->getNamespace(), $wgArticleCommentsNSDisplayList ):
 374+ false
 375+ );
376376
377 - # Check whether the article or its talk page contains a <comments /> flag
378 - if ( !$skipCheck &&
379 - preg_match( '/<comments( +[^>]*)?\\/>/', $articleContent ) === 0 &&
380 - preg_match( '/<comments( +[^>]*)?\\/>/', $talkContent ) === 0
381 - ) {
382 - $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
383 - $wgOut->addWikiText(
384 - "<div class='errorbox'>" .
385 - wfMsgForContent( $ac . 'no-comments', $title->getPrefixedText() ) .
386 - "</div>"
387 - );
388 - return;
389 - }
 377+ # Check whether the article or its talk page contains a <comments /> flag
 378+ if ( !$skipCheck &&
 379+ preg_match( '/<comments( +[^>]*)?\\/>/', $articleContent ) === 0 &&
 380+ preg_match( '/<comments( +[^>]*)?\\/>/', $talkContent ) === 0
 381+ ) {
 382+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
 383+ $wgOut->addWikiText(
 384+ "<div class='errorbox'>" .
 385+ wfMsgForContent( $ac . 'no-comments', $title->getPrefixedText() ) .
 386+ "</div>"
 387+ );
 388+ return;
 389+ }
390390
391 - # Run spam checks
392 - $isspam = false;
 391+ # Run spam checks
 392+ $isspam = false;
393393 wfRunHooks( 'ArticleCommentsSpamCheck', array( $comment , $commenterName, $commenterURL, &$isspam ) );
394394
395 - # If it's spam - it's gone!
396 - if ( $isspam ) {
397 - $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
398 - $wgOut->addWikiText(
399 - "<div class='errorbox'>" .
400 - wfMsgForContent( $ac . 'no-spam' ) .
401 - "</div>"
402 - );
403 - return;
404 - }
 395+ # If it's spam - it's gone!
 396+ if ( $isspam ) {
 397+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
 398+ $wgOut->addWikiText(
 399+ "<div class='errorbox'>" .
 400+ wfMsgForContent( $ac . 'no-spam' ) .
 401+ "</div>"
 402+ );
 403+ return;
 404+ }
405405
406 - # Initialize the talk page's content.
407 - if ( $talkContent == '' ) {
408 - $talkContent = wfMsgForContent( $ac . 'talk-page-starter', $title->getPrefixedText() );
409 - }
 406+ # Initialize the talk page's content.
 407+ if ( $talkContent == '' ) {
 408+ $talkContent = wfMsgForContent( $ac . 'talk-page-starter', $title->getPrefixedText() );
 409+ }
410410
411 - # Determine signature components
412 - if ( $commenterURL != '' ) $sigText = "[$commenterURL $commenterName]";
413 - else if ( $wgUser->isLoggedIn() ) $sigText = $wgParser->getUserSig( $wgUser );
414 - else $sigText = $commenterName;
 411+ # Determine signature components
 412+ if ( $commenterURL != '' ) $sigText = "[$commenterURL $commenterName]";
 413+ else if ( $wgUser->isLoggedIn() ) $sigText = $wgParser->getUserSig( $wgUser );
 414+ else $sigText = $commenterName;
415415
416 - # Search for insertion point, or append most recent comment.
417 - $commentText = wfMsgForContent(
418 - $ac . 'new-comment',
419 - wfMsgForContent( $ac . 'commenter-said', $commenterName ),
420 - $comment,
421 - $sigText,
422 - '~~~~~'
423 - );
 416+ # Search for insertion point, or append most recent comment.
 417+ $commentText = wfMsgForContent(
 418+ $ac . 'new-comment',
 419+ wfMsgForContent( $ac . 'commenter-said', $commenterName ),
 420+ $comment,
 421+ $sigText,
 422+ '~~~~~'
 423+ );
424424
425 - $posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' );
426 - if ( $posAbove === false ) $posBelow = stripos( $talkContent, '<!--COMMENTS_BELOW-->' );
427 - if ( $posAbove !== false ) {
428 - # Insert comments above HTML marker
429 - $talkContent = substr( $talkContent, 0, $posAbove ) . $commentText . substr( $talkContent, $posAbove );
430 - } else if ( $posBelow !== false ) {
431 - # Insert comments below HTML marker
432 - $talkContent = substr( $talkContent, 0, $posBelow + 21 ) . $commentText . substr( $talkContent, $posBelow + 21 );
433 - } else {
434 - # No marker found, append to bottom (default)
435 - $talkContent .= $commentText;
436 - }
 425+ $posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' );
 426+ if ( $posAbove === false ) $posBelow = stripos( $talkContent, '<!--COMMENTS_BELOW-->' );
 427+ if ( $posAbove !== false ) {
 428+ # Insert comments above HTML marker
 429+ $talkContent = substr( $talkContent, 0, $posAbove ) . $commentText . substr( $talkContent, $posAbove );
 430+ } else if ( $posBelow !== false ) {
 431+ # Insert comments below HTML marker
 432+ $talkContent = substr( $talkContent, 0, $posBelow + 21 ) . $commentText . substr( $talkContent, $posBelow + 21 );
 433+ } else {
 434+ # No marker found, append to bottom (default)
 435+ $talkContent .= $commentText;
 436+ }
437437
438438 # Update the talkArticle with the new comment
439439 $summary = wfMsgForContent( $ac . 'summary', $commenterName );
440440 $talkArticle->doEdit( $talkContent, $summary );
441441
442 - $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-succeeded' ) );
443 - $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-success', $title->getPrefixedText() ) );
444 - $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-view-all', $talkTitle->getPrefixedText() ) );
 442+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-succeeded' ) );
 443+ $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-success', $title->getPrefixedText() ) );
 444+ $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-view-all', $talkTitle->getPrefixedText() ) );
445445 }
446446
447447 /**
@@ -454,40 +454,40 @@
455455 */
456456 function defaultArticleCommentSpamCheck( $comment, $commenterName, $commenterURL, $isspam ) {
457457
458 - # Short-circuit if spam has already been determined
459 - if ( $isspam ) return true;
460 - $fields = array( $comment, $commenterName, $commenterURL );
 458+ # Short-circuit if spam has already been determined
 459+ if ( $isspam ) return true;
 460+ $fields = array( $comment, $commenterName, $commenterURL );
461461
462 - # Run everything through $wgSpamRegex if it has been specified
463 - global $wgSpamRegex;
464 - if ( $wgSpamRegex ) {
465 - foreach ( $fields as $field ) {
466 - if ( preg_match( $wgSpamRegex, $field ) ) return $isspam = true;
467 - }
468 - }
 462+ # Run everything through $wgSpamRegex if it has been specified
 463+ global $wgSpamRegex;
 464+ if ( $wgSpamRegex ) {
 465+ foreach ( $fields as $field ) {
 466+ if ( preg_match( $wgSpamRegex, $field ) ) return $isspam = true;
 467+ }
 468+ }
469469
470 - # Rudimentary spam protection
471 - $spampatterns = array(
472 - '%\\[url=(https?|ftp)://%smi',
473 - '%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi'
474 - );
475 - foreach ( $spampatterns as $sp ) {
476 - foreach ( array( $comment, $commenterName, $commenterURL ) as $field ) {
477 - if ( preg_match( $sp, $field ) ) return $isspam = true;
478 - }
479 - }
 470+ # Rudimentary spam protection
 471+ $spampatterns = array(
 472+ '%\\[url=(https?|ftp)://%smi',
 473+ '%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi'
 474+ );
 475+ foreach ( $spampatterns as $sp ) {
 476+ foreach ( array( $comment, $commenterName, $commenterURL ) as $field ) {
 477+ if ( preg_match( $sp, $field ) ) return $isspam = true;
 478+ }
 479+ }
480480
481 - # Check for bad input for commenterName (seems to be a popular spam location)
482 - $spampatterns = array(
483 - '%<a\\s+%smi',
484 - '%(https?|ftp)://%smi',
485 - '%(\\n|\\r)%smi'
486 - );
487 - foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName ) ) return $isspam = true;
 481+ # Check for bad input for commenterName (seems to be a popular spam location)
 482+ $spampatterns = array(
 483+ '%<a\\s+%smi',
 484+ '%(https?|ftp)://%smi',
 485+ '%(\\n|\\r)%smi'
 486+ );
 487+ foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName ) ) return $isspam = true;
488488
489 - # Fail for length violations
490 - if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 ) return $isspam = true;
 489+ # Fail for length violations
 490+ if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 ) return $isspam = true;
491491
492 - # We made it this far, leave $isspam alone and give other implementors a chance.
493 - return true;
 492+ # We made it this far, leave $isspam alone and give other implementors a chance.
 493+ return true;
494494 }
Index: trunk/extensions/ArticleComments/ArticleComments.i18n.php
@@ -9,31 +9,31 @@
1010 $messages = array();
1111
1212 $messages['en'] = array(
13 - 'article-comments-title-string' => 'title',
14 - 'article-comments-name-string' => 'Name',
15 - 'article-comments-name-field' => 'Name (required):',
16 - 'article-comments-url-field' => 'Website:',
17 - 'article-comments-url-string' => 'URL',
18 - 'article-comments-comment-string' => 'Comment',
19 - 'article-comments-comment-field' => 'Comment:',
20 - 'article-comments-submit-button' => 'Submit',
21 - 'article-comments-leave-comment-link' => 'Leave a comment ...',
22 - 'article-comments-invalid-field' => 'The $1 provided <nowiki>[$2]</nowiki> is invalid.',
23 - 'article-comments-required-field' => '$1 field is required.',
24 - 'article-comments-submission-failed' => 'Comment Submission Failed',
25 - 'article-comments-failure-reasons' => 'Sorry, your comment submission failed for the following reason(s):',
26 - 'article-comments-no-comments' => 'Sorry, the article &quot;[[$1]]&quot; is not accepting comments at this time.',
27 - 'article-comments-talk-page-starter' => "<noinclude>Comments on [[$1]]\n<comments />\n----- __NOEDITSECTION__</noinclude>\n",
28 - 'article-comments-commenter-said' => '$1 said ...',
29 - 'article-comments-summary' => 'Comment provided by $1 - via ArticleComments extension',
30 - 'article-comments-submission-succeeded' => 'Comment submission succeeded',
31 - 'article-comments-submission-success' => 'You have successfully submitted a comment for [[$1]]',
32 - 'article-comments-submission-view-all' => 'You may view all comments on that article [[$1|here]]',
33 - 'article-comments-prefilled-comment-text' => '',
34 - 'article-comments-user-is-blocked' => 'Your user account is currently blocked from editing [[$1]].',
35 - 'article-comments-new-comment' => "\n== \$1 ==\n\n<div class='commentBlock'>\n\$2\n\n--\$3 \$4\n</div>\n",
36 - 'article-comments-no-spam' => 'At least one of the submitted fields was flagged as spam.',
37 - 'processcomment' => 'Process Article Comment',
 13+ 'article-comments-title-string' => 'title',
 14+ 'article-comments-name-string' => 'Name',
 15+ 'article-comments-name-field' => 'Name (required):',
 16+ 'article-comments-url-field' => 'Website:',
 17+ 'article-comments-url-string' => 'URL',
 18+ 'article-comments-comment-string' => 'Comment',
 19+ 'article-comments-comment-field' => 'Comment:',
 20+ 'article-comments-submit-button' => 'Submit',
 21+ 'article-comments-leave-comment-link' => 'Leave a comment ...',
 22+ 'article-comments-invalid-field' => 'The $1 provided <nowiki>[$2]</nowiki> is invalid.',
 23+ 'article-comments-required-field' => '$1 field is required.',
 24+ 'article-comments-submission-failed' => 'Comment Submission Failed',
 25+ 'article-comments-failure-reasons' => 'Sorry, your comment submission failed for the following reason(s):',
 26+ 'article-comments-no-comments' => 'Sorry, the article &quot;[[$1]]&quot; is not accepting comments at this time.',
 27+ 'article-comments-talk-page-starter' => "<noinclude>Comments on [[$1]]\n<comments />\n----- __NOEDITSECTION__</noinclude>\n",
 28+ 'article-comments-commenter-said' => '$1 said ...',
 29+ 'article-comments-summary' => 'Comment provided by $1 - via ArticleComments extension',
 30+ 'article-comments-submission-succeeded' => 'Comment submission succeeded',
 31+ 'article-comments-submission-success' => 'You have successfully submitted a comment for [[$1]]',
 32+ 'article-comments-submission-view-all' => 'You may view all comments on that article [[$1|here]]',
 33+ 'article-comments-prefilled-comment-text' => '',
 34+ 'article-comments-user-is-blocked' => 'Your user account is currently blocked from editing [[$1]].',
 35+ 'article-comments-new-comment' => "\n== \$1 ==\n\n<div class='commentBlock'>\n\$2\n\n--\$3 \$4\n</div>\n",
 36+ 'article-comments-no-spam' => 'At least one of the submitted fields was flagged as spam.',
 37+ 'processcomment' => 'Process Article Comment',
3838 );
3939
4040 $messages['qqq'] = array(

Status & tagging log