You are here

function theme_fivestar_node_type_form in Fivestar 5

Same name and namespace in other branches
  1. 6 fivestar.module \theme_fivestar_node_type_form()

Theme function to add the Fivestar preview to the node type form.

1 theme call to theme_fivestar_node_type_form()
fivestar_form_alter in ./fivestar.module
Implementation of hook_form_alter().

File

./fivestar.module, line 307
A simple n-star voting widget, usable in other forms.

Code

function theme_fivestar_node_type_form($form) {
  drupal_add_js(drupal_get_path('module', 'fivestar') . '/js/fivestar-admin.js');
  drupal_add_js(array(
    'fivestar' => array(
      'preview_url' => url('fivestar/preview/node'),
    ),
  ), 'setting');
  drupal_add_css(drupal_get_path('module', 'fivestar') . '/css/fivestar-admin.css', 'module', 'all', FALSE);
  $output = '';
  $output .= drupal_render($form['fivestar']);
  $output .= drupal_render($form['fivestar_stars']);

  // Star labels.
  $output .= drupal_render($form['labels']);

  // Direct rating settings form.
  $direct = '';
  $direct .= '<div id="fivestar-direct-form">';
  $direct .= drupal_render($form['direct']['fivestar_style']);
  $direct .= drupal_render($form['direct']['fivestar_text']);
  $direct .= drupal_render($form['direct']['fivestar_title']);
  $direct .= drupal_render($form['direct']['fivestar_unvote']);
  $direct .= drupal_render($form['direct']['fivestar_feedback']);
  $direct .= drupal_render($form['direct']['fivestar_position_teaser']);
  $direct .= drupal_render($form['direct']['fivestar_position']);
  $direct .= '</div>';
  $direct .= '<div id="fivestar-direct-preview">';
  $direct .= drupal_render($form['direct']['fivestar_direct_preview']);
  $direct .= '</div>';
  $form['direct']['#children'] = $direct;
  $output .= drupal_render($form['direct']);

  // Comment settings form.
  if (module_exists('fivestar_comment')) {
    $comment = '';
    $comment .= '<div id="fivestar-comment-form">';
    $comment .= drupal_render($form['comment']['fivestar_comment']);
    $comment .= '</div>';
    $comment .= '<div id="fivestar-comment-preview">';
    $comment .= drupal_render($form['comment']['fivestar_comment_preview']);
    $comment .= '</div>';
    $form['comment']['#children'] = $comment;
    $output .= drupal_render($form['comment']);
  }

  // Any remaining cruft (should be empty).
  $output .= drupal_render($form);
  return $output;
}