From e998857eb8a5ef4d2ebe381a57c19b1b355fe4ef Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Wed, 19 Aug 2009 13:31:14 +0000 Subject: #516138 by yched, KarenS, quicksketch, bangpound, et al.: CC-FREAKING-K IN CORE! OH YEAH! :D --- modules/taxonomy/taxonomy.module | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'modules/taxonomy/taxonomy.module') diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index c68056337..6294cf131 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -64,6 +64,25 @@ function taxonomy_field_build_modes($obj_type) { return $modes; } +/** + * Implement hook_field_extra_fields(). + */ +function taxonomy_field_extra_fields($bundle) { + $extra = array(); + + if ($type = node_type_get_type($bundle)) { + if (taxonomy_get_vocabularies($bundle)) { + $extra['taxonomy'] = array( + 'label' => t('Taxonomy'), + 'description' => t('Taxonomy module element.'), + 'weight' => -3, + ); + } + } + + return $extra; +} + /** * Implement hook_theme(). */ @@ -2247,3 +2266,35 @@ function taxonomy_elements() { ), ); } + +/** + * Implement hook_field_settings_form(). + */ +function taxonomy_field_settings_form($field, $instance) { + // Get proper values for 'allowed_values_function', which is a core setting. + $vocabularies = taxonomy_get_vocabularies(); + $options = array(); + foreach ($vocabularies as $vocabulary) { + $options[$vocabulary->vid] = $vocabulary->name; + } + $form['allowed_values'] = array( + '#tree' => TRUE, + ); + + foreach ($field['settings']['allowed_values'] as $delta => $tree) { + $form['allowed_values'][$delta]['vid'] = array( + '#type' => 'select', + '#title' => t('Vocabulary'), + '#default_value' => $tree['vid'], + '#options' => $options, + '#required' => TRUE, + '#description' => t('The vocabulary which supplies the options for this field.'), + ); + $form['allowed_values'][$delta]['parent'] = array( + '#type' => 'value', + '#value' => $tree['parent'], + ); + } + + return $form; +} -- cgit v1.2.3