You are here

function fivestar_votingapi_metadata_alter in Fivestar 6

Same name and namespace in other branches
  1. 6.2 fivestar.module \fivestar_votingapi_metadata_alter()
  2. 7.2 fivestar.module \fivestar_votingapi_metadata_alter()

Implementation of hook_votingapi_metadata_alter().

File

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

Code

function fivestar_votingapi_metadata_alter(&$data) {
  static $tags;
  if (!isset($tags)) {
    $tags = array();
    module_load_install('content');
    module_load_include('inc', 'content', 'includes/content.admin');
    module_load_include('inc', 'content', 'includes/content.crud');

    // Grab the list of fields to update.
    foreach (content_types_install() as $type_name => $fields) {
      foreach ($fields as $field) {
        if ($field['type'] == 'fivestar') {
          if (!empty($field['axis'])) {
            $data['tags'][$field['axis']] = array(
              'name' => drupal_ucfirst($field['axis']),
              'description' => t('Used by %field in the %type content type.', array(
                '%type' => $type_name,
                '%field' => $field['field_name'],
              )),
              'module' => 'fivestar',
            );
          }
        }
      }
    }
  }
  return $tags;
}