summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/comment.module67
1 files changed, 29 insertions, 38 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 5fa5f4e6c..5d3949289 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -152,32 +152,32 @@ function comment_theme() {
'arguments' => array('form' => NULL),
),
'comment_preview' => array(
- 'arguments' => array('comment' => NULL, 'links' => array(), 'visible' => 1),
+ 'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array(), 'visible' => 1),
),
'comment_view' => array(
- 'arguments' => array('comment' => NULL, 'links' => array(), 'visible' => 1),
+ 'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array(), 'visible' => 1),
),
'comment_controls' => array(
'arguments' => array('form' => NULL),
),
'comment' => array(
- 'arguments' => array('comment' => NULL, 'links' => array()),
+ 'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array()),
'file' => 'comment.tpl.php',
),
'comment_folded' => array(
'arguments' => array('comment' => NULL),
),
'comment_flat_collapsed' => array(
- 'arguments' => array('comment' => NULL),
+ 'arguments' => array('comment' => NULL, 'node' => NULL),
),
'comment_flat_expanded' => array(
- 'arguments' => array('comment' => NULL),
+ 'arguments' => array('comment' => NULL, 'node' => NULL),
),
'comment_thread_collapsed' => array(
- 'arguments' => array('comment' => NULL),
+ 'arguments' => array('comment' => NULL, 'node' => NULL),
),
'comment_thread_expanded' => array(
- 'arguments' => array('comment' => NULL),
+ 'arguments' => array('comment' => NULL, 'node' => NULL),
),
'comment_post_forbidden' => array(
'arguments' => array('nid' => NULL),
@@ -689,7 +689,7 @@ function comment_reply($node, $pid = NULL) {
// Display the parent comment
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- $output .= theme('comment_view', $comment);
+ $output .= theme('comment_view', $comment, $node);
}
else {
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
@@ -988,7 +988,7 @@ function comment_render($node, $cid = 0) {
$links = module_invoke_all('link', 'comment', $comment, 1);
drupal_alter('link', $links, $node);
- $output .= theme('comment_view', $comment, $links);
+ $output .= theme('comment_view', $comment, $node, $links);
}
}
else {
@@ -1057,16 +1057,16 @@ function comment_render($node, $cid = 0) {
}
if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
- $output .= theme('comment_flat_collapsed', $comment);
+ $output .= theme('comment_flat_collapsed', $comment, $node);
}
else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
- $output .= theme('comment_flat_expanded', $comment);
+ $output .= theme('comment_flat_expanded', $comment, $node);
}
else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
- $output .= theme('comment_thread_collapsed', $comment);
+ $output .= theme('comment_thread_collapsed', $comment, $node);
}
else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
- $output .= theme('comment_thread_expanded', $comment);
+ $output .= theme('comment_thread_expanded', $comment, $node);
}
}
for ($i = 0; $i < $divs; $i++) {
@@ -1626,6 +1626,7 @@ function comment_form_add_preview($form, &$form_state) {
drupal_set_title(t('Preview comment'));
$output = '';
+ $node = node_load($edit['nid']);
// Invoke full validation for the form, to protect against cross site
// request forgeries (CSRF) and setting arbitrary values for fields such as
@@ -1651,7 +1652,7 @@ function comment_form_add_preview($form, &$form_state) {
$comment->name = variable_get('anonymous', t('Anonymous'));
}
$comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time();
- $output .= theme('comment_view', $comment);
+ $output .= theme('comment_view', $comment, $node);
}
$form['comment_preview'] = array(
'#value' => $output,
@@ -1666,10 +1667,10 @@ function comment_form_add_preview($form, &$form_state) {
$comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED));
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- $output .= theme('comment_view', $comment);
+ $output .= theme('comment_view', $comment, $node);
}
else {
- $form['#suffix'] = node_view(node_load($edit['nid']));
+ $form['#suffix'] = node_view($node);
$edit['pid'] = 0;
}
@@ -1724,19 +1725,7 @@ function comment_form_submit($form, &$form_state) {
}
}
-/*
-** Renderer or visualization functions this can be optionally
-** overridden by themes.
-*/
-
-function theme_comment_preview($comment, $links = array(), $visible = 1) {
- $output = '<div class="preview">';
- $output .= theme('comment_view', $comment, $links, $visible);
- $output .= '</div>';
- return $output;
-};
-
-function theme_comment_view($comment, $links = array(), $visible = 1) {
+function theme_comment_view($comment, $node, $links = array(), $visible = 1) {
static $first_new = TRUE;
$output = '';
@@ -1757,7 +1746,7 @@ function theme_comment_view($comment, $links = array(), $visible = 1) {
// Comment API hook
comment_invoke_comment($comment, 'view');
- $output .= theme('comment', $comment, $links);
+ $output .= theme('comment', $comment, $node, $links);
}
else {
$output .= theme('comment_folded', $comment);
@@ -1825,6 +1814,7 @@ function comment_controls_submit($form, &$form_state) {
*/
function template_preprocess_comment(&$variables) {
$comment = $variables['comment'];
+ $node = $variables['node'];
$variables['author'] = theme('username', $comment);
$variables['comment'] = $comment;
$variables['content'] = $comment->comment;
@@ -1837,6 +1827,7 @@ function template_preprocess_comment(&$variables) {
array('!a' => theme('username', $comment),
'@b' => format_date($comment->timestamp)));
$variables['title'] = l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid"));
+ $variables['template_files'][] = 'comment-'. $node->type;
}
function theme_comment_folded($comment) {
@@ -1847,22 +1838,22 @@ function theme_comment_folded($comment) {
return $output;
}
-function theme_comment_flat_collapsed($comment) {
- return theme('comment_view', $comment, '', 0);
+function theme_comment_flat_collapsed($comment, $node) {
+ return theme('comment_view', $comment, $node, '', 0);
}
-function theme_comment_flat_expanded($comment) {
- return theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 0));
+function theme_comment_flat_expanded($comment, $node) {
+ return theme('comment_view', $comment, $node, module_invoke_all('link', 'comment', $comment, 0));
}
-function theme_comment_thread_collapsed($comment) {
- $output .= theme('comment_view', $comment, '', 0);
+function theme_comment_thread_collapsed($comment, $node) {
+ $output .= theme('comment_view', $comment, $node, '', 0);
return $output;
}
-function theme_comment_thread_expanded($comment) {
+function theme_comment_thread_expanded($comment, $node) {
$output = '';
- $output .= theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 0));
+ $output .= theme('comment_view', $comment, $node, module_invoke_all('link', 'comment', $comment, 0));
return $output;
}