From 29055d34d6f0ceee253a4122bb6c9dae6cb53b2b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 27 Apr 2007 07:42:54 +0000 Subject: - Patch #137236 by merlinofchaos: provide a way to secure the theme variables system. --- modules/comment/comment.module | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'modules/comment/comment.module') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8cf30b3dc..1357a3462 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -162,6 +162,7 @@ function comment_theme() { ), 'comment' => array( 'arguments' => array('comment' => NULL, 'links' => array()), + 'file' => 'comment.tpl.php', ), 'comment_folded' => array( 'arguments' => array('comment' => NULL), @@ -1811,15 +1812,23 @@ function comment_controls_submit($form_id, $form_values) { } } -function theme_comment($comment, $links = array()) { - $output = '
'; - $output .= '
'. l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) .' '. theme('mark', $comment->new) ."
\n"; - $output .= '
'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."
\n"; - $output .= '
'. $comment->comment .'
'; - $output .= theme('user_signature', $comment->signature); - $output .= ''; - $output .= '
'; - return $output; +/** + * Prepare values for comment.tpl.php + */ +function template_preprocess_comment(&$variables) { + $comment = $variables['comment']; + $variables['author'] = theme('username', $comment); + $variables['comment'] = $comment; + $variables['content'] = $comment->comment; + $variables['date'] = format_date($comment->timestamp); + $variables['links'] = isset($variables['links']) ? theme('links', $variables['links']) : ''; + $variables['new'] = $comment->new ? t('new') : ''; + $variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : ''; + $variables['signature'] = $comment->signature; + $variables['submitted'] = t('Submitted by !a on @b.', + array('!a' => theme('username', $comment), + '@b' => format_date($comment->timestamp))); + $variables['title'] = l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")); } function theme_comment_folded($comment) { -- cgit v1.2.3