예제 #1
0
파일: template.php 프로젝트: redbtn/wcc
/**
 * Modify and extend the comment template theming.
 */
function arthemia_preprocess_comment(&$variables)
{
    //Add a comment number and link to comments, borrowed from Advanced Forum module.
    if (!isset($comment_number)) {
        static $comment_number = 0;
    }
    $comments_per_page = _comment_get_display_setting('comments_per_page', $variables['node']);
    $page_number = $_GET['page'];
    if (!$page_number) {
        $page_number = 0;
    }
    $comment_number++;
    $post_number++;
    $fragment = 'comment-' . $variables['comment']->cid;
    $query = $page_number ? 'page=' . $page_number : NULL;
    $linktext = '#' . ($page_number * $comments_per_page + $comment_number);
    $linkpath = 'node/' . $variables['node']->nid;
    $variables['comment_link'] = l($linktext, $linkpath, array('query' => $query, 'fragment' => $fragment, 'class' => 'comment-link'));
}
예제 #2
0
파일: template.php 프로젝트: rasjones/csa
/**
 * Implementation of template_preprocess_comment().
 */
function csa_base_preprocess_comment(&$variables)
{
    $comment_classes = array();
    $comment_classes[] = 'comment';
    if ($variables['comment']->status == COMMENT_NOT_PUBLISHED) {
        $comment_classes[] = 'comment-unpublished';
    }
    $comments_per_page = _comment_get_display_setting('comments_per_page', $variables['node']);
    $comments_left = $variables['node']->comment_count % $comments_per_page;
    if ($variables['id'] == $comments_per_page || $variables['id'] == $comments_left) {
        $comment_classes[] = 'comment-last';
    } elseif ($variables['id'] == 1) {
        $comment_classes[] = 'comment-first';
    }
    $variables['comment_classes'] = implode(' ', $comment_classes);
}
예제 #3
0
/**
 * Renders a comment form.
 *
 * @param $node
 *   The node which comment(s) needs rendering.
 * @param $form
 *   Which form should be rendered: 'comment_form' or 'comment_controls'.
 */
function comment_display_comment_form_render($node, $form = 'comment')
{
    $output = '';
    $nid = $node->nid;
    $mode = _comment_get_display_setting('mode', $node);
    $order = _comment_get_display_setting('sort', $node);
    $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
    if ($form == 'comment_form') {
        // If enabled, show new comment form if it's not already being displayed.
        $reply = arg(0) == 'comment' && arg(1) == 'reply';
        if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW && !$reply) {
            $output .= comment_form_box(array('nid' => $nid), t('Post new comment'));
        }
    } elseif ($form == 'comment_controls') {
        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
    }
    return $output;
}
예제 #4
0
/**
 * Add a pager at the top of a list of comments.
 */
function zen_comment_wrapper($content)
{
    $comments_per_page = _comment_get_display_setting('comments_per_page');
    $content = theme('pager', NULL, $comments_per_page, 0) . $content;
    return theme_comment_wrapper($content);
}
예제 #5
0
function phptemplate_views_view_table_forumTracker($view, $nodes, $type)
{
    $fields = _views_get_fields();
    $comments_per_page = _comment_get_display_setting('comments_per_page');
    foreach ($nodes as $node) {
        $row = array();
        foreach ($view->field as $field) {
            if ($fields[$field['id']]['visible'] !== FALSE) {
                if ($field['field'] == 'comment_count') {
                    $count = db_result(db_query('SELECT COUNT(c.cid) FROM {comments} c WHERE c.nid=%d', $node->nid));
                    // Find the ending point. The pager URL is always 1 less than
                    // the number being displayed because the first page is 0.
                    $last_display_page = ceil($count / $comments_per_page);
                    $last_pager_page = $last_display_page - 1;
                    if ($last_pager_page < 0) {
                        $last_pager_page = 0;
                    }
                    $cell['data'] = $node->node_comment_statistics_comment_count . '<br />';
                    //$cell['data'] .= l('new', 'node/'.$node->nid, array(), 'page='.$last_pager_page.'#new');
                    $cell['data'] .= advanced_forum_first_new_post_link($node, $count);
                    $cell['class'] = "view-field " . views_css_safe('view-field-' . $field['queryname']);
                    $row[] = $cell;
                } else {
                    $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
                    $cell['class'] = "view-field " . views_css_safe('view-field-' . $field['queryname']);
                    $row[] = $cell;
                }
            }
        }
        $rows[] = $row;
    }
    return theme('table', $view->table_header, $rows);
}