From 52172450ac3373cf75c1510db08f23dbbad12720 Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Sat, 18 Dec 2010 02:45:03 -0500 Subject: [PATCH] feature #791082 by realityloop, marvil07 | donquixote, Fidelix: Let separate voting widget from $comment->comment. --- vud_comment/vud_comment.install | 1 + vud_comment/vud_comment.module | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git vud_comment/vud_comment.install vud_comment/vud_comment.install index ab88d69..b7f7143 100644 --- vud_comment/vud_comment.install +++ vud_comment/vud_comment.install @@ -27,6 +27,7 @@ function vud_comment_uninstall() { drupal_uninstall_schema('vud_comment'); variable_del('vud_comment_node_types'); variable_del('vud_comment_widget'); + variable_del('vud_comment_widget_display'); variable_del('vud_comment_votes'); variable_del('vud_comment_reset'); } \ No newline at end of file diff --git vud_comment/vud_comment.module vud_comment/vud_comment.module index d7b922d..65f7c47 100644 --- vud_comment/vud_comment.module +++ vud_comment/vud_comment.module @@ -6,6 +6,9 @@ * Adds a voting widget to comments. */ +define('VUD_COMMENT_DISPLAY_HIDDEN', 0); +define('VUD_COMMENT_DISPLAY_NORMAL', 1); + /** * Implementation of hook_perm(). */ @@ -48,6 +51,16 @@ function vud_comment_admin_settings() { '#default_value' => variable_get('vud_comment_widget', 'plain'), '#options' => vud_widget_get_names(), ); + $form['vud_comment_widget_display'] = array( + '#type' => 'radios', + '#title' => t('Widget display'), + '#description' => t('Select how the voting widget will be displayed.'), + '#default_value' => variable_get('vud_comment_widget_display', VUD_COMMENT_DISPLAY_NORMAL), + '#options' => array( + VUD_COMMENT_DISPLAY_NORMAL => t('Append to the comment content.'), + VUD_COMMENT_DISPLAY_HIDDEN => t('Do not append. I will manually insert $comment->vud_comment_widget variable on my theme.'), + ), + ); $form['vud_comment_votes'] = array( '#type' => 'radios', '#title' => t('Votes display'), @@ -99,7 +112,10 @@ function vud_comment_comment(&$comment, $op) { if ($comment_allow && user_access('use vote up/down on comments')) { $tag = variable_get('vud_tag', 'vote'); $widget = variable_get('vud_comment_widget', 'plain'); - $comment->comment = theme('vud_widget', $comment->cid, 'comment', $tag, $widget) . $comment->comment; + $comment->vud_comment_widget = theme('vud_widget', $comment->cid, 'comment', $tag, $widget); + if (variable_get('vud_comment_widget_display', VUD_COMMENT_DISPLAY_HIDDEN) == VUD_COMMENT_DISPLAY_NORMAL) { + $comment->comment = $comment->vud_comment_widget . $comment->comment; + } } break; } -- 1.7.2.3