http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74154
Revision: 74154
Author: platonides
Date: 2010-10-02 21:20:45 +0000 (Sat, 02 Oct 2010)
Log Message:
-----------
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
trunk/extensions/ArticleComments/ArticleComments.php
Modified: trunk/extensions/ArticleComments/ArticleComments.i18n.php
===================================================================
--- trunk/extensions/ArticleComments/ArticleComments.i18n.php 2010-10-02
21:17:29 UTC (rev 74153)
+++ trunk/extensions/ArticleComments/ArticleComments.i18n.php 2010-10-02
21:20:45 UTC (rev 74154)
@@ -9,31 +9,31 @@
$messages = array();
$messages['en'] = array(
- 'article-comments-title-string' => 'title',
- 'article-comments-name-string' => 'Name',
- 'article-comments-name-field' => 'Name (required):',
- 'article-comments-url-field' => 'Website:',
- 'article-comments-url-string' => 'URL',
- 'article-comments-comment-string' => 'Comment',
- 'article-comments-comment-field' => 'Comment:',
- 'article-comments-submit-button' => 'Submit',
- 'article-comments-leave-comment-link' => 'Leave a comment ...',
- 'article-comments-invalid-field' => 'The $1 provided <nowiki>[$2]</nowiki>
is invalid.',
- 'article-comments-required-field' => '$1 field is required.',
- 'article-comments-submission-failed' => 'Comment Submission Failed',
- 'article-comments-failure-reasons' => 'Sorry, your comment submission
failed for the following reason(s):',
- 'article-comments-no-comments' => 'Sorry, the article "[[$1]]"
is not accepting comments at this time.',
- 'article-comments-talk-page-starter' => "<noinclude>Comments on
[[$1]]\n<comments />\n----- __NOEDITSECTION__</noinclude>\n",
- 'article-comments-commenter-said' => '$1 said ...',
- 'article-comments-summary' => 'Comment provided by $1 - via
ArticleComments extension',
- 'article-comments-submission-succeeded' => 'Comment submission succeeded',
- 'article-comments-submission-success' => 'You have successfully submitted
a comment for [[$1]]',
- 'article-comments-submission-view-all' => 'You may view all comments on
that article [[$1|here]]',
- 'article-comments-prefilled-comment-text' => '',
- 'article-comments-user-is-blocked' => 'Your user account is currently
blocked from editing [[$1]].',
- 'article-comments-new-comment' => "\n== \$1 ==\n\n<div
class='commentBlock'>\n\$2\n\n--\$3 \$4\n</div>\n",
- 'article-comments-no-spam' => 'At least one of the submitted fields was
flagged as spam.',
- 'processcomment' => 'Process Article Comment',
+ 'article-comments-title-string' => 'title',
+ 'article-comments-name-string' => 'Name',
+ 'article-comments-name-field' => 'Name (required):',
+ 'article-comments-url-field' => 'Website:',
+ 'article-comments-url-string' => 'URL',
+ 'article-comments-comment-string' => 'Comment',
+ 'article-comments-comment-field' => 'Comment:',
+ 'article-comments-submit-button' => 'Submit',
+ 'article-comments-leave-comment-link' => 'Leave a comment ...',
+ 'article-comments-invalid-field' => 'The $1 provided
<nowiki>[$2]</nowiki> is invalid.',
+ 'article-comments-required-field' => '$1 field is required.',
+ 'article-comments-submission-failed' => 'Comment Submission Failed',
+ 'article-comments-failure-reasons' => 'Sorry, your comment submission
failed for the following reason(s):',
+ 'article-comments-no-comments' => 'Sorry, the article
"[[$1]]" is not accepting comments at this time.',
+ 'article-comments-talk-page-starter' => "<noinclude>Comments on
[[$1]]\n<comments />\n----- __NOEDITSECTION__</noinclude>\n",
+ 'article-comments-commenter-said' => '$1 said ...',
+ 'article-comments-summary' => 'Comment provided by $1 - via
ArticleComments extension',
+ 'article-comments-submission-succeeded' => 'Comment submission
succeeded',
+ 'article-comments-submission-success' => 'You have successfully
submitted a comment for [[$1]]',
+ 'article-comments-submission-view-all' => 'You may view all comments on
that article [[$1|here]]',
+ 'article-comments-prefilled-comment-text' => '',
+ 'article-comments-user-is-blocked' => 'Your user account is currently
blocked from editing [[$1]].',
+ 'article-comments-new-comment' => "\n== \$1 ==\n\n<div
class='commentBlock'>\n\$2\n\n--\$3 \$4\n</div>\n",
+ 'article-comments-no-spam' => 'At least one of the submitted fields was
flagged as spam.',
+ 'processcomment' => 'Process Article Comment',
);
$messages['qqq'] = array(
Modified: trunk/extensions/ArticleComments/ArticleComments.php
===================================================================
--- trunk/extensions/ArticleComments/ArticleComments.php 2010-10-02
21:17:29 UTC (rev 74153)
+++ trunk/extensions/ArticleComments/ArticleComments.php 2010-10-02
21:20:45 UTC (rev 74154)
@@ -76,11 +76,11 @@
# Credits
$wgExtensionCredits['other'][] = array(
- 'name' => 'ArticleComments',
- 'author' => 'Jim R. Wilson - wilson.jim.r <at> gmail.com',
- 'url' => 'http://jimbojw.com/wiki/index.php?title=ArticleComments',
- 'description' => 'Enables comment sections on article pages.',
- 'version' => '0.5'
+ 'name' => 'ArticleComments',
+ 'author' => 'Jim R. Wilson - wilson.jim.r <at> gmail.com',
+ 'url' => 'http://jimbojw.com/wiki/index.php?title=ArticleComments',
+ 'description' => 'Enables comment sections on article pages.',
+ 'version' => '0.5'
);
# Add Extension Functions
@@ -113,22 +113,22 @@
$wgExtensionFunctions[] = 'setupSpecialProcessComment';
function setupSpecialProcessComment() {
- SpecialPage::addPage( new SpecialPage( 'ProcessComment', '', true,
'specialProcessComment', false ) );
+ SpecialPage::addPage( new SpecialPage( 'ProcessComment', '', true,
'specialProcessComment', false ) );
}
# Sets up the ArticleComments Parser hook for <comments />
function wfArticleCommentsParserSetup( &$parser ) {
- $parser->setHook( 'comments', 'wfArticleCommentsParserHook' );
- return true;
+ $parser->setHook( 'comments', 'wfArticleCommentsParserHook' );
+ return true;
}
function wfArticleCommentsParserHook( $text, $params = array(), $parser ) {
- # Generate a comment form for display
- $commentForm = wfArticleCommentForm( $parser->mTitle, $params );
+ # Generate a comment form for display
+ $commentForm = wfArticleCommentForm( $parser->mTitle, $params );
- # Hide content from the Parser using base64 to avoid mangling.
- # Note: Content will be decoded after Tidy has finished its processing of
the page.
- return '<pre>@ENCODED@' . base64_encode( $commentForm ) .
'@ENCODED@</pre>';
+ # Hide content from the Parser using base64 to avoid mangling.
+ # Note: Content will be decoded after Tidy has finished its processing
of the page.
+ return '<pre>@ENCODED@' . base64_encode( $commentForm ) .
'@ENCODED@</pre>';
}
/**
@@ -138,33 +138,33 @@
*/
function wfArticleCommentsAfterContent( $data, $skin ) {
- global $wgRequest, $wgArticleCommentsNSDisplayList;
+ global $wgRequest, $wgArticleCommentsNSDisplayList;
- # Short circuit for anything other than action=view or action=purge
- if ( $wgRequest->getVal( 'action' ) &&
- $wgRequest->getVal( 'action' ) != 'view' &&
- $wgRequest->getVal( 'action' ) != 'purge'
- ) return true;
+ # Short circuit for anything other than action=view or action=purge
+ if ( $wgRequest->getVal( 'action' ) &&
+ $wgRequest->getVal( 'action' ) != 'view' &&
+ $wgRequest->getVal( 'action' ) != 'purge'
+ ) return true;
- # Short-circuit if displaylist is undefined, empty or null
- if ( $wgArticleCommentsNSDisplayList == null )
+ # Short-circuit if displaylist is undefined, empty or null
+ if ( $wgArticleCommentsNSDisplayList == null )
return true;
$title = $skin->getTitle();
- if ( !$title->exists() ) {
+ if ( !$title->exists() ) {
return true;
}
- # Ensure that the namespace list is an actual list
- $nsList = $wgArticleCommentsNSDisplayList;
- if ( !is_array( $nsList ) ) $nsList = array( $nsList );
+ # Ensure that the namespace list is an actual list
+ $nsList = $wgArticleCommentsNSDisplayList;
+ if ( !is_array( $nsList ) ) $nsList = array( $nsList );
- # Display the form
- if ( in_array( $title->getNamespace(), $nsList ) ) {
- $data .= wfArticleCommentForm( $title );
- }
+ # Display the form
+ if ( in_array( $title->getNamespace(), $nsList ) ) {
+ $data .= wfArticleCommentForm( $title );
+ }
- return true;
+ return true;
}
/**
@@ -181,7 +181,7 @@
$tmp[strtolower( $k )] = (bool)strcasecmp( $v, "false" );
}
$params = $tmp;
- $ac = 'article-comments-';
+ $ac = 'article-comments-';
# Build out the comment form.
$content = '<div id="commentForm">';
@@ -207,64 +207,64 @@
$content .= '<p>' . Html::input( 'comment-submit', wfMsgForContent( $ac
. 'submit-button' ), 'submit' ) . '</p>';
$content .= '</form></div>';
- # Short-circuit if noScript has been set to anything other than false
- if ( $params['noscript'] ) {
- return $content;
- }
+ # Short-circuit if noScript has been set to anything other than false
+ if ( $params['noscript'] ) {
+ return $content;
+ }
- # Inline JavaScript to make form behavior more rich (must degrade well in
JS-disabled browsers)
- $content .= "<script type='text/javascript'>//<![CDATA[\n(function(){\n";
+ # Inline JavaScript to make form behavior more rich (must degrade well
in JS-disabled browsers)
+ $content .= "<script
type='text/javascript'>//<![CDATA[\n(function(){\n";
- # Prefill the name field if the user is logged in.
- $content .=
- 'var prefillUserName = function(){' . "\n" .
- 'var ptu=document.getElementById("pt-userpage");' . "\n" .
- 'if (ptu) document.getElementById("commenterName").value=' .
- 'ptu.getElementsByTagName("a")[0].innerHTML;};' . "\n" .
- 'if (window.addEventListener) window.addEventListener' .
- '("load",prefillUserName,false);' . "\n" .
- 'else if (window.attachEvent) window.attachEvent' .
- '("onload",prefillUserName);' . "\n";
+ # Prefill the name field if the user is logged in.
+ $content .=
+ 'var prefillUserName = function(){' . "\n" .
+ 'var ptu=document.getElementById("pt-userpage");' . "\n" .
+ 'if (ptu) document.getElementById("commenterName").value=' .
+ 'ptu.getElementsByTagName("a")[0].innerHTML;};' . "\n" .
+ 'if (window.addEventListener) window.addEventListener' .
+ '("load",prefillUserName,false);' . "\n" .
+ 'else if (window.attachEvent) window.attachEvent' .
+ '("onload",prefillUserName);' . "\n";
- # Prefill comment text if it has been specified by a system message
- # Note: This is done dynamically with JavaScript since it would be annoying
- # for JS-disabled browsers to have the prefilled text (since they'd have
- # to manually delete it) and would break parser output caching
- $pretext = wfMsgForContent( $ac . 'prefilled-comment-text' );
- if ( $pretext ) {
- $content .=
- 'var comment = document.getElementById("comment");' . "\n" .
- 'comment._everFocused=false;' . "\n" .
- 'comment.innerHTML="' . htmlspecialchars( $pretext ) . '";' . "\n"
.
- 'var clearCommentOnFirstFocus = function() {' . "\n" .
- 'var c=document.getElementById("comment");' . "\n" .
- 'if (!c._everFocused) {' . "\n" .
- 'c._everFocused=true;' . "\n" .
- 'c.value="";}}' . "\n" .
- 'if (comment.addEventListener) comment.addEventListener' .
- '("focus",clearCommentOnFirstFocus,false);' . "\n" .
- 'else if (comment.attachEvent) comment.attachEvent' .
- '("onfocus",clearCommentOnFirstFocus);' . "\n";
- }
+ # Prefill comment text if it has been specified by a system message
+ # Note: This is done dynamically with JavaScript since it would be
annoying
+ # for JS-disabled browsers to have the prefilled text (since they'd have
+ # to manually delete it) and would break parser output caching
+ $pretext = wfMsgForContent( $ac . 'prefilled-comment-text' );
+ if ( $pretext ) {
+ $content .=
+ 'var comment = document.getElementById("comment");' .
"\n" .
+ 'comment._everFocused=false;' . "\n" .
+ 'comment.innerHTML="' . htmlspecialchars( $pretext ) .
'";' . "\n" .
+ 'var clearCommentOnFirstFocus = function() {' . "\n" .
+ 'var c=document.getElementById("comment");' . "\n" .
+ 'if (!c._everFocused) {' . "\n" .
+ 'c._everFocused=true;' . "\n" .
+ 'c.value="";}}' . "\n" .
+ 'if (comment.addEventListener)
comment.addEventListener' .
+ '("focus",clearCommentOnFirstFocus,false);' . "\n" .
+ 'else if (comment.attachEvent) comment.attachEvent' .
+ '("onfocus",clearCommentOnFirstFocus);' . "\n";
+ }
- # Hides the commentForm until the "Make a comment" link is clicked
- # Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in
LocalSettings.php
- if ( !isset( $params['hideform'] ) ||
- ( $params['hideform'] != 'false' &&
- !$params['hideform'] === false ) ) {
- $content .=
- 'var cf=document.getElementById("commentForm");' . "\n" .
- 'cf.style.display="none";' . "\n" .
- 'var p=document.createElement("p");' . "\n" .
- 'p.innerHTML="<a href=\'javascript:void(0)\' onclick=\'' .
-
'document.getElementById(\\"commentForm\\").style.display=\\"block\\";' .
- 'this.style.display=\\"none\\";false' .
- '\'>' . wfMsgForContent( $ac . 'leave-comment-link' ) . '</a>";' .
"\n" .
- 'cf.parentNode.insertBefore(p,cf);' . "\n";
- }
+ # Hides the commentForm until the "Make a comment" link is clicked
+ # Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in
LocalSettings.php
+ if ( !isset( $params['hideform'] ) ||
+ ( $params['hideform'] != 'false' &&
+ !$params['hideform'] === false ) ) {
+ $content .=
+ 'var cf=document.getElementById("commentForm");' . "\n"
.
+ 'cf.style.display="none";' . "\n" .
+ 'var p=document.createElement("p");' . "\n" .
+ 'p.innerHTML="<a href=\'javascript:void(0)\'
onclick=\'' .
+
'document.getElementById(\\"commentForm\\").style.display=\\"block\\";' .
+ 'this.style.display=\\"none\\";false' .
+ '\'>' . wfMsgForContent( $ac . 'leave-comment-link' ) .
'</a>";' . "\n" .
+ 'cf.parentNode.insertBefore(p,cf);' . "\n";
+ }
- $content .= "})();\n//]]></script>";
- return $content;
+ $content .= "})();\n//]]></script>";
+ return $content;
}
/**
@@ -275,12 +275,12 @@
* @return Boolean Always tru to give other hooking methods a chance to run.
*/
function wfProcessEncodedContent( $out, $text ) {
- $text = preg_replace(
- '/<pre>\...@encoded@([0-9a-zA-Z\\+\\/]+=*)@enco...@\n<\\/pre>/e',
- 'base64_decode("$1")',
- $text
- );
- return true;
+ $text = preg_replace(
+
'/<pre>\...@encoded@([0-9a-zA-Z\\+\\/]+=*)@enco...@\n<\\/pre>/e',
+ 'base64_decode("$1")',
+ $text
+ );
+ return true;
}
/**
@@ -288,13 +288,13 @@
*/
function specialProcessComment() {
- global $wgOut, $wgParser, $wgUser, $wgContLang, $wgRequest;
+ global $wgOut, $wgParser, $wgUser, $wgContLang, $wgRequest;
- # Retrieve submitted values
- $titleText = $wgRequest->getVal( 'commentArticle' );
- $commenterName = $wgRequest->getVal( 'commenterName' );
- $commenterURL = trim( $wgRequest->getVal( 'commenterURL' ) );
- $comment = $wgRequest->getVal( 'comment' );
+ # Retrieve submitted values
+ $titleText = $wgRequest->getVal( 'commentArticle' );
+ $commenterName = $wgRequest->getVal( 'commenterName' );
+ $commenterURL = trim( $wgRequest->getVal( 'commenterURL' ) );
+ $comment = $wgRequest->getVal( 'comment' );
// The default value is the same as not providing a URL
if ( $commenterURL == 'http://' ) {
@@ -303,144 +303,144 @@
$title = Title::newFromText( $titleText );
- # Perform validation checks on supplied fields
- $ac = 'article-comments-';
- $messages = array();
+ # Perform validation checks on supplied fields
+ $ac = 'article-comments-';
+ $messages = array();
if ( !$wgRequest->wasPosted() )
$messages[] = wfMsgForContent( $ac . 'not-posted' );
- if ( $titleText === '' || !$title ) {
+ if ( $titleText === '' || !$title ) {
$messages[] = wfMsgForContent(
- $ac . 'invalid-field', wfMsgForContent( $ac . 'title-string' ),
$titleText );
+ $ac . 'invalid-field', wfMsgForContent( $ac . 'title-string' ),
$titleText );
}
- if ( !$commenterName ) $messages[] = wfMsgForContent(
- $ac . 'required-field', wfMsgForContent( $ac . 'name-string' ) );
+ if ( !$commenterName ) $messages[] = wfMsgForContent(
+ $ac . 'required-field', wfMsgForContent( $ac . 'name-string' )
);
if ( !preg_match( "/^(" . wfUrlProtocols() . ')' .
Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) )
$messages[] = wfMsgForContent(
- $ac . 'invalid-field', wfMsgForContent( $ac . 'url-string' ),
$commenterURL );
+ $ac . 'invalid-field', wfMsgForContent( $ac . 'url-string' ),
$commenterURL );
- if ( !$comment ) $messages[] = wfMsgForContent(
- $ac . 'required-field', wfMsgForContent( $ac . 'comment-string' ) );
- if ( !empty( $messages ) ) {
- $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
- $wikiText = "<div class='errorbox'>";
- $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
- foreach ( $messages as $message ) {
- $wikiText .= "* $message\n";
- }
- $wgOut->addWikiText( $wikiText . "</div>" );
- return;
- }
+ if ( !$comment ) $messages[] = wfMsgForContent(
+ $ac . 'required-field', wfMsgForContent( $ac . 'comment-string'
) );
+ if ( !empty( $messages ) ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac .
'submission-failed' ) );
+ $wikiText = "<div class='errorbox'>";
+ $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) .
"\n\n";
+ foreach ( $messages as $message ) {
+ $wikiText .= "* $message\n";
+ }
+ $wgOut->addWikiText( $wikiText . "</div>" );
+ return;
+ }
- # Setup title and talkTitle object
- $article = new Article( $title );
+ # Setup title and talkTitle object
+ $article = new Article( $title );
- $talkTitle = $title->getTalkPage();
- $talkArticle = new Article( $talkTitle );
+ $talkTitle = $title->getTalkPage();
+ $talkArticle = new Article( $talkTitle );
- # Check whether user is blocked from editing the talk page
- if ( $wgUser->isBlockedFrom( $talkTitle ) ) {
- $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
- $wikiText = "<div class='errorbox'>";
- $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
- $wikiText .= '* ' . wfMsgForContent( $ac . 'user-is-blocked',
$talkTitle->getPrefixedText() ) . "\n";
- $wgOut->addWikiText( $wikiText . "</div>" );
- return;
- }
+ # Check whether user is blocked from editing the talk page
+ if ( $wgUser->isBlockedFrom( $talkTitle ) ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac .
'submission-failed' ) );
+ $wikiText = "<div class='errorbox'>";
+ $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) .
"\n\n";
+ $wikiText .= '* ' . wfMsgForContent( $ac . 'user-is-blocked',
$talkTitle->getPrefixedText() ) . "\n";
+ $wgOut->addWikiText( $wikiText . "</div>" );
+ return;
+ }
- # Retrieve article content
- $articleContent = '';
- if ( $title->exists() ) {
- $articleContent = $article->getContent();
- }
+ # Retrieve article content
+ $articleContent = '';
+ if ( $title->exists() ) {
+ $articleContent = $article->getContent();
+ }
- # Retrieve existing talk content
- $talkContent = '';
- if ( $talkTitle->exists() ) {
- $talkContent = $talkArticle->getContent();
- }
+ # Retrieve existing talk content
+ $talkContent = '';
+ if ( $talkTitle->exists() ) {
+ $talkContent = $talkArticle->getContent();
+ }
- # Check if talk NS is in the Namespace display list
- # Note: if so, then there's no need to confirm that <comments /> appears
in the article or talk page.
- global $wgArticleCommentsNSDisplayList;
- $skipCheck = (
- is_array( $wgArticleCommentsNSDisplayList ) ?
- in_array( $talkTitle->getNamespace(), $wgArticleCommentsNSDisplayList
):
- false
- );
+ # Check if talk NS is in the Namespace display list
+ # Note: if so, then there's no need to confirm that <comments />
appears in the article or talk page.
+ global $wgArticleCommentsNSDisplayList;
+ $skipCheck = (
+ is_array( $wgArticleCommentsNSDisplayList ) ?
+ in_array( $talkTitle->getNamespace(),
$wgArticleCommentsNSDisplayList ):
+ false
+ );
- # Check whether the article or its talk page contains a <comments /> flag
- if ( !$skipCheck &&
- preg_match( '/<comments( +[^>]*)?\\/>/', $articleContent ) === 0 &&
- preg_match( '/<comments( +[^>]*)?\\/>/', $talkContent ) === 0
- ) {
- $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
- $wgOut->addWikiText(
- "<div class='errorbox'>" .
- wfMsgForContent( $ac . 'no-comments', $title->getPrefixedText() ) .
- "</div>"
- );
- return;
- }
+ # Check whether the article or its talk page contains a <comments />
flag
+ if ( !$skipCheck &&
+ preg_match( '/<comments( +[^>]*)?\\/>/', $articleContent ) ===
0 &&
+ preg_match( '/<comments( +[^>]*)?\\/>/', $talkContent ) === 0
+ ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac .
'submission-failed' ) );
+ $wgOut->addWikiText(
+ "<div class='errorbox'>" .
+ wfMsgForContent( $ac . 'no-comments',
$title->getPrefixedText() ) .
+ "</div>"
+ );
+ return;
+ }
- # Run spam checks
- $isspam = false;
+ # Run spam checks
+ $isspam = false;
wfRunHooks( 'ArticleCommentsSpamCheck', array( $comment ,
$commenterName, $commenterURL, &$isspam ) );
- # If it's spam - it's gone!
- if ( $isspam ) {
- $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
- $wgOut->addWikiText(
- "<div class='errorbox'>" .
- wfMsgForContent( $ac . 'no-spam' ) .
- "</div>"
- );
- return;
- }
+ # If it's spam - it's gone!
+ if ( $isspam ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac .
'submission-failed' ) );
+ $wgOut->addWikiText(
+ "<div class='errorbox'>" .
+ wfMsgForContent( $ac . 'no-spam' ) .
+ "</div>"
+ );
+ return;
+ }
- # Initialize the talk page's content.
- if ( $talkContent == '' ) {
- $talkContent = wfMsgForContent( $ac . 'talk-page-starter',
$title->getPrefixedText() );
- }
+ # Initialize the talk page's content.
+ if ( $talkContent == '' ) {
+ $talkContent = wfMsgForContent( $ac . 'talk-page-starter',
$title->getPrefixedText() );
+ }
- # Determine signature components
- if ( $commenterURL != '' ) $sigText = "[$commenterURL $commenterName]";
- else if ( $wgUser->isLoggedIn() ) $sigText = $wgParser->getUserSig(
$wgUser );
- else $sigText = $commenterName;
+ # Determine signature components
+ if ( $commenterURL != '' ) $sigText = "[$commenterURL $commenterName]";
+ else if ( $wgUser->isLoggedIn() ) $sigText = $wgParser->getUserSig(
$wgUser );
+ else $sigText = $commenterName;
- # Search for insertion point, or append most recent comment.
- $commentText = wfMsgForContent(
- $ac . 'new-comment',
- wfMsgForContent( $ac . 'commenter-said', $commenterName ),
- $comment,
- $sigText,
- '~~~~~'
- );
+ # Search for insertion point, or append most recent comment.
+ $commentText = wfMsgForContent(
+ $ac . 'new-comment',
+ wfMsgForContent( $ac . 'commenter-said', $commenterName ),
+ $comment,
+ $sigText,
+ '~~~~~'
+ );
- $posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' );
- if ( $posAbove === false ) $posBelow = stripos( $talkContent,
'<!--COMMENTS_BELOW-->' );
- if ( $posAbove !== false ) {
- # Insert comments above HTML marker
- $talkContent = substr( $talkContent, 0, $posAbove ) . $commentText .
substr( $talkContent, $posAbove );
- } else if ( $posBelow !== false ) {
- # Insert comments below HTML marker
- $talkContent = substr( $talkContent, 0, $posBelow + 21 ) .
$commentText . substr( $talkContent, $posBelow + 21 );
- } else {
- # No marker found, append to bottom (default)
- $talkContent .= $commentText;
- }
+ $posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' );
+ if ( $posAbove === false ) $posBelow = stripos( $talkContent,
'<!--COMMENTS_BELOW-->' );
+ if ( $posAbove !== false ) {
+ # Insert comments above HTML marker
+ $talkContent = substr( $talkContent, 0, $posAbove ) .
$commentText . substr( $talkContent, $posAbove );
+ } else if ( $posBelow !== false ) {
+ # Insert comments below HTML marker
+ $talkContent = substr( $talkContent, 0, $posBelow + 21 ) .
$commentText . substr( $talkContent, $posBelow + 21 );
+ } else {
+ # No marker found, append to bottom (default)
+ $talkContent .= $commentText;
+ }
# Update the talkArticle with the new comment
$summary = wfMsgForContent( $ac . 'summary', $commenterName );
$talkArticle->doEdit( $talkContent, $summary );
- $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-succeeded' ) );
- $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-success',
$title->getPrefixedText() ) );
- $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-view-all',
$talkTitle->getPrefixedText() ) );
+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-succeeded' ) );
+ $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-success',
$title->getPrefixedText() ) );
+ $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-view-all',
$talkTitle->getPrefixedText() ) );
}
/**
@@ -454,40 +454,40 @@
*/
function defaultArticleCommentSpamCheck( $comment, $commenterName,
$commenterURL, $isspam ) {
- # Short-circuit if spam has already been determined
- if ( $isspam ) return true;
- $fields = array( $comment, $commenterName, $commenterURL );
+ # Short-circuit if spam has already been determined
+ if ( $isspam ) return true;
+ $fields = array( $comment, $commenterName, $commenterURL );
- # Run everything through $wgSpamRegex if it has been specified
- global $wgSpamRegex;
- if ( $wgSpamRegex ) {
- foreach ( $fields as $field ) {
- if ( preg_match( $wgSpamRegex, $field ) ) return $isspam = true;
- }
- }
+ # Run everything through $wgSpamRegex if it has been specified
+ global $wgSpamRegex;
+ if ( $wgSpamRegex ) {
+ foreach ( $fields as $field ) {
+ if ( preg_match( $wgSpamRegex, $field ) ) return
$isspam = true;
+ }
+ }
- # Rudimentary spam protection
- $spampatterns = array(
- '%\\[url=(https?|ftp)://%smi',
- '%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi'
- );
- foreach ( $spampatterns as $sp ) {
- foreach ( array( $comment, $commenterName, $commenterURL ) as $field )
{
- if ( preg_match( $sp, $field ) ) return $isspam = true;
- }
- }
+ # Rudimentary spam protection
+ $spampatterns = array(
+ '%\\[url=(https?|ftp)://%smi',
+ '%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi'
+ );
+ foreach ( $spampatterns as $sp ) {
+ foreach ( array( $comment, $commenterName, $commenterURL ) as
$field ) {
+ if ( preg_match( $sp, $field ) ) return $isspam = true;
+ }
+ }
- # Check for bad input for commenterName (seems to be a popular spam
location)
- $spampatterns = array(
- '%<a\\s+%smi',
- '%(https?|ftp)://%smi',
- '%(\\n|\\r)%smi'
- );
- foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName ) )
return $isspam = true;
+ # Check for bad input for commenterName (seems to be a popular spam
location)
+ $spampatterns = array(
+ '%<a\\s+%smi',
+ '%(https?|ftp)://%smi',
+ '%(\\n|\\r)%smi'
+ );
+ foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName )
) return $isspam = true;
- # Fail for length violations
- if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 )
return $isspam = true;
+ # Fail for length violations
+ if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 )
return $isspam = true;
- # We made it this far, leave $isspam alone and give other implementors a
chance.
- return true;
+ # We made it this far, leave $isspam alone and give other implementors
a chance.
+ return true;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs