Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.830 diff -u -p -r1.830 comment.module --- modules/comment/comment.module 11 Jan 2010 16:25:16 -0000 1.830 +++ modules/comment/comment.module 12 Jan 2010 14:38:32 -0000 @@ -119,6 +119,17 @@ function comment_entity_info() { foreach (node_type_get_names() as $type => $name) { $return['comment']['bundles']['comment_node_' . $type] = array( 'label' => $name, + 'admin' => array( + // Place the Field UI paths for comments one level below the + // corresponding paths for nodes, so that they appear in the same set + // of local tasks. + // @see comment_field_extract_bundle_alter() + // @see comment_menu_alter() + 'path' => 'admin/structure/types/manage/%node_type/comment', + 'bundle argument' => 4, + 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment', + 'access arguments' => array('administer content types'), + ), ); } @@ -126,6 +137,43 @@ function comment_entity_info() { } /** + * Implements hook_field_extract_bundle_alter(). + */ +function comment_field_extract_bundle_alter(&$bundle_name, $context) { + // Handle the specific case of comments, for which the bundle name received + // is the name of the node type. + if ($context['obj_type'] == 'comment' && strpos($bundle_name, 'comment_node_') !== 0) { + $bundle_name = 'comment_node_' . $bundle_name; + } +} + +/** + * Implements hook_field_extra_fields(). + */ +function comment_field_extra_fields() { + $return = array(); + + foreach (node_type_get_types() as $type) { + if (variable_get('comment_subject_field_' . $type->type, 1) == 1) { + $return['comment']['comment_node_' . $type->type] = array( + 'author' => array( + 'label' => t('Author'), + 'description' => t('Author textfield'), + 'weight' => -2, + ), + 'title' => array( + 'label' => t('Subject'), + 'description' => t('Subject textfield'), + 'weight' => -1, + ), + ); + } + } + + return $return; +} + +/** * Implements hook_theme(). */ function comment_theme() { @@ -2488,6 +2536,13 @@ function comment_ranking() { function comment_menu_alter(&$items) { // Add comments to the description for admin/content. $items['admin/content']['description'] = "View, edit, and delete your site's content and comments."; + + // Adjust the Field UI tabs on admin/structure/types/manage/[node-type]. + // @see comment_entity_info() + $items['admin/structure/types/manage/%node_type/comment/fields']['title'] = 'Comment fields'; + $items['admin/structure/types/manage/%node_type/comment/fields']['weight'] = 3; + $items['admin/structure/types/manage/%node_type/comment/display']['title'] = 'Comment display'; + $items['admin/structure/types/manage/%node_type/comment/display']['weight'] = 4; } /** Index: modules/field/field.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v retrieving revision 1.60 diff -u -p -r1.60 field.api.php --- modules/field/field.api.php 9 Jan 2010 21:54:00 -0000 1.60 +++ modules/field/field.api.php 12 Jan 2010 14:35:49 -0000 @@ -19,7 +19,7 @@ * field_attach_extra_weight() to retrieve the user-defined weight when * inserting the component. * - * @return @todo + * @return * An array of 'pseudo-field' components. The keys are the name of the element * as it appears in the form structure. The values are arrays with the * following key/value pairs: @@ -182,6 +182,25 @@ function hook_field_info_alter(&$info) { } /** + * Alter the auto-determined bundle name for an object type. + * + * @param $bundle_name + * The bundle name for the object type, as determined in + * field_extract_bundle(); passed by reference. + * @param $context + * An associative array containing: + * - obj_type: The type of object the bundle belongs to. + * - field_name: (optional) The name of the field instance being edited. + */ +function hook_field_extract_bundle_alter(&$bundle_name, $context) { + // Handle the specific case of comments, for which the bundle name received + // is the name of the node type. + if ($obj_type == 'comment' && strpos($bundle_name, 'comment_node_') !== 0) { + $bundle_name = 'comment_node_' . $bundle_name; + } +} + +/** * Define the Field API schema for a field structure. * * @param $field Index: modules/field/field.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.module,v retrieving revision 1.60 diff -u -p -r1.60 field.module --- modules/field/field.module 4 Jan 2010 21:31:52 -0000 1.60 +++ modules/field/field.module 12 Jan 2010 14:35:23 -0000 @@ -736,7 +736,10 @@ function field_extract_bundle($obj_type, $info = entity_get_info($obj_type); if (is_object($bundle) && isset($info['bundle keys']['bundle']) && isset($bundle->{$info['bundle keys']['bundle']})) { - return $bundle->{$info['bundle keys']['bundle']}; + $bundle_name = $bundle->{$info['bundle keys']['bundle']}; + $context = array('obj_type' => $obj_type); + drupal_alter('field_extract_bundle', $bundle_name, $context); + return $bundle_name; } } Index: modules/field_ui/field_ui.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.module,v retrieving revision 1.22 diff -u -p -r1.22 field_ui.module --- modules/field_ui/field_ui.module 3 Jan 2010 21:01:04 -0000 1.22 +++ modules/field_ui/field_ui.module 12 Jan 2010 14:33:59 -0000 @@ -139,6 +139,9 @@ function field_ui_menu() { */ function field_ui_menu_load($field_name, $obj_type, $bundle_name) { $bundle_name = strtr($bundle_name, array('-' => '_')); + $context = array('obj_type' => $obj_type, 'field_name' => $field_name); + drupal_alter('field_extract_bundle', $bundle_name, $context); + if ($instance = field_info_instance($obj_type, $field_name, $bundle_name)) { return $instance; }