--- ../fivestarextra/fivestarextra.install 2008-10-26 13:53:52.000000000 -0500
+++ fivestarextra.install 2011-07-26 13:10:25.000000000 -0500
@@ -6,9 +6,11 @@
*/
function fivestarextraextra_uninstall() {
//Get rid of our variables
- $variables = array('fivestarextra_stars','fivestarextra_labels_enable','fivestarextra_style','fivestarextra_text','fivestarextra_title','fivestarextra_unvote','fivestarextra_feedback','fivestarextra_position','fivestarextra_labels','fivestarextra_enable');
+ $variables = array('fivestarextra_stars','fivestarextra_labels_enable','fivestarextra_style','fivestarextra_text','fivestarextra_title','fivestarextra_unvote','fivestarextra_feedback','fivestarextra_position','fivestarextra_labels','fivestarextra_enable','fivestarextra_noderestrict','fivestarextra_heading');
foreach ($variables as $variable) {
- variable_del($variable .'_comment');
- variable_del($variable .'_user');
- };
+ $result = db_query("SELECT name FROM {variable} WHERE name like '%s'",$variable.'_%');
+ while ($row = db_fetch_object($result)) {
+ variable_del($row->name);
+ }
+ }
}
--- ../fivestarextra/fivestarextra.module 2009-08-29 16:24:36.000000000 -0500
+++ fivestarextra.module 2011-07-26 00:27:23.000000000 -0500
@@ -9,16 +9,47 @@
/**
+ * Implementation of hook_help().
+ */
+function fivestarextra_help($path, $arg) {
+ if(preg_match("/admin\/settings\/fivestarextra_/",$path)) {
+ $output = t('This menu is used to configure Rating of ' . preg_replace("/.*fivestarextra_/","",$path) . ' for the configured voting axes, by default "vote". Click on the axis you wish to configure. To create additional axes, visit Fivestar settings page.',array('!url' => url('admin/settings/fivestar')));
+ }
+ return $output;
+}
+
+
+/**
* Implementation of hook_menu.
*/
function fivestarextra_menu() {
$items = array();
-
+ foreach (fivestar_get_tags() as $tag) {
+ $items['admin/settings/fivestarextra_comments/'. urlencode($tag)] = array(
+ 'title' => $tag,
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('fivestarextra_comments_admin_form',$tag),
+ 'description' => 'Configure Fivestar setting for the rating of comments for the "' . $tag . '" axis.',
+ 'type' => MENU_LOCAL_TASK,
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'fivestarextra.admin.inc',
+ );
+ $items['admin/settings/fivestarextra_users/'. urlencode($tag)] = array(
+ 'title' => $tag,
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('fivestarextra_users_admin_form',$tag),
+ 'description' => 'Configure Fivestar setting for the rating of users for the "' . $tag . '" axis.',
+ 'type' => MENU_LOCAL_TASK,
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'fivestarextra.admin.inc',
+ );
+ }
$items['admin/settings/fivestarextra_comments'] = array(
'title' => 'Fivestar Comments Rating',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('fivestarextra_comments_admin_form'),
- 'description' => 'Configure Fivestar setting for the rating of comments.',
+ 'description' => 'Configure Fivestar setting for the rating of comments on configured axes',
'type' => MENU_NORMAL_ITEM,
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
@@ -27,14 +58,12 @@
$items['admin/settings/fivestarextra_users'] = array(
'title' => 'Fivestar Users Rating',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('fivestarextra_users_admin_form'),
- 'description' => 'Configure Fivestar setting for the rating of users.',
+ 'description' => 'Configure Fivestar setting for the rating of users on configured axes',
'type' => MENU_NORMAL_ITEM,
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
'file' => 'fivestarextra.admin.inc',
);
-
return $items;
}
@@ -59,7 +88,7 @@
* so the Fivestar form has to be concatenated with the comment text itself.
*/
function fivestarextra_comment(&$comment, $op) {
-
+ global $user;
$path = arg();
//If we are on the comment reply page, adding a dynamic rating form causes problems, so exit
if ( $path[0] == 'comment' && $path[1] == 'reply' ) {
@@ -67,35 +96,53 @@
}
if ($op == 'view' && $comment->preview != 'Preview') {
- if (variable_get('fivestarextra_enable_comment', FALSE)) {
+ //fivestar heading.
+ $comment->comment .= '
';
+ if($comment->uid == $user->uid) {
+ $appendstring.= variable_get('fivestarextra_heading_enable_comment_'.$tag,1)? ($v=variable_get('fivestarextra_heading_self_comment_'.$tag)) ? t($v) : t('Rate comment on %tag:', array('%tag' => $tag)) : "" ;
+ $appendstring.=fivestar_static('comment', $comment->cid,NULL,$tag);
+ } else {
+ $appendstring.= variable_get('fivestarextra_heading_enable_comment_'.$tag,1)? ($v=variable_get('fivestarextra_heading_other_comment_'.$tag)) ? t($v) : t('Rate comment on %tag:', array('%tag' => $tag)) : "" ;
+ $appendstring.=drupal_get_form('fivestarextra_form_comment_'. $comment->cid . '_' . $tag, 'comment', $comment->cid,$tag);
+ }
+ $appendstring.= '
';
+
switch ($position) {
case 'above':
- $comment->comment = drupal_get_form('fivestarextra_form_comment_'. $comment->cid, 'comment', $comment->cid) . $comment->comment;
+ $comment->comment = $appendstring . $comment->comment;
break;
case 'below':
- $comment->comment .= drupal_get_form('fivestarextra_form_comment_'. $comment->cid, 'comment', $comment->cid);
+ $comment->comment .= $appendstring;
break;
default:
// We'll do nothing.
break;
}
-
}
}
}
-
+}
/**
* Implementation of hook_forms
@@ -105,13 +152,13 @@
*/
function fivestarextra_forms($form_id, $args) {
if (strpos($form_id, 'fivestarextra_form_comment_') !== FALSE) {
- if ($form_id == 'fivestarextra_form_comment_'. $args[1]) {
+ if ($form_id == 'fivestarextra_form_comment_'. $args[1] . '_' . $args[2]) {
$forms[$form_id] = array('callback' => 'fivestarextra_widget_form');
return $forms;
}
}
if (strpos($form_id, 'fivestarextra_form_user_') !== FALSE) {
- if ($form_id == 'fivestarextra_form_user_'. $args[1]) {
+ if ($form_id == 'fivestarextra_form_user_'. $args[1] . '_' . $args[2]) {
$forms[$form_id] = array('callback' => 'fivestarextra_widget_form');
return $forms;
}
@@ -122,46 +169,45 @@
/**
* Modified version of fivestar_form for comments and users.
*/
-function fivestarextra_widget_form(&$form_state, $content_type, $content_id) {
-
+function fivestarextra_widget_form(&$form_state, $content_type, $content_id, $tag) {
global $user;
-
- $votes = fivestar_get_votes($content_type, $content_id);
+ if (variable_get('fivestarextra_enable_'. $content_type . '_' . $tag, FALSE)) {
+ $votes = fivestar_get_votes($content_type, $content_id,$tag);
$values = array(
'user' => isset($votes['user']['value']) ? $votes['user']['value'] : NULL,
'average' => isset($votes['average']['value']) ? $votes['average']['value'] : NULL,
'count' => isset($votes['count']['value']) ? $votes['count']['value'] : NULL,
);
-
$settings = array(
- 'stars' => variable_get('fivestarextra_stars_'. $content_type, 5),
- 'allow_clear' => variable_get('fivestarextra_unvote_'. $content_type, FALSE),
- 'style' => variable_get('fivestarextra_style_'. $content_type, 'average'),
- 'text' => variable_get('fivestarextra_text_'. $content_type, 'dual'),
+ 'fivestar' => 1,
+ 'stars' => variable_get('fivestarextra_stars_'. $content_type . '_' . $tag, 5),
+ 'allow_clear' => variable_get('fivestarextra_unvote_'. $content_type . '_' . $tag, FALSE),
+ 'star_display' => variable_get('fivestarextra_style_'. $content_type . '_' . $tag, 'average'),
+ 'text_display' => variable_get('fivestarextra_text_'. $content_type . '_' . $tag, 'dual'),
+ 'position' => variable_get('fivestarextra_position_'. $content_type . '_' . $tag, 'below'),
+ 'position_teaser' => variable_get('fivestarextra_position_teaser_'. $content_type . '_' . $tag, 'hidden'),
'content_type' => $content_type,
'content_id' => $content_id,
- 'tag' => 'vote',
+ 'tag' => $tag,
'autosubmit' => TRUE,
- 'title' => variable_get('fivestarextra_title_'. $content_type, 1) ? NULL : FALSE,
- 'feedback_enable' => variable_get('fivestarextra_feedback_'. $content_type, 1),
- 'labels_enable' => variable_get('fivestarextra_labels_enable_'. $content_type, 1),
- 'labels' => variable_get('fivestarextra_labels_'. $content_type, array()),
+ 'title' => variable_get('fivestarextra_title_enable_' . $content_type . '_' . $tag,true)? ($v=variable_get('fivestarextra_title_other_'. $content_type . '_' . $tag))? t($v) : t('Your rating ('. ucfirst($tag) .')') : "",
+ 'feedback_enable' => variable_get('fivestarextra_feedback_'. $content_type . '_' . $tag, 1),
+ 'labels_enable' => variable_get('fivestarextra_labels_enable_'. $content_type . '_' . $tag, 1),
+ 'labels' => variable_get('fivestarextra_labels_'. $content_type . '_' . $tag, array()),
);
-
- $myform = fivestar_custom_widget($form_state, $values, $settings);
-
- return $myform;
}
-
+ return fivestar_custom_widget($form_state, $values, $settings);
+}
/**
* Implementation of hook_fivestar_access().
*/
-function fivestarextra_fivestar_access($type, $id, $account) {
+function fivestarextra_fivestar_access($type, $id, $tag, $account) {
+
global $user;
if ($type == 'comment') {
- if (variable_get('fivestarextra_enable_comment', 0)) {
+ if (variable_get('fivestarextra_enable_comment_'.$tag, 0)) {
return TRUE;
}
else {
@@ -169,7 +215,7 @@
}
}
if ($type == 'user') {
- if (variable_get('fivestarextra_enable_user', 0) && $user->uid != $id ) {
+ if (variable_get('fivestarextra_enable_user_'.$tag, 0) && $user->uid != $id ) {
return TRUE;
}
else {
@@ -186,31 +232,37 @@
global $user;
switch ($op) {
case 'view':
- if (variable_get('fivestarextra_enable_user', FALSE)) {
- //Return the category
$account->content['fivestarextra'] = array(
'#type' => 'user_profile_category',
- '#title' => t('User Rating'),
- '#weight' => variable_get('fivestarextra_position_user', '100'),
+ '#title' => variable_get('fivestarextra_title_enable_user',1)? ($v=variable_get('fivestarextra_title_user'))? t($v) : t('User Rating:') : NULL,
+ // '#weight' => variable_get('fivestarextra_position_user', '100'),
+ );
+ foreach (fivestar_get_tags() as $tag) {
+ if (variable_get('fivestarextra_enable_user_'.$tag, FALSE)) {
+ //Return the category
+ $account->content['fivestarextra'][$tag] = array(
+ '#type' => 'user_profile_category',
+ '#weight' => variable_get('fivestarextra_position_user_'.$tag, '100'),
);
if ($user->uid == $account->uid) {
//If the user is viewing their own page, return a static form so they cannot vote
- $account->content['fivestarextra']['widget'] = array(
+ $account->content['fivestarextra'][$tag]['widget'] = array(
'#type' => 'user_profile_item',
- '#title' => t('Your Rating:'),
- '#value' => fivestar_static('user', $account->uid),
+ '#title' => variable_get('fivestarextra_heading_enable_user_'.$tag,1)? ($v=variable_get('fivestarextra_heading_self_user_'.$tag))? t($v) : t('Your Rating:') : NULL,
+ '#value' => fivestar_static('user', $account->uid,NULL,$tag),
);
}
else {
//If it is not their own profile page, return the normal fivestar widget
- $account->content['fivestarextra']['widget'] = array(
+ $account->content['fivestarextra'][$tag]['widget'] = array(
'#type' => 'user_profile_item',
- '#title' => t('Rate %username:', array('%username' => $account->name)),
- '#value' => drupal_get_form('fivestarextra_form_user_'. $account->uid, 'user', $account->uid),
+ '#title' => variable_get('fivestarextra_heading_enable_user_'.$tag,1)? ($v=variable_get('fivestarextra_heading_other_user_'.$tag)) ? t($v) : t('Rate %username on %tag:', array('%username' => $account->name,'%tag' => $tag)) : NULL,
+ '#value' => drupal_get_form('fivestarextra_form_user_'. $account->uid . '_' . $tag, 'user', $account->uid,$tag),
);
}
}
+ }
break;
}
}
--- ../fivestarextra/fivestarextra.admin.inc 2008-10-27 07:34:28.000000000 -0500
+++ fivestarextra.admin.inc 2011-07-26 00:07:44.000000000 -0500
@@ -12,7 +12,31 @@
* Admin settings form, mainly cannibalised from fivestar_form_alter,
* with a few important modifications.
*/
-function fivestarextra_comments_admin_form(&$form_state) {
+function fivestarextra_comments_admin_form(&$form_state,$tag) {
+ if(!isset($tag)) $tag='vote';
+
+ $form['global'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Global Fivestar comments title settings'),
+ '#collapsible' => FALSE,
+ '#description' => t('These are settings that control the main title for the entire set of axes enabled for comments'),
+ '#weight' => -1,
+ );
+
+ $form['global']['fivestar_maintitle_enable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show fivestar title'),
+ '#default_value' => variable_get('fivestarextra_title_enable_comment',1),
+ '#return_value' => 1,
+ );
+
+ $form['global']['fivestar_maintitle'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default title text'),
+ '#default_value' => variable_get('fivestarextra_title_comment',NULL),
+ '#description' => t('default is null'),
+ '#return_value' => 1,
+ );
$form['fivestar'] = array(
'#type' => 'fieldset',
@@ -24,17 +48,18 @@
$form['fivestar']['fivestar'] = array(
'#type' => 'checkbox',
- '#title' => t('Enable Fivestar rating on comments'),
- '#default_value' => variable_get('fivestarextra_enable_comment', 0),
+ '#title' => t('Enable Fivestar rating on comments for the "@tag" tag', array('@tag' => $tag)),
+ '#default_value' => variable_get('fivestarextra_enable_comment_'.$tag, 0),
'#return_value' => 1,
'#weight' => -5,
+ '#tag' => $tag,
);
$form['fivestar']['fivestar_stars'] = array(
'#type' => 'select',
'#title' => t('Number of stars'),
'#options' => drupal_map_assoc(range(1, 10)),
- '#default_value' => variable_get('fivestarextra_stars_comment', 5),
+ '#default_value' => variable_get('fivestarextra_stars_comment_'.$tag, 5),
'#weight' => -4,
);
@@ -50,7 +75,7 @@
$form['fivestar']['labels']['fivestar_labels_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Display labels on mouse over'),
- '#default_value' => variable_get('fivestarextra_labels_enable_comment', 1),
+ '#default_value' => variable_get('fivestarextra_labels_enable_comment_'.$tag, 1),
'#return_value' => 1,
'#weight' => -5,
'#description' => t('When enabled, the star labels will dynamically appear underneath the stars as the user hovers over each star to provide a more descriptive qualitative meaning for each star value.'),
@@ -58,8 +83,8 @@
// Create the Mouseover text forms for each of the rating options
// This form depends on the number of stars, and these extra textfields will be hidden with javascript
- $star_count = variable_get('fivestarextra_stars_comment', 5);
- $labels = variable_get('fivestarextra_labels_comment', array());
+ $star_count = variable_get('fivestarextra_stars_comment_'.$tag, 5);
+ $labels = variable_get('fivestarextra_labels_comment_'.$tag, array());
for ($n = 0; $n <= 10; $n++) {
if ($star_count == 5 && $n <= 5) {
// If the default 5 stars are chosen, then use these five default label values.
@@ -92,7 +117,7 @@
$form['fivestar']['direct']['fivestar_style'] = array(
'#type' => 'select',
'#title' => t('Star display style'),
- '#default_value' => variable_get('fivestarextra_style_comment', 'average'),
+ '#default_value' => variable_get('fivestarextra_style_comment_'.$tag, 'average'),
'#options' => array(
'average' => t('Display average vote value'),
'user' => t('Display user vote value'),
@@ -104,7 +129,7 @@
$form['fivestar']['direct']['fivestar_text'] = array(
'#type' => 'select',
'#title' => t('Text display style'),
- '#default_value' => variable_get('fivestarextra_text_comment', 'dual'),
+ '#default_value' => variable_get('fivestarextra_text_comment_'.$tag, 'dual'),
'#options' => array(
'none' => t('Display no text beneath stars'),
'average' => t('Current average in text'),
@@ -114,31 +139,84 @@
),
);
- $form['fivestar']['direct']['fivestar_title'] = array(
+ $form['fivestar']['direct']['fivestar_heading_enable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show widget heading'),
+ '#default_value' => variable_get('fivestarextra_heading_enable_comment_'.$tag,1),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_heading_self'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget heading for user\'s own score'),
+ '#default_value' => variable_get('fivestarextra_heading_self_comment_'.$tag,NULL),
+ '#description' => t('default is "Your Rating"'),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_heading_other'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget heading for user\'s rating of others'),
+ '#default_value' => variable_get('fivestarextra_heading_other_comment_'.$tag,NULL),
+ '#description' => t('default is "Rate comment on axis"'),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_title_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Show widget title'),
- '#default_value' => variable_get('fivestarextra_title_comment', 1),
+ '#default_value' => variable_get('fivestarextra_title_enable_comment_'.$tag,1),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_title_self'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget title for user\'s own score'),
+ '#default_value' => variable_get('fivestarextra_title_self_comment_'.$tag,NULL),
+ '#description' => t('default is null'),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_title_other'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget title for user\'s rating of others'),
+ '#default_value' => variable_get('fivestarextra_title_other_comment_'.$tag,NULL),
+ '#description' => t('default is "Your rating (axis)"'),
'#return_value' => 1,
);
$form['fivestar']['direct']['fivestar_feedback'] = array(
'#type' => 'checkbox',
'#title' => t('Enable feedback during vote saving and deletion'),
- '#default_value' => variable_get('fivestarextra_feedback_comment', 1),
+ '#default_value' => variable_get('fivestarextra_feedback_comment_'.$tag, 1),
'#return_value' => 1
);
$form['fivestar']['direct']['fivestar_unvote'] = array(
'#type' => 'checkbox',
'#title' => t('Allow users to undo their votes'),
- '#default_value' => variable_get('fivestarextra_unvote_comment', 0),
+ '#default_value' => variable_get('fivestarextra_unvote_comment_'.$tag, 0),
'#return_value' => 1,
);
+ $form['fivestar']['direct']['fivestar_position_teaser'] = array(
+ '#type' => 'select',
+ '#title' => t('Teaser display'),
+ '#default_value' => variable_get('fivestarextra_position_teaser_comment_'. $tag, 'hidden'),
+ '#options' => array(
+ 'above' => t('Clickable widget above teaser'),
+ 'below' => t('Clickable widget below teaser'),
+ 'above_static' => t('Static display above teaser'),
+ 'below_static' => t('Static display below teaser'),
+ 'link' => t('Teaser link to full node widget'),
+ 'hidden' => '<'. t('hidden') .'>',
+ ),
+ );
+
$form['fivestar']['direct']['fivestar_position'] = array(
'#type' => 'select',
'#title' => t('Display mode'),
- '#default_value' => variable_get('fivestarextra_position_comment', 'below'),
+ '#default_value' => variable_get('fivestarextra_position_comment_'.$tag, 'below'),
'#options' => array(
'above' => t('Clickable widget above comment body'),
'below' => t('Clickable widget below comment body'),
@@ -157,7 +235,7 @@
$form['fivestar']['direct']['fivestar_unvote']['#default_value'],
$form['fivestar']['direct']['fivestar_title']['#default_value'] ? NULL : FALSE,
$form['fivestar']['labels']['fivestar_labels_enable']['#default_value'],
- variable_get('fivestarextra_labels_comment', array())
+ variable_get('fivestarextra_labels_comment_'.$tag, array())
),
);
if (!$form['fivestar']['fivestar']['#default_value']) {
@@ -179,9 +257,9 @@
$form['fivestar']['nodetypes']['fivestar_noderestrict_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Restrict By Node Type'),
- '#default_value' => variable_get('fivestarextra_noderestrict_enable_comment', 0),
+ '#default_value' => variable_get('fivestarextra_noderestrict_enable_comment_'.$tag, 0),
'#return_value' => 1,
- '#prefix' => theme('fivestarextra_noderestrict_enable_comment',''),
+ '#prefix' => theme('fivestarextra_noderestrict_enable_comment_'.$tag,''),
'#weight' => -5,
);
@@ -189,7 +267,7 @@
$form['fivestar']['nodetypes']['fivestar_noderestrict_nodetypes'] = array(
'#type' => 'checkboxes',
'#title' => t('Enable Comment Rating on These Node Types'),
- '#default_value' => variable_get('fivestarextra_noderestrict_nodetypes', array_keys($nodetypes)),
+ '#default_value' => variable_get('fivestarextra_noderestrict_nodetypes_'.$tag, array_keys($nodetypes)),
'#options' => $nodetypes,
'#attributes' => array('class' => 'fivestarextra_noderestrict_nodetypes'),
'#weight' => 0,
@@ -210,11 +288,13 @@
* Admin settings form submit function. It simply saves the variables.
*/
function fivestarextra_comments_admin_form_submit($form, &$form_state) {
- variable_set('fivestarextra_enable_comment',$form_state['values']['fivestar']);
-
- $variables = array('stars','labels_enable','style','text','title','unvote','feedback','position','noderestrict_enable');
+ $tag=$form['fivestar']['fivestar']['#tag'];
+ variable_set('fivestarextra_enable_comment_'.$tag,$form_state['values']['fivestar']);
+ variable_set('fivestarextra_title_enable_comment',$form_state['values']['fivestar_maintitle_enable']);
+ variable_set('fivestarextra_title_comment',$form_state['values']['fivestar_maintitle']);
+ $variables = array('stars','labels_enable','style','text','title','unvote','feedback','position','heading_enable','heading_self','heading_other','title_enable','title_self','title_other','noderestrict_enable','position_teaser');
foreach ($variables as $variable) {
- variable_set('fivestarextra_'.$variable .'_comment',$form_state['values']['fivestar_'.$variable]);
+ variable_set('fivestarextra_'.$variable .'_comment_'.$tag,$form_state['values']['fivestar_'.$variable]);
}
//Merge node types into an array
@@ -224,17 +304,17 @@
$nodetypes[] = $type;
}
}
- variable_set('fivestarextra_noderestrict_nodetypes',$nodetypes);
+ variable_set('fivestarextra_noderestrict_nodetypes_'.$tag,$nodetypes);
// Merge labels into a single variable.
$labels = array();
for ($n = 0; $n <= 10; $n++) {
$labels[] = $form_state['values']['fivestar_label_'. $n];
- variable_del('fivestarextra_label_'. $n .'_comment');
+ variable_del('fivestarextra_label_'. $n .'_comment_'.$tag);
}
- variable_del('fivestar_labels_comment');
+ variable_del('fivestar_labels_comment_'.$tag);
if ($form_state['values']['fivestar_labels_enable']) {
- variable_set('fivestarextra_labels_comment', $labels);
+ variable_set('fivestarextra_labels_comment_'.$tag, $labels);
}
};
@@ -252,11 +332,33 @@
* Admin settings form, mainly cannibalised from fivestar_form_alter,
* with a few important modifications.
*/
-function fivestarextra_users_admin_form(&$form_state) {
+function fivestarextra_users_admin_form(&$form_state,$tag) {
+ $form['global'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Global Fivestar users title settings'),
+ '#collapsible' => FALSE,
+ '#description' => t('These are settings that control the main title for the entire set of axes enabled for users'),
+ '#weight' => -1,
+ );
+
+ $form['global']['fivestar_maintitle_enable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show fivestar title'),
+ '#default_value' => variable_get('fivestarextra_title_enable_user',1),
+ '#return_value' => 1,
+ );
+
+ $form['global']['fivestar_maintitle'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default title text'),
+ '#default_value' => variable_get('fivestarextra_title_user',NULL),
+ '#description' => t('default is "User Rating"'),
+ '#return_value' => 1,
+ );
$form['fivestar'] = array(
'#type' => 'fieldset',
- '#title' => t('Fivestar users Rating'),
+ '#title' => t('Fivestar users Rating for ' . $tag . ''),
'#description' => t('This is for rating users, as in whether a particular user is good or bad. For writing reviews of nodes, including users, see the module Fivestar users.'),
'#theme' => 'fivestar_node_type_form',
'#attributes' => array('id' => 'fivestar-node-type-form'),
@@ -264,18 +366,19 @@
$form['fivestar']['fivestar'] = array(
'#type' => 'checkbox',
- '#title' => t('Enable Fivestar rating on users'),
- '#default_value' => variable_get('fivestarextra_enable_user', 0),
+ '#title' => t('Enable Fivestar rating on users for the "@tag" tag', array('@tag' => $tag)),
+ '#default_value' => variable_get('fivestarextra_enable_user_'.$tag, 0),
'#return_value' => 1,
'#weight' => -5,
+ '#tag' => $tag,
);
$form['fivestar']['fivestar_stars'] = array(
'#type' => 'select',
'#title' => t('Number of stars'),
'#options' => drupal_map_assoc(range(1, 10)),
- '#default_value' => variable_get('fivestarextra_stars_user', 5),
- '#weight' => -4,
+ '#default_value' => variable_get('fivestarextra_stars_user_'.$tag, 5),
+ '#weight' => -2,
);
@@ -290,7 +393,7 @@
$form['fivestar']['labels']['fivestar_labels_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Display labels on mouse over'),
- '#default_value' => variable_get('fivestarextra_labels_enable_user', 1),
+ '#default_value' => variable_get('fivestarextra_labels_enable_user_'.$tag, 1),
'#return_value' => 1,
'#weight' => -5,
'#description' => t('When enabled, the star labels will dynamically appear underneath the stars as the user hovers over each star to provide a more descriptive qualitative meaning for each star value.'),
@@ -298,8 +401,8 @@
// Create the Mouseover text forms for each of the rating options
// This form depends on the number of stars, and these extra textfields will be hidden with javascript
- $star_count = variable_get('fivestarextra_stars_user', 5);
- $labels = variable_get('fivestarextra_labels_user', array());
+ $star_count = variable_get('fivestarextra_stars_user_'.$tag, 5);
+ $labels = variable_get('fivestarextra_labels_user_'.$tag, array());
for ($n = 0; $n <= 10; $n++) {
if ($star_count == 5 && $n <= 5) {
// If the default 5 stars are chosen, then use these five default label values.
@@ -332,7 +435,7 @@
$form['fivestar']['direct']['fivestar_style'] = array(
'#type' => 'select',
'#title' => t('Star display style'),
- '#default_value' => variable_get('fivestarextra_style_user', 'average'),
+ '#default_value' => variable_get('fivestarextra_style_user_'.$tag, 'average'),
'#options' => array(
'average' => t('Display average vote value'),
'user' => t('Display user vote value'),
@@ -344,7 +447,7 @@
$form['fivestar']['direct']['fivestar_text'] = array(
'#type' => 'select',
'#title' => t('Text display style'),
- '#default_value' => variable_get('fivestarextra_text_user', 'dual'),
+ '#default_value' => variable_get('fivestarextra_text_user_'.$tag, 'dual'),
'#options' => array(
'none' => t('Display no text beneath stars'),
'average' => t('Current average in text'),
@@ -354,27 +457,80 @@
),
);
- $form['fivestar']['direct']['fivestar_title'] = array(
+ $form['fivestar']['direct']['fivestar_heading_enable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show widget heading'),
+ '#default_value' => variable_get('fivestarextra_heading_enable_user_'.$tag,1),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_heading_self'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget heading for user\'s own score'),
+ '#default_value' => variable_get('fivestarextra_heading_self_user_'.$tag,NULL),
+ '#description' => t('default is "Your Rating"'),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_heading_other'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget heading for user\'s rating of others'),
+ '#default_value' => variable_get('fivestarextra_heading_other_user_'.$tag,NULL),
+ '#description' => t('default is "Rate user on axis"'),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_title_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Show widget title'),
- '#default_value' => variable_get('fivestarextra_title_user', 1),
+ '#default_value' => variable_get('fivestarextra_title_enable_user_'.$tag,1),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_title_self'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget title for user\'s own score'),
+ '#default_value' => variable_get('fivestarextra_title_self_user_'.$tag,NULL),
+ '#description' => t('default is null'),
+ '#return_value' => 1,
+ );
+
+ $form['fivestar']['direct']['fivestar_title_other'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Override default text of widget title for user\'s rating of others'),
+ '#default_value' => variable_get('fivestarextra_title_other_user_'.$tag,NULL),
+ '#description' => t('default is "Your rating (axis)"'),
'#return_value' => 1,
);
$form['fivestar']['direct']['fivestar_feedback'] = array(
'#type' => 'checkbox',
'#title' => t('Enable feedback during vote saving and deletion'),
- '#default_value' => variable_get('fivestarextra_feedback_user', 1),
+ '#default_value' => variable_get('fivestarextra_feedback_user_'.$tag, 1),
'#return_value' => 1
);
$form['fivestar']['direct']['fivestar_unvote'] = array(
'#type' => 'checkbox',
'#title' => t('Allow users to undo their votes'),
- '#default_value' => variable_get('fivestarextra_unvote_user', 0),
+ '#default_value' => variable_get('fivestarextra_unvote_user_'.$tag, 0),
'#return_value' => 1,
);
+ $form['fivestar']['direct']['fivestar_position_teaser'] = array(
+ '#type' => 'select',
+ '#title' => t('Teaser display'),
+ '#default_value' => variable_get('fivestarextra_position_teaser_user_'. $tag, 'hidden'),
+ '#options' => array(
+ 'above' => t('Clickable widget above teaser'),
+ 'below' => t('Clickable widget below teaser'),
+ 'above_static' => t('Static display above teaser'),
+ 'below_static' => t('Static display below teaser'),
+ 'link' => t('Teaser link to full node widget'),
+ 'hidden' => '<'. t('hidden') .'>',
+ ),
+ );
+
$weightoptions = array('hidden' => t(''));
foreach (range(-100,100) as $weight) {
$weightoptions[$weight] = $weight;
@@ -384,7 +540,7 @@
'#type' => 'select',
'#title' => t('Weight'),
'#description' => t('Determines the position of the voting widget on the user page. Higher values are lower down.'),
- '#default_value' => variable_get('fivestarextra_position_user', '100'),
+ '#default_value' => variable_get('fivestarextra_position_user_'.$tag, '100'),
'#options' => $weightoptions,
);
@@ -399,7 +555,7 @@
$form['fivestar']['direct']['fivestar_unvote']['#default_value'],
$form['fivestar']['direct']['fivestar_title']['#default_value'] ? NULL : FALSE,
$form['fivestar']['labels']['fivestar_labels_enable']['#default_value'],
- variable_get('fivestarextra_labels_user', array())
+ variable_get('fivestarextra_labels_user_'.$tag, array())
),
);
if (!$form['fivestar']['fivestar']['#default_value']) {
@@ -424,23 +580,24 @@
* Admin settings form submit function. It simply saves the variables.
*/
function fivestarextra_users_admin_form_submit($form, &$form_state) {
-
- variable_set('fivestarextra_enable_user',$form_state['values']['fivestar']);
-
- $variables = array('stars','labels_enable','style','text','title','unvote','feedback','position');
+ $tag=$form['fivestar']['fivestar']['#tag'];
+ variable_set('fivestarextra_enable_user_'.$tag,$form_state['values']['fivestar']);
+ variable_set('fivestarextra_title_enable_user',$form_state['values']['fivestar_maintitle_enable']);
+ variable_set('fivestarextra_title_user',$form_state['values']['fivestar_maintitle']);
+ $variables = array('stars','labels_enable','style','text','title','unvote','feedback','position','heading_enable','heading_self','heading_other','title_enable','title_self','title_other','position_teaser');
foreach ($variables as $variable) {
- variable_set('fivestarextra_'.$variable .'_user',$form_state['values']['fivestar_'.$variable]);
+ variable_set('fivestarextra_'.$variable .'_user_'.$tag,$form_state['values']['fivestar_'.$variable]);
}
// Merge labels into a single variable.
$labels = array();
for ($n = 0; $n <= 10; $n++) {
$labels[] = $form_state['values']['fivestar_label_'. $n];
- variable_del('fivestarextra_label_'. $n .'_user');
+ variable_del('fivestarextra_label_'. $n .'_user_'.$tag);
}
- variable_del('fivestar_labels_user');
+ variable_del('fivestar_labels_user_'.$tag);
if ($form_state['values']['fivestar_labels_enable']) {
- variable_set('fivestarextra_labels_user', $labels);
+ variable_set('fivestarextra_labels_user_'.$tag, $labels);
}
};