? .cache ? .settings Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.837 diff -u -p -r1.837 comment.module --- modules/comment/comment.module 14 Jan 2010 02:00:08 -0000 1.837 +++ modules/comment/comment.module 20 Jan 2010 21:03:31 -0000 @@ -104,9 +104,6 @@ function comment_entity_info() { 'id' => 'cid', 'bundle' => 'node_type', ), - 'bundle keys' => array( - 'bundle' => 'type', - ), 'bundles' => array(), 'view modes' => array( 'full' => array( @@ -120,6 +117,19 @@ 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. Note that the paths use a different placeholder name + // and thus a different menu loader callback, so that Field UI page + // callbacks get a comment bundle name from the node type in the URL. + // @see comment_node_type_load() + // @see comment_menu_alter() + 'path' => 'admin/structure/types/manage/%comment_node_type/comment', + 'bundle argument' => 4, + 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment', + 'access arguments' => array('administer content types'), + ), ); } @@ -127,6 +137,17 @@ function comment_entity_info() { } /** + * Menu loader callback for Field UI paths. + * + * Return a comment bundle name from a node type in the URL. + */ +function comment_node_type_load($name) { + if ($type = node_type_get_type(strtr($name, array('-' => '_')))) { + return 'comment_node_' . $type->type; + } +} + +/** * Entity path callback. */ function comment_path($comment) { @@ -134,6 +155,32 @@ function comment_path($comment) { } /** + * 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() { @@ -2499,6 +2546,13 @@ function comment_ranking() { function comment_menu_alter(&$items) { // Add comments to the description for admin/content. $items['admin/content']['description'] = "Administer content and comments"; + + // Adjust the Field UI tabs on admin/structure/types/manage/[node-type]. + // @see comment_entity_info() + $items['admin/structure/types/manage/%comment_node_type/comment/fields']['title'] = 'Comment fields'; + $items['admin/structure/types/manage/%comment_node_type/comment/fields']['weight'] = 3; + $items['admin/structure/types/manage/%comment_node_type/comment/display']['title'] = 'Comment display'; + $items['admin/structure/types/manage/%comment_node_type/comment/display']['weight'] = 4; } /** Index: modules/field_ui/field_ui.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v retrieving revision 1.36 diff -u -p -r1.36 field_ui.admin.inc --- modules/field_ui/field_ui.admin.inc 13 Jan 2010 05:43:01 -0000 1.36 +++ modules/field_ui/field_ui.admin.inc 20 Jan 2010 20:39:57 -0000 @@ -807,9 +807,9 @@ function field_ui_existing_field_options /** * Menu callback; presents the field settings edit page. */ -function field_ui_field_settings_form($form, &$form_state, $obj_type, $bundle, $instance) { +function field_ui_field_settings_form($form, &$form_state, $obj_type, $bundle, $field) { $bundle = field_extract_bundle($obj_type, $bundle); - $field = field_info_field($instance['field_name']); + $instance = field_info_instance($obj_type, $field['field_name'], $bundle); // When a field is first created, we have to get data from the db. if (!isset($instance['label'])) { @@ -895,9 +895,11 @@ function field_ui_field_settings_form_su /** * Menu callback; select a widget for the field. */ -function field_ui_widget_type_form($form, &$form_state, $obj_type, $bundle, $instance) { +function field_ui_widget_type_form($form, &$form_state, $obj_type, $bundle, $field) { $bundle = field_extract_bundle($obj_type, $bundle); - $field = field_read_field($instance['field_name']); + $instance = field_info_instance($obj_type, $field['field_name'], $bundle); + + drupal_set_title($instance['label']); $field_type = field_info_field_types($field['type']); $widget_type = field_info_widget_types($instance['widget']['type']); @@ -955,9 +957,9 @@ function field_ui_widget_type_form_submi /** * Menu callback; present a form for removing a field from a content type. */ -function field_ui_field_delete_form($form, &$form_state, $obj_type, $bundle, $instance) { +function field_ui_field_delete_form($form, &$form_state, $obj_type, $bundle, $field) { $bundle = field_extract_bundle($obj_type, $bundle); - $field = field_info_field($instance['field_name']); + $instance = field_info_instance($obj_type, $field['field_name'], $bundle); $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); $form['object_type'] = array('#type' => 'value', '#value' => $obj_type); @@ -1012,10 +1014,10 @@ function field_ui_field_delete_form_subm /** * Menu callback; presents the field instance edit page. */ -function field_ui_field_edit_form($form, &$form_state, $obj_type, $bundle, $instance) { +function field_ui_field_edit_form($form, &$form_state, $obj_type, $bundle, $field) { $bundle = field_extract_bundle($obj_type, $bundle); + $instance = field_info_instance($obj_type, $field['field_name'], $bundle); - $field = field_info_field($instance['field_name']); $form['#field'] = $field; if (!empty($field['locked'])) { 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 20 Jan 2010 20:40:39 -0000 @@ -56,7 +56,7 @@ function field_ui_menu() { $path = $bundle_info['admin']['path']; $bundle_arg = isset($bundle_info['admin']['bundle argument']) ? $bundle_info['admin']['bundle argument'] : $bundle_name; $access = array_intersect_key($bundle_info['admin'], drupal_map_assoc(array('access callback', 'access arguments'))); - $instance_position = count(explode('/', $path)) + 1; + $field_position = count(explode('/', $path)) + 1; $items["$path/fields"] = array( 'title' => 'Manage fields', @@ -67,43 +67,32 @@ function field_ui_menu() { 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu"] = array( - 'title callback' => 'field_ui_menu_label', - 'title arguments' => array($instance_position), - 'load arguments' => array($obj_type, $bundle_arg), 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $instance_position), + 'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/edit"] = array( - 'title' => 'Edit instance settings', - 'load arguments' => array($obj_type, $bundle_arg), 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $instance_position), + 'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $field_position), 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/field-settings"] = array( - 'title' => 'Edit field settings', - 'load arguments' => array($obj_type, $bundle_arg), 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_settings_form', $obj_type, $bundle_arg, $instance_position), + 'page arguments' => array('field_ui_field_settings_form', $obj_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/widget-type"] = array( - 'title' => 'Change widget type', - 'load arguments' => array($obj_type, $bundle_arg), 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_widget_type_form', $obj_type, $bundle_arg, $instance_position), + 'page arguments' => array('field_ui_widget_type_form', $obj_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/delete"] = array( - 'title' => 'Delete instance', - 'load arguments' => array($obj_type, $bundle_arg), 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_delete_form', $obj_type, $bundle_arg, $instance_position), + 'page arguments' => array('field_ui_field_delete_form', $obj_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; @@ -135,24 +124,16 @@ function field_ui_menu() { } /** - * Menu loader; Load a field instance based on its name. + * Menu loader; Load a field based on its name. */ -function field_ui_menu_load($field_name, $obj_type, $bundle_name) { - $bundle_name = strtr($bundle_name, array('-' => '_')); - if ($instance = field_info_instance($obj_type, $field_name, $bundle_name)) { - return $instance; +function field_ui_menu_load($field_name) { + if ($field = field_info_field($field_name)) { + return $field; } return FALSE; } /** - * Menu title callback; Return a field label based on its instance. - */ -function field_ui_menu_label($instance) { - return t($instance['label']); -} - -/** * Implements hook_theme(). */ function field_ui_theme() {