function theme_fivestar_preview_widget in Fivestar 7.2
Same name and namespace in other branches
- 8 includes/fivestar.theme.inc \theme_fivestar_preview_widget()
- 5 fivestar.module \theme_fivestar_preview_widget()
- 6.2 includes/fivestar.admin.inc \theme_fivestar_preview_widget()
- 6 fivestar.module \theme_fivestar_preview_widget()
Show a preview of a widget using a custom CSS file.
1 theme call to theme_fivestar_preview_widget()
- fivestar_previews_expand in includes/
fivestar.field.inc
File
- includes/
fivestar.theme.inc, line 11 - Provides the theming functions for fivestar.
Code
function theme_fivestar_preview_widget($variables) {
$path = drupal_get_path('module', 'fivestar');
$form = array(
'#post' => array(),
'#programmed' => FALSE,
'#tree' => FALSE,
'#parents' => array(),
'#array_parents' => array(),
'#required' => FALSE,
'#attributes' => array(),
'#title_display' => 'before',
);
$form_state = form_state_defaults();
$form_state['values'] = array();
$form_state['process_input'] = array();
$form_state['complete form'] = array();
$form['vote'] = array(
'#type' => 'fivestar',
'#stars' => 5,
'#auto_submit' => FALSE,
'#allow_clear' => TRUE,
'#allow_revote' => TRUE,
'#allow_ownvote' => TRUE,
'#widget' => array(
'name' => isset($variables['name']) ? $variables['name'] : 'default',
'css' => isset($variables['css']) && $variables['css'] != 'default' ? $variables['css'] : FALSE,
),
);
// Attach necessary JS settings.
$settings = array(
'titleUser' => t('Your rating') . ': ',
'titleAverage' => t('Average') . ': ',
'feedbackSavingVote' => t('Saving your vote...'),
'feedbackVoteSaved' => t('Your vote has been saved.'),
'feedbackDeletingVote' => t('Deleting your vote...'),
'feedbackVoteDeleted' => t('Your vote has been deleted.'),
);
drupal_add_js(array(
'fivestar' => $settings,
), 'setting');
$form = form_builder('fivestar_preview', $form, $form_state);
$output = '<div class="fivestar-star-preview fivestar-' . $form['vote']['#widget']['name'] . '">';
$output .= drupal_render_children($form);
$output .= '</div>';
return $output;
}