You are here

function rate_vote_ajax in Rate 7.2

AJAX callback for Rate widgets.

1 string reference to 'rate_vote_ajax'
rate_menu in ./rate.module
Implements hook_menu().

File

./rate.module, line 415
Main module file for the Rate module.

Code

function rate_vote_ajax() {
  $entity_type = preg_replace('/[^\\w\\-]/', '', $_GET['entity_type']);
  $entity_id = (int) $_GET['entity_id'];
  $field_name = preg_replace('/[^\\w\\-]/', '', $_GET['field_name']);
  $widget_mode = preg_replace('/[^\\w\\-]/', '', $_GET['widget_mode']);
  $entities = entity_load($entity_type, array(
    $entity_id,
  ));
  if (!isset($entities[$entity_id])) {
    return MENU_NOT_FOUND;
  }
  $display = array(
    'label' => 'hidden',
    'type' => "rate_{$widget_mode}",
  );
  $widget = field_view_field($entity_type, $entities[$entity_id], $field_name, $display);
  print drupal_render($widget);
}