r73909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73908‎ | r73909 | r73910 >
Date:15:31, 28 September 2010
Author:jimbojw
Status:deferred
Tags:
Comment:
Import of ArticleComments v0.4.3 by Jim R. Wilson from http://jimbojw.com/wiki/index.php?title=ArticleComments&oldid=6933
Modified paths:
  • /trunk/extensions/ArticleComments/ArticleComments.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleComments/ArticleComments.php
@@ -2,7 +2,7 @@
33 /*
44 * ArticleComments.php - A MediaWiki extension for adding comment sections to articles.
55 * @author Jim R. Wilson
6 - * @version 0.4.2
 6+ * @version 0.4.3
77 * @copyright Copyright (C) 2007 Jim R. Wilson
88 * @license The MIT License - http://www.opensource.org/licenses/mit-license.php
99 * -----------------------------------------------------------------------
@@ -22,6 +22,9 @@
2323 * <comments />
2424 * Note: Typically this would be placed at the end of the article text.
2525 * Version Notes:
 26+ * version 0.4.3:
 27+ * Added new insertion feature, comments will now be inserted before <!--COMMENTS_ABOVE--> if present
 28+ * Or, after <!--COMMENTS_BELOW--> if present (the latter causes reverse chronological comment ordering).
2629 * version 0.4.2:
2730 * Updated default spam filtering code to check all fields against $wgSpamRegex, if specified.
2831 * version 0.4.1:
@@ -413,17 +416,28 @@
414417 if ($commenterURL && $commenterURL!='http://') $sigText = "[$commenterURL $commenterName]";
415418 else if ($wgUser->isLoggedIn()) $sigText = $wgParser->getUserSig( $wgUser );
416419 else $sigText = $commenterName;
 420+
 421+ # Search for insertion point, or append most recent comment.
 422+ $commentText = wfMsgForContent(
 423+ $ac.'new-comment',
 424+ wfMsgForContent($ac.'commenter-said', $commenterName),
 425+ $comment,
 426+ $sigText,
 427+ $d
 428+ );
 429+ $posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' );
 430+ if ($posAbove===false) $posBelow = stripos( $talkContent, '<!--COMMENTS_BELOW-->' );
 431+ if ($posAbove!==false) {
 432+ # Insert comments above HTML marker
 433+ $talkContent = substr( $talkContent, 0, $posAbove ) . $commentText . substr( $talkContent, $posAbove );
 434+ } else if ($posBelow!==false) {
 435+ # Insert comments below HTML marker
 436+ $talkContent = substr( $talkContent, 0, $posBelow + 21 ) . $commentText . substr( $talkContent, $posBelow + 21 );
 437+ } else {
 438+ # No marker found, append to bottom (default)
 439+ $talkContent .= $commentText;
 440+ }
417441
418 - # Append most recent comment
419 - $talkContent .=
420 - wfMsgForContent(
421 - $ac.'new-comment',
422 - wfMsgForContent($ac.'commenter-said', $commenterName),
423 - $comment,
424 - $sigText,
425 - $d
426 - );
427 -
428442 # Update the talkArticle with the new comment
429443 $summary = wfMsgForContent($ac.'summary', $commenterName);
430444 if (method_exists($talkArticle, 'doEdit')) {

Status & tagging log