function theme_fivestar_preview in Fivestar 5
Same name and namespace in other branches
- 8 includes/fivestar.theme.inc \theme_fivestar_preview()
- 6.2 includes/fivestar.admin.inc \theme_fivestar_preview()
- 6 fivestar.module \theme_fivestar_preview()
- 7.2 includes/fivestar.theme.inc \theme_fivestar_preview()
3 theme calls to theme_fivestar_preview()
- fivestar_comment_form_alter in ./
fivestar_comment.module - Form alter specification for comments.
- fivestar_form_alter in ./
fivestar.module - Implementation of hook_form_alter().
- fivestar_preview in ./
fivestar.module - Callback function for fivestar/preview/node. Outputs a JSON page containing a Fivestar preview of a node rating widget.
File
- ./
fivestar.module, line 598 - A simple n-star voting widget, usable in other forms.
Code
function theme_fivestar_preview($style = NULL, $text = NULL, $stars = NULL, $unvote = NULL, $title = NULL, $feedback_enable = TRUE, $labels_enable = TRUE, $labels = array()) {
$values = array(
'average' => 50,
'user' => 80,
'count' => 20,
);
$settings = array(
'stars' => $stars,
'allow_clear' => $unvote,
'style' => $style,
'text' => $text,
'title' => $title,
'autosubmit' => FALSE,
'feedback_enable' => $feedback_enable,
'labels_enable' => $labels_enable,
'labels' => $labels,
);
$form = drupal_get_form('fivestar_custom_widget', $values, $settings);
// This regex is sadly necessary because having duplicate form_tokens or
// form_id elements can cause the content type form to choke. Forms inside of
// forms is also frowned upon, so this removes the wrapping form tag as well.
$form = str_replace(array(
'<form',
'</form>',
), array(
'<div',
'</div>',
), $form);
$form = preg_replace('/( method=".*?")|( action=".*?")|(<input.*?name="(form_token|form_id|destination)".*?\\/>)/', '', $form);
return $form;
}