You are here

function rate_field_prepare_view in Rate 7.2

Implements hook_field_prepare_view().

File

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

Code

function rate_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
  $entity_info = entity_get_info($entity_type);
  foreach ($entities as $id => $entity) {

    // Strip off "rate_widget_" from field type to get the widget type.
    $type = substr($instances[$id]['widget']['type'], 12);
    $widget_info = _rate_get_widgets($type);
    _rate_load_widget($widget_info);
    if (class_exists($widget_info->class)) {
      $item = array(
        'class' => $widget_info->class,
        'attributes' => array(
          'type' => $type,
          'entity_type' => $entity_type,
          'entity_id' => $id,
        ),
      );
      $items[$id] = array(
        $item,
      );
    }
  }
}