Remove CVS $Id$ tags to make Git work easier.
[project/zen.git] / zen / template.comment.inc
1 <?php
2 /**
3 * @file
4 * Contains functions only needed when rendering comments.
5 */
6
7 /**
8 * Override or insert variables into the comment templates.
9 *
10 * @param $vars
11 * An array of variables to pass to the theme template.
12 * @param $hook
13 * The name of the template being rendered ("comment" in this case.)
14 */
15 function _zen_preprocess_comment(&$vars, $hook) {
16 // Add an "unpublished" flag.
17 $vars['unpublished'] = ($vars['comment']->status == COMMENT_NOT_PUBLISHED);
18
19 // If comment subjects are disabled, don't display them.
20 if (variable_get('comment_subject_field_' . $vars['node']->type, 1) == 0) {
21 $vars['title'] = '';
22 }
23
24 // Special classes for comments.
25 $classes = array('comment');
26 if ($vars['comment']->new) {
27 $classes[] = 'comment-new';
28 }
29 $classes[] = $vars['status'];
30 $classes[] = $vars['zebra'];
31 if ($vars['id'] == 1) {
32 $classes[] = 'first';
33 }
34 if ($vars['id'] == $vars['node']->comment_count) {
35 $classes[] = 'last';
36 }
37 if ($vars['comment']->uid == 0) {
38 // Comment is by an anonymous user.
39 $classes[] = 'comment-by-anon';
40 }
41 else {
42 if ($vars['comment']->uid == $vars['node']->uid) {
43 // Comment is by the node author.
44 $classes[] = 'comment-by-author';
45 }
46 if ($vars['comment']->uid == $GLOBALS['user']->uid) {
47 // Comment was posted by current user.
48 $classes[] = 'comment-mine';
49 }
50 }
51 $vars['classes'] = implode(' ', $classes);
52 }