You are here

function _fivestar_get_microdata_property_info in Fivestar 7.2

Get microdata attributes for Fivestar field.

1 call to _fivestar_get_microdata_property_info()
fivestar_field_formatter_view in includes/fivestar.field.inc
Implements hook_field_formatter_view().

File

includes/fivestar.field.inc, line 841
Provides CCK integration for fivestar module.

Code

function _fivestar_get_microdata_property_info($entity_type, $entity, $field, $instance) {

  // If microdata module is enabled, attach the microdata attributes the module
  // adds to the entity object.
  if (module_exists('microdata')) {
    $microdata = $entity->microdata[$field['field_name']];
  }
  else {
    $microdata = array(
      '#attributes' => array(),
    );

    // If Entity API is enabled, we can use that to get the properties.
    // Otherwise, replicate the Entity API logic for getting the properties.
    if (module_exists('entity')) {
      $entity_info = entity_get_all_property_info($entity_type);
    }
    else {
      $info = array();
      $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']] = array();
      fivestar_property_info_callback($info, $entity_type, $field, $instance, 'fivestar');
      $entity_info = $info[$entity_type]['bundles'][$instance['bundle']]['properties'];
    }
    foreach ($entity_info[$field['field_name']]['property info'] as $property_name => $property) {
      $microdata[$property_name]['#attributes'] = array();
    }
  }
  return $microdata;
}