diff options
-rw-r--r-- | modules/comment/comment.module | 60 | ||||
-rw-r--r-- | modules/field_ui/field_ui.admin.inc | 18 | ||||
-rw-r--r-- | modules/field_ui/field_ui.module | 39 |
3 files changed, 77 insertions, 40 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 97d862f73..556c234c2 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -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() { @@ -2501,6 +2548,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; } /** diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 4104e04cf..a3bba857e 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -812,9 +812,9 @@ function field_ui_existing_field_options($obj_type, $bundle) { /** * 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'])) { @@ -900,9 +900,11 @@ function field_ui_field_settings_form_submit($form, &$form_state) { /** * 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']); @@ -960,9 +962,9 @@ function field_ui_widget_type_form_submit($form, &$form_state) { /** * 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); @@ -1017,10 +1019,10 @@ function field_ui_field_delete_form_submit($form, &$form_state) { /** * 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'])) { diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module index 93c436fa7..411375388 100644 --- a/modules/field_ui/field_ui.module +++ b/modules/field_ui/field_ui.module @@ -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() { |