- <?php
- * @file
- * Theme functions for the Comment module.
- */
-
- * Returns HTML for a list of recent comments.
- *
- * @ingroup themeable
- */
- function theme_comment_block($variables) {
- $items = array();
- foreach ($variables['comments'] as $comment) {
- $items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . ' <span>' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) . '</span>';
- }
-
- if ($items) {
- return theme('item_list', array('items' => $items));
- }
- else {
- return t('No comments available.');
- }
- }
-
- * Returns HTML for a "you can't post comments" notice.
- *
- * @param $variables
- * An associative array containing:
- * - node: The comment node.
- *
- * @ingroup themeable
- */
- function theme_comment_post_forbidden($variables) {
- $node = $variables['node'];
- $node_type = node_type_get_type($node->type);
- global $user;
-
-
-
- $authenticated_post_comments = &backdrop_static(__FUNCTION__, NULL);
-
- if (!$user->uid) {
- if (!isset($authenticated_post_comments)) {
-
-
- $comment_roles = user_roles(TRUE, 'post comments');
- $authenticated_post_comments = isset($comment_roles[BACKDROP_AUTHENTICATED_ROLE]);
- }
-
- if ($authenticated_post_comments) {
-
-
- if ($node_type->settings['comment_form_location'] == COMMENT_FORM_SEPARATE_PAGE) {
- $destination = array('destination' => "comment/reply/$node->nid#comment-form");
- }
- else {
- $destination = array('destination' => "node/$node->nid#comment-form");
- }
-
- if (config_get('system.core', 'user_register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
-
- return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
- }
- else {
-
- return t('<a href="@login">Log in</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
- }
- }
- }
- }
-
- * Preprocesses variables for comment.tpl.php.
- *
- * @see comment.tpl.php
- */
- function template_preprocess_comment(&$variables) {
- $variables['view_mode'] = $variables['elements']['#view_mode'];
- $variables['bundle'] = $variables['elements']['#bundle'];
- $comment = $variables['elements']['#comment'];
- $node = $variables['elements']['#node'];
- $node_type = node_type_get_type($node->type);
-
- $variables['comment'] = $comment;
- $variables['node'] = $node;
- $variables['author'] = theme('username', array('account' => $comment));
- $variables['user_picture'] = '';
- $variables['created'] = format_date($comment->created);
-
- if ($comment->changed == $comment->created) {
- $variables['changed'] = $variables['created'];
- }
- else {
- $variables['changed'] = format_date($comment->changed);
- }
-
- $variables['new'] = !empty($comment->new) ? t('new') : '';
- if ($node_type->settings['comment_user_picture']) {
- $variables['user_picture'] = theme('user_picture', array('account' => $comment));
- }
- $variables['signature'] = $comment->signature;
-
- $uri = $comment->uri();
- $uri['options'] += array('attributes' => array('class' => array('permalink'), 'rel' => 'bookmark'));
-
- $variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
- $variables['permalink_path'] = $uri['path'] . "#" . $uri['options']['fragment'];
- $variables['title_display'] = $node_type->settings['comment_title_options'] != COMMENT_TITLE_HIDDEN;
- $variables['title'] = l($comment->subject, $uri['path'], $uri['options']);
- $variables['submitted'] = t('!datetime by !username', array('!datetime' => $variables['created'], '!username' => $variables['author']));
-
-
- field_attach_preprocess('comment', $comment, $variables['elements'], $variables);
-
-
- foreach (element_children($variables['elements']) as $key) {
- $variables['content'][$key] = $variables['elements'][$key];
- }
-
-
- if (isset($comment->in_preview)) {
- $variables['status'] = 'comment-preview';
- }
- else {
- $variables['status'] = ($comment->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
- }
-
-
-
-
- if ($variables['status'] != 'comment-published') {
- $variables['classes'][] = $variables['status'];
- }
- if ($variables['new']) {
- $variables['classes'][] = 'comment-new';
- }
- if (!$comment->uid) {
- $variables['classes'][] = 'comment-by-anonymous';
- }
- else {
- if ($comment->uid == $variables['node']->uid) {
- $variables['classes'][] = 'comment-by-node-author';
- }
- if ($comment->uid == $variables['user']->uid) {
- $variables['classes'][] = 'comment-by-viewer';
- }
- }
- if ($node_type->settings['comment_title_options'] == COMMENT_TITLE_HIDDEN) {
- $variables['classes'][] = 'comment-title-hidden';
- }
- elseif ($node_type->settings['comment_title_options'] == COMMENT_TITLE_AUTO) {
- $variables['classes'][] = 'comment-title-auto';
- }
- else {
- $variables['classes'][] = 'comment-title-custom';
- }
-
-
- $variables['title_classes'][] = 'comment-title';
- }