You are here

function hs_taxonomy_hierarchical_select_config_info in Hierarchical Select 7.3

Same name and namespace in other branches
  1. 5.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_config_info()
  2. 6.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_config_info()

Implementation of hook_hierarchical_select_config_info().

File

modules/hs_taxonomy.module, line 891
Implementation of the Hierarchical Select API for the Taxonomy module.

Code

function hs_taxonomy_hierarchical_select_config_info() {
  static $config_info;
  if (!isset($config_info)) {
    $config_info = array();
    $fields = field_info_fields();
    foreach ($fields as $field_name => $field) {
      foreach ($field['bundles'] as $entity_type => $bundles) {
        $bundle_links = array();
        foreach ($bundles as $bundle) {
          $instance = field_info_instance($entity_type, $field_name, $bundle);
          if ($instance['widget']['type'] == 'taxonomy_hs') {
            $bundles_info = field_info_bundles($entity_type);
            $bundle_links[] = l($bundles_info[$bundle]['label'], $bundles_info[$bundle]['admin']['real path']);
            $entity_info = entity_get_info($entity_type);
            $machine_name = $field['settings']['allowed_values'][0]['vocabulary'];
            $vocabulary = taxonomy_vocabulary_machine_name_load($machine_name);
            $config_id = hs_taxonomy_get_config_id($field_name);
            $config_info[$config_id] = array(
              'config_id' => $config_id,
              'hierarchy type' => t('Taxonomy'),
              'hierarchy' => t('Vocabulary') . ': ' . l(t($vocabulary->name), "admin/structure/taxonomy/{$machine_name}") . '<br /><small>' . t('Field label') . ': ' . $instance['label'] . '<br />' . t('Field machine name') . ': ' . $field_name . '</small>',
              'entity type' => $entity_info['label'],
              'bundle' => implode('<br />', $bundle_links),
              'context type' => '',
              'context' => '',
              'edit link' => isset($bundles_info[$bundle]['admin']['real path']) ? $bundles_info[$bundle]['admin']['real path'] . "/fields/{$field_name}/widget-type" : $bundles_info[$bundle]['admin']['path'] . "/fields/{$field_name}/widget-type",
            );
          }
        }
      }
    }
  }
  return $config_info;
}