| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.module,v 1.22 2009/07/01 00:01:17 quicksketch Exp $ |
// $Id: fivestar.module,v 1.23 2009/07/01 02:18:13 quicksketch Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 738 |
$form['content_type'] = array( |
$form['content_type'] = array( |
| 739 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 740 |
'#value' => $settings['content_type'], |
'#value' => $settings['content_type'], |
|
'#id' => $settings['content_id'] ? 'edit-content-type-'. $settings['content_id'] : NULL, |
|
| 741 |
); |
); |
| 742 |
} |
} |
| 743 |
|
|
| 745 |
$form['content_id'] = array( |
$form['content_id'] = array( |
| 746 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 747 |
'#value' => $settings['content_id'], |
'#value' => $settings['content_id'], |
|
'#id' => $settings['content_id'] ? 'edit-content-id-'. $settings['content_id'] : NULL, |
|
| 748 |
); |
); |
| 749 |
} |
} |
| 750 |
|
|
| 774 |
$form['destination'] = array( |
$form['destination'] = array( |
| 775 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 776 |
'#value' => $_GET['q'], |
'#value' => $_GET['q'], |
|
'#id' => isset($settings['content_id']) ? 'edit-destination-'. $settings['content_id'] : NULL, |
|
| 777 |
); |
); |
| 778 |
|
|
| 779 |
$form['fivestar_submit'] = array( |
$form['fivestar_submit'] = array( |
| 780 |
'#type' => 'submit', |
'#type' => 'submit', |
| 781 |
'#value' => t('Rate'), |
'#value' => t('Rate'), |
| 782 |
'#attributes' => array('class' => 'fivestar-submit'), |
'#attributes' => array('class' => 'fivestar-submit'), |
|
'#id' => isset($settings['content_id']) ? 'edit-fivestar-submit-'. $settings['content_id'] : NULL, |
|
| 783 |
); |
); |
| 784 |
|
|
| 785 |
$form['vote']['#attributes']['class'] = isset($form['vote']['#attributes']['class']) ? $form['vote']['#attributes']['class'] : ''; |
$form['vote']['#attributes']['class'] = isset($form['vote']['#attributes']['class']) ? $form['vote']['#attributes']['class'] : ''; |
| 1116 |
* Process callback for fivestar_element -- see fivestar_element() |
* Process callback for fivestar_element -- see fivestar_element() |
| 1117 |
*/ |
*/ |
| 1118 |
function fivestar_expand($element) { |
function fivestar_expand($element) { |
|
static $fivestar_id = 0; |
|
| 1119 |
|
|
| 1120 |
if (isset($element['#vote_count'])) { |
if (isset($element['#vote_count'])) { |
| 1121 |
$element['vote_count'] = array( |
$element['vote_count'] = array( |
| 1122 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 1123 |
'#value' => $element['#vote_count'], |
'#value' => $element['#vote_count'], |
|
'#id' => 'edit-vote-count-'. $fivestar_id, |
|
| 1124 |
); |
); |
| 1125 |
} |
} |
| 1126 |
|
|
| 1128 |
$element['vote_average'] = array( |
$element['vote_average'] = array( |
| 1129 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 1130 |
'#value' => $element['#vote_average'], |
'#value' => $element['#vote_average'], |
|
'#id' => 'edit-vote-average-'. $fivestar_id, |
|
| 1131 |
); |
); |
| 1132 |
} |
} |
| 1133 |
|
|
| 1136 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 1137 |
'#value' => url($element['#auto_submit_path']), |
'#value' => url($element['#auto_submit_path']), |
| 1138 |
'#attributes' => array('class' => 'fivestar-path'), |
'#attributes' => array('class' => 'fivestar-path'), |
|
'#id' => 'edit-auto-submit-path-'. $fivestar_id, |
|
| 1139 |
); |
); |
| 1140 |
$element['auto_submit_token'] = array( |
$element['auto_submit_token'] = array( |
| 1141 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 1142 |
'#value' => fivestar_get_token($element['#auto_submit_path']), |
'#value' => fivestar_get_token($element['#auto_submit_path']), |
| 1143 |
'#attributes' => array('class' => 'fivestar-token'), |
'#attributes' => array('class' => 'fivestar-token'), |
|
'#id' => 'edit-auto-submit-token-'. $fivestar_id, |
|
| 1144 |
); |
); |
| 1145 |
} |
} |
| 1146 |
|
|
| 1179 |
'#required' => $element['#required'], |
'#required' => $element['#required'], |
| 1180 |
'#default_value' => $default_value, |
'#default_value' => $default_value, |
| 1181 |
'#parents' => $element['#parents'], |
'#parents' => $element['#parents'], |
|
'#id' => 'edit-vote-'. $fivestar_id, |
|
| 1182 |
'#theme' => 'fivestar_select', |
'#theme' => 'fivestar_select', |
| 1183 |
'#weight' => $element['#weight'], |
'#weight' => $element['#weight'], |
| 1184 |
); |
); |
| 1191 |
// Set a class for the display of label text on hover. |
// Set a class for the display of label text on hover. |
| 1192 |
$label_class = $element['#labels_enable'] ? ' fivestar-labels-hover' : ''; |
$label_class = $element['#labels_enable'] ? ' fivestar-labels-hover' : ''; |
| 1193 |
|
|
|
$element['#id'] = 'edit-vote-'. $fivestar_id; |
|
| 1194 |
$element['#prefix'] = '<div class="fivestar-form-item '. (isset($element['#attributes']['class']) ? $element['#attributes']['class'] : '') . $label_class .'">'; |
$element['#prefix'] = '<div class="fivestar-form-item '. (isset($element['#attributes']['class']) ? $element['#attributes']['class'] : '') . $label_class .'">'; |
| 1195 |
$element['#suffix'] = '</div>'; |
$element['#suffix'] = '</div>'; |
| 1196 |
|
|
| 1197 |
// Add validation function that considers a 0 value as empty. |
// Add validation function that considers a 0 value as empty. |
| 1198 |
$element['#element_validate'] = array('fivestar_validate'); |
$element['#element_validate'] = array('fivestar_validate'); |
| 1199 |
|
|
|
$fivestar_id++; |
|
| 1200 |
return $element; |
return $element; |
| 1201 |
} |
} |
| 1202 |
|
|