_comment_form_submit
modules/comment/comment.module, строка 1508
- Версии
- 5
_comment_form_submit(
$form_values)- 6
_comment_form_submit(&$comment_values)
Prepare a comment for submission.
Параметры
$comment_values
An associative array containing the comment data.
Код
<?php
function _comment_form_submit(&$comment_values) {
$comment_values += array('subject' => '');
if (!isset($comment_values['date'])) {
$comment_values['date'] = 'now';
}
$comment_values['timestamp'] = strtotime($comment_values['date']);
if (isset($comment_values['author'])) {
$account = user_load(array('name' => $comment_values['author']));
$comment_values['uid'] = $account->uid;
$comment_values['name'] = $comment_values['author'];
}
// Validate the comment's subject. If not specified, extract
// one from the comment's body.
if (trim($comment_values['subject']) == '') {
// The body may be in any format, so we:
// 1) Filter it into HTML
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
// Note: format is checked by check_markup().
$comment_values['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment_values['comment'], $comment_values['format'])))), 29, TRUE);
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($comment_values['subject'] == '') {
$comment_values['subject'] = t('(No subject)');
}
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии