Index: trunk/extensions/ArticleComments/ArticleComments.php |
— | — | @@ -288,29 +288,40 @@ |
289 | 289 | */ |
290 | 290 | function specialProcessComment() { |
291 | 291 | |
292 | | - global $wgOut, $wgParser, $wgUser, $wgContLang; |
| 292 | + global $wgOut, $wgParser, $wgUser, $wgContLang, $wgRequest; |
293 | 293 | |
294 | 294 | # Retrieve submitted values |
295 | | - $titleKey = $_POST['titleKey']; |
296 | | - $titleNS = intval($_POST['titleNS']); |
297 | | - $commenterName = $_POST['commenterName']; |
298 | | - $commenterURL = isset($_POST['commenterURL']) ? $_POST['commenterURL'] : ''; |
299 | | - $comment = $_POST['comment']; |
300 | | - global $wgRequest; |
| 295 | + $titleText = $wgRequest->getVal( 'commentArticle' ); |
| 296 | + $commenterName = $wgRequest->getVal( 'commenterName' ); |
| 297 | + $commenterURL = trim( $wgRequest->getVal( 'commenterURL' ) ); |
| 298 | + $comment = $wgRequest->getVal( 'comment' ); |
301 | 299 | |
302 | | - $titleText = $wgRequest->getVal( 'commentArticle' ); |
| 300 | + // The default value is the same as not providing a URL |
| 301 | + if ( $commenterURL == 'http://' ) { |
| 302 | + $commenterURL = ''; |
| 303 | + } |
| 304 | + |
303 | 305 | $title = Title::newFromText( $titleText ); |
304 | 306 | |
305 | 307 | # Perform validation checks on supplied fields |
306 | 308 | $ac = 'article-comments-'; |
307 | 309 | $messages = array(); |
| 310 | + |
| 311 | + if ( !$wgRequest->wasPosted() ) |
| 312 | + $messages[] = wfMsgForContent( $ac.'not-posted' ); |
| 313 | + |
308 | 314 | if ( $titleText === '' || !$title) { |
309 | 315 | $messages[] = wfMsgForContent( |
310 | | - $ac.'invalid-field', wfMsgForContent($ac.'title-field'), $titleKey ); |
| 316 | + $ac.'invalid-field', wfMsgForContent($ac.'title-string'), $titleText ); |
311 | 317 | } |
312 | 318 | |
313 | 319 | if (!$commenterName) $messages[] = wfMsgForContent( |
314 | 320 | $ac.'required-field', wfMsgForContent($ac.'name-string')); |
| 321 | + |
| 322 | + if ( !preg_match( "/^(" . wfUrlProtocols() . ')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) ) |
| 323 | + $messages[] = wfMsgForContent( |
| 324 | + $ac.'invalid-field', wfMsgForContent($ac.'url-string'), $commenterURL ); |
| 325 | + |
315 | 326 | if (!$comment) $messages[] = wfMsgForContent( |
316 | 327 | $ac.'required-field', wfMsgForContent($ac.'comment-string')); |
317 | 328 | if (!empty($messages)) { |
— | — | @@ -397,8 +408,7 @@ |
398 | 409 | } |
399 | 410 | |
400 | 411 | # Determine signature components |
401 | | - $d = $wgContLang->timeanddate( date( 'YmdHis' ), false, false) . ' (' . date( 'T' ) . ')'; |
402 | | - if ($commenterURL && $commenterURL!='http://') $sigText = "[$commenterURL $commenterName]"; |
| 412 | + if ($commenterURL != '') $sigText = "[$commenterURL $commenterName]"; |
403 | 413 | else if ($wgUser->isLoggedIn()) $sigText = $wgParser->getUserSig( $wgUser ); |
404 | 414 | else $sigText = $commenterName; |
405 | 415 | |
— | — | @@ -408,7 +418,7 @@ |
409 | 419 | wfMsgForContent($ac.'commenter-said', $commenterName), |
410 | 420 | $comment, |
411 | 421 | $sigText, |
412 | | - $d |
| 422 | + '~~~~~' |
413 | 423 | ); |
414 | 424 | |
415 | 425 | $posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' ); |
— | — | @@ -424,15 +434,9 @@ |
425 | 435 | $talkContent .= $commentText; |
426 | 436 | } |
427 | 437 | |
428 | | - # Update the talkArticle with the new comment |
429 | | - $summary = wfMsgForContent($ac.'summary', $commenterName); |
430 | | - if (method_exists($talkArticle, 'doEdit')) { |
431 | | - $talkArticle->doEdit($talkContent, $summary); |
432 | | - } else { |
433 | | - $method = ($talkArticle->exists() ? 'updateArticle' : 'insertNewArticle' ); |
434 | | - $talkArticle->$method($talkContent, $summary, false, false); |
435 | | - return; |
436 | | - } |
| 438 | + # Update the talkArticle with the new comment |
| 439 | + $summary = wfMsgForContent($ac.'summary', $commenterName); |
| 440 | + $talkArticle->doEdit($talkContent, $summary); |
437 | 441 | |
438 | 442 | $wgOut->setPageTitle(wfMsgForContent($ac.'submission-succeeded')); |
439 | 443 | $wgOut->addWikiText(wfMsgForContent($ac.'submission-success', $title->getPrefixedText())); |
Index: trunk/extensions/ArticleComments/ArticleComments.i18n.php |
— | — | @@ -9,12 +9,13 @@ |
10 | 10 | $messages = array(); |
11 | 11 | |
12 | 12 | $messages['en'] = array( |
13 | | - 'article-comments-title-field' => 'Title', |
| 13 | + 'article-comments-title-string' => 'title', |
14 | 14 | 'article-comments-name-string' => 'Name', |
15 | | - 'article-comments-name-field' => 'Name (required): ', |
16 | | - 'article-comments-url-field' => 'Website: ', |
| 15 | + 'article-comments-name-field' => 'Name (required):', |
| 16 | + 'article-comments-url-field' => 'Website:', |
| 17 | + 'article-comments-url-string' => 'URL', |
17 | 18 | 'article-comments-comment-string' => 'Comment', |
18 | | - 'article-comments-comment-field' => 'Comment: ', |
| 19 | + 'article-comments-comment-field' => 'Comment:', |
19 | 20 | 'article-comments-submit-button' => 'Submit', |
20 | 21 | 'article-comments-leave-comment-link' => 'Leave a comment ...', |
21 | 22 | 'article-comments-invalid-field' => 'The $1 provided <nowiki>[$2]</nowiki> is invalid.', |
— | — | @@ -35,3 +36,14 @@ |
36 | 37 | 'processcomment' => 'Process Article Comment', |
37 | 38 | ); |
38 | 39 | |
| 40 | +$messages['qqq'] = array( |
| 41 | + 'article-comments-required-field' => 'Shown as a list below article-comments-failure-reasons. With $1 being one of article-comments-*-string messages.', |
| 42 | + 'article-comments-submission-failed' => 'Page title when there are errors in the comment submission', |
| 43 | + 'article-comments-invalid-field' => 'Shown as a list below article-comments-failure-reasons. With $1 being article-comments-title-string or article-comments-url-string messages, and $2 the wrong value.', |
| 44 | + 'article-comments-new-comment' => 'Text to add in the new comment. |
| 45 | +* $1 - Expansion of article-comments-commenter-said. |
| 46 | +* $2 - Comment text. |
| 47 | +* $3 - Commenter name, possibly linking to its web. |
| 48 | +* $4 - Datetime.', |
| 49 | +); |
| 50 | + |