function rate_ui_widget_elements in Rate 7.2
Generate a list of available widget elements based on current form values.
Parameters
array $storage: Values from $form_state['storage'].
3 calls to rate_ui_widget_elements()
- rate_ui_widget_form_step_layout in ui/
rate_ui.form.inc - Generate form fields for the sixth step in the rate widget form.
- rate_ui_widget_load_layout in ui/
rate_ui.form.inc - Load widget layout from database into storage array.
- rate_ui_widget_save_layout in ui/
rate_ui.form.inc - Save widget layout from storage array into database.
File
- ui/
rate_ui.form.inc, line 992 - This file contains the differtent Rate UI forms.
Code
function rate_ui_widget_elements($storage) {
$elements = array();
// Add option counts.
for ($i = 1; $i <= $storage['buttoncount']; ++$i) {
if (empty($storage["button{$i}_label"])) {
// Button label is empty. Do not use this button.
continue;
}
$elements["button{$i}"] = t('Button %label', array(
'%label' => $storage["button{$i}_label"],
));
if ($storage['mode'] == 'option') {
$elements["button{$i}_count"] = t('Button %label vote count', array(
'%label' => $storage["button{$i}_label"],
));
}
}
// Check for thumbs up / down.
if ($storage['mode'] == 'points' && $storage['buttoncount'] == 2) {
if (min($storage['button1_value'], $storage['button2_value']) == -1 && max($storage['button1_value'], $storage['button2_value']) == 1) {
$elements['up_count'] = t('Up count');
$elements['up_percent'] = t('Up percent');
$elements['down_count'] = t('Down count');
$elements['down_percent'] = t('Down percent');
}
}
if (!empty($storage['button0_label'])) {
$elements['button0'] = t('Revoke button');
}
if ($storage['mode'] == 'percent') {
$elements['rating'] = t('Average rating');
}
if ($storage['mode'] == 'points') {
$elements['rating'] = t('Points');
}
$elements['description'] = t('Description');
$elements['count'] = t('Vote count');
return $elements;
}